> ## Documentation Index
> Fetch the complete documentation index at: https://docs.theomnibot.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Contact: Add a New Contact to Your Workspace

> Use POST /api/v1/contacts to add a new contact to your ChatbotX Workspace with a phone number, email address, gender, and optional name fields.

The Create Contact endpoint adds a new contact record to your Workspace. At minimum, you must supply a phone number, an email address, and a gender value. You can optionally provide a first name and last name. The response returns the complete contact object, including generated IDs, timestamps, and all related sub-resources.

<Info>
  **POST** `/api/v1/contacts`
</Info>

## Request Body

<ParamField body="phoneNumber" type="string" required>
  The contact's phone number. Must be 10–20 digits and may include a leading `+`. Pattern: `\+?\d{10,20}`.
</ParamField>

<ParamField body="email" type="string" required>
  The contact's email address. Must be a valid email format.
</ParamField>

<ParamField body="gender" type="string" required>
  The contact's gender. One of: `male`, `female`, `unknown`.
</ParamField>

<ParamField body="firstName" type="string">
  The contact's first name. Maximum 100 characters.
</ParamField>

<ParamField body="lastName" type="string">
  The contact's last name. Maximum 100 characters.
</ParamField>

## Code Examples

<CodeGroup>
  ```bash curl theme={null}
  curl --request POST \
    --url https://app.chatbotx.io/api/v1/contacts \
    --header "Authorization: Bearer YOUR_API_TOKEN" \
    --header "Content-Type: application/json" \
    --data '{
      "phoneNumber": "+84708123123",
      "email": "jane.doe@example.com",
      "gender": "female",
      "firstName": "Jane",
      "lastName": "Doe"
    }'
  ```

  ```python Python theme={null}
  import requests

  url = "https://app.chatbotx.io/api/v1/contacts"
  headers = {
      "Authorization": "Bearer YOUR_API_TOKEN",
      "Content-Type": "application/json"
  }
  payload = {
      "phoneNumber": "+84708123123",
      "email": "jane.doe@example.com",
      "gender": "female",
      "firstName": "Jane",
      "lastName": "Doe"
  }

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

  ```javascript JavaScript theme={null}
  const options = {
    method: 'POST',
    headers: {
      Authorization: 'Bearer YOUR_API_TOKEN',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      phoneNumber: '+84708123123',
      email: 'jane.doe@example.com',
      gender: 'female',
      firstName: 'Jane',
      lastName: 'Doe'
    })
  };

  fetch('https://app.chatbotx.io/api/v1/contacts', options)
    .then(res => res.json())
    .then(data => console.log(data))
    .catch(err => console.error(err));
  ```
</CodeGroup>

## Response Fields

<ResponseField name="id" type="string" required>Unique contact ID generated by ChatbotX.</ResponseField>
<ResponseField name="createdAt" type="string (date-time)" required>Timestamp when the contact was created.</ResponseField>
<ResponseField name="updatedAt" type="string (date-time)" required>Timestamp of the last update.</ResponseField>
<ResponseField name="avatar" type="string | null" required>URL of the contact's profile image.</ResponseField>
<ResponseField name="phoneNumber" type="string | null" required>Contact's phone number.</ResponseField>
<ResponseField name="email" type="string | null" required>Contact's email address.</ResponseField>
<ResponseField name="emailVerified" type="boolean" required>Whether the email has been verified.</ResponseField>
<ResponseField name="emailOptIn" type="boolean" required>Whether the contact has opted in to email communications.</ResponseField>
<ResponseField name="firstName" type="string | null" required>Contact's first name.</ResponseField>
<ResponseField name="lastName" type="string | null" required>Contact's last name.</ResponseField>
<ResponseField name="fullName" type="string | null" required>Contact's computed full name.</ResponseField>
<ResponseField name="gender" type="string | null" required>One of `male`, `female`, `unknown`.</ResponseField>
<ResponseField name="lastReadAt" type="string (date-time) | null" required>When the contact last read a message.</ResponseField>
<ResponseField name="ref" type="string | null" required>External reference identifier.</ResponseField>
<ResponseField name="country" type="string | null" required>Contact's country.</ResponseField>
<ResponseField name="state" type="string | null" required>Contact's state or region.</ResponseField>
<ResponseField name="city" type="string | null" required>Contact's city.</ResponseField>
<ResponseField name="locale" type="string | null" required>Contact's locale string.</ResponseField>
<ResponseField name="timezone" type="string | null" required>Contact's timezone.</ResponseField>
<ResponseField name="subscribedAt" type="string (date-time) | null" required>When the contact subscribed.</ResponseField>
<ResponseField name="broadcastSubscribedAt" type="string (date-time) | null" required>When the contact subscribed to broadcasts.</ResponseField>
<ResponseField name="blockedAt" type="string (date-time) | null" required>When the contact was blocked, or `null`.</ResponseField>
<ResponseField name="workspaceId" type="string" required>The Workspace this contact belongs to.</ResponseField>
<ResponseField name="contactCustomFields" type="array" required>Custom field values assigned to the contact.</ResponseField>
<ResponseField name="tags" type="array" required>Tags applied to the contact.</ResponseField>
<ResponseField name="contactNotes" type="array" required>Notes attached to the contact.</ResponseField>
<ResponseField name="contactInboxes" type="array" required>Inbox connections for this contact.</ResponseField>
<ResponseField name="conversation" type="object | null" required>Most recent conversation, or `null`.</ResponseField>

## Example Response

```json theme={null}
{
  "id": "clx2def456",
  "createdAt": "2024-01-15T09:00:00Z",
  "updatedAt": "2024-01-15T09:00:00Z",
  "avatar": null,
  "phoneNumber": "+84708123123",
  "email": "jane.doe@example.com",
  "emailVerified": false,
  "emailOptIn": false,
  "firstName": "Jane",
  "lastName": "Doe",
  "fullName": "Jane Doe",
  "gender": "female",
  "lastReadAt": null,
  "ref": null,
  "country": null,
  "state": null,
  "city": null,
  "location": null,
  "locale": null,
  "timezone": null,
  "subscribedAt": null,
  "broadcastSubscribedAt": null,
  "blockedAt": null,
  "workspaceId": "ws123",
  "contactCustomFields": [],
  "tags": [],
  "contactNotes": [],
  "contactInboxes": [],
  "conversation": null
}
```
