# Create a customer

Create a customer record with attributes and an optional channel identity.

API 4.0

In the API, a customer is a **user**. Agents are your staff and are not created here.

Use this endpoint to add a customer from your system, such as a CRM contact or a new sign-up. If the customer comes from a connected channel such as Facebook or Zalo, use [Find or create by channel identity](/developers/api-reference/users/identity) instead to avoid duplicates.

## Before you begin

- Get a [Bearer access token](/developers/get-started/authentication). The customer is created in the token's account.
- Use attribute keys defined in your account, with values of the matching type.

## Request body

| Field | Type | Description |
| --- | --- | --- |
| `attributes` | array | Customer data, one item per attribute. |
| `attributes[].key` | string | Attribute key, such as `fullname`. |
| `attributes[].text` | string | Value for text attributes. Use `number`, `boolean`, or `datetime` for other types. |
| `channel` | string | Optional. Channel of an external identity, such as `facebook`. |
| `channel_source` | string | Optional. Connected page or account on that channel. |
| `profile_id` | string | Optional. Customer's ID on that channel. |

Other fields, such as `id` or `account_id`, are ignored.

```json
{
  "attributes": [
    {
      "key": "fullname",
      "text": "Alex Example"
    },
    {
      "key": "emails",
      "text": "alex@example.com"
    },
    {
      "key": "phones",
      "text": "+84900000000"
    }
  ]
}
```

## Common attributes

These built-in keys exist in every account. See [User and attribute format](/developers/users/format) for value types and multiple values.

| Key | Type | Description |
| --- | --- | --- |
| `fullname` | text | Full name. |
| `display_name` | text | Display name. |
| `emails` | text | Email address. |
| `phones` | text | Phone number. |
| `address`, `city`, `district` | text | Address. |
| `gender` | text | Gender. |
| `job_title` | text | Job title. |
| `birthdate` | datetime | Date of birth. |

Some built-in attributes, such as `created` or `last_message_sent`, are set by Subiz and are read-only.

## Response

A successful request returns HTTP `200` with the new customer. Selected fields:

```json
{
  "id": "user_example",
  "account_id": "account_example",
  "attributes": [
    {
      "key": "fullname",
      "text": "Alex Example"
    }
  ]
}
```

Store the `id`. You need it to [read](/developers/api-reference/users/retrieve), [update](/developers/api-reference/users/update), or [message](/developers/api-reference/messages/send-to-user) this customer.

Each request creates a new record. To change an existing customer, use [Update customer details](/developers/api-reference/users/update) instead of creating it again.

## Limits and errors

A request can contain up to 1,000 attributes, and each value up to 2,048 bytes. See [Customer attribute limits](/developers/get-started/usage-limits#customer-attribute-limits) and [Errors](/developers/get-started/errors).

## HTTP request

Replace `YOUR_ACCESS_TOKEN` with your token.

```http
POST https://api.subiz.com.vn/4.0/users
Authorization: Bearer YOUR_ACCESS_TOKEN
Content-Type: application/json

{
  "attributes": [
    {
      "key": "fullname",
      "text": "Alex Example"
    }
  ]
}
```