# Create a field

`POST /v1/fields`

Required scope: `schema:write`

A custom field on contacts or companies.

## Header parameters

- `Idempotency-Key` (string or null, optional)

## Request body (application/json)

- `ai_prompt` (string or null, optional)
- `description` (string or null, optional)
- `group` (string, optional) Default: `"Custom"`.
- `label` (string, required)
- `link_object` (string or null, optional) Allowed values: `"contacts"`, `"companies"`.
- `object` (string, required) Allowed values: `"contacts"`, `"companies"`.
- `picklist_id` (string or null, optional)
- `type` (string, required) Allowed values: `"text"`, `"long_text"`, `"number"`, `"currency"`, `"date"`, `"datetime"`, `"checkbox"`, `"picklist"`, `"multi_picklist"`, `"url"`, `"phone"`, `"email"`, `"user"`, `"record_link"`.

## Responses

- `201`: Successful Response
- `400`: The request is not valid.
- `401`: Not signed in, or the credentials are not valid.
- `402`: The balance is too low.
- `403`: Not allowed to do this.
- `404`: Not found.
- `409`: Conflicts with the current state.
- `413`: The request body is too large.
- `415`: The content type is not supported.
- `422`: A value in the request is not valid.
- `429`: Too many requests. Wait for `Retry-After` seconds.
- `500`: Something went wrong on our side.
- `502`: A service Valeron depends on refused the request.
- `503`: A service Valeron depends on is unavailable.

## Examples

### Request

```bash title="cURL"
curl -X POST "https://api.valeron.io/v1/fields" \
  -H "Authorization: Bearer $VALERON_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "ai_prompt": "example",
  "description": "A short description.",
  "group": "Custom",
  "label": "Example",
  "link_object": "contacts",
  "object": "contacts",
  "type": "text"
}'
```

```js title="JavaScript"
const response = await fetch("https://api.valeron.io/v1/fields", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.VALERON_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "ai_prompt": "example",
    "description": "A short description.",
    "group": "Custom",
    "label": "Example",
    "link_object": "contacts",
    "object": "contacts",
    "type": "text"
  }),
});
if (!response.ok) throw new Error(`Valeron returned ${response.status}`);
const data = await response.json();
```

```python title="Python"
import os
import requests

response = requests.post(
    "https://api.valeron.io/v1/fields",
    headers={"Authorization": f"Bearer {os.environ['VALERON_API_KEY']}"},
    json={
        "ai_prompt": "example",
        "description": "A short description.",
        "group": "Custom",
        "label": "Example",
        "link_object": "contacts",
        "object": "contacts",
        "type": "text",
    },
)
response.raise_for_status()
data = response.json()
```

### Response 201

```json
{
  "ai_prompt": "example",
  "can_filter": true,
  "can_group": true,
  "can_sort": true,
  "description": "A short description.",
  "group": "example",
  "id": "fld_01JW2FN60M",
  "is_ai": true,
  "is_custom": true,
  "is_multi": true,
  "is_read_only": true,
  "is_required": true,
  "key": "example_key",
  "label": "Example",
  "link_object": "example",
  "metric": {
    "key": "example_key",
    "minimum_sample": 1,
    "period": "example",
    "unit": "example"
  }
}
```

### Response 401

```json
{
  "error": null
}
```

### Response 402

```json
{
  "error": null
}
```

### Response 403

```json
{
  "error": null
}
```

### Response 404

```json
{
  "error": null
}
```
