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

# Send a message

> Adds a message from the conversation's customer. Sending the same `idempotencyKey` again returns the first message (`200`) instead of adding another.

Required scope: `conversations:write`.




## OpenAPI

````yaml /openapi.yaml post /conversations/{conversationId}/messages
openapi: 3.1.0
info:
  title: Cerium API
  version: 1.0.0
  description: |
    Send your customers and their conversations to Cerium from your own backend.
    Every request is authenticated with an API key.
servers:
  - url: https://api.usecerium.com/v1
    description: Production
security:
  - apiKey: []
tags:
  - name: Customers
  - name: Conversations
  - name: Messages
paths:
  /conversations/{conversationId}/messages:
    parameters:
      - $ref: '#/components/parameters/ConversationId'
    post:
      tags:
        - Messages
      summary: Send a message
      description: >
        Adds a message from the conversation's customer. Sending the same
        `idempotencyKey` again returns the first message (`200`) instead of
        adding another.


        Required scope: `conversations:write`.
      operationId: sendMessage
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SendMessage'
            example:
              body: Here is the receipt.
              idempotencyKey: order-1042-msg-2
              attachments:
                - url: https://files.example.com/receipts/1042.pdf
                  fileName: receipt-1042.pdf
                  mimeType: application/pdf
                  size: 48213
      responses:
        '200':
          description: >-
            This `idempotencyKey` was already used. The first message is
            returned and nothing new is added.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MessageResponse'
        '201':
          description: The message was added.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MessageResponse'
        '400':
          $ref: '#/components/responses/Invalid'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
components:
  parameters:
    ConversationId:
      name: conversationId
      in: path
      required: true
      description: The conversation's id.
      schema:
        type: string
      example: thr_01k9z3m4q8
  schemas:
    SendMessage:
      type: object
      required:
        - body
      properties:
        body:
          type: string
          minLength: 1
          maxLength: 20000
        idempotencyKey:
          type: string
          minLength: 1
          maxLength: 64
          description: >-
            A unique key for this attempt. Sending it again returns the first
            message instead of adding another.
          example: order-1042-msg-1
        attachments:
          type: array
          maxItems: 10
          items:
            $ref: '#/components/schemas/Attachment'
    MessageResponse:
      type: object
      properties:
        message:
          type: string
          example: Message received.
        status:
          type: string
          example: success
        data:
          $ref: '#/components/schemas/Message'
    Attachment:
      type: object
      required:
        - url
      properties:
        url:
          type: string
          format: uri
          maxLength: 2048
          description: An https address the team can open.
        fileName:
          type:
            - string
            - 'null'
          maxLength: 255
        mimeType:
          type:
            - string
            - 'null'
          maxLength: 100
        size:
          type:
            - integer
            - 'null'
          minimum: 0
          description: Size in bytes.
    Message:
      type: object
      properties:
        id:
          type: string
          example: msg_5d1c
        conversationId:
          type: string
          example: thr_01k9z3m4q8
        from:
          type: string
          enum:
            - customer
            - agent
          description: Which side wrote it. AI replies and system notices are `agent`.
        senderType:
          type: string
          enum:
            - customer
            - agent
            - ai
            - system
        senderName:
          type:
            - string
            - 'null'
          example: Ada Obi
        body:
          type: string
        attachments:
          type: array
          items:
            $ref: '#/components/schemas/Attachment'
        status:
          type: string
          example: sent
        sentAt:
          type: string
          format: date-time
    Error:
      type: object
      description: >
        `message` is always present. `code` is a stable identifier for specific
        errors you may want to handle in code.

        A validation error has a `message` that is a list of everything to fix.
      properties:
        code:
          type: string
          description: A stable identifier you can match on.
        message:
          oneOf:
            - type: string
            - type: array
              items:
                type: string
        statusCode:
          type: integer
        error:
          type: string
      required:
        - message
  responses:
    Invalid:
      description: The request is not valid. `message` says what to fix.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            statusCode: 400
            error: Bad Request
            message:
              - email must be an email
    Unauthorized:
      description: The key is missing or not valid.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            statusCode: 401
            message: Authentication token is missing.
    Forbidden:
      description: The key does not have the scope this call needs.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            statusCode: 403
            message: This key cannot do that.
    NotFound:
      description: Nothing has that id.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            code: thread_not_found
            message: No conversation has that id.
    RateLimited:
      description: Too many requests. Wait, then try again.
      headers:
        Retry-After:
          description: Seconds to wait before trying again.
          schema:
            type: integer
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer
      description: >
        Your API key, sent as `Authorization: Bearer <key>`. Create keys in the
        Cerium dashboard.

        Keep them on your servers only.

````