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

# List conversations

> Returns a list of an agent's conversations on every channel, sorted by start time with the newest first, so pages don't shift as new messages arrive. Playground tests are included with `channel: playground`. Conversations where the user never sent a message aren't included, except API conversations.

Filters combine with AND, and filters that take a comma-separated list match any of the values. Unknown query parameters return `validation_failed`, and IDs that match nothing return an empty list.



## OpenAPI

````yaml /api-reference/v3/openapi.json get /conversations
openapi: 3.1.0
info:
  title: Chatling API
  version: 3.0.0-draft
  summary: Manage Chatling AI agents and chatbots with an API key.
  description: >
    Internal draft, not published yet. It documents every endpoint in
    `routes/api_public_v3.php`, and
    `tests/Feature/PublicApiV3/OpenApiSpecTest.php` fails if this file and the
    routes differ.


    ## Authentication


    The Chatling API uses API keys to authenticate requests. Create and manage
    keys in the dashboard under Project settings > API keys. Each key belongs to
    one project, and the project's plan must include API access.


    Send the key in the `Authorization` header as a bearer token:
    `Authorization: Bearer <key>`.


    ## Key restrictions


    You can restrict a key in three ways when you create it in the dashboard:


    - **Permissions:** Read and write (the default), read only, or custom.
    Custom permissions grant create, read, update, and delete access for each
    permission group, and publish access for workflows, which makes a workflow
    run on users' conversations. `GET` requests need read access, `POST` create,
    `PATCH` update, and `DELETE` delete, unless an endpoint says otherwise.

    - **Agent access:** All agents, or selected agents. A key limited to
    selected agents gets 404 for other agents, and can't use project-wide
    endpoints such as Create an AI agent.

    - **Expiry:** Requests with an expired key fail with 401 `api_key_expired`.


    ## Errors


    Chatling uses conventional HTTP response codes to indicate the success or
    failure of an API request. Codes in the 2xx range indicate success. Codes in
    the 4xx range indicate an error caused by the request, such as a missing
    parameter. Codes in the 5xx range indicate an error with Chatling's servers.


    Every error returns an `error` object:


    ```json

    {
      "error": {
        "type": "invalid_request_error",
        "code": "validation_failed",
        "message": "The name field is required.",
        "param": "name",
        "request_id": "req_8fK2mQ9xLp4TzR7vWc1Ns3Yb",
        "errors": [
          { "param": "name", "message": "The name field is required." },
          { "param": "color", "message": "The color must be a hex color such as #3B82F6." }
        ]
      }
    }

    ```


    | Field | Description |

    | --- | --- |

    | `type` | The type of error. One of the types listed below. |

    | `code` | A short string identifying the error, such as `validation_failed`
    or `conversation_ended`. Codes are stable, so handle errors by `code`. New
    codes may be added. |

    | `message` | A human-readable message with more details. The wording can
    change, so don't parse it. |

    | `param` | If the error is parameter-specific, the parameter related to the
    error, such as `name`. Nested fields and array items use dot notation, such
    as `variables.plan` or `member_ids.1` for the second item. `null` if no
    single parameter caused the error. |

    | `request_id` | The ID of the request, also returned in the `X-Request-Id`
    header. Include it when you contact support. |

    | `errors` | For `validation_failed` only: every invalid parameter, each
    with its own `param` and `message`. The top-level `param` and `message`
    match the first entry. |


    Every `code` is listed under Error codes below.


    | `type` | Status | Description |

    | --- | --- | --- |

    | `authentication_error` | 401 | No valid API key was provided. |

    | `permission_error` | 403 | The API key or the project's plan doesn't allow
    the request. |

    | `not_found_error` | 404, 410 | The resource doesn't exist, or the API key
    can't access it. |

    | `invalid_request_error` | 400, 405, 409, 413, 422 | The request has
    invalid parameters or conflicts with the resource's current state. |

    | `idempotency_error` | 409, 422 | An `Idempotency-Key` was reused for a
    different request, or its first request is still running. |

    | `rate_limit_error` | 429 | Too many requests hit the API too quickly.
    Retry after `Retry-After` seconds. |

    | `api_error` | 500, 503 | Something went wrong on Chatling's end. These are
    rare. |


    ## Agents


    Chatling has two kinds of agent: AI agents and flow-builder chatbots. Most
    endpoints work with both. Resources that belong to an agent, such as
    conversations, contacts, knowledge base sources, and labels, take either
    kind's ID as `agent_id`. Pass it in the query string when listing, and in
    the body when creating. It's required.


    Only the endpoints that manage the agent itself are separate: `/agents` for
    AI agents and `/chatbots` for chatbots. Using one kind's ID at the other's
    path returns 404, with a message pointing to the right path.


    Endpoints available for AI agents only, such as WhatsApp templates and
    variables, return 409 `unsupported_agent_type` for a chatbot.


    Endpoints for a single resource, such as `/conversations/{conversation}`,
    don't take `agent_id`. The resource's `agent` field has the agent's `id`,
    `type` (`ai_agent` or `chatbot`), and `name`.


    A chatbot's flow doesn't run through the API. When you send a chatbot a user
    message, it answers from its knowledge base using the AI settings in `ai`.


    ## Pagination


    Lists of members, agents, chatbots, conversations, messages, contacts,
    knowledge base sources, and analytics rankings return one page at a time:
    `{"object": "list", "data", "has_more", "next_cursor"}`. To fetch the next
    page, pass `next_cursor` as `cursor`, with the same filters. `limit` sets
    the page size, from 1 to 100. It defaults to 20 unless a list says
    otherwise, and can change between pages.


    Cursors are opaque and expire after 24 hours. They only work with the same
    list, filters, and project. Otherwise, the request fails with 422
    `invalid_cursor`.


    Pages follow the list's order, not an offset, so items that exist the whole
    time are returned exactly once, even if others are added or removed while
    you page. Items added while you page might be missed. Start again from the
    first page to include them.


    Analytics rankings, such as List countries, page by rank instead. Keep the
    same `limit` on every page. If the data refreshes while you page, a row can
    move to another page.


    AI models, labels, teams, topics, and variables always return every item in
    one page.


    ## Rate limits


    Each API key can make 500 requests per minute. Every response includes the
    `X-RateLimit-Limit`, `X-RateLimit-Remaining`, and `X-RateLimit-Reset` (a
    Unix timestamp) headers. Requests over the limit fail with 429
    `rate_limit_exceeded` and a `Retry-After` header.


    ## Idempotent requests


    The API supports idempotency for safely retrying `POST` requests without
    performing the same operation twice. Send an `Idempotency-Key` header with a
    unique value of 1 to 255 printable ASCII characters, such as a V4 UUID.


    For 24 hours, retrying with the same key and the same request returns the
    saved response with an `Idempotent-Replayed: true` header, instead of
    running the request again. Reusing a key for a different request fails with
    422 `idempotency_key_reused`.


    Only successful responses are saved, so you can retry a failed request with
    the same key. The exception is `message_not_saved` from Send a WhatsApp
    template: the template was already delivered, so don't retry.


    ## Request IDs


    Each API request has a request ID, returned in the `X-Request-Id` header and
    in error responses. Include it when you contact support.


    ## Error codes


    Every `code` the API returns, grouped by `type`. New codes may be added, so
    handle unknown codes by their `type`.


    ### `authentication_error`


    No valid API key was provided.


    | Code | Status | Description |

    | --- | --- | --- |

    | `missing_api_key` | 401 | No API key was provided in the `Authorization`
    header. |

    | `invalid_api_key` | 401 | The API key doesn't exist or was revoked. |

    | `api_key_expired` | 401 | The API key has expired. |


    ### `permission_error`


    The API key or the project's plan doesn't allow the request.


    | Code | Status | Description |

    | --- | --- | --- |

    | `insufficient_permission` | 403 | The API key doesn't have permission to
    perform the request. |

    | `project_suspended` | 403 | The project is suspended or no longer exists.
    |

    | `plan_feature_unavailable` | 403 | The project's plan doesn't include this
    feature, such as API access, attachments, auto-sync, or a workflow action. |

    | `agent_limit_reached` | 403 | The plan's limit on AI agents and chatbots
    was reached. |

    | `agent_suspended` | 403 | The agent is suspended. It can't be updated,
    duplicated, or reply. |

    | `ai_credits_exhausted` | 403 | The project has no AI credits left, so the
    agent can't reply. |

    | `agent_credit_limit_reached` | 403 | The agent reached its AI credit
    limit. |

    | `user_blocked` | 403 | The user is blocked from messaging this agent. |

    | `knowledge_base_limit_reached` | 403 | The plan's knowledge base character
    limit was reached. |

    | `resync_credits_exhausted` | 403 | The project has no resync credits left.
    |

    | `invalid_attachment_url` | 403 | The attachment URL is invalid or expired.
    List the conversation's messages to get a new one. |


    ### `not_found_error`


    The resource doesn't exist, or the API key can't access it.


    | Code | Status | Description |

    | --- | --- | --- |

    | `resource_not_found` | 404 | The resource doesn't exist, or the API key
    can't access it. |

    | `route_not_found` | 404 | No endpoint matches the method and path. |

    | `attachment_unavailable` | 410 | The channel no longer has the file. |


    ### `invalid_request_error`


    The request has invalid parameters or conflicts with the resource's current
    state. Fix the request before retrying, except for `resource_busy` and
    `source_not_ready`, which you can retry unchanged later.


    | Code | Status | Description |

    | --- | --- | --- |

    | `invalid_json` | 400 | The request body isn't valid JSON. |

    | `invalid_idempotency_key` | 400 | The `Idempotency-Key` header isn't 1 to
    255 printable ASCII characters. |

    | `method_not_allowed` | 405 | The endpoint doesn't support this HTTP
    method. |

    | `request_too_large` | 413 | The request body is too large. |

    | `validation_failed` | 422 | One or more parameters are invalid. `errors`
    lists each one. |

    | `invalid_cursor` | 422 | The pagination cursor is invalid or expired.
    Start again from the first page. |

    | `resource_busy` | 409 | Another request for this project is still running.
    Retry shortly. |

    | `conversation_ended` | 409 | The conversation has ended and can't take new
    messages or attachments. |

    | `reply_window_closed` | 409 | The channel's reply window is closed, so
    team members can't reply. |

    | `wrong_channel` | 409 | The action is only available for conversations on
    the API channel. |

    | `contact_already_exists` | 409 | A contact with this email already exists.
    |

    | `message_not_rateable` | 409 | Only AI-written answers can be rated. |

    | `channel_not_connected` | 409 | The channel isn't connected to the agent.
    Connect it in the dashboard first. |

    | `unsupported_agent_type` | 409 | The endpoint is available for AI agents
    only, and the agent is a chatbot. |

    | `whatsapp_send_failed` | 409 | Meta didn't send the WhatsApp template.
    `message` includes Meta's reason. |

    | `system_variable_read_only` | 409 | System variables can't be updated or
    deleted. |

    | `workflow_not_published` | 409 | The workflow was never published, so it
    can't be turned on or off. Publish it in the dashboard first. |

    | `knowledge_base_linked` | 409 | The agent uses another agent's knowledge
    base and has no sources of its own. |

    | `source_already_exists` | 409 | The knowledge base already has a source
    with this URL. |

    | `source_not_ready` | 409 | The source is still training. Retry after it's
    processed or failed. |

    | `resync_already_queued` | 409 | The source is already queued for a resync.
    |

    | `resync_unavailable` | 409 | This type of source, such as a document,
    can't be resynced. |

    | `upload_already_used` | 409 | The upload was already added as a knowledge
    base source. |

    | `attachments_unavailable` | 409 | The conversation doesn't accept these
    attachments in its current mode. |

    | `too_many_pending_attachments` | 409 | Too many uploaded files are waiting
    to be sent. Send or delete some first. |

    | `unsupported_file_type` | 422 | The file type isn't supported. |

    | `file_too_large` | 422 | The file exceeds the size limit. |

    | `file_type_not_allowed` | 422 | The AI agent's attachment settings don't
    allow this file type. |

    | `invalid_image` | 422 | The image can't be read. |

    | `attachment_rejected` | 422 | The image violates the content policy. |

    | `too_many_attachments` | 422 | The message has more attachments than
    allowed. |

    | `attachment_not_found` | 422 | An attachment doesn't exist in this
    conversation, or was already sent. |

    | `attachment_not_allowed` | 422 | An attachment is no longer allowed in
    this conversation. |


    ### `idempotency_error`


    The `Idempotency-Key` can't be used for this request.


    | Code | Status | Description |

    | --- | --- | --- |

    | `idempotency_key_reused` | 422 | The key was already used for a different
    request. |

    | `idempotency_request_in_progress` | 409 | The first request with this key
    is still running. Retry shortly. |


    ### `rate_limit_error`


    Too many requests hit the API too quickly. Retry after `Retry-After`
    seconds.


    | Code | Status | Description |

    | --- | --- | --- |

    | `rate_limit_exceeded` | 429 | The API key's rate limit, or the agent's
    per-user message limit, was reached. |


    ### `api_error`


    Something went wrong on Chatling's end. Retry shortly.


    | Code | Status | Description |

    | --- | --- | --- |

    | `internal_error` | 500 | An unexpected error occurred. Include the
    `request_id` if you contact support. |

    | `service_unavailable` | 503 | The API is temporarily unavailable. |

    | `message_not_saved` | 503 | The team message couldn't be saved. If the
    request was Send a WhatsApp template, the template was already sent, so
    don't retry. |

    | `end_failed` | 503 | The conversation couldn't be ended. |

    | `upload_failed` | 503 | The file couldn't be stored. |

    | `delete_failed` | 503 | The attachment couldn't be deleted. |

    | `attachment_check_unavailable` | 503 | The image couldn't be checked
    against the content policy. |

    | `analytics_unavailable` | 503 | Analytics couldn't be loaded. |

    | `whatsapp_request_failed` | 503 | Meta couldn't be reached or rejected the
    request. |
