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

# Send agent response

> Sends an agent's reply to the contact in a conversation. Call it every time an agent replies in your third-party system, so WotNot can pass the reply on to the user.



## OpenAPI

````yaml POST /api/v1/conversation/{conversation_id}/messages
openapi: 3.1.0
info:
  title: WotNot API
  version: 1.0.0
  description: 'WotNot API: Send agent response.'
servers:
  - url: https://api.wotnot.io
    description: Production
security:
  - bearerAuth: []
paths:
  /api/v1/conversation/{conversation_id}/messages:
    post:
      summary: Send agent response
      description: >-
        Sends an agent's reply to the contact in a conversation. Call it every
        time an agent replies in your third-party system, so WotNot can pass the
        reply on to the user.
      operationId: sendAgentResponse
      parameters:
        - name: conversation_id
          in: path
          required: true
          description: >-
            The ID of the conversation to reply in. It's the `conversation.id`
            you get back from Create conversation.
          schema:
            type: string
      requestBody:
        required: true
        description: >-
          The message to send. Its shape depends on the kind of message: text,
          file, voice or template.
        content:
          application/json:
            schema:
              oneOf:
                - $ref: '#/components/schemas/AgentTextMessage'
                  title: Text
                - $ref: '#/components/schemas/AgentFileMessage'
                  title: File
                - $ref: '#/components/schemas/AgentVoiceMessage'
                  title: Voice
                - $ref: '#/components/schemas/AgentTemplateMessage'
                  title: Template message
            examples:
              text:
                summary: Text
                value:
                  message:
                    data:
                      body: Hi
                    type: text
                  user:
                    by: agent_email@domain.com
              file:
                summary: File
                value:
                  message:
                    file:
                      path: >-
                        https://framerusercontent.com/images/L2xfXiiCkddPZOjvWCGTusENwb4.png
                      size: 1
                      type: image/png
                      name: L2xfXiiCkddPZOjvWCGTusENwb4.png
                    type: file
                  user:
                    by: agent_email@domain.com
              voice:
                summary: Voice
                value:
                  message:
                    file:
                      path: >-
                        https://file-examples.com/storage/fe32d8b189680228b9ad370/2017/11/file_example_WAV_1MG.wav
                      size: 1
                      type: audio/wav
                      name: file_example_WAV_1MG.wav
                    type: voice
                  user:
                    by: agent_email@domain.com
              template:
                summary: Template message
                value:
                  message:
                    data:
                      template: template_1
                    type: template
                  user:
                    by: agent_email@domain.com
      responses:
        '200':
          description: >-
            The message was sent. Returns `ok` set to `true` and the new
            message's ID.
          content:
            application/json:
              schema:
                type: object
                required:
                  - ok
                  - message_id
                properties:
                  ok:
                    type: boolean
                    description: '`true` when the request worked. Errors return `false`.'
                    example: true
                  message_id:
                    type: string
                    description: The ID of the message that was sent.
                    example: 6HRBshHEcV8P103039226478taGDJQxC
              example:
                ok: true
                message_id: 6HRBshHEcV8P103039226478taGDJQxC
        '400':
          description: >-
            The message couldn't be sent. The examples show the possible
            reasons, such as a closed conversation, a conversation assigned to a
            bot, or a blocked contact. Check `error` to see which.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CodedError'
              examples:
                invalid_data:
                  summary: Invalid data
                  value:
                    ok: false
                    error: INVALID_DATA
                    code: INVALID_DATA
                    message: Error message
                    status: 400
                conversation_closed:
                  summary: Conversation is closed
                  value:
                    ok: false
                    error: CONVERSATION_CLOSED
                    code: CONVERSATION_CLOSED
                    message: Assignee cannot be changed on closed conversation.
                    status: 400
                assigned_to_bot:
                  summary: Conversation is assigned to a bot
                  value:
                    ok: false
                    error: CONVERSATION_ASSIGNED_TO_BOT
                    code: CONVERSATION_ASSIGNED_TO_BOT
                    message: Agent message cannot be sent on bot assigned conversation.
                    status: 400
                contact_blocked:
                  summary: Contact is blocked
                  value:
                    ok: false
                    error: CONTACT_IS_BLOCKED
                    code: CONTACT_IS_BLOCKED
                    message: Conversation cannot be created for blocked contact.
                    status: 400
                user_limit:
                  summary: User limit reached
                  value:
                    ok: false
                    error: MESSAGE_NOT_SENT
                    code: MESSAGE_NOT_SENT
                    message: Message is not sent due to user limit validation.
                    status: 400
        '401':
          $ref: '#/components/responses/InvalidJwt'
        '404':
          $ref: '#/components/responses/ConversationNotFound'
