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

# List messages

> List the agent's messages, newest first. To page back, pass the last message's id as before.



## OpenAPI

````yaml /openapi.json get /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.ai/api
security:
  - token: []
paths:
  /agents/{id}/messages:
    get:
      tags:
        - Messages
      summary: List messages
      description: >-
        List the agent's messages, newest first. To page back, pass the last
        message's id as before.
      operationId: listMessages
      parameters:
        - in: path
          name: id
          required: true
          description: The agent's id
          schema:
            type: string
            format: uuid
        - in: query
          name: channel
          schema:
            type: string
            enum:
              - email
              - sms
              - telegram
        - in: query
          name: direction
          schema:
            type: string
            enum:
              - inbound
              - outbound
        - in: query
          name: limit
          schema:
            type: integer
            minimum: 1
            maximum: 50
        - in: query
          name: counterpart
          schema:
            type: string
            minLength: 1
            maxLength: 320
          description: Keep the messages from or to this address or number
        - in: query
          name: before
          schema:
            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: List the messages older than this one, to page back
      responses:
        '200':
          description: The messages
          content:
            application/json:
              schema:
                type: array
                items:
                  $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
            - telegram
        direction:
          type: string
          enum:
            - inbound
            - outbound
        counterpart:
          type: string
          description: Who sent an inbound message, or the recipients of an outbound one
        counterpartName:
          description: >-
            The name an inbound message's sender goes by, when the channel tells
            it
          type:
            - string
            - 'null'
        to:
          type: array
          items:
            type: string
          description: >-
            Whom the message names as its recipients; an inbound one names the
            agent unless it got a blind copy
        cc:
          type: array
          items:
            type: string
          description: Whom the message names as getting a copy
        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
        thread:
          anyOf:
            - type: object
              properties:
                messageId:
                  type: string
                references:
                  type: array
                  items:
                    type: string
              required:
                - messageId
                - references
            - type: 'null'
          description: >-
            For received and imported email, its Message-ID and References; for
            email the agent sent, those of the email it answered
        status:
          type: string
          enum:
            - received
            - refused
            - sending
            - sent
            - failed
            - imported
            - reported
          description: '`reported` when the recipient marked an email the agent sent as spam'
        refusal:
          anyOf:
            - type: string
              enum:
                - self
                - spam
                - plan_limit
                - rate_limit
                - sender
                - outsider
                - unverified
            - type: 'null'
          description: Why a refused message did not wake the agent
        admission:
          anyOf:
            - type: string
              enum:
                - team
                - listed
                - anyone
            - type: 'null'
          description: >-
            Who the sender of a received message is to the agent: `team` for a
            member or agent of the workspace, `listed` for a sender on the
            channel's list, and `anyone` for everyone else, including senders
            who could not be verified
        error:
          description: Why a failed message was not sent or did not arrive
          type:
            - string
            - 'null'
        createdAt:
          type: string
          format: date-time
      required:
        - id
        - addressId
        - channel
        - direction
        - counterpart
        - counterpartName
        - to
        - cc
        - subject
        - text
        - attachments
        - thread
        - status
        - refusal
        - admission
        - 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.