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

# Send a message

> Answer a message by giving its id as replyTo, or start a new one with a channel and recipients in to.



## OpenAPI

````yaml /openapi.json post /agents/{id}/messages
openapi: 3.1.0
info:
  title: Artil API
  description: Give AI agents their own email inbox, SMS number and secret storage.
  version: 1.0.0
servers:
  - url: https://app.artil.dev/api
security:
  - token: []
paths:
  /agents/{id}/messages:
    post:
      tags:
        - Messages
      summary: Send a message
      description: >-
        Answer a message by giving its id as replyTo, or start a new one with a
        channel and recipients in to.
      operationId: sendMessage
      parameters:
        - in: path
          name: id
          required: true
          description: The agent's id
          schema:
            type: string
            format: uuid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                replyTo:
                  type: string
                  format: uuid
                  pattern: >-
                    ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
                channel:
                  type: string
                  enum:
                    - email
                    - sms
                to:
                  minItems: 1
                  maxItems: 10
                  type: array
                  items:
                    type: string
                    minLength: 1
                    maxLength: 320
                subject:
                  type: string
                  maxLength: 240
                text:
                  type: string
                  minLength: 1
                  maxLength: 32000
              required:
                - text
      responses:
        '201':
          description: The sent message
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Message'
        default:
          $ref: '#/components/responses/Failure'
components:
  schemas:
    Message:
      type: object
      properties:
        id:
          type: string
          format: uuid
          pattern: >-
            ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
        addressId:
          type: string
          format: uuid
          pattern: >-
            ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
          description: The agent's address the message came to or went from
        channel:
          type: string
          enum:
            - email
            - sms
        direction:
          type: string
          enum:
            - inbound
            - outbound
        counterpart:
          type: string
          description: Who sent an inbound message, or the recipients of an outbound one
        subject:
          type:
            - string
            - 'null'
        text:
          type: string
        attachments:
          type: array
          items:
            type: object
            properties:
              name:
                type: string
              type:
                type: string
              size:
                type: number
            required:
              - name
              - type
              - size
        status:
          type: string
          enum:
            - received
            - refused
            - sending
            - sent
            - failed
        refusal:
          anyOf:
            - type: string
              enum:
                - self
                - spam
                - plan_limit
                - rate_limit
                - sender
                - unverified
            - type: 'null'
          description: Why a refused message did not wake the agent
        error:
          description: Why a failed message was not sent
          type:
            - string
            - 'null'
        createdAt:
          type: string
          format: date-time
      required:
        - id
        - addressId
        - channel
        - direction
        - counterpart
        - subject
        - text
        - attachments
        - status
        - refusal
        - error
        - createdAt
  responses:
    Failure:
      description: The request failed; the error says why
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: object
                properties:
                  code:
                    type: string
                    enum:
                      - invalid_input
                      - unauthorized
                      - forbidden
                      - plan_limit
                      - not_found
                      - conflict
                      - rate_limited
                      - internal
                      - unavailable
                  message:
                    type: string
                required:
                  - code
                  - message
            required:
              - error
  securitySchemes:
    token:
      type: http
      scheme: bearer

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.