openapi: 3.0.4
info:
  title: Evolution Foundation - CRM Service - Inboxes
  description: Management of contacts, conversations, inboxes, labels and macros
  version: 1.1.0
servers:
- url: https://api.evoai.app
  description: Production server
- url: http://localhost:3000
  description: Development server
  variables:
    port:
      default: '3000'
- url: '{customUrl}'
  description: Custom server
  variables:
    customUrl:
      default: https://your-instance.com
      description: Enter your server URL
paths:
  /api/v1/inbox_members:
    parameters: []
    post:
      operationId: add-new-agent-to-inbox
      summary: Add a New Agent
      description: Add a new Agent to Inbox
      security:
      - userApiKey: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - inbox_id
              - user_ids
              properties:
                inbox_id:
                  type: string
                  format: uuid
                  description: The ID of the inbox
                  example: 123e4567-e89b-12d3-a456-426614174000
                user_ids:
                  type: array
                  items:
                    type: integer
                  description: IDs of users to be added to the inbox
                  example:
                  - 1
      responses:
        '200':
          description: Agent added successfully
          content:
            application/json:
              schema:
                type: object
                required:
                - success
                - data
                - meta
                - message
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: array
                    description: Array of all active agents
                    items:
                      $ref: '#/components/schemas/agent'
                  meta:
                    type: object
                    properties:
                      timestamp:
                        type: string
                        format: date-time
                        description: Response timestamp
                        example: '2024-01-15T10:30:00Z'
                  message:
                    type: string
                    description: Success message
                    example: Agent added successfully
              example:
                success: true
                data: []
                meta:
                  timestamp: '2024-01-15T10:30:00Z'
                message: Agent added successfully
        '400':
          description: Bad Request (invalid data)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                bad_request:
                  summary: Invalid request data
                  value:
                    success: false
                    error:
                      code: BAD_REQUEST
                      message: Invalid request data
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inbox_members
                      method: POST
        '401':
          description: Unauthorized (invalid or missing token)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                unauthorized:
                  summary: Unauthorized
                  value:
                    success: false
                    error:
                      code: UNAUTHORIZED
                      message: Unauthorized
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inbox_members
                      method: POST
        '403':
          description: Forbidden (insufficient permissions)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                forbidden:
                  summary: Forbidden
                  value:
                    success: false
                    error:
                      code: FORBIDDEN
                      message: Forbidden
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inbox_members
                      method: POST
        '404':
          description: Not Found (resource not found)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                not_found:
                  summary: Inbox not found
                  value:
                    success: false
                    error:
                      code: NOT_FOUND
                      message: Inbox not found
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inbox_members
                      method: POST
        '422':
          description: Unprocessable Entity (validation error)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                validation_error:
                  summary: User must exist
                  value:
                    success: false
                    error:
                      code: VALIDATION_ERROR
                      message: User must exist
                      details:
                        user_ids: One or more user IDs do not exist
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inbox_members
                      method: POST
        '500':
          description: Internal Server Error (server error)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                internal_error:
                  summary: Internal server error
                  value:
                    success: false
                    error:
                      code: INTERNAL_ERROR
                      message: An internal server error occurred
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inbox_members
                      method: POST
    patch:
      operationId: update-agents-in-inbox
      summary: Update Agents in Inbox
      description: All agents except the one passed in params will be removed
      security:
      - userApiKey: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - inbox_id
              - user_ids
              properties:
                inbox_id:
                  type: string
                  format: uuid
                  description: The ID of the inbox
                  example: 123e4567-e89b-12d3-a456-426614174000
                user_ids:
                  type: array
                  items:
                    type: integer
                  description: IDs of users to be added to the inbox
                  example:
                  - 1
      responses:
        '200':
          description: Agents updated successfully
          content:
            application/json:
              schema:
                type: object
                required:
                - success
                - data
                - meta
                - message
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: array
                    description: Array of all active agents
                    items:
                      $ref: '#/components/schemas/agent'
                  meta:
                    type: object
                    properties:
                      timestamp:
                        type: string
                        format: date-time
                        description: Response timestamp
                        example: '2024-01-15T10:30:00Z'
                  message:
                    type: string
                    description: Success message
                    example: Agents updated successfully
              example:
                success: true
                data: []
                meta:
                  timestamp: '2024-01-15T10:30:00Z'
                message: Agents updated successfully
        '400':
          description: Bad Request (invalid data)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                bad_request:
                  summary: Invalid request data
                  value:
                    success: false
                    error:
                      code: BAD_REQUEST
                      message: Invalid request data
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inbox_members
                      method: PATCH
        '401':
          description: Unauthorized (invalid or missing token)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                unauthorized:
                  summary: Unauthorized
                  value:
                    success: false
                    error:
                      code: UNAUTHORIZED
                      message: Unauthorized
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inbox_members
                      method: PATCH
        '403':
          description: Forbidden (insufficient permissions)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                forbidden:
                  summary: Forbidden
                  value:
                    success: false
                    error:
                      code: FORBIDDEN
                      message: Forbidden
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inbox_members
                      method: PATCH
        '404':
          description: Not Found (resource not found)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                not_found:
                  summary: Inbox not found
                  value:
                    success: false
                    error:
                      code: NOT_FOUND
                      message: Inbox not found
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inbox_members
                      method: PATCH
        '422':
          description: Unprocessable Entity (validation error)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                validation_error:
                  summary: User must exist
                  value:
                    success: false
                    error:
                      code: VALIDATION_ERROR
                      message: User must exist
                      details:
                        user_ids: One or more user IDs do not exist
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inbox_members
                      method: PATCH
        '500':
          description: Internal Server Error (server error)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                internal_error:
                  summary: Internal server error
                  value:
                    success: false
                    error:
                      code: INTERNAL_ERROR
                      message: An internal server error occurred
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inbox_members
                      method: PATCH
    delete:
      operationId: delete-agent-in-inbox
      summary: Remove an Agent from Inbox
      description: Remove an Agent from Inbox
      security:
      - userApiKey: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - inbox_id
              - user_ids
              properties:
                inbox_id:
                  type: string
                  format: uuid
                  description: The ID of the inbox
                  example: 123e4567-e89b-12d3-a456-426614174000
                user_ids:
                  type: array
                  items:
                    type: integer
                  description: IDs of users to be deleted from the inbox
                  example:
                  - 1
      responses:
        '200':
          description: Agent removed successfully
          content:
            application/json:
              schema:
                type: object
                required:
                - success
                - data
                - meta
                - message
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: object
                    nullable: true
                    description: Null for delete operations
                    example: null
                  meta:
                    type: object
                    properties:
                      timestamp:
                        type: string
                        format: date-time
                        description: Response timestamp
                        example: '2024-01-15T10:30:00Z'
                  message:
                    type: string
                    description: Success message
                    example: Agent removed successfully
              example:
                success: true
                data: null
                meta:
                  timestamp: '2024-01-15T10:30:00Z'
                message: Agent removed successfully
        '400':
          description: Bad Request (invalid data)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                bad_request:
                  summary: Invalid request data
                  value:
                    success: false
                    error:
                      code: BAD_REQUEST
                      message: Invalid request data
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inbox_members
                      method: DELETE
        '401':
          description: Unauthorized (invalid or missing token)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                unauthorized:
                  summary: Unauthorized
                  value:
                    success: false
                    error:
                      code: UNAUTHORIZED
                      message: Unauthorized
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inbox_members
                      method: DELETE
        '403':
          description: Forbidden (insufficient permissions)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                forbidden:
                  summary: Forbidden
                  value:
                    success: false
                    error:
                      code: FORBIDDEN
                      message: Forbidden
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inbox_members
                      method: DELETE
        '404':
          description: Not Found (resource not found)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                not_found:
                  summary: Inbox not found
                  value:
                    success: false
                    error:
                      code: NOT_FOUND
                      message: Inbox not found
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inbox_members
                      method: DELETE
        '422':
          description: Unprocessable Entity (validation error)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                validation_error:
                  summary: User must exist
                  value:
                    success: false
                    error:
                      code: VALIDATION_ERROR
                      message: User must exist
                      details:
                        user_ids: One or more user IDs do not exist
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inbox_members
                      method: DELETE
        '500':
          description: Internal Server Error (server error)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                internal_error:
                  summary: Internal server error
                  value:
                    success: false
                    error:
                      code: INTERNAL_ERROR
                      message: An internal server error occurred
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inbox_members
                      method: DELETE
  /api/v1/inbox_members/{inbox_id}:
    parameters:
    - $ref: '#/components/parameters/inbox_id'
    get:
      operationId: get-inbox-members
      summary: List Agents in Inbox
      description: Get Details of Agents in an Inbox
      security:
      - userApiKey: []
      parameters:
      - $ref: '#/components/parameters/inbox_id'
      responses:
        '200':
          description: Agents retrieved successfully
          content:
            application/json:
              schema:
                type: object
                required:
                - success
                - data
                - meta
                - message
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: array
                    description: Array of all active agents
                    items:
                      $ref: '#/components/schemas/agent'
                  meta:
                    type: object
                    properties:
                      timestamp:
                        type: string
                        format: date-time
                        description: Response timestamp
                        example: '2024-01-15T10:30:00Z'
                  message:
                    type: string
                    description: Success message
                    example: Agents retrieved successfully
              example:
                success: true
                data: []
                meta:
                  timestamp: '2024-01-15T10:30:00Z'
                message: Agents retrieved successfully
        '400':
          description: Bad Request (invalid data)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                bad_request:
                  summary: Invalid request data
                  value:
                    success: false
                    error:
                      code: BAD_REQUEST
                      message: Invalid request data
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inbox_members/{inbox_id}
                      method: GET
        '401':
          description: Unauthorized (invalid or missing token)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                unauthorized:
                  summary: Unauthorized
                  value:
                    success: false
                    error:
                      code: UNAUTHORIZED
                      message: Unauthorized
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inbox_members/{inbox_id}
                      method: GET
        '403':
          description: Forbidden (insufficient permissions)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                forbidden:
                  summary: Forbidden
                  value:
                    success: false
                    error:
                      code: FORBIDDEN
                      message: Forbidden
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inbox_members/{inbox_id}
                      method: GET
        '404':
          description: Not Found (resource not found)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                not_found:
                  summary: Inbox not found
                  value:
                    success: false
                    error:
                      code: NOT_FOUND
                      message: Inbox not found
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inbox_members/{inbox_id}
                      method: GET
        '500':
          description: Internal Server Error (server error)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                internal_error:
                  summary: Internal server error
                  value:
                    success: false
                    error:
                      code: INTERNAL_ERROR
                      message: An internal server error occurred
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inbox_members/{inbox_id}
                      method: GET
  /api/v1/inboxes:
    get:
      operationId: listAllInboxes
      summary: List all inboxes
      description: List all inboxes available in the current account
      security:
      - userApiKey: []
      parameters: []
      responses:
        '200':
          description: Inboxes retrieved successfully
          content:
            application/json:
              schema:
                type: object
                required:
                - success
                - data
                - meta
                - message
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: array
                    description: Array of inboxes
                    items:
                      $ref: '#/components/schemas/inbox'
                  meta:
                    type: object
                    properties:
                      timestamp:
                        type: string
                        format: date-time
                        description: Response timestamp
                        example: '2024-01-15T10:30:00Z'
                  message:
                    type: string
                    description: Success message
                    example: Inboxes retrieved successfully
              example:
                success: true
                data:
                - id: 550e8400-e29b-41d4-a716-446655440000
                  name: Support Inbox
                  channel_type: website
                - id: 660e8400-e29b-41d4-a716-446655440001
                  name: Sales Inbox
                  channel_type: Channel::Email
                meta:
                  timestamp: '2024-01-15T10:30:00Z'
                message: Inboxes retrieved successfully
        '400':
          description: Bad Request (invalid data)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                bad_request:
                  summary: Invalid request data
                  value:
                    success: false
                    error:
                      code: BAD_REQUEST
                      message: Invalid request data
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes
                      method: GET
        '401':
          description: Unauthorized (invalid or missing token)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                unauthorized:
                  summary: Unauthorized
                  value:
                    success: false
                    error:
                      code: UNAUTHORIZED
                      message: Unauthorized
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes
                      method: GET
        '403':
          description: Forbidden (insufficient permissions)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                forbidden:
                  summary: Forbidden
                  value:
                    success: false
                    error:
                      code: FORBIDDEN
                      message: Forbidden
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes
                      method: GET
        '404':
          description: Not Found (resource not found)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                not_found:
                  summary: Resource not found
                  value:
                    success: false
                    error:
                      code: NOT_FOUND
                      message: Resource not found
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes
                      method: GET
        '500':
          description: Internal Server Error (server error)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                internal_error:
                  summary: Internal server error
                  value:
                    success: false
                    error:
                      code: INTERNAL_ERROR
                      message: An internal server error occurred
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes
                      method: GET
    post:
      operationId: inboxCreation
      summary: Create an inbox
      description: You can create more than one website inbox in each account
      security:
      - userApiKey: []
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/inbox_create_payload'
      responses:
        '200':
          description: Inbox created successfully
          content:
            application/json:
              schema:
                type: object
                required:
                - success
                - data
                - meta
                - message
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    $ref: '#/components/schemas/inbox'
                  meta:
                    type: object
                    properties:
                      timestamp:
                        type: string
                        format: date-time
                        description: Response timestamp
                        example: '2024-01-15T10:30:00Z'
                  message:
                    type: string
                    description: Success message
                    example: Inbox created successfully
              example:
                success: true
                data:
                  id: 550e8400-e29b-41d4-a716-446655440000
                  name: Support Inbox
                  channel_type: website
                meta:
                  timestamp: '2024-01-15T10:30:00Z'
                message: Inbox created successfully
        '400':
          description: Bad Request (invalid data)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                bad_request:
                  summary: Invalid request data
                  value:
                    success: false
                    error:
                      code: BAD_REQUEST
                      message: Invalid request data
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes
                      method: POST
        '401':
          description: Unauthorized (invalid or missing token)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                unauthorized:
                  summary: Unauthorized
                  value:
                    success: false
                    error:
                      code: UNAUTHORIZED
                      message: Unauthorized
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes
                      method: POST
        '403':
          description: Forbidden (insufficient permissions)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                forbidden:
                  summary: Forbidden
                  value:
                    success: false
                    error:
                      code: FORBIDDEN
                      message: Forbidden
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes
                      method: POST
        '404':
          description: Not Found (resource not found)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                not_found:
                  summary: Resource not found
                  value:
                    success: false
                    error:
                      code: NOT_FOUND
                      message: Resource not found
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes
                      method: POST
        '500':
          description: Internal Server Error (server error)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                internal_error:
                  summary: Internal server error
                  value:
                    success: false
                    error:
                      code: INTERNAL_ERROR
                      message: An internal server error occurred
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes
                      method: POST
  /api/v1/inboxes/{id}:
    parameters:
    - name: id
      in: path
      schema:
        type: string
        format: uuid
      description: ID of the inbox
      required: true
    get:
      operationId: GetInbox
      summary: Get an inbox
      security:
      - userApiKey: []
      description: Get an inbox available in the current account
      responses:
        '200':
          description: Inbox retrieved successfully
          content:
            application/json:
              schema:
                type: object
                required:
                - success
                - data
                - meta
                - message
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    $ref: '#/components/schemas/inbox'
                  meta:
                    type: object
                    properties:
                      timestamp:
                        type: string
                        format: date-time
                        description: Response timestamp
                        example: '2024-01-15T10:30:00Z'
                  message:
                    type: string
                    description: Success message
                    example: Inbox retrieved successfully
              example:
                success: true
                data:
                  id: 01d9f573-f953-4210-a99a-cdd3bd7f37a6
                  channel_id: d6b55c22-03c4-4778-a6d9-2d7b63e602f4
                  name: davidson-gomes
                  channel_type: Channel::Whatsapp
                  enable_auto_assignment: true
                  greeting_enabled: false
                  greeting_message: null
                  working_hours_enabled: false
                  out_of_office_message: null
                  timezone: UTC
                  enable_email_collect: true
                  csat_survey_enabled: false
                  allow_messages_after_resolved: true
                  auto_assignment_config: {}
                  lock_to_single_conversation: false
                  csat_config: {}
                  sender_name_type: friendly
                  business_name: null
                  display_name: Davidson Gomes
                  default_conversation_status: null
                  avatar_url: ''
                  working_hours:
                  - day_of_week: 0
                    closed_all_day: true
                    open_hour: null
                    open_minutes: null
                    close_hour: null
                    close_minutes: null
                    open_all_day: false
                  - day_of_week: 1
                    closed_all_day: false
                    open_hour: 9
                    open_minutes: 0
                    close_hour: 17
                    close_minutes: 0
                    open_all_day: false
                  - day_of_week: 2
                    closed_all_day: false
                    open_hour: 9
                    open_minutes: 0
                    close_hour: 17
                    close_minutes: 0
                    open_all_day: false
                  - day_of_week: 3
                    closed_all_day: false
                    open_hour: 9
                    open_minutes: 0
                    close_hour: 17
                    close_minutes: 0
                    open_all_day: false
                  - day_of_week: 4
                    closed_all_day: false
                    open_hour: 9
                    open_minutes: 0
                    close_hour: 17
                    close_minutes: 0
                    open_all_day: false
                  - day_of_week: 5
                    closed_all_day: false
                    open_hour: 9
                    open_minutes: 0
                    close_hour: 17
                    close_minutes: 0
                    open_all_day: false
                  - day_of_week: 6
                    closed_all_day: true
                    open_hour: null
                    open_minutes: null
                    close_hour: null
                    close_minutes: null
                    open_all_day: false
                  created_at: 1769624054
                  updated_at: 1769624054
                  provider: whatsapp_cloud
                meta:
                  timestamp: '2026-02-05T16:18:53Z'
                message: Inbox retrieved successfully
        '400':
          description: Bad Request (invalid data)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                bad_request:
                  summary: Invalid request data
                  value:
                    success: false
                    error:
                      code: BAD_REQUEST
                      message: Invalid request data
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes/{id}
                      method: GET
        '401':
          description: Unauthorized (invalid or missing token)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                unauthorized:
                  summary: Unauthorized
                  value:
                    success: false
                    error:
                      code: UNAUTHORIZED
                      message: Unauthorized
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes/{id}
                      method: GET
        '403':
          description: Forbidden (insufficient permissions)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                forbidden:
                  summary: Forbidden
                  value:
                    success: false
                    error:
                      code: FORBIDDEN
                      message: Forbidden
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes/{id}
                      method: GET
        '404':
          description: Not Found (resource not found)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                not_found:
                  summary: Inbox not found
                  value:
                    success: false
                    error:
                      code: NOT_FOUND
                      message: Inbox not found
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes/{id}
                      method: GET
        '500':
          description: Internal Server Error (server error)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                internal_error:
                  summary: Internal server error
                  value:
                    success: false
                    error:
                      code: INTERNAL_ERROR
                      message: An internal server error occurred
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes/{id}
                      method: GET
    patch:
      operationId: updateInbox
      summary: Update Inbox
      security:
      - userApiKey: []
      description: Update an existing inbox
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/inbox_update_payload'
      responses:
        '200':
          description: Inbox updated successfully
          content:
            application/json:
              schema:
                type: object
                required:
                - success
                - data
                - meta
                - message
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    $ref: '#/components/schemas/inbox'
                  meta:
                    type: object
                    properties:
                      timestamp:
                        type: string
                        format: date-time
                        description: Response timestamp
                        example: '2024-01-15T10:30:00Z'
                  message:
                    type: string
                    description: Success message
                    example: Inbox updated successfully
              example:
                success: true
                data:
                  id: 550e8400-e29b-41d4-a716-446655440000
                  name: Support Inbox
                  channel_type: website
                meta:
                  timestamp: '2024-01-15T10:30:00Z'
                message: Inbox updated successfully
        '400':
          description: Bad Request (invalid data)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                bad_request:
                  summary: Invalid request data
                  value:
                    success: false
                    error:
                      code: BAD_REQUEST
                      message: Invalid request data
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes/{id}
                      method: PATCH
        '401':
          description: Unauthorized (invalid or missing token)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                unauthorized:
                  summary: Unauthorized
                  value:
                    success: false
                    error:
                      code: UNAUTHORIZED
                      message: Unauthorized
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes/{id}
                      method: PATCH
        '403':
          description: Forbidden (insufficient permissions)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                forbidden:
                  summary: Forbidden
                  value:
                    success: false
                    error:
                      code: FORBIDDEN
                      message: Forbidden
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes/{id}
                      method: PATCH
        '404':
          description: Not Found (resource not found)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                not_found:
                  summary: Inbox not found
                  value:
                    success: false
                    error:
                      code: NOT_FOUND
                      message: Inbox not found
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes/{id}
                      method: PATCH
        '500':
          description: Internal Server Error (server error)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                internal_error:
                  summary: Internal server error
                  value:
                    success: false
                    error:
                      code: INTERNAL_ERROR
                      message: An internal server error occurred
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes/{id}
                      method: PATCH
    delete:
      operationId: deleteInbox
      summary: Delete Inbox
      description: Deletes an inbox permanently
      security:
      - userApiKey: []
      responses:
        '200':
          description: Inbox deleted successfully
          content:
            application/json:
              schema:
                type: object
                required:
                - success
                - data
                - meta
                - message
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: object
                    nullable: true
                    description: Null for delete operations
                    example: null
                  meta:
                    type: object
                    properties:
                      timestamp:
                        type: string
                        format: date-time
                        description: Response timestamp
                        example: '2024-01-15T10:30:00Z'
                  message:
                    type: string
                    description: Success message
                    example: Inbox deleted successfully
              example:
                success: true
                data: null
                meta:
                  timestamp: '2024-01-15T10:30:00Z'
                message: Inbox deleted successfully
        '400':
          description: Bad Request (invalid data)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                bad_request:
                  summary: Invalid request data
                  value:
                    success: false
                    error:
                      code: BAD_REQUEST
                      message: Invalid request data
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes/{id}
                      method: DELETE
        '401':
          description: Unauthorized (invalid or missing token)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                unauthorized:
                  summary: Unauthorized
                  value:
                    success: false
                    error:
                      code: UNAUTHORIZED
                      message: Unauthorized
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes/{id}
                      method: DELETE
        '403':
          description: Forbidden (insufficient permissions)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                forbidden:
                  summary: Forbidden
                  value:
                    success: false
                    error:
                      code: FORBIDDEN
                      message: Forbidden
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes/{id}
                      method: DELETE
        '404':
          description: Not Found (resource not found)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                not_found:
                  summary: Inbox not found
                  value:
                    success: false
                    error:
                      code: NOT_FOUND
                      message: Inbox not found
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes/{id}
                      method: DELETE
        '500':
          description: Internal Server Error (server error)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                internal_error:
                  summary: Internal server error
                  value:
                    success: false
                    error:
                      code: INTERNAL_ERROR
                      message: An internal server error occurred
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes/{id}
                      method: DELETE
  /api/v1/inboxes/{id}/agent_bot:
    get:
      operationId: getInboxAgentBot
      summary: Show Inbox Agent Bot
      description: See if an agent bot is associated to the Inbox
      security:
      - userApiKey: []
      parameters:
      - name: id
        in: path
        schema:
          type: string
          format: uuid
        description: ID of the inbox
        required: true
      responses:
        '200':
          description: Agent bot retrieved successfully
          content:
            application/json:
              schema:
                type: object
                required:
                - success
                - data
                - meta
                - message
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: object
                    nullable: true
                    description: Agent bot data or null if not associated
                    properties:
                      id:
                        type: integer
                        description: Agent bot ID
                        example: 1
                      name:
                        type: string
                        description: Agent bot name
                        example: Support Bot
                      description:
                        type: string
                        nullable: true
                        description: Agent bot description
                        example: Automated support assistant
                  meta:
                    type: object
                    properties:
                      timestamp:
                        type: string
                        format: date-time
                        description: Response timestamp
                        example: '2024-01-15T10:30:00Z'
                  message:
                    type: string
                    description: Success message
                    example: Agent bot retrieved successfully
              example:
                success: true
                data:
                  id: 1
                  name: Support Bot
                  description: Automated support assistant
                meta:
                  timestamp: '2024-01-15T10:30:00Z'
                message: Agent bot retrieved successfully
        '400':
          description: Bad Request (invalid data)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                bad_request:
                  summary: Invalid request data
                  value:
                    success: false
                    error:
                      code: BAD_REQUEST
                      message: Invalid request data
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes/{id}/agent_bot
                      method: GET
        '401':
          description: Unauthorized (invalid or missing token)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                unauthorized:
                  summary: Unauthorized
                  value:
                    success: false
                    error:
                      code: UNAUTHORIZED
                      message: Unauthorized
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes/{id}/agent_bot
                      method: GET
        '403':
          description: Forbidden (insufficient permissions)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                forbidden:
                  summary: Forbidden
                  value:
                    success: false
                    error:
                      code: FORBIDDEN
                      message: Forbidden
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes/{id}/agent_bot
                      method: GET
        '404':
          description: Not Found (resource not found)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                not_found:
                  summary: Inbox or agent bot not found
                  value:
                    success: false
                    error:
                      code: NOT_FOUND
                      message: Inbox not found or Agent bot not found
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes/{id}/agent_bot
                      method: GET
        '500':
          description: Internal Server Error (server error)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                internal_error:
                  summary: Internal server error
                  value:
                    success: false
                    error:
                      code: INTERNAL_ERROR
                      message: An internal server error occurred
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes/{id}/agent_bot
                      method: GET
  /api/v1/inboxes/{id}/assignable_agents:
    get:
      operationId: getAssignableAgents
      summary: Get Assignable Agents
      description: Returns list of agents that can be assigned to conversations in this inbox
      security:
      - userApiKey: []
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
          format: uuid
        description: ID of the inbox
      responses:
        '200':
          description: Assignable agents retrieved successfully
          content:
            application/json:
              schema:
                type: object
                required:
                - success
                - data
                - meta
                - message
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: array
                    description: Array of assignable agents
                    items:
                      $ref: '#/components/schemas/agent'
                  meta:
                    type: object
                    properties:
                      timestamp:
                        type: string
                        format: date-time
                        description: Response timestamp
                        example: '2024-01-15T10:30:00Z'
                  message:
                    type: string
                    description: Success message
                    example: Assignable agents retrieved successfully
              example:
                success: true
                data: []
                meta:
                  timestamp: '2024-01-15T10:30:00Z'
                message: Assignable agents retrieved successfully
        '400':
          description: Bad Request (invalid data)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                bad_request:
                  summary: Invalid request data
                  value:
                    success: false
                    error:
                      code: BAD_REQUEST
                      message: Invalid request data
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes/{id}/assignable_agents
                      method: GET
        '401':
          description: Unauthorized (invalid or missing token)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                unauthorized:
                  summary: Unauthorized
                  value:
                    success: false
                    error:
                      code: UNAUTHORIZED
                      message: Unauthorized
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes/{id}/assignable_agents
                      method: GET
        '403':
          description: Forbidden (insufficient permissions)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                forbidden:
                  summary: Forbidden
                  value:
                    success: false
                    error:
                      code: FORBIDDEN
                      message: Forbidden
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes/{id}/assignable_agents
                      method: GET
        '404':
          description: Not Found (resource not found)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                not_found:
                  summary: Inbox not found
                  value:
                    success: false
                    error:
                      code: NOT_FOUND
                      message: Inbox not found
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes/{id}/assignable_agents
                      method: GET
        '500':
          description: Internal Server Error (server error)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                internal_error:
                  summary: Internal server error
                  value:
                    success: false
                    error:
                      code: INTERNAL_ERROR
                      message: An internal server error occurred
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes/{id}/assignable_agents
                      method: GET
  /api/v1/inboxes/{id}/disconnect_channel_provider:
    post:
      operationId: disconnectChannelProvider
      summary: Disconnect Channel Provider
      description: Disconnects the channel provider from the inbox
      security:
      - userApiKey: []
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
          format: uuid
        description: ID of the inbox
      responses:
        '200':
          description: Channel provider disconnected successfully
          content:
            application/json:
              schema:
                type: object
                required:
                - success
                - data
                - meta
                - message
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: object
                    nullable: true
                    description: Null for disconnect operations
                    example: null
                  meta:
                    type: object
                    properties:
                      timestamp:
                        type: string
                        format: date-time
                        description: Response timestamp
                        example: '2024-01-15T10:30:00Z'
                  message:
                    type: string
                    description: Success message
                    example: Channel provider disconnected successfully
              example:
                success: true
                data: null
                meta:
                  timestamp: '2024-01-15T10:30:00Z'
                message: Channel provider disconnected successfully
        '400':
          description: Bad Request (invalid data)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                bad_request:
                  summary: Invalid request data
                  value:
                    success: false
                    error:
                      code: BAD_REQUEST
                      message: Invalid request data
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes/{id}/disconnect_channel_provider
                      method: POST
        '401':
          description: Unauthorized (invalid or missing token)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                unauthorized:
                  summary: Unauthorized
                  value:
                    success: false
                    error:
                      code: UNAUTHORIZED
                      message: Unauthorized
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes/{id}/disconnect_channel_provider
                      method: POST
        '403':
          description: Forbidden (insufficient permissions)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                forbidden:
                  summary: Forbidden
                  value:
                    success: false
                    error:
                      code: FORBIDDEN
                      message: Forbidden
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes/{id}/disconnect_channel_provider
                      method: POST
        '404':
          description: Not Found (resource not found)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                not_found:
                  summary: Inbox not found
                  value:
                    success: false
                    error:
                      code: NOT_FOUND
                      message: Inbox not found
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes/{id}/disconnect_channel_provider
                      method: POST
        '500':
          description: Internal Server Error (server error)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                internal_error:
                  summary: Internal server error
                  value:
                    success: false
                    error:
                      code: INTERNAL_ERROR
                      message: An internal server error occurred
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes/{id}/disconnect_channel_provider
                      method: POST
  /api/v1/inboxes/{id}/message_templates:
    parameters:
    - name: id
      in: path
      required: true
      schema:
        type: string
        format: uuid
      description: ID of the inbox
    get:
      operationId: listMessageTemplates
      summary: List Message Templates
      description: Returns all WhatsApp message templates for the inbox
      security:
      - userApiKey: []
      responses:
        '200':
          description: Message templates retrieved successfully
          content:
            application/json:
              schema:
                type: object
                required:
                - success
                - data
                - meta
                - message
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: array
                    description: Array of message templates
                    items:
                      type: object
                      properties:
                        id:
                          type: string
                          example: '1234567890'
                        name:
                          type: string
                          example: welcome_message
                        category:
                          type: string
                          example: UTILITY
                        language:
                          type: string
                          example: en
                        status:
                          type: string
                          example: APPROVED
                        components:
                          type: array
                          items:
                            type: object
                  meta:
                    type: object
                    properties:
                      pagination:
                        type: object
                        properties:
                          page:
                            type: integer
                            description: Current page number
                            example: 1
                          pageSize:
                            type: integer
                            description: Number of items per page
                            example: 20
                          total:
                            type: integer
                            description: Total number of items
                            example: 0
                          totalPages:
                            type: integer
                            description: Total number of pages
                            example: 0
                          hasNextPage:
                            type: boolean
                            nullable: true
                            description: Whether there is a next page
                            example: null
                          hasPreviousPage:
                            type: boolean
                            nullable: true
                            description: Whether there is a previous page
                            example: null
                      timestamp:
                        type: string
                        format: date-time
                        description: Response timestamp
                        example: '2026-02-05T16:40:06Z'
                  message:
                    type: string
                    description: Success message
                    example: Inbox templates retrieved successfully
              example:
                success: true
                data: []
                meta:
                  pagination:
                    page: 1
                    pageSize: 20
                    total: 0
                    totalPages: 0
                    hasNextPage: null
                    hasPreviousPage: null
                  timestamp: '2026-02-05T16:40:06Z'
                message: Inbox templates retrieved successfully
        '400':
          description: Bad Request (invalid data)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                bad_request:
                  summary: Invalid request data
                  value:
                    success: false
                    error:
                      code: BAD_REQUEST
                      message: Invalid request data
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes/{id}/message_templates
                      method: GET
        '401':
          description: Unauthorized (invalid or missing token)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                unauthorized:
                  summary: Unauthorized
                  value:
                    success: false
                    error:
                      code: UNAUTHORIZED
                      message: Unauthorized
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes/{id}/message_templates
                      method: GET
        '403':
          description: Forbidden (insufficient permissions)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                forbidden:
                  summary: Forbidden
                  value:
                    success: false
                    error:
                      code: FORBIDDEN
                      message: Forbidden
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes/{id}/message_templates
                      method: GET
        '404':
          description: Not Found (resource not found)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                not_found:
                  summary: Inbox not found
                  value:
                    success: false
                    error:
                      code: NOT_FOUND
                      message: Inbox not found
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes/{id}/message_templates
                      method: GET
        '500':
          description: Internal Server Error (server error)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                internal_error:
                  summary: Internal server error
                  value:
                    success: false
                    error:
                      code: INTERNAL_ERROR
                      message: An internal server error occurred
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes/{id}/message_templates
                      method: GET
    post:
      operationId: createMessageTemplate
      summary: Create Message Template
      description: Creates a new WhatsApp message template
      security:
      - userApiKey: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - name
              - category
              - language
              - components
              properties:
                name:
                  type: string
                  description: Template name
                  example: welcome_message
                category:
                  type: string
                  enum:
                  - UTILITY
                  - MARKETING
                  - AUTHENTICATION
                  description: Template category
                  example: UTILITY
                language:
                  type: string
                  description: Template language code
                  example: en
                components:
                  type: array
                  description: Template components
                  items:
                    type: object
      responses:
        '200':
          description: Template created successfully
          content:
            application/json:
              schema:
                type: object
                required:
                - success
                - data
                - meta
                - message
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: object
                    description: Created template data
                    properties:
                      id:
                        type: string
                        example: '1234567890'
                      name:
                        type: string
                        example: welcome_message
                      category:
                        type: string
                        example: UTILITY
                      language:
                        type: string
                        example: en
                      status:
                        type: string
                        example: PENDING
                  meta:
                    type: object
                    properties:
                      timestamp:
                        type: string
                        format: date-time
                        description: Response timestamp
                        example: '2024-01-15T10:30:00Z'
                  message:
                    type: string
                    description: Success message
                    example: Template created successfully
              example:
                success: true
                data:
                  id: '1234567890'
                  name: welcome_message
                  category: UTILITY
                  language: en
                  status: PENDING
                meta:
                  timestamp: '2024-01-15T10:30:00Z'
                message: Template created successfully
        '400':
          description: Bad Request (invalid data)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                bad_request:
                  summary: Invalid request data
                  value:
                    success: false
                    error:
                      code: BAD_REQUEST
                      message: Invalid request data
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes/{id}/message_templates
                      method: POST
        '401':
          description: Unauthorized (invalid or missing token)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                unauthorized:
                  summary: Unauthorized
                  value:
                    success: false
                    error:
                      code: UNAUTHORIZED
                      message: Unauthorized
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes/{id}/message_templates
                      method: POST
        '403':
          description: Forbidden (insufficient permissions)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                forbidden:
                  summary: Forbidden
                  value:
                    success: false
                    error:
                      code: FORBIDDEN
                      message: Forbidden
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes/{id}/message_templates
                      method: POST
        '404':
          description: Not Found (resource not found)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                not_found:
                  summary: Inbox not found
                  value:
                    success: false
                    error:
                      code: NOT_FOUND
                      message: Inbox not found
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes/{id}/message_templates
                      method: POST
        '422':
          description: Unprocessable Entity (validation error)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                validation_error:
                  summary: Validation error
                  value:
                    success: false
                    error:
                      code: VALIDATION_ERROR
                      message: Validation error
                      details:
                        components: Template components are invalid
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes/{id}/message_templates
                      method: POST
        '500':
          description: Internal Server Error (server error)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                internal_error:
                  summary: Internal server error
                  value:
                    success: false
                    error:
                      code: INTERNAL_ERROR
                      message: An internal server error occurred
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes/{id}/message_templates
                      method: POST
  /api/v1/inboxes/{id}/message_templates/sync:
    post:
      operationId: syncMessageTemplates
      summary: Sync Message Templates
      description: Syncs message templates from WhatsApp Business API
      security:
      - userApiKey: []
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
          format: uuid
        description: ID of the inbox
      responses:
        '200':
          description: Templates synced successfully
          content:
            application/json:
              schema:
                type: object
                required:
                - success
                - data
                - meta
                - message
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: array
                    description: Sync operation result data (empty array when sync is not supported)
                    items:
                      type: object
                  meta:
                    type: object
                    properties:
                      timestamp:
                        type: string
                        format: date-time
                        description: Response timestamp
                        example: '2026-02-05T16:44:17Z'
                  message:
                    type: string
                    description: Success message or sync status message
                    example: Sync not supported for this channel type
              example:
                success: true
                data: []
                meta:
                  timestamp: '2026-02-05T16:44:17Z'
                message: Sync not supported for this channel type
        '400':
          description: Bad Request (invalid data)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                bad_request:
                  summary: Invalid request data
                  value:
                    success: false
                    error:
                      code: BAD_REQUEST
                      message: Invalid request data
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes/{id}/message_templates/sync
                      method: POST
        '401':
          description: Unauthorized (invalid or missing token)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                unauthorized:
                  summary: Unauthorized
                  value:
                    success: false
                    error:
                      code: UNAUTHORIZED
                      message: Unauthorized
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes/{id}/message_templates/sync
                      method: POST
        '403':
          description: Forbidden (insufficient permissions)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                forbidden:
                  summary: Forbidden
                  value:
                    success: false
                    error:
                      code: FORBIDDEN
                      message: Forbidden
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes/{id}/message_templates/sync
                      method: POST
        '404':
          description: Not Found (resource not found)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                not_found:
                  summary: Inbox not found
                  value:
                    success: false
                    error:
                      code: NOT_FOUND
                      message: Inbox not found
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes/{id}/message_templates/sync
                      method: POST
        '500':
          description: Internal Server Error (server error)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                internal_error:
                  summary: Internal server error
                  value:
                    success: false
                    error:
                      code: INTERNAL_ERROR
                      message: An internal server error occurred
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes/{id}/message_templates/sync
                      method: POST
  /api/v1/inboxes/{id}/message_templates/{template_id}:
    parameters:
    - name: id
      in: path
      required: true
      schema:
        type: string
        format: uuid
      description: ID of the inbox
    - name: template_id
      in: path
      required: true
      schema:
        type: string
      description: ID of the template
    put:
      operationId: updateMessageTemplate
      summary: Update Message Template
      description: Updates an existing message template
      security:
      - userApiKey: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                components:
                  type: array
                  description: Updated template components
                  items:
                    type: object
      responses:
        '200':
          description: Template updated successfully
          content:
            application/json:
              schema:
                type: object
                required:
                - success
                - data
                - meta
                - message
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: object
                    description: Updated template data
                    properties:
                      id:
                        type: string
                        example: '1234567890'
                      name:
                        type: string
                        example: welcome_message
                      status:
                        type: string
                        example: PENDING
                  meta:
                    type: object
                    properties:
                      timestamp:
                        type: string
                        format: date-time
                        description: Response timestamp
                        example: '2024-01-15T10:30:00Z'
                  message:
                    type: string
                    description: Success message
                    example: Template updated successfully
              example:
                success: true
                data:
                  id: '1234567890'
                  name: welcome_message
                  status: PENDING
                meta:
                  timestamp: '2024-01-15T10:30:00Z'
                message: Template updated successfully
        '400':
          description: Bad Request (invalid data)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                bad_request:
                  summary: Invalid request data
                  value:
                    success: false
                    error:
                      code: BAD_REQUEST
                      message: Invalid request data
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes/{id}/message_templates/{template_id}
                      method: PUT
        '401':
          description: Unauthorized (invalid or missing token)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                unauthorized:
                  summary: Unauthorized
                  value:
                    success: false
                    error:
                      code: UNAUTHORIZED
                      message: Unauthorized
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes/{id}/message_templates/{template_id}
                      method: PUT
        '403':
          description: Forbidden (insufficient permissions)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                forbidden:
                  summary: Forbidden
                  value:
                    success: false
                    error:
                      code: FORBIDDEN
                      message: Forbidden
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes/{id}/message_templates/{template_id}
                      method: PUT
        '404':
          description: Not Found (resource not found)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                not_found:
                  summary: Inbox or template not found
                  value:
                    success: false
                    error:
                      code: NOT_FOUND
                      message: Inbox or template not found
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes/{id}/message_templates/{template_id}
                      method: PUT
        '422':
          description: Unprocessable Entity (validation error)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                validation_error:
                  summary: Validation error
                  value:
                    success: false
                    error:
                      code: VALIDATION_ERROR
                      message: Validation error
                      details:
                        components: Template components are invalid
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes/{id}/message_templates/{template_id}
                      method: PUT
        '500':
          description: Internal Server Error (server error)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                internal_error:
                  summary: Internal server error
                  value:
                    success: false
                    error:
                      code: INTERNAL_ERROR
                      message: An internal server error occurred
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes/{id}/message_templates/{template_id}
                      method: PUT
    delete:
      operationId: deleteMessageTemplate
      summary: Delete Message Template
      description: Deletes a message template
      security:
      - userApiKey: []
      responses:
        '200':
          description: Template deleted successfully
          content:
            application/json:
              schema:
                type: object
                required:
                - success
                - data
                - meta
                - message
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: object
                    nullable: true
                    description: Null for delete operations
                    example: null
                  meta:
                    type: object
                    properties:
                      timestamp:
                        type: string
                        format: date-time
                        description: Response timestamp
                        example: '2024-01-15T10:30:00Z'
                  message:
                    type: string
                    description: Success message
                    example: Template deleted successfully
              example:
                success: true
                data: null
                meta:
                  timestamp: '2024-01-15T10:30:00Z'
                message: Template deleted successfully
        '400':
          description: Bad Request (invalid data)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                bad_request:
                  summary: Invalid request data
                  value:
                    success: false
                    error:
                      code: BAD_REQUEST
                      message: Invalid request data
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes/{id}/message_templates/{template_id}
                      method: DELETE
        '401':
          description: Unauthorized (invalid or missing token)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                unauthorized:
                  summary: Unauthorized
                  value:
                    success: false
                    error:
                      code: UNAUTHORIZED
                      message: Unauthorized
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes/{id}/message_templates/{template_id}
                      method: DELETE
        '403':
          description: Forbidden (insufficient permissions)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                forbidden:
                  summary: Forbidden
                  value:
                    success: false
                    error:
                      code: FORBIDDEN
                      message: Forbidden
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes/{id}/message_templates/{template_id}
                      method: DELETE
        '404':
          description: Not Found (resource not found)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                not_found:
                  summary: Inbox or template not found
                  value:
                    success: false
                    error:
                      code: NOT_FOUND
                      message: Inbox or template not found
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes/{id}/message_templates/{template_id}
                      method: DELETE
        '500':
          description: Internal Server Error (server error)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                internal_error:
                  summary: Internal server error
                  value:
                    success: false
                    error:
                      code: INTERNAL_ERROR
                      message: An internal server error occurred
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes/{id}/message_templates/{template_id}
                      method: DELETE
  /api/v1/inboxes/{id}/set_agent_bot:
    post:
      operationId: updateAgentBot
      summary: Add or remove agent bot
      security:
      - userApiKey: []
      description: To add an agent bot pass agent_bot id, to remove agent bot from an inbox pass null
      parameters:
      - name: id
        in: path
        schema:
          type: string
          format: uuid
        description: ID of the inbox
        required: true
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - agent_bot
              properties:
                agent_bot:
                  type: number
                  nullable: true
                  description: Agent bot ID (pass null to remove)
                  example: 1
      responses:
        '200':
          description: Agent bot updated successfully
          content:
            application/json:
              schema:
                type: object
                required:
                - success
                - data
                - meta
                - message
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: object
                    nullable: true
                    description: Updated agent bot data or null if removed
                    properties:
                      id:
                        type: integer
                        description: Agent bot ID
                        example: 1
                      name:
                        type: string
                        description: Agent bot name
                        example: Support Bot
                  meta:
                    type: object
                    properties:
                      timestamp:
                        type: string
                        format: date-time
                        description: Response timestamp
                        example: '2024-01-15T10:30:00Z'
                  message:
                    type: string
                    description: Success message
                    example: Agent bot updated successfully
              example:
                success: true
                data:
                  id: 1
                  name: Support Bot
                meta:
                  timestamp: '2024-01-15T10:30:00Z'
                message: Agent bot updated successfully
        '400':
          description: Bad Request (invalid data)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                bad_request:
                  summary: Invalid request data
                  value:
                    success: false
                    error:
                      code: BAD_REQUEST
                      message: Invalid request data
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes/{id}/set_agent_bot
                      method: POST
        '401':
          description: Unauthorized (invalid or missing token)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                unauthorized:
                  summary: Unauthorized
                  value:
                    success: false
                    error:
                      code: UNAUTHORIZED
                      message: Unauthorized
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes/{id}/set_agent_bot
                      method: POST
        '403':
          description: Forbidden (insufficient permissions)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                forbidden:
                  summary: Forbidden
                  value:
                    success: false
                    error:
                      code: FORBIDDEN
                      message: Forbidden
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes/{id}/set_agent_bot
                      method: POST
        '404':
          description: Not Found (resource not found)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                not_found:
                  summary: Inbox or agent bot not found
                  value:
                    success: false
                    error:
                      code: NOT_FOUND
                      message: Inbox not found or Agent bot not found
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes/{id}/set_agent_bot
                      method: POST
        '500':
          description: Internal Server Error (server error)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                internal_error:
                  summary: Internal server error
                  value:
                    success: false
                    error:
                      code: INTERNAL_ERROR
                      message: An internal server error occurred
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes/{id}/set_agent_bot
                      method: POST
  /api/v1/inboxes/{id}/setup_channel_provider:
    post:
      operationId: setupChannelProvider
      summary: Setup Channel Provider
      description: Configures the channel provider integration for the inbox
      security:
      - userApiKey: []
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
          format: uuid
        description: ID of the inbox
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - provider
              properties:
                provider:
                  type: string
                  description: Provider name (twilio, whatsapp, evolution, etc.)
                  example: whatsapp
                provider_config:
                  type: object
                  description: Provider-specific configuration
                  additionalProperties: true
      responses:
        '200':
          description: Channel provider configured successfully
          content:
            application/json:
              schema:
                type: object
                required:
                - success
                - data
                - meta
                - message
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: object
                    nullable: true
                    description: Channel provider configuration data
                    properties:
                      provider:
                        type: string
                        example: whatsapp
                      status:
                        type: string
                        example: configured
                  meta:
                    type: object
                    properties:
                      timestamp:
                        type: string
                        format: date-time
                        description: Response timestamp
                        example: '2024-01-15T10:30:00Z'
                  message:
                    type: string
                    description: Success message
                    example: Channel provider configured successfully
              example:
                success: true
                data:
                  provider: whatsapp
                  status: configured
                meta:
                  timestamp: '2024-01-15T10:30:00Z'
                message: Channel provider configured successfully
        '400':
          description: Bad Request (invalid data)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                bad_request:
                  summary: Invalid request data
                  value:
                    success: false
                    error:
                      code: BAD_REQUEST
                      message: Invalid request data
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes/{id}/setup_channel_provider
                      method: POST
        '401':
          description: Unauthorized (invalid or missing token)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                unauthorized:
                  summary: Unauthorized
                  value:
                    success: false
                    error:
                      code: UNAUTHORIZED
                      message: Unauthorized
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes/{id}/setup_channel_provider
                      method: POST
        '403':
          description: Forbidden (insufficient permissions)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                forbidden:
                  summary: Forbidden
                  value:
                    success: false
                    error:
                      code: FORBIDDEN
                      message: Forbidden
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes/{id}/setup_channel_provider
                      method: POST
        '404':
          description: Not Found (resource not found)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                not_found:
                  summary: Inbox not found
                  value:
                    success: false
                    error:
                      code: NOT_FOUND
                      message: Inbox not found
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes/{id}/setup_channel_provider
                      method: POST
        '422':
          description: Unprocessable Entity (validation error)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                validation_error:
                  summary: Invalid configuration
                  value:
                    success: false
                    error:
                      code: VALIDATION_ERROR
                      message: Invalid configuration
                      details:
                        provider_config: Provider configuration is invalid
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes/{id}/setup_channel_provider
                      method: POST
        '500':
          description: Internal Server Error (server error)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                internal_error:
                  summary: Internal server error
                  value:
                    success: false
                    error:
                      code: INTERNAL_ERROR
                      message: An internal server error occurred
                    meta:
                      timestamp: '2024-01-15T10:30:00Z'
                      path: /api/v1/inboxes/{id}/setup_channel_provider
                      method: POST
components:
  schemas:
    ErrorResponse:
      type: object
      required:
      - success
      - error
      - meta
      properties:
        success:
          type: boolean
          example: false
        error:
          type: object
          required:
          - code
          - message
          properties:
            code:
              type: string
              example: VALIDATION_ERROR
            message:
              type: string
              example: Validation failed
            details:
              type: object
              additionalProperties: true
              nullable: true
        meta:
          type: object
          required:
          - timestamp
          - path
          - method
          properties:
            timestamp:
              type: string
              format: date-time
              example: '2024-01-15T10:30:00Z'
            path:
              type: string
              example: /public/api/v1/inboxes/{inbox_identifier}/contacts
            method:
              type: string
              example: POST
  securitySchemes:
    userApiKey:
      type: apiKey
      in: header
      name: api_access_token
    ApiAccessToken:
      type: apiKey
      in: header
      name: api_access_token
      description: API access token for user authentication
  parameters:
    inbox_id:
      name: id
      in: path
      required: true
      description: ID da inbox (UUID)
      schema:
        type: string
        format: uuid
      example: 9e56942b-50d2-4322-90e1-105274ec7752
