# Create contact

> POST https://api.nabrah.ai/api/ext/omni_v2/contact

Group: Contacts. Page: https://www.nabrah.ai/en/docs/api-reference/contacts/create-contact

Creates a new contact in the project the API key is scoped to. Supply at least one identifying field (such as `phone_number` or `email`) along with an optional `name`, structured `additional_attributes`, and free-form `custom_attributes`. On success the API returns the fully created contact wrapped in `payload.contact`, including the server-assigned numeric `id` you should store as the `contact_id` for subsequent calls.

## Authentication

- **X-API-Key header**: Send your Web API key in the `X-API-Key` header (prefix `nb_`, from the dashboard Developers tab). The key is scoped to one project, so the contact is created in that project automatically — no `project_id` is required.

## Request body fields

Base your request on the default JSON body below.

- **Core fields**: `phone_number`, `name`, and `email` describe the person. Provide a phone number and/or email so the contact can be matched and reached across channels. Fields: `phone_number`, `name`, `email`.
- **additional_attributes**: Optional structured profile object with `city`, `country`, `description`, `company_name`, `country_code`, and `social_profiles`. Fields: `city`, `country`, `description`, `company_name`, `country_code`, `social_profiles`.
- **custom_attributes**: Optional free-form key/value object for workspace-defined custom fields.

Read the created contact's `id` from `payload.contact.id` and reuse it as `contact_id` elsewhere.

## Authorization

- `X-API-Key` (string, header, required): your workspace API key.

## Body (application/json)

### Example: Full contact

Create a contact with core fields plus structured and custom attributes.

```json
{
  "phone_number": "+15551234567",
  "name": "Sarah Johnson",
  "email": "sarah.johnson@example.com",
  "additional_attributes": {
    "city": "Riyadh",
    "country": "Saudi Arabia",
    "description": "Returning enterprise customer",
    "company_name": "Acme Corp",
    "country_code": "SA",
    "social_profiles": {
      "twitter": "sarahjohnson",
      "linkedin": "in/sarahjohnson"
    }
  },
  "custom_attributes": {
    "account_tier": "gold",
    "lifetime_value": 4200
  }
}
```

### Example: Minimal

Create a contact with only the essential identifying fields.

```json
{
  "phone_number": "+15557654321",
  "name": "Omar Haddad",
  "email": "omar.haddad@example.com",
  "additional_attributes": {},
  "custom_attributes": {}
}
```

## Response

### 200 Successful Response

Content type: `application/json`

```json
{
  "payload": {
    "contact": {
      "id": 0,
      "additional_attributes": {
        "city": null,
        "country": null,
        "description": null,
        "company_name": null,
        "country_code": null,
        "social_profiles": null
      },
      "availability_status": "string",
      "email": "string",
      "name": "string",
      "phone_number": "string",
      "blocked": false,
      "identifier": "string",
      "thumbnail": "string",
      "custom_attributes": {},
      "last_activity_at": 0,
      "created_at": 0
    }
  }
}
```

### 422 Validation Error

Content type: `application/json`

```json
{
  "detail": [
    {
      "loc": [
        "string"
      ],
      "msg": "string",
      "type": "string"
    }
  ]
}
```

## Request examples

### cURL

```bash
curl --request POST \
  --url 'https://api.nabrah.ai/api/ext/omni_v2/contact' \
  --header 'X-API-Key: <your-api-key>' \
  --header 'Content-Type: application/json' \
  --data '{
  "phone_number": "+15551234567",
  "name": "Sarah Johnson",
  "email": "sarah.johnson@example.com",
  "additional_attributes": {
    "city": "Riyadh",
    "country": "Saudi Arabia",
    "description": "Returning enterprise customer",
    "company_name": "Acme Corp",
    "country_code": "SA",
    "social_profiles": {
      "twitter": "sarahjohnson",
      "linkedin": "in/sarahjohnson"
    }
  },
  "custom_attributes": {
    "account_tier": "gold",
    "lifetime_value": 4200
  }
}'
```

### Python

```python
import requests

url = "https://api.nabrah.ai/api/ext/omni_v2/contact"
headers = {
    "X-API-Key": "<your-api-key>",
}
payload = {
    "phone_number": "+15551234567",
    "name": "Sarah Johnson",
    "email": "sarah.johnson@example.com",
    "additional_attributes": {
        "city": "Riyadh",
        "country": "Saudi Arabia",
        "description": "Returning enterprise customer",
        "company_name": "Acme Corp",
        "country_code": "SA",
        "social_profiles": {
            "twitter": "sarahjohnson",
            "linkedin": "in/sarahjohnson"
        }
    },
    "custom_attributes": {
        "account_tier": "gold",
        "lifetime_value": 4200
    }
}

response = requests.post(url, headers=headers, json=payload)
response.raise_for_status()
print(response.json())
```

### JavaScript

```javascript
const response = await fetch("https://api.nabrah.ai/api/ext/omni_v2/contact", {
  method: "POST",
  headers: {
    "X-API-Key": "<your-api-key>",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "phone_number": "+15551234567",
    "name": "Sarah Johnson",
    "email": "sarah.johnson@example.com",
    "additional_attributes": {
      "city": "Riyadh",
      "country": "Saudi Arabia",
      "description": "Returning enterprise customer",
      "company_name": "Acme Corp",
      "country_code": "SA",
      "social_profiles": {
        "twitter": "sarahjohnson",
        "linkedin": "in/sarahjohnson"
      }
    },
    "custom_attributes": {
      "account_tier": "gold",
      "lifetime_value": 4200
    }
  }),
});

const data = await response.json();
console.log(data);
```

### Go

```go
package main

import (
	"fmt"
	"io"
	"net/http"
	"strings"
)

func main() {
	payload := strings.NewReader(`{
  "phone_number": "+15551234567",
  "name": "Sarah Johnson",
  "email": "sarah.johnson@example.com",
  "additional_attributes": {
    "city": "Riyadh",
    "country": "Saudi Arabia",
    "description": "Returning enterprise customer",
    "company_name": "Acme Corp",
    "country_code": "SA",
    "social_profiles": {
      "twitter": "sarahjohnson",
      "linkedin": "in/sarahjohnson"
    }
  },
  "custom_attributes": {
    "account_tier": "gold",
    "lifetime_value": 4200
  }
}`)

	req, _ := http.NewRequest("POST", "https://api.nabrah.ai/api/ext/omni_v2/contact", payload)
	req.Header.Set("X-API-Key", "<your-api-key>")
	req.Header.Set("Content-Type", "application/json")

	res, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer res.Body.Close()

	out, _ := io.ReadAll(res.Body)
	fmt.Println(string(out))
}
```