servers:
  - url: https://api.chatling.ai/v3
security:
  - apiKey: []
tags:
  - name: API key
    description: The API key making the request.
  - name: Project
    description: >-
      The project the API key belongs to, and its usage against its plan,
      add-ons, and lifetime grants.


      Permission groups: `project` (read, update) and `usage` (read).
  - name: Members
    description: >-
      The project's team members and pending invites. Invite, change, and remove
      members in the dashboard. A member's `account_id` identifies them as a
      conversation assignee, a team member, and the author of replies and notes.


      Permission group: `members` (read).
  - name: AI models
    description: >-
      The AI models available to AI agents, and to chatbot replies sent through
      the API.


      Permission group: `agents`.
  - name: Agents
    description: >-
      AI agents and their settings, such as the business name, time zone, and AI
      settings like the model and instructions. Chatbots have their own
      endpoints under Chatbots.


      Permission group: `agents`.
  - name: Chatbots
    description: >-
      Flow-builder chatbots. You build and publish a chatbot's flow in the
      dashboard. The API can create, list, update, duplicate, and delete
      chatbots.


      Use a chatbot's `id` as `agent_id` in endpoints for resources that belong
      to it, such as conversations, contacts, and the knowledge base. Endpoints
      that only support AI agents say so.


      Permission group: `agents`.
  - name: Analytics
    description: >-
      An agent's analytics over a range of days, matching the dashboard's
      Analytics page: an overview with totals and daily series, and rankings of
      countries, channels, pages, topics, and busiest hours. Days are in UTC,
      and data refreshes every hour.


      Requires analytics on the plan. Topics and sentiment also require advanced
      analytics, and are only available for AI agents.


      Permission group: `analytics` (read).
  - name: Channels
    description: >-
      The WhatsApp, Instagram, Messenger, and Telegram accounts connected to an
      agent, and each channel's settings. Connect and disconnect channels in the
      dashboard. The website widget isn't listed because it doesn't need a
      connection.


      Chatbots built for WhatsApp can only use WhatsApp, and web chatbots have
      no channels.


      Permission group: `channels` (read, update).
  - name: WhatsApp
    description: >-
      Message templates of the WhatsApp account connected to an AI agent. Create
      and edit templates in the dashboard. Meta reviews each template before it
      can be sent.


      Permission group: `whatsapp`. Listing and retrieving templates requires
      read access, sending requires create, refreshing requires update, and
      deleting requires delete.
  - name: Conversations
    description: >-
      Conversations with AI agents and chatbots on every channel. Use these
      endpoints to chat with an agent as a user over the API channel, and to
      handle live chat as the team: send replies and internal notes, hand
      conversations over, assign them, and end them. Playground tests are
      included with `channel: playground`.


      Permission group: `conversations`. Read covers conversations, messages,
      and usage. Create covers starting conversations, sending messages,
      replies, and notes, and uploading attachments. Update covers changing and
      ending conversations. Delete covers deleting conversations and unsent
      attachments.
  - name: Contacts
    description: >-
      The people an agent has details for, such as a name and email, collected
      in conversations or added through the API. Each contact belongs to one
      agent. To link a contact to a new conversation, pass `contact_id` to
      [Start a
      conversation](/api-reference/v3/conversations/start-conversation). To find
      a contact's conversations, filter [List
      conversations](/api-reference/v3/conversations/list-conversations) by
      `contact_id`.


      Permission group: `contacts`.
  - name: Knowledge base
    description: >-
      An agent's knowledge base sources: the web pages, text, FAQs, and
      documents its answers draw on. New and changed sources train in the
      background. A source starts as `pending`, and the agent uses it once it's
      `processed`.


      Adding sources uses the plan's knowledge base characters, and retraining a
      source uses resync credits. Adding a document takes three requests,
      described in [Create a document
      upload](/api-reference/v3/knowledge-base/create-knowledge-base-upload).
      You can delete or resync up to 100 sources in one request.


      Zoho Desk, Zendesk, Notion, and SharePoint sources are added in the
      dashboard through a connection. The API can list, resync, and delete them,
      and change their auto-sync. Website crawls are also started in the
      dashboard, and the pages they add are `link` sources. An agent that uses
      another agent's knowledge base has no sources of its own.


      Permission group: `knowledge_base`.
  - name: Labels
    description: >-
      Labels an agent can add to its conversations. Add them to a conversation
      with [Update a
      conversation](/api-reference/v3/conversations/update-conversation).


      Permission group: `labels`.
  - name: Teams
    description: >-
      An agent's teams of members. Conversations can be assigned to a team, and
      live chat routing uses teams. Team members must be active, have the owner,
      admin, or agent role, and have access to the agent.


      Permission group: `teams`.
  - name: Topics
    description: >-
      The topics and subtopics an AI agent sorts its conversations into. Create
      and edit topics in the dashboard. Add topics to a conversation with
      [Update a
      conversation](/api-reference/v3/conversations/update-conversation), which
      requires topic analysis on the plan.


      Permission group: `topics` (read).
  - name: Variables
    description: >-
      An AI agent's variables, which store values such as an order number during
      a conversation. You can create, update, and delete custom variables.
      System variables, such as the contact's first name, are built in and
      read-only. Set a custom variable's value for one conversation with [Start
      a conversation](/api-reference/v3/conversations/start-conversation) or
      [Update a
      conversation](/api-reference/v3/conversations/update-conversation).


      Permission group: `variables`.
  - name: Workflows
    description: >-
      An AI agent's workflows. A workflow runs steps, such as sending a message,
      updating a contact, or calling an integration, when an event happens, such
      as a conversation starting. Workflows are built and published in the
      dashboard. The API lists them, shows what they do and how their runs went,
      and turns published workflows on or off.


      To help plan a workflow before it's built in the dashboard, [Retrieve the
      workflow catalog](/api-reference/v3/workflows/get-workflow-catalog) lists
      the triggers, actions, conditions, and limits the project's plan allows.


      Permission group: `workflows`.
