> ## 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.

# Events

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

## Send event

Sends an event object. Use this method to send a message by specifying the message event type in the request. Updates the requester's `events_seen_up_to` as if they've seen all chat events.

**Specifics**

|                        |                                                           |
| ---------------------- | --------------------------------------------------------- |
| **Action**             | `send_event`                                              |
| **Web API equivalent** | [`send_event`](/api/customer-chat/v3.7/events/send-event) |
| **Push message**       | `incoming_event`                                          |

**Request**

| Parameter               | Required | Type     | Notes                                                                                                                                                             |
| ----------------------- | -------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `chat_id`               | Yes      | `string` | The ID of the chat you want to send the message to.                                                                                                               |
| `event`                 | Yes      | `object` | An event object. Does not support the `form` type event in Text.                                                                                                  |
| `attach_to_last_thread` | No       | `bool`   | The flag is ignored for active chats. For inactive chats: if set to `true`, the event will be added to the last thread. If set to `false`: the request will fail. |

**Response**

| Field      | Type     | Notes |
| ---------- | -------- | ----- |
| `event_id` | `string` |       |

```json title="Request" theme={null}
{
  "action": "send_event",
  "payload": {
    "chat_id": "PW94SJTGW6",
    "event": {
      "type": "message",
      "text": "hello world",
      "recipients": "all"
    }
  }
}
```

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

***

## Delete event

Deletes an event object. Deleted events are hidden from all Customer Chat API responses but remain visible via the Agent Chat API.

In the Agent Chat API, this method replaces the original event with a deleted event for agents with the `normal` role. Agents with higher roles (`administrator`, `viceowner`, and `owner`) see the original event with a `deleted` flag.

**Specifics**

|                        |                                                               |
| ---------------------- | ------------------------------------------------------------- |
| **Action**             | `delete_event`                                                |
| **Web API equivalent** | [`delete_event`](/api/customer-chat/v3.7/events/delete-event) |
| **Push message**       | `event_deleted`                                               |

**Request**

| Parameter   | Required | Type     | Notes                                         |
| ----------- | -------- | -------- | --------------------------------------------- |
| `chat_id`   | Yes      | `string` | The ID of the chat to delete an event from.   |
| `thread_id` | Yes      | `string` | The ID of the thread to delete an event from. |
| `event_id`  | Yes      | `string` | The ID of the event to delete.                |

No response payload.

```json title="Request" theme={null}
{
  "action": "delete_event",
  "payload": {
    "chat_id": "123-123-123-123",
    "thread_id": "E2WDHA8A",
    "event_id": "E2WDHA8A_4"
  }
}
```

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

***

## Send rich message postback

**Specifics**

|                        |                                                                                                 |
| ---------------------- | ----------------------------------------------------------------------------------------------- |
| **Action**             | `send_rich_message_postback`                                                                    |
| **Web API equivalent** | [`send_rich_message_postback`](/api/customer-chat/v3.7/events/send-rich-message-postback)       |
| **Push message**       | <Tooltip tip="Will be sent only for active threads.">`incoming_rich_message_postback`</Tooltip> |

**Request**

| Parameter                       | Required | Type     | Notes                                                                                         |
| ------------------------------- | -------- | -------- | --------------------------------------------------------------------------------------------- |
| `chat_id`                       | Yes      | `string` |                                                                                               |
| `thread_id`                     | Yes      | `string` |                                                                                               |
| `event_id`                      | Yes      | `string` |                                                                                               |
| `postback`                      | Yes      | `object` |                                                                                               |
| `postback.id`                   | Yes      | `string` | The postback name of the button.                                                              |
| `postback.toggled`              | Yes      | `bool`   | If set to `true`: the postback is toggled on. If set to `false`: the postback is toggled off. |
| `postback.button_type`          | No       | `string` |                                                                                               |
| `postback.button_value`         | No       | `string` |                                                                                               |
| `postback.ecommerce`            | No       | `object` |                                                                                               |
| `postback.ecommerce.product_id` | No       | `string` | Required when `postback.ecommerce` is included.                                               |
| `postback.ecommerce.option_id`  | No       | `string` | Required when `postback.ecommerce` is included.                                               |
| `postback.ecommerce.quantity`   | No       | `number` |                                                                                               |

No response payload.

```json title="Request" theme={null}
{
  "action": "send_rich_message_postback",
  "payload": {
    "chat_id": "PJ0MRSHTDG",
    "thread_id": "K600PKZON8",
    "event_id": "a0c22fdd-fb71-40b5-bfc6-a8a0bc3117f7",
    "postback": {
      "id": "Method URL_yes",
      "toggled": true
    }
  }
}
```

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

***

## Send sneak peek

Sends a sneak peek to a chat.

**Specifics**

|                        |                                                                     |
| ---------------------- | ------------------------------------------------------------------- |
| **Action**             | `send_sneak_peek`                                                   |
| **Web API equivalent** | [`send_sneak_peek`](/api/customer-chat/v3.7/events/send-sneak-peek) |
| **Push message**       | —                                                                   |

**Request**

| Parameter         | Required | Type     | Notes                                       |
| ----------------- | -------- | -------- | ------------------------------------------- |
| `chat_id`         | Yes      | `string` | The ID of the chat to send a sneak peek to. |
| `sneak_peek_text` | Yes      | `string` | The sneak peek text.                        |

No response payload.

```json title="Request" theme={null}
{
  "action": "send_sneak_peek",
  "payload": {
    "chat_id": "PJ0MRSHTDG",
    "sneak_peek_text": "hello world"
  }
}
```

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