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

# Send a message

> Sends a message to Ask Circuit. With a permit, Ask can read the user's account and propose trades and agents: the message comes back while Ask is working, so read the chat to get the reply, and pass `chat: null` to start a chat or a `chat_` id to continue one. Without a permit, Ask answers questions about Circuit and markets before the user links your app: the reply comes back in the response, nothing is proposed, and each message stands alone.



## OpenAPI

````yaml /partner-openapi.gen.json post /partner/v0.1/messages
openapi: 3.1.0
info:
  title: Circuit partner API
  version: '0.1'
servers:
  - url: https://api.circuit.org
security: []
paths:
  /partner/v0.1/messages:
    post:
      summary: Send a message
      description: >-
        Sends a message to Ask Circuit. With a permit, Ask can read the user's
        account and propose trades and agents: the message comes back while Ask
        is working, so read the chat to get the reply, and pass `chat: null` to
        start a chat or a `chat_` id to continue one. Without a permit, Ask
        answers questions about Circuit and markets before the user links your
        app: the reply comes back in the response, nothing is proposed, and each
        message stands alone.
      operationId: sendMessage
      parameters:
        - name: idempotency-key
          in: header
          required: false
          schema:
            description: >-
              Optional. A UUID your app generates for this request. Send the
              same value when you retry, and Circuit returns the first result
              instead of acting twice. Reusing a key with different contents
              returns 409. Without a key, a retried request can act twice.
            type: string
            format: uuid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                chat:
                  description: >-
                    The chat to continue, starting with `chat_`. Null starts a
                    new chat.
                  type:
                    - string
                    - 'null'
                  examples:
                    - null
                text:
                  description: What the user wrote.
                  type: string
                  examples:
                    - Start Macro Trend on paper money
              additionalProperties: false
              required:
                - text
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                description: One message in a chat and Ask's reply to it.
                type: object
                properties:
                  id:
                    description: The message's id, starting with `msg_`.
                    type: string
                  chat:
                    description: >-
                      The chat it belongs to, starting with `chat_`. Null for a
                      message sent before the user linked your app; those
                      messages stand alone.
                    type:
                      - string
                      - 'null'
                  status:
                    $ref: '#/components/schemas/MessageStatus'
                  text:
                    description: >-
                      What the user wrote. Null when Circuit followed up on its
                      own.
                    type:
                      - string
                      - 'null'
                  reply:
                    description: Ask's reply in Markdown. Null while Ask is still working.
                    type:
                      - string
                      - 'null'
                  proposals:
                    description: >-
                      Trades, agent starts and top-ups that Ask proposed in this
                      reply. Each needs your approval.
                    type: array
                    items:
                      $ref: '#/components/schemas/PartnerProposal'
                required:
                  - id
                  - status
                  - proposals
        default:
          description: Failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerFailure'
      security:
        - {}
        - permit: []
components:
  schemas:
    MessageStatus:
      oneOf:
        - description: Ask is still writing its reply.
          type: string
          const: working
        - description: The reply is complete.
          type: string
          const: done
        - description: Ask could not answer. `reply` says why.
          type: string
          const: failed
    PartnerProposal:
      description: >-
        Something Ask proposed, such as a trade or an agent start, that waits
        for your approval.
      type: object
      properties:
        id:
          description: The proposal's id, starting with `prop_`.
          type: string
        title:
          description: >-
            What it does, starting with a verb, such as "Buy 0.04 ETH on
            Lighter" or "Start Macro Trend".
          type: string
        status:
          $ref: '#/components/schemas/PartnerProposalStatus'
        error:
          description: Why it failed when `status` is `failed`. Null otherwise.
          type:
            - string
            - 'null'
        session:
          description: >-
            The session it started or changed, starting with `ses_`. Null for
            trades.
          type:
            - string
            - 'null'
      required:
        - id
        - title
        - status
    PartnerFailure:
      description: >-
        A failed call. Handle it by HTTP status and `code`, and show `error` to
        the user.
      type: object
      properties:
        error:
          description: A message you can show the user.
          type: string
        code:
          description: >-
            A stable code such as `BAD_REQUEST`, `NOT_FOUND`, `CONFLICT` or
            `UNAUTHORIZED`. New codes can appear.
          type: string
      required:
        - error
        - code
    PartnerProposalStatus:
      oneOf:
        - description: Waiting for you to approve or decline it.
          type: string
          const: review
        - description: Approved, and Circuit is carrying it out.
          type: string
          const: processing
        - description: Carried out.
          type: string
          const: done
        - description: Declined, or it expired before anyone approved it.
          type: string
          const: declined
        - description: It could not be carried out. `error` says why.
          type: string
          const: failed
  securitySchemes:
    permit:
      description: The permit the user approved for your app.
      type: http
      scheme: bearer

````

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