paths:
  /conversations:
    get:
      tags:
        - Conversations
      summary: List conversations
      description: >-
        Returns a list of an agent's conversations on every channel, sorted by
        start time with the newest first, so pages don't shift as new messages
        arrive. Playground tests are included with `channel: playground`.
        Conversations where the user never sent a message aren't included,
        except API conversations.


        Filters combine with AND, and filters that take a comma-separated list
        match any of the values. Unknown query parameters return
        `validation_failed`, and IDs that match nothing return an empty list.
      operationId: listConversations
      parameters:
        - $ref: '#/components/parameters/AgentIdQuery'
        - $ref: '#/components/parameters/Limit'
        - $ref: '#/components/parameters/Cursor'
        - name: channel
          in: query
          required: false
          description: >-
            Only return conversations on these channels, comma-separated. `web`
            doesn't include playground tests, so use `playground` for those.
          schema:
            type: string
            pattern: >-
              ^(web|whatsapp|api|instagram|messenger|telegram|playground)(,(web|whatsapp|api|instagram|messenger|telegram|playground))*$
          style: form
          explode: false
        - name: status
          in: query
          required: false
          description: Only return results with these statuses, comma-separated.
          schema:
            type: string
            pattern: ^(open|resolved|closed)(,(open|resolved|closed))*$
          style: form
          explode: false
        - name: read
          in: query
          required: false
          description: >-
            Only return read (`true`) or unread (`false`) conversations. Unread
            conversations have user messages the team hasn't read.
          schema:
            type: string
            enum:
              - 'true'
              - 'false'
        - name: important
          in: query
          required: false
          description: >-
            Only return conversations that are (`true`) or aren't (`false`)
            marked important.
          schema:
            type: string
            enum:
              - 'true'
              - 'false'
        - name: priority
          in: query
          required: false
          description: Only return conversations with these priorities, comma-separated.
          schema:
            type: string
            pattern: ^(low|medium|high|urgent)(,(low|medium|high|urgent))*$
          style: form
          explode: false
        - name: mode
          in: query
          required: false
          description: Only return conversations in these modes, comma-separated.
          schema:
            type: string
            pattern: ^(ai|live|pending_handoff)(,(ai|live|pending_handoff))*$
          style: form
          explode: false
        - name: assignee_id
          in: query
          required: false
          description: >-
            Only return conversations assigned to these team members, as
            comma-separated `account_id`s.
          schema:
            type: string
          style: form
          explode: false
        - name: team_id
          in: query
          required: false
          description: >-
            Only return conversations assigned to these teams, as
            comma-separated IDs.
          schema:
            type: string
          style: form
          explode: false
        - name: label_id
          in: query
          required: false
          description: >-
            Only return conversations with any of these labels, as
            comma-separated IDs.
          schema:
            type: string
          style: form
          explode: false
        - name: topic_id
          in: query
          required: false
          description: >-
            Only return conversations with any of these topics, as
            comma-separated IDs.
          schema:
            type: string
          style: form
          explode: false
        - name: contact_id
          in: query
          required: false
          description: >-
            Only return conversations linked to any of these contacts, as
            comma-separated IDs.
          schema:
            type: string
          style: form
          explode: false
        - name: sentiment
          in: query
          required: false
          description: Only return conversations with these sentiments, comma-separated.
          schema:
            type: string
            pattern: >-
              ^(positive|neutral|negative|unknown)(,(positive|neutral|negative|unknown))*$
          style: form
          explode: false
        - name: user_id
          in: query
          required: false
          description: Only return the conversations of this user, by `user_id`.
          schema:
            type: string
            maxLength: 191
        - name: external_user_id
          in: query
          required: false
          description: Only return API conversations started with this `external_user_id`.
          schema:
            type: string
            maxLength: 191
        - name: created_after
          in: query
          required: false
          description: Only return conversations started at or after this time (ISO 8601).
          schema:
            type: string
            format: date-time
        - name: created_before
          in: query
          required: false
          description: Only return conversations started before this time (ISO 8601).
          schema:
            type: string
            format: date-time
      responses:
        '200':
          description: A page of conversations.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ConversationList'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/AgentNotFound'
        '422':
          $ref: '#/components/responses/ValidationFailed'
        '429':
          $ref: '#/components/responses/RateLimited'