components:
  schemas:
    AgentTextMessage:
      type: object
      title: Text
      description: Send a text message.
      required:
        - message
        - user
      properties:
        message:
          type: object
          description: The message to send.
          required:
            - data
            - type
          properties:
            data:
              type: object
              description: The message content.
              required:
                - body
              properties:
                body:
                  type: string
                  description: The message text.
                  example: Hi
            type:
              type: string
              description: Set to `text`.
              example: text
              const: text
        user:
          $ref: '#/components/schemas/AgentUser'
          description: The agent sending the message.
    AgentFileMessage:
      type: object
      title: File
      description: Send a file, such as an image.
      required:
        - message
        - user
      properties:
        message:
          type: object
          description: The message to send.
          required:
            - file
            - type
          properties:
            file:
              $ref: '#/components/schemas/MessageFile'
            type:
              type: string
              description: Set to `file`.
              example: file
              const: file
        user:
          $ref: '#/components/schemas/AgentUser'
          description: The agent sending the message.
    AgentVoiceMessage:
      type: object
      title: Voice
      description: Send an audio file as a voice message.
      required:
        - message
        - user
      properties:
        message:
          type: object
          description: The message to send.
          required:
            - file
            - type
          properties:
            file:
              $ref: '#/components/schemas/MessageFile'
            type:
              type: string
              description: Set to `voice`.
              example: voice
              const: voice
        user:
          $ref: '#/components/schemas/AgentUser'
          description: The agent sending the message.
    AgentTemplateMessage:
      type: object
      title: Template message
      description: Send a template.
      required:
        - message
        - user
      properties:
        message:
          type: object
          description: The message to send.
          required:
            - data
            - type
          properties:
            data:
              type: object
              description: The template to send.
              required:
                - template
              properties:
                template:
                  type: string
                  description: The name of the template to send, for example `template_1`.
                  example: template_1
            type:
              type: string
              description: Set to `template`.
              example: template
              const: template
        user:
          $ref: '#/components/schemas/AgentUser'
          description: The agent sending the message.
    CodedError:
      type: object
      description: An error with a short code that says what went wrong.
      required:
        - ok
        - message
        - error
        - code
      properties:
        ok:
          type: boolean
          description: Always `false` when something went wrong.
          example: false
        message:
          type: string
          description: What went wrong, in plain words.
          example: Please reach out to support to use this feature
        error:
          type: string
          description: >-
            A short error code in capital letters, for example
            `UNAUTHORIZED_FEATURE`. Check this in your code to tell errors
            apart.
          example: UNAUTHORIZED_FEATURE
        code:
          type: string
          description: A code for the result. In these examples it matches `error`.
          example: UNAUTHORIZED_FEATURE
        status:
          type: integer
          description: >-
            The HTTP status code, repeated in the body. Not every error includes
            it.
          example: 401
    AgentUser:
      type: object
      description: The agent doing this.
      required:
        - by
      properties:
        by:
          type: string
          description: The agent's email address.
          example: agent_email@domain.com
    MessageFile:
      type: object
      description: The file to send.
      required:
        - path
        - size
        - type
        - name
      properties:
        path:
          type: string
          description: The URL of the file.
          example: https://framerusercontent.com/images/L2xfXiiCkddPZOjvWCGTusENwb4.png
        size:
          type: integer
          description: The file's size in MB, for example `1`.
          example: 1
        type:
          type: string
          description: The file's MIME type, for example `image/png`.
          example: image/png
        name:
          type: string
          description: The file's name.
          example: L2xfXiiCkddPZOjvWCGTusENwb4.png
  responses:
    InvalidJwt:
      description: Your token is invalid. Check the `Authorization` header.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/CodedError'
          example:
            ok: false
            error: JWT_SIGNATURE_EXCEPTION
            code: JWT_SIGNATURE_EXCEPTION
            message: Invalid JWT token
            status: 401
    ConversationNotFound:
      description: No conversation was found with this `conversation_id`. Check the ID.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/CodedError'
          example:
            ok: false
            error: CONVERSATION_NOT_FOUND
            code: CONVERSATION_NOT_FOUND
            message: Conversation is not available.
            status: 404
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        All of WotNot's APIs use Bearer token authentication. Send your account
        token as `Bearer <token>`. You can find it in Settings > Account
        Settings > Developer. Keep it on your server: anyone who has it can call
        the API as your account.

````

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