# Create a contact

`POST /v1/contacts`

Required scope: `contacts:write`

Create a contact from `fields`. When one with the same email address or phone number already exists, the values are added onto it and it comes back with `is_matched: true` and a 200 instead of a 201. Send an `Idempotency-Key` header to make a retry safe. The values are recorded with source `api`.

## Header parameters

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

## Request body (application/json)

- `fields` (object (values: string | integer | number | boolean | string[] | object), required)

## 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/contacts" \
  -H "Authorization: Bearer $VALERON_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "fields": {
    "email": {
      "amount": 2400000,
      "currency": "USD"
    }
  }
}'
```

```js title="JavaScript"
const response = await fetch("https://api.valeron.io/v1/contacts", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.VALERON_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "fields": {
      "email": {
        "amount": 2400000,
        "currency": "USD"
      }
    }
  }),
});
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/contacts",
    headers={"Authorization": f"Bearer {os.environ['VALERON_API_KEY']}"},
    json={
        "fields": {
            "email": {
                "amount": 2400000,
                "currency": "USD",
            },
        },
    },
)
response.raise_for_status()
data = response.json()
```

### Response 201

```json
{
  "archived_at": null,
  "fields": {
    "email": {
      "has_history": false,
      "items": [
        {
          "is_primary": true,
          "source": "example",
          "value": "example"
        }
      ],
      "label": "Example",
      "source": "example",
      "type": "text",
      "value": {
        "amount": 2400000,
        "currency": "USD"
      }
    }
  },
  "id": "ct_01J59XB017",
  "is_matched": true,
  "object": "contacts",
  "processing": {
    "error": null,
    "fields_pending": [
      "example"
    ],
    "status": "pending"
  },
  "updated_at": "2026-12-03T14:30:00Z"
}
```

### Response 401

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

### Response 402

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

### Response 403

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

### Response 404

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