> ## 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.

# Update Chat AI Settings

> Toggles the AI permissions of this chat: whether the AI agent may reply to messages and whether AI flagging may flag them. At least one flag is required; omitted flags are unchanged.



## OpenAPI

````yaml api-reference/openapi-generated.json PATCH /v1/chats/{chat_id}/ai
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/chats/{chat_id}/ai:
    patch:
      tags:
        - Chats
      summary: Update the AI settings of a chat
      description: >-
        Toggles the AI permissions of this chat: whether the AI agent may reply
        to messages and whether AI flagging may flag them. At least one flag is
        required; omitted flags are unchanged.
      operationId: updateChatAiSettings
      parameters:
        - schema:
            type: string
            minLength: 1
            description: >-
              Unique id of the chat. For 1-1 chats, country code + number
              optionally suffixed with @c.us (e.g. 922222222222@c.us — the
              suffix is added automatically when omitted); for groups, the id
              ending with @g.us.
            example: 120363000000000000@g.us
          required: true
          description: >-
            Unique id of the chat. For 1-1 chats, country code + number
            optionally suffixed with @c.us (e.g. 922222222222@c.us — the suffix
            is added automatically when omitted); for groups, the id ending with
            @g.us.
          name: chat_id
          in: path
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                is_agent_allowed:
                  type: boolean
                  description: >-
                    Whether the AI agent may reply to messages in this chat.
                    Overrides the org-wide default for this chat.
                  example: true
                is_flagging_allowed:
                  type: boolean
                  description: Whether AI flagging may flag messages in this chat.
                  example: true
      responses:
        '200':
          description: The effective AI settings of the chat
          content:
            application/json:
              schema:
                type: object
                properties:
                  chat_id:
                    type: string
                    description: Id of the chat the settings apply to
                    example: 120363000000000000@g.us
                  is_agent_allowed:
                    type: boolean
                    description: Effective agent permission for this chat
                    example: true
                  is_flagging_allowed:
                    type: boolean
                    description: Effective flagging permission for this chat
                    example: true
              examples:
                default:
                  summary: Response body
                  value:
                    chat_id: 120363000000000000@g.us
                    is_agent_allowed: true
                    is_flagging_allowed: true
        '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
        '404':
          description: Chat not found
          content:
            application/json:
              examples:
                error:
                  summary: Chat not found
                  value:
                    code: NOT_FOUND_ERROR
                    message: Chat not found
                    status: 404
              schema:
                type: object
                properties:
                  code:
                    type: string
                    example: NOT_FOUND_ERROR
                  message:
                    type: string
                    example: Chat not found
                  status:
                    type: integer
                    example: 404
                example:
                  code: NOT_FOUND_ERROR
                  message: Chat not found
                  status: 404
        '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.chats.updateChatAiSettings({
                chat_id: '120363000000000000@g.us',
                is_agent_allowed: true,
              });
              console.log(response);
            }

            main();
        - lang: bash
          label: cURL
          source: >-
            curl -X PATCH
            'https://api.periskope.app/v1/chats/120363000000000000@g.us/ai' \
              -H 'Authorization: Bearer YOUR_API_KEY' \
              -H 'Content-Type: application/json' \
              -d '{
                "is_agent_allowed": true
              }'
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.

````