components:
  parameters:
    AgentIdQuery:
      name: agent_id
      in: query
      required: true
      description: ID of the agent.
      schema:
        type: string
        maxLength: 64
      example: '3132353852'
    Limit:
      name: limit
      in: query
      description: The maximum number of items to return, from 1 to 100.
      schema:
        type: integer
        minimum: 1
        maximum: 100
        default: 20
    Cursor:
      name: cursor
      in: query
      description: >-
        A cursor for pagination. Pass the `next_cursor` from the previous page,
        with the same filters, to fetch the next page.
      schema:
        type: string
        maxLength: 4096
  schemas:
    ConversationList:
      type: object
      required:
        - object
        - data
        - has_more
        - next_cursor
      properties:
        object:
          const: list
        data:
          type: array
          items:
            $ref: '#/components/schemas/Conversation'
        has_more:
          type: boolean
        next_cursor:
          type:
            - string
            - 'null'
    Conversation:
      type: object
      required:
        - object
        - id
        - agent
        - channel
        - user_id
        - external_user_id
        - status
        - mode
        - ended_at
        - read
        - important
        - priority
        - labels
        - topics
        - sentiment
        - assignee
        - team
        - contact
        - variables
        - locale
        - country
        - reply_window
        - created_at
        - last_message_at
      properties:
        object:
          const: conversation
        id:
          type: string
          example: 5f0c1c2e-6c1d-4a8f-9a59-0d4c4f1b2a10
        agent:
          $ref: '#/components/schemas/AgentReference'
        channel:
          type: string
          enum:
            - web
            - api
            - whatsapp
            - instagram
            - messenger
            - telegram
            - playground
          description: >-
            Share links count as `web`. `playground` is a test from an AI
            agent's playground or a chatbot's builder preview.
        user_id:
          type:
            - string
            - 'null'
          description: >-
            Identifies the person chatting. It's the same in all their
            conversations with the agent, including for anonymous widget users
            who aren't contacts. On the web, it's the widget's ID for the user's
            browser. Through the API, it's derived from `external_user_id`, or
            new for each conversation without one. On WhatsApp, it's the user's
            phone number. On Instagram and Messenger, it's the user's ID for the
            account or page, and on Telegram, the chat ID. `null` for some older
            conversations.
          example: 0b6f3c1e-8d2a-4f5b-9c7e-1a2b3c4d5e6f
        external_user_id:
          type:
            - string
            - 'null'
          description: >-
            The `external_user_id` the conversation was started with through the
            API, if any.
        status:
          type: string
          enum:
            - open
            - resolved
            - closed
        mode:
          type: string
          enum:
            - ai
            - live
            - pending_handoff
          description: >-
            The agent only replies in `ai` mode. In `live` mode, the team
            replies. `pending_handoff` means the conversation is waiting for a
            team member to take over.
        ended_at:
          type:
            - string
            - 'null'
          format: date-time
          description: >-
            Time at which the user's session ended. Ended conversations can't
            receive user messages.
        read:
          type: boolean
          description: >-
            Whether the team has read the latest user message. Read status is
            shared by the team.
        important:
          type: boolean
        priority:
          type:
            - string
            - 'null'
          enum:
            - low
            - medium
            - high
            - urgent
            - null
        labels:
          type: array
          items:
            type: object
            required:
              - id
              - name
            properties:
              id:
                type: string
              name:
                type: string
            description: A label.
        topics:
          type: array
          items:
            type: object
            required:
              - id
              - name
              - source
            properties:
              id:
                type: string
              name:
                type: string
              source:
                type: string
                enum:
                  - ai
                  - user
          description: Always `[]` for chatbot conversations.
        sentiment:
          type:
            - string
            - 'null'
          enum:
            - positive
            - neutral
            - negative
            - unknown
            - null
          description: >-
            `null` until the conversation is analysed, and always for chatbot
            conversations.
        assignee:
          oneOf:
            - type: object
              required:
                - id
                - name
              properties:
                id:
                  type: string
                  description: >-
                    The member's `account_id`, from [List
                    members](/api-reference/v3/members/list-members).
                name:
                  type: string
              description: The assigned team member.
            - type: 'null'
        team:
          oneOf:
            - type: object
              required:
                - id
                - name
              properties:
                id:
                  type: string
                  description: >-
                    ID of the team, from [List
                    teams](/api-reference/v3/teams/list-teams).
                name:
                  type: string
              description: The assigned team.
            - type: 'null'
        contact:
          oneOf:
            - $ref: '#/components/schemas/ConversationContact'
            - type: 'null'
        variables:
          type: array
          items:
            $ref: '#/components/schemas/ConversationVariable'
          description: >-
            The AI agent's custom variables. System variables aren't included.
            Always `[]` for chatbot conversations.
        locale:
          type:
            - string
            - 'null'
        country:
          type:
            - string
            - 'null'
          description: The user's country as an ISO 3166-1 alpha-2 code, if known.
        reply_window:
          oneOf:
            - type: object
              required:
                - closes_at
                - team_reply_closes_at
              properties:
                closes_at:
                  type:
                    - string
                    - 'null'
                  format: date-time
                  description: >-
                    Any reply can be sent until this time, including the AI
                    agent's: 24 hours after the user's last message.
                team_reply_closes_at:
                  type:
                    - string
                    - 'null'
                  format: date-time
                  description: >-
                    A team member can reply until this time. Only later than
                    `closes_at` on Messenger.
            - type: 'null'
          description: >-
            `null` on channels without a reply window: web, API, and Telegram.
            On WhatsApp, Instagram, and Messenger, both times are `null` until
            the user writes.
        created_at:
          type:
            - string
            - 'null'
          format: date-time
        last_message_at:
          type:
            - string
            - 'null'
          format: date-time
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - type
            - code
            - message
            - param
            - request_id
          properties:
            type:
              type: string
              enum:
                - authentication_error
                - permission_error
                - not_found_error
                - invalid_request_error
                - idempotency_error
                - rate_limit_error
                - api_error
              description: The type of error returned.
            code:
              type: string
              description: >-
                A short string identifying the error. Codes are stable, so
                handle errors by `code`. New codes may be added.
              examples:
                - validation_failed
                - insufficient_permission
                - resource_not_found
            message:
              type: string
              description: >-
                A human-readable message with more details about the error. The
                wording can change, so don't parse it.
            param:
              type:
                - string
                - 'null'
              description: >-
                If the error is parameter-specific, the parameter related to the
                error, in dot notation for nested fields, such as
                `member_ids.1`. For `validation_failed`, the first entry of
                `errors`.
            request_id:
              type: string
              description: >-
                The ID of the request, also returned in the `X-Request-Id`
                header. Include it when you contact support.
            errors:
              type: array
              description: >-
                For `validation_failed` only: every invalid parameter. The
                top-level `param` and `message` match the first entry.
              items:
                type: object
                required:
                  - param
                  - message
                properties:
                  param:
                    type: string
                    description: The invalid parameter, in dot notation for nested fields.
                  message:
                    type: string
                    description: >-
                      A human-readable message about the problem. The wording
                      can change.
    AgentReference:
      type: object
      description: The agent this belongs to.
      required:
        - id
        - type
        - name
      properties:
        id:
          type: string
          description: ID of the agent, as passed in `agent_id`.
          example: '3132353852'
        type:
          $ref: '#/components/schemas/AgentType'
        name:
          type: string
          example: Support agent
    ConversationContact:
      type: object
      required:
        - id
        - first_name
        - last_name
        - email
        - phone
        - job_title
        - company
        - website
        - industry
        - address
        - city
        - state
        - zip
        - country
      properties:
        id:
          type: string
          description: ID of the contact, for use with the Contacts endpoints.
        first_name:
          type:
            - string
            - 'null'
        last_name:
          type:
            - string
            - 'null'
        email:
          type:
            - string
            - 'null'
        phone:
          type:
            - string
            - 'null'
        job_title:
          type:
            - string
            - 'null'
        company:
          type:
            - string
            - 'null'
        website:
          type:
            - string
            - 'null'
        industry:
          type:
            - string
            - 'null'
        address:
          type:
            - string
            - 'null'
        city:
          type:
            - string
            - 'null'
        state:
          type:
            - string
            - 'null'
        zip:
          type:
            - string
            - 'null'
        country:
          type:
            - string
            - 'null'
      description: The contact fields shown in the dashboard. `zip` is the postal code.
    ConversationVariable:
      type: object
      required:
        - id
        - name
        - value
      properties:
        id:
          type: string
          description: >-
            ID of the variable, from [List
            variables](/api-reference/v3/variables/list-variables).
          example: 7c9e6679-7425-40de-944b-e07fc1f90ae7
        name:
          type: string
          example: order_id
        value:
          type:
            - string
            - 'null'
          description: >-
            The variable's value in this conversation, or its default if none is
            set.
    AgentType:
      type: string
      enum:
        - ai_agent
        - chatbot
      description: >-
        `ai_agent` for an AI agent, at `/agents`, or `chatbot` for a
        flow-builder chatbot, at `/chatbots`.
  responses:
    Unauthorized:
      description: '`missing_api_key`, `invalid_api_key`, or `api_key_expired`.'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              type: authentication_error
              code: invalid_api_key
              message: The API key is invalid or has been revoked.
              param: null
              request_id: req_8Fq2kLm9TzX4vB7nC1dR5sYw
    Forbidden:
      description: >-
        `insufficient_permission`, `project_suspended`, or
        `plan_feature_unavailable`.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              type: permission_error
              code: insufficient_permission
              message: This API key doesn't have delete access to agents.
              param: null
              request_id: req_8Fq2kLm9TzX4vB7nC1dR5sYw
    AgentNotFound:
      description: >-
        `resource_not_found`: No agent with this ID exists in the project, or
        the key can't access it.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              type: not_found_error
              code: resource_not_found
              message: No agent with this ID exists, or this API key can't access it.
              param: null
              request_id: req_8Fq2kLm9TzX4vB7nC1dR5sYw
    ValidationFailed:
      description: '`validation_failed`, or `invalid_cursor` for lists.'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              type: invalid_request_error
              code: validation_failed
              message: The name field is required.
              param: name
              request_id: req_8Fq2kLm9TzX4vB7nC1dR5sYw
              errors:
                - param: name
                  message: The name field is required.
    RateLimited:
      description: '`rate_limit_exceeded`.'
      headers:
        Retry-After:
          $ref: '#/components/headers/RetryAfter'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  headers:
    RetryAfter:
      description: The number of seconds to wait before retrying.
      schema:
        type: integer
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer
      description: A project API key, created in the dashboard.

````

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