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

# Customers

> Reference of Customers methods for the Customer Chat RTM API v3.7.

## Update customer

**Specifics**

|                        |                                                                        |
| ---------------------- | ---------------------------------------------------------------------- |
| **Action**             | `update_customer`                                                      |
| **Web API equivalent** | [`update_customer`](/api/customer-chat/v3.7/customers/update-customer) |
| **Push message**       | `customer_updated`                                                     |

**Request**

At least one optional parameter must be included in the request payload.

| Parameter                                  | Required | Type       | Notes                                                                            |
| ------------------------------------------ | -------- | ---------- | -------------------------------------------------------------------------------- |
| `name`                                     | No       | `string`   |                                                                                  |
| `email`                                    | No       | `string`   |                                                                                  |
| `avatar`                                   | No       | `string`   | The URL of the customer's avatar.                                                |
| `session_fields`                           | No       | `[]object` | An array of custom object-enclosed key-value pairs. Respects the order of items. |
| `omnichannel`                              | No       | `object`   |                                                                                  |
| `omnichannel.fbmessenger`                  | No       | `object`   |                                                                                  |
| `omnichannel.fbmessenger.id`               | Yes      | `string`   | Required when `omnichannel.fbmessenger` is included.                             |
| `omnichannel.fbmessenger.name`             | No       | `string`   |                                                                                  |
| `omnichannel.fbmessenger.first_name`       | No       | `string`   |                                                                                  |
| `omnichannel.fbmessenger.last_name`        | No       | `string`   |                                                                                  |
| `omnichannel.fbmessenger.profile_pic`      | No       | `string`   |                                                                                  |
| `omnichannel.fbmessenger.gender`           | No       | `string`   |                                                                                  |
| `omnichannel.fbmessenger.locale`           | No       | `string`   |                                                                                  |
| `omnichannel.fbmessenger.is_verified_user` | No       | `bool`     |                                                                                  |
| `omnichannel.twilio`                       | No       | `object`   |                                                                                  |
| `omnichannel.twilio.phone_number`          | Yes      | `string`   | Required when `omnichannel.twilio` is included.                                  |
| `address`                                  | No       | `object`   | The customer's address.                                                          |
| `address.address`                          | No       | `string`   | The street address.                                                              |
| `address.city`                             | No       | `string`   | The city name.                                                                   |
| `address.country`                          | No       | `string`   | The country name.                                                                |
| `address.state`                            | No       | `string`   | The state name.                                                                  |
| `address.postal_code`                      | No       | `string`   | The postal code.                                                                 |

No response payload.

```json title="Request" theme={null}
{
  "action": "update_customer",
  "payload": {
    "name": "Thomas Anderson",
    "email": "t.anderson@example.com",
    "avatar": "https://example.com/avatars/1.png",
    "session_fields": [
      { "custom_key": "custom_value" },
      { "another_custom_key": "another_custom_value" }
    ]
  }
}
```

```json title="Response" theme={null}
{
  "request_id": "<request_id>",
  "action": "update_customer",
  "type": "response",
  "success": true,
  "payload": {}
}
```

***

## Update customer page

Updates the page the customer is currently visiting. Agent and referrer are updated by default using the browser's headers.

**Specifics**

|                        |                        |
| ---------------------- | ---------------------- |
| **Action**             | `update_customer_page` |
| **Web API equivalent** | —                      |
| **Push message**       | —                      |

**Request**

| Parameter | Required | Type     | Notes |
| --------- | -------- | -------- | ----- |
| `url`     | Yes      | `string` |       |
| `title`   | No       | `string` |       |

**Response**

| Field    | Data type | Notes                                                                                                                                                                                                              |
| -------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `groups` | `array`   | Optional. An array of objects with `id` and `status` properties. Present only if the customer's group assignment has changed as a result of this call. Possible statuses: `online`, `online_for_queue`, `offline`. |

```json title="Request" theme={null}
{
  "action": "update_customer_page",
  "payload": {
    "url": "https://www.text.com/pricing"
  }
}
```

```json title="Response" theme={null}
{
  "request_id": "<request_id>",
  "action": "update_customer_page",
  "type": "response",
  "success": true,
  "payload": {
    "groups": [
      {
        "id": 1,
        "status": "online"
      }
    ]
  }
}
```

***

## Set customer session fields

**Specifics**

|                        |                                                                                                |
| ---------------------- | ---------------------------------------------------------------------------------------------- |
| **Action**             | `set_customer_session_fields`                                                                  |
| **Web API equivalent** | [`set_customer_session_fields`](/api/customer-chat/v3.7/customers/set-customer-session-fields) |
| **Push message**       | `customer_updated`                                                                             |

**Request**

Agent and referrer are updated by default using the browser's headers.

| Parameter        | Required | Type       | Notes                                                                                               |
| ---------------- | -------- | ---------- | --------------------------------------------------------------------------------------------------- |
| `session_fields` | Yes      | `[]object` | An array of custom object-enclosed key-value pairs. Respects the order of items. Maximum: 100 keys. |

No response payload.

```json title="Request" theme={null}
{
  "action": "set_customer_session_fields",
  "payload": {
    "session_fields": [
      { "custom_key": "custom_value" },
      { "another_custom_key": "another_custom_value" }
    ]
  }
}
```

```json title="Response" theme={null}
{
  "request_id": "<request_id>",
  "action": "set_customer_session_fields",
  "type": "response",
  "success": true,
  "payload": {}
}
```

***

## Get customer

Returns the info about the customer requesting it.

**Specifics**

|                        |                                                                  |
| ---------------------- | ---------------------------------------------------------------- |
| **Action**             | `get_customer`                                                   |
| **Web API equivalent** | [`get_customer`](/api/customer-chat/v3.7/customers/get-customer) |
| **Push message**       | —                                                                |

**Response**

| Field            | Type       | Notes                                                                                                         |
| ---------------- | ---------- | ------------------------------------------------------------------------------------------------------------- |
| `name`           | `string`   | The customer's name. Returned only if set.                                                                    |
| `email`          | `string`   | The customer's email. Returned only if set.                                                                   |
| `avatar`         | `string`   | The customer's avatar. Returned only if set.                                                                  |
| `phone_number`   | `string`   | The customer's phone number. Returned only if set.                                                            |
| `session_fields` | `[]object` | An array of custom object-enclosed key-value pairs. Returned only if set. Available for the session duration. |
| `omnichannel`    | `object`   | The customer's omnichannel data.                                                                              |
| `address`        | `object`   | The customer's address data. Returned only if set.                                                            |

```json title="Request" theme={null}
{
  "action": "get_customer",
  "payload": {}
}
```

```json title="Response" theme={null}
{
  "request_id": "<request_id>",
  "action": "get_customer",
  "type": "response",
  "success": true,
  "payload": {
    "id": "b7eff798-f8df-4364-8059-649c35c9ed0c",
    "type": "customer",
    "name": "Thomas Anderson",
    "email": "t.anderson@example.com",
    "avatar": "https://example.com/avatars/1.jpg",
    "session_fields": [
      { "custom_key": "custom_value" },
      { "another_custom_key": "another_custom_value" }
    ]
  }
}
```
