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

# Trigger AI Reply

> Queues the org AI agent to reply to a message in a chat. Asynchronous — 200 means the run was accepted, not sent. Requires the AI agent to be available and enabled for the org and allowed in the chat.



## OpenAPI

````yaml api-reference/openapi-generated.json POST /v1/ai/reply
openapi: 3.0.3
info:
  title: Periskope API
  version: 1.0.0
  description: >-
    Periskope external API.


    Responses use a flat, unwrapped shape: most endpoints return the resource at
    the top level, and list endpoints return a wrapper object with pagination
    inline (e.g. `{ from, to, count, chats: [...] }`). The documented response
    schemas describe these shapes directly.
servers:
  - url: https://api.periskope.app
security:
  - bearerAuth: []
paths:
  /v1/ai/reply:
    post:
      tags:
        - AI
      summary: Trigger an AI reply
      description: >-
        Queues the org AI agent to reply to a message in a chat. Asynchronous —
        200 means the run was accepted, not sent. Requires the AI agent to be
        available and enabled for the org and allowed in the chat.
      operationId: triggerAiReply
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                chat_id:
                  type: string
                  minLength: 1
                  description: >-
                    Id of the chat the AI agent should reply in — an individual
                    chat (countrycode + number followed by @c.us, e.g.
                    911111111111@c.us) or a group chat (id followed by @g.us).
                  example: 120363000000000000@g.us
                unique_id:
                  type: string
                  minLength: 1
                  description: >-
                    Unique id of the message the AI agent should reply to, as
                    returned in the unique_id field of message records. The
                    generated reply is sent as a reply to this message.
                  example: 3B35D00FB468D3XE3XBX
                org_phone:
                  type: string
                  minLength: 1
                  description: >-
                    Org phone the AI agent should reply from, in WhatsApp server
                    format: country code + number followed by @c.us (e.g.
                    911111111111@c.us). Must be a phone connected to the org.
                  example: 911111111111@c.us
              required:
                - chat_id
                - unique_id
                - org_phone
      responses:
        '200':
          description: The AI reply run was queued
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    enum:
                      - true
                    description: Always true when the AI reply run was queued
                  message:
                    type: string
                    description: Human-readable confirmation message
                    example: AI reply triggered
                  trace_id:
                    type: string
                    description: >-
                      Trace id (UUID) assigned to the queued AI reply run. Use
                      it to correlate the run in logs and when reporting issues
                      — the 200 response only confirms the run was queued, not
                      that the reply was sent.
                    example: 00000000-0000-0000-0000-000000000000
              examples:
                default:
                  summary: Response body
                  value:
                    success: true
                    message: AI reply triggered
                    trace_id: 00000000-0000-0000-0000-000000000000
        '400':
          description: >-
            AI agent unavailable: the org is not eligible (inactive
            subscription, or a non-Pro plan without a free trial), the AI agent
            is disabled in the org settings, or the agent is not allowed on this
            chat
          content:
            application/json:
              examples:
                error:
                  summary: >-
                    AI agent unavailable: the org is not eligible (inactive
                    subscription, or a non-Pro plan without a free trial), the
                    AI agent is disabled in the org settings, or the agent is
                    not allowed on this chat
                  value:
                    code: ERROR
                    message: >-
                      AI agent unavailable: the org is not eligible (inactive
                      subscription, or a non-Pro plan without a free trial), the
                      AI agent is disabled in the org settings, or the agent is
                      not allowed on this chat
                    status: 400
              schema:
                type: object
                properties:
                  code:
                    type: string
                    example: ERROR
                  message:
                    type: string
                    example: >-
                      AI agent unavailable: the org is not eligible (inactive
                      subscription, or a non-Pro plan without a free trial), the
                      AI agent is disabled in the org settings, or the agent is
                      not allowed on this chat
                  status:
                    type: integer
                    example: 400
                example:
                  code: ERROR
                  message: >-
                    AI agent unavailable: the org is not eligible (inactive
                    subscription, or a non-Pro plan without a free trial), the
                    AI agent is disabled in the org settings, or the agent is
                    not allowed on this chat
                  status: 400
        '401':
          description: Invalid, expired or missing API token
          content:
            application/json:
              examples:
                error:
                  summary: Invalid, expired or missing API token
                  value:
                    code: UNAUTHORIZED_ERROR
                    message: Invalid bearer auth token
                    status: 401
              schema:
                type: object
                properties:
                  code:
                    type: string
                    example: UNAUTHORIZED_ERROR
                  message:
                    type: string
                    example: Invalid bearer auth token
                  status:
                    type: integer
                    example: 401
                example:
                  code: UNAUTHORIZED_ERROR
                  message: Invalid bearer auth token
                  status: 401
        '422':
          description: Request validation failed
          content:
            application/json:
              examples:
                error:
                  summary: Request validation failed
                  value:
                    code: VALIDATION_ERROR
                    message: Request validation failed
                    status: 422
                    fields:
                      body.chat_id:
                        message: chat_id is required
              schema:
                type: object
                properties:
                  code:
                    type: string
                    example: VALIDATION_ERROR
                  message:
                    type: string
                    example: Request validation failed
                  status:
                    type: integer
                    example: 422
                  fields:
                    type: object
                    additionalProperties:
                      type: object
                      properties:
                        message:
                          type: string
                        value: {}
                    example:
                      body.chat_id:
                        message: chat_id is required
                example:
                  code: VALIDATION_ERROR
                  message: Request validation failed
                  status: 422
                  fields:
                    body.chat_id:
                      message: chat_id is required
        '429':
          description: Rate limit exceeded
          content:
            application/json:
              examples:
                error:
                  summary: Rate limit exceeded
                  value:
                    code: RATE_LIMIT_ERROR
                    message: You can only make 100 requests per second
                    status: 429
              schema:
                type: object
                properties:
                  code:
                    type: string
                    example: RATE_LIMIT_ERROR
                  message:
                    type: string
                    example: You can only make 100 requests per second
                  status:
                    type: integer
                    example: 429
                example:
                  code: RATE_LIMIT_ERROR
                  message: You can only make 100 requests per second
                  status: 429
        '500':
          description: Internal server error
          content:
            application/json:
              examples:
                error:
                  summary: Internal server error
                  value:
                    code: UNKNOWN_ERROR
                    message: Internal server error
                    status: 500
              schema:
                type: object
                properties:
                  code:
                    type: string
                    example: UNKNOWN_ERROR
                  message:
                    type: string
                    example: Internal server error
                  status:
                    type: integer
                    example: 500
                example:
                  code: UNKNOWN_ERROR
                  message: Internal server error
                  status: 500
      security:
        - bearerAuth: []
      x-codeSamples:
        - lang: typescript
          label: TypeScript
          source: |-
            import { PeriskopeApi } from '@periskope/periskope-client';

            const client = new PeriskopeApi({
              authToken: 'YOUR_API_KEY',
            });

            async function main() {
              const response = await client.ai.triggerAiReply({
                chat_id: '120363000000000000@g.us',
                unique_id: '3B35D00FB468D3XE3XBX',
                org_phone: '911111111111@c.us',
              });
              console.log(response);
            }

            main();
        - lang: bash
          label: cURL
          source: |-
            curl -X POST 'https://api.periskope.app/v1/ai/reply' \
              -H 'Authorization: Bearer YOUR_API_KEY' \
              -H 'Content-Type: application/json' \
              -d '{
                "chat_id": "120363000000000000@g.us",
                "unique_id": "3B35D00FB468D3XE3XBX",
                "org_phone": "911111111111@c.us"
              }'
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Your Periskope API token, sent as `Authorization: Bearer <token>`.
        Generate one from the Periskope dashboard under **Settings → API &
        Webhooks**. API access requires an active Pro or Enterprise plan.

````

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