---
title: "/chat/{id}/messages"
method: POST
path: "/chat/{id}/messages"
tags: ["Chat"]
---

# /chat/{id}/messages

`POST /chat/{id}/messages`

## Request

- Base URL: `<<api-url>>` (relative, and the document’s source URL is not known)
- URL: `<<api-url>>/chat/{id}/messages`
- Auth: API key in header `X-API-KEY`

Send a message to a open chat

## Path parameters

- `id` string, required

## Headers

- `octa-agent-email` string

## Request body

- MessageSend
  - `chatId` string: Id of the chat that this message will be included
  - `type` 'public' | 'internal', required: Indicate whether the message is intended for internal or public communication
  - `body` string: Message content
  - `attachments` AttachmentSend[]: Attachments included in the message
    - `name` string, required: Name of the attachment sent
    - `base64` string: The attachment content encoded in Base64. Ensure that the string only contains the Base64 encoded data without any metadata like "data:image/png;base64,". Required if url is not provided.
    - `mimeType` string: The MIME type of the attachment, which indicates the format of the file. This is important for correctly interpreting the attachment. Common examples include "application/pdf", "image/png", "text/plain". Required if base64 is provided.
    - `url` string: URL of the attachment. Must be from a Octadesk bucket. Provide either url OR base64+mimeType.
  - `mentions` User[]: Mentions made in the message
    - `id` string, required: Person identifier
    - `name` string, required: Person name
    - `email` string, required: Person email
    - `type` string: Person type, if is an agent or a contact
    - `phoneContacts` PhoneContacts: Person phone number
      - `number` string, required: Phone Number that will receive the message
      - `countryCode` string: Country code
    - `customFields` CustomFields: Custom fields
      - `key` string, required: Key of the field
      - `value` union, required: Value of the field
        - string
        - number
        - boolean
    - `organization` Organization: This field refers to the organization to which the contact belongs
      - `id` string, required: Organization ID
      - `name` string, required: Organization name
      - `customField` CustomFields[], required: Organization custom fields
        - `key` string, required: Key of the field
        - `value` union, required: Value of the field
          - string
          - number
          - boolean
  - `quoted` Quoted: Message that was quoted
    - `messageId` string, required: Message id that will be quoted
  - `channel` 'whatsapp' | 'web' | 'facebook-messenger' | 'instagram' | 'email' | 'widget', required: Channel that this message is from

## Response `201`

- Message
  - `id` string, required: Message identifier
  - `chatId` string, required: Chat identifier
  - `time` string, date-time, required: Message sending date
  - `type` 'public' | 'internal', required: Indicate whether the message is intended for internal or public communication
  - `body` string, required: Message content
  - `readAt` string, date-time: Date the message was read
  - `attachments` Attachment[]: Attachments included in the message
    - `id` string, required: The attachment id
    - `name` string: Name of the attachment sent
    - `url` string: Attachment link in Octadesk files
  - `sentBy` User, required: Information about who sent the message
    - `id` string, required: Person identifier
    - `name` string, required: Person name
    - `email` string, required: Person email
    - `type` string: Person type, if is an agent or a contact
    - `phoneContacts` PhoneContacts: Person phone number
      - `number` string, required: Phone Number that will receive the message
      - `countryCode` string: Country code
    - `customFields` CustomFields: Custom fields
      - `key` string, required: Key of the field
      - `value` union, required: Value of the field
        - string
        - number
        - boolean
    - `organization` Organization: This field refers to the organization to which the contact belongs
      - `id` string, required: Organization ID
      - `name` string, required: Organization name
      - `customField` CustomFields[], required: Organization custom fields
        - `key` string, required: Key of the field
        - `value` union, required: Value of the field
          - string
          - number
          - boolean
  - `status` 'sending' | 'sended' | 'received' | 'read' | 'error' | 'deleted' | 'scheduled' | 'spam', required: Message status
  - `mentions` User[]: Mentions made in the message
    - `id` string, required: Person identifier
    - `name` string, required: Person name
    - `email` string, required: Person email
    - `type` string: Person type, if is an agent or a contact
    - `phoneContacts` PhoneContacts: Person phone number
      - `number` string, required: Phone Number that will receive the message
      - `countryCode` string: Country code
    - `customFields` CustomFields: Custom fields
      - `key` string, required: Key of the field
      - `value` union, required: Value of the field
        - string
        - number
        - boolean
    - `organization` Organization: This field refers to the organization to which the contact belongs
      - `id` string, required: Organization ID
      - `name` string, required: Organization name
      - `customField` CustomFields[], required: Organization custom fields
        - `key` string, required: Key of the field
        - `value` union, required: Value of the field
          - string
          - number
          - boolean
  - `quoted` object: Message that was quoted
  - `externalLink` string: External links sent in the message
  - `errorSource` string: Source of the error (e.g. "meta", "platform") when status is "error"
  - `errorCode` string: Error code returned by the provider (e.g. Meta/WhatsApp) when status is "error"
  - `errorMessage` string: Detailed error message from the provider when status is "error"

---

[API](https://skmtc.dev/octadesk/apis/octadesk-api.md) - [All operations](https://skmtc.dev/octadesk/apis/octadesk-api/llms.txt) - [OpenAPI document](https://skmtc.dev/octadesk/apis/octadesk-api/revisions/cf3224b37a34?raw)
