# Create Contact

Add a contact to your organization. Campaigns, automations and analytics all target contacts.

## Endpoint

```
POST /contacts
```

**Returns:** `201 Created`

## Headers

| Header | Value | Required |
|--------|-------|----------|
| `Authorization` | `Bearer <your-api-key>` | Yes |
| `Content-Type` | `application/json` | Yes |

## Body Parameters

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `email` | string | Conditional | Contact's email address. |
| `phone_number` | string | Conditional | Phone number in E.164 format (e.g., `+966512345678`). |
| `external_id` | string | Conditional | **Your own** identifier for this person. Max 255 characters, unique within your organization. |
| `first_name` | string | No | First name. Max 100 characters. |
| `last_name` | string | No | Last name. Max 100 characters. |
| `properties` | object | No | Custom property key-value pairs. Keys must match your organization's custom property schema. |
| `list_ids` | string[] | No | Array of list IDs to add the contact to upon creation. |

:::warning[At Least One Identifier]
You must provide at least one of `email`, `phone_number` or `external_id`. You may provide any combination.
:::

### Using `external_id`

`external_id` is the identifier **you** already use for this person, such as a
user ID from your own database. It outranks `email` and `phone_number`
everywhere in Arsel:

- **Migrating from another platform.** Set it during import and every later
  [event](https://docs.arsel.sa/api/events/send-event) resolves to the same contact, even for people
  whose email you don't have.
- **Contact details that change.** An email or phone can be edited;
  `external_id` doesn't change, so history stays attached to the right person.

Reusing an `external_id` that another contact already holds returns `409`. To
find whether you have already imported someone, filter for it on
[List contacts](https://docs.arsel.sa/api/contacts/list-contacts) instead of searching by email.

### Custom Properties

Define your property schema in the [Arsel Dashboard](https://arsel.sa) under **Audience > Properties** before sending values.

```json
{
  "properties": {
    "company": "Acme Inc",
    "age": 30,
    "is_vip": true,
    "birthdate": "1995-06-15"
  }
}
```

---

## Response

```json
{
  "id": "01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6a",
  "email": "john.doe@example.com",
  "phone_number": "+201234567890",
  "external_id": "user_10294",
  "first_name": "John",
  "last_name": "Doe",
  "source": "api",
  "properties": {
    "company": "Acme Inc"
  },
  "is_suppressed": false,
  "created_at": "2026-03-08T12:00:00.000Z",
  "updated_at": "2026-03-08T12:00:00.000Z"
}
```

| Field | Type | Description |
|-------|------|-------------|
| `id` | string | Unique contact ID (UUIDv7) |
| `email` | string \| null | Contact email address |
| `phone_number` | string \| null | Contact phone number |
| `external_id` | string \| null | Your own identifier for this person |
| `first_name` | string \| null | First name |
| `last_name` | string \| null | Last name |
| `source` | string | How the contact was created: `api`, `manual`, `import`, `transactional`. Always `api` for contacts created here. |
| `properties` | object | Custom property values |
| `is_suppressed` | boolean | `true` if the contact has unsubscribed, bounced, been blocked by email validation, or been manually suppressed |
| `created_at` | string | ISO 8601 timestamp |
| `updated_at` | string | ISO 8601 timestamp |

---

## Examples

### Basic Contact

```bash
curl -X POST "https://api.arsel.sa/v1/contacts" \
  -H "Authorization: Bearer $ARSEL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "email": "john.doe@example.com",
    "first_name": "John",
    "last_name": "Doe"
  }'
```

### With Custom Properties and Lists

```bash
curl -X POST "https://api.arsel.sa/v1/contacts" \
  -H "Authorization: Bearer $ARSEL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "email": "sara@example.com",
    "phone_number": "+966512345678",
    "first_name": "Sara",
    "last_name": "Ahmed",
    "properties": {
      "company": "Acme Inc",
      "job_title": "Marketing Manager",
      "city": "Riyadh"
    },
    "list_ids": ["01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6a"]
  }'
```

---

## Error Responses

**422 Validation Error**

```json
{
  "status_code": 422,
  "name": "validation_error",
  "message": "At least one of email or phone_number must be provided"
}
```

**409 Conflict**

```json
{
  "status_code": 409,
  "name": "conflict",
  "message": "A contact with this email already exists in your organization"
}
```
