# Contact fields

## List the contact fields

`GET /v1/c/{slug}/contact-fields` · Scopes: `fields:read` · `contacts:read`

The company's fields (key, name in three languages, type, options). Each contact's values come in the contact's `fields`.

### Path parameters

| Field | Notes |
|---|---|
| `slug` | The company's identifier in DoneTalk (the key's own). |

### Request example

```bash
curl -X GET "https://api.donetalk.com/v1/c/demo/contact-fields" \
  -H "Authorization: Bearer $DONETALK_KEY"
```

### Response 200

```json
{
  "fields": [
    {
      "key": "cpf",
      "label": {
        "pt-BR": "CPF",
        "en": "CPF",
        "es": "CPF"
      },
      "type": "cpf",
      "options": null,
      "aiExtractable": true,
      "aiExtractionHint": null,
      "required": false,
      "sort": 1,
      "isActive": true
    }
  ]
}
```

### Possible errors

- `401` `unauthorized`
- `403` `insufficient_scope`
- `422` `validation_failed`
- `429` `rate_limited`

## Create a field

`POST /v1/c/{slug}/contact-fields` · Scopes: `fields:write`

### Path parameters

| Field | Notes |
|---|---|
| `slug` | The company's identifier in DoneTalk (the key's own). |

### Request body

| Field | Type | Required | Notes |
|---|---|---|---|
| `key` | string | yes |  |
| `label` | string · object | yes |  |
| `type` | one of `text`, `number`, `date`, `boolean`, `select`, `phone`, `email`, `cpf`, `cnpj` | yes |  |
| `options` | list of string | no | up to 50; null |
| `aiExtractable` | boolean | no | default `false` |
| `aiExtractionHint` | string | no | up to 300 characters; null |
| `required` | boolean | no | default `false` |
| `sort` | integer | no | up to 1000 |

### Request example

```bash
curl -X POST "https://api.donetalk.com/v1/c/demo/contact-fields" \
  -H "Authorization: Bearer $DONETALK_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "key": "plano",
  "label": "Plano",
  "type": "select",
  "options": [
    "mensal",
    "anual"
  ]
}'
```

### Response 201

```json
{
  "field": {
    "key": "cpf",
    "label": {
      "pt-BR": "CPF",
      "en": "CPF",
      "es": "CPF"
    },
    "type": "cpf",
    "options": null,
    "aiExtractable": true,
    "aiExtractionHint": null,
    "required": false,
    "sort": 1,
    "isActive": true
  }
}
```

### Possible errors

- `401` `unauthorized`
- `403` `insufficient_scope`
- `422` `validation_failed`
- `429` `rate_limited`

## Edit a field

`PATCH /v1/c/{slug}/contact-fields/{key}` · Scopes: `fields:write`

### Path parameters

| Field | Notes |
|---|---|
| `slug` | The company's identifier in DoneTalk (the key's own). |
| `key` | The key (of the field or the card). |

### Request body

| Field | Type | Required | Notes |
|---|---|---|---|
| `label` | string · object | no |  |
| `options` | list of string | no | up to 50; null |
| `aiExtractable` | boolean | no |  |
| `aiExtractionHint` | string | no | up to 300 characters; null |
| `required` | boolean | no |  |
| `sort` | integer | no | up to 1000 |
| `isActive` | boolean | no |  |

### Request example

```bash
curl -X PATCH "https://api.donetalk.com/v1/c/demo/contact-fields/:key" \
  -H "Authorization: Bearer $DONETALK_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "options": [
    "mensal",
    "semestral",
    "anual"
  ]
}'
```

### Response 200

```json
{
  "ok": true
}
```

### Possible errors

- `401` `unauthorized`
- `403` `insufficient_scope`
- `422` `validation_failed`
- `429` `rate_limited`

