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

# Send Message to Contact on Any Active Channel

> Use POST /api/v1/contacts/{identifier}/messages to send a text, file, or flow message to a contact on their active ChatbotX channel inbox.

The Send Message endpoint delivers a message to a contact on one of their active channel inboxes. You can send plain text, file attachments, or trigger a specific flow node. If you specify an `inboxId`, the message is sent on that inbox's channel; if you omit it, ChatbotX sends on the last channel the contact interacted on. A successful request returns HTTP `204 No Content`.

<Info>
  **POST** `/api/v1/contacts/{identifier}/messages`
</Info>

## Path Parameters

<ParamField path="identifier" type="string" required>
  A contact lookup string. Minimum length: 1 character.

  | Format          | Example                  |
  | --------------- | ------------------------ |
  | `id:<value>`    | `id:123456789`           |
  | `email:<value>` | `email:user@example.com` |
  | `phone:<value>` | `phone:+84708123123`     |
</ParamField>

## Request Body

<ParamField body="text" type="string">
  The text content of the message. Must be between 1 and 1,000 characters. Required if `files` or `flowId` is not provided.
</ParamField>

<ParamField body="files" type="array">
  Array of file attachments to send. Minimum 1 item when provided.
</ParamField>

<ParamField body="flowId" type="string">
  ID of the flow to trigger for this contact. Must be a numeric string matching the pattern `\d+`.
</ParamField>

<ParamField body="nodeId" type="string">
  ID of a specific flow node to start from. Must be a numeric string matching the pattern `\d+`.
</ParamField>

<ParamField body="inboxId" type="string">
  ID of the inbox (channel) to send the message on. If omitted, ChatbotX uses the contact's last active channel. Must be a numeric string matching `\d+`.
</ParamField>

<ParamField body="clientId" type="string">
  An optional client-side idempotency identifier. Must be a numeric string matching `\d+`.
</ParamField>

## Code Examples

<CodeGroup>
  ```bash curl theme={null}
  # Send a text message
  curl --request POST \
    --url "https://app.chatbotx.io/api/v1/contacts/email:user@example.com/messages" \
    --header "Authorization: Bearer YOUR_API_TOKEN" \
    --header "Content-Type: application/json" \
    --data '{
      "text": "Hello from ChatbotX! Your order has shipped.",
      "inboxId": "42"
    }'
  ```

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

  identifier = "email:user@example.com"
  url = f"https://app.chatbotx.io/api/v1/contacts/{identifier}/messages"
  headers = {
      "Authorization": "Bearer YOUR_API_TOKEN",
      "Content-Type": "application/json"
  }
  payload = {
      "text": "Hello from ChatbotX! Your order has shipped.",
      "inboxId": "42"
  }

  response = requests.post(url, json=payload, headers=headers)
  print(response.status_code)  # 204 on success
  ```

  ```javascript JavaScript theme={null}
  const identifier = 'email:user@example.com';
  const options = {
    method: 'POST',
    headers: {
      Authorization: 'Bearer YOUR_API_TOKEN',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      text: 'Hello from ChatbotX! Your order has shipped.',
      inboxId: '42'
    })
  };

  fetch(`https://app.chatbotx.io/api/v1/contacts/${identifier}/messages`, options)
    .then(res => {
      if (res.status === 204) console.log('Message sent successfully');
    })
    .catch(err => console.error(err));
  ```
</CodeGroup>

## Response

A successful request returns **HTTP 204 No Content** with no response body, confirming the message was queued for delivery.

```
HTTP/1.1 204 No Content
```

<Note>
  Always test message sending on a test contact before running bulk operations to verify message delivery.
</Note>
