{
  "openapi": "3.1.0",
  "info": {
    "title": "Chatter public API",
    "version": "1.0.0",
    "description": "Server-to-server REST API of Chatter, available from the Basic plan. Authentication: `Authorization: Bearer chk_<48 hex>` (company API key). Rate limits: 120 requests per minute per key and 300 per minute per company (all keys together); responses carry `X-RateLimit-Limit` and `X-RateLimit-Remaining`; exceeding returns 429. Successful responses are `{ \"data\": ... }` (lists add limit/offset/total), failures are `{ \"error\": \"...\" }`. Every resource is scoped to the company of the key; ids of other companies answer 404. There is no endpoint to message a number that never wrote first. Error message texts are in Spanish."
  },
  "servers": [
    {
      "url": "https://chat.teraservercloud.com/api/v1"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "tags": [
    {
      "name": "Conversations"
    },
    {
      "name": "Read"
    },
    {
      "name": "Tickets"
    },
    {
      "name": "Configuration"
    },
    {
      "name": "Knowledge and AI"
    },
    {
      "name": "Agenda"
    }
  ],
  "paths": {
    "/conversations": {
      "get": {
        "operationId": "listConversations",
        "tags": [
          "Conversations"
        ],
        "summary": "List conversations",
        "description": "Newest activity first. Text search (`q`) only looks at the last 180 days (or from `since` if more recent).",
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "open",
                "closed",
                "all"
              ],
              "default": "all"
            },
            "description": "`open` = new, open and pending."
          },
          {
            "name": "channel",
            "in": "query",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/Channel"
            }
          },
          {
            "name": "since",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "description": "ISO 8601: conversations with activity since then."
          },
          {
            "name": "assigned_user_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^(none|[1-9][0-9]*)$"
            },
            "description": "User id, or `none` for unassigned."
          },
          {
            "name": "contact",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 2,
              "maxLength": 100
            },
            "description": "Phone or name (partial match)."
          },
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 2,
              "maxLength": 100
            },
            "description": "Text inside messages."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConversationList"
                }
              }
            }
          },
          "400": {
            "description": "Invalid format or type.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing, malformed or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Company inactive or plan without API access.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/conversations/{id}": {
      "get": {
        "operationId": "getConversation",
        "tags": [
          "Conversations"
        ],
        "summary": "Get a conversation with its messages",
        "description": "Get a conversation with its messages",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 4294967295
            },
            "description": "Conversation id."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConversationWithMessages"
                }
              }
            }
          },
          "401": {
            "description": "Missing, malformed or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Company inactive or plan without API access.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found (or belongs to another company).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/conversations/{id}/messages": {
      "post": {
        "operationId": "sendMessage",
        "tags": [
          "Conversations"
        ],
        "summary": "Reply to a conversation",
        "description": "Sends a text reply on an existing open conversation, through the conversation channel. Limits per conversation: 5 API messages per minute and 10 in a row without a customer reply (429). Instagram/Facebook only within 24 h of the last customer message (409); email requires a verified outgoing SMTP (409). Phone conversations cannot be replied to (409).",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 4294967295
            },
            "description": "Conversation id."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SendTextRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Message created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SendTextResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid format or type.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing, malformed or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Company inactive or plan without API access.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found (or belongs to another company).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Incompatible state or duplicate.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Delivery failed on the channel.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeliveryFailed"
                }
              }
            }
          }
        }
      }
    },
    "/conversations/{id}/close": {
      "post": {
        "operationId": "closeConversation",
        "tags": [
          "Conversations"
        ],
        "summary": "Close a conversation",
        "description": "Same path as closing from the panel (event, sockets, satisfaction survey when enabled).",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 4294967295
            },
            "description": "Conversation id."
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OkResponse"
                }
              }
            }
          },
          "401": {
            "description": "Missing, malformed or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Company inactive or plan without API access.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found (or belongs to another company).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Incompatible state or duplicate.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/conversations/{id}/reopen": {
      "post": {
        "operationId": "reopenConversation",
        "tags": [
          "Conversations"
        ],
        "summary": "Reopen a closed conversation",
        "description": "Returns it to the queue (status `new`) unassigned.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 4294967295
            },
            "description": "Conversation id."
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "integer"
                        },
                        "status": {
                          "type": "string",
                          "const": "new"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, malformed or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Company inactive or plan without API access.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found (or belongs to another company).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Incompatible state or duplicate.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/conversations/{id}/assign": {
      "post": {
        "operationId": "assignConversation",
        "tags": [
          "Conversations"
        ],
        "summary": "Assign a conversation to an agent or return it to the queue",
        "description": "Closed conversations cannot be assigned (409). The target user must be active (422) and belong to the company (404).",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 4294967295
            },
            "description": "Conversation id."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AssignRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IdStatus"
                }
              }
            }
          },
          "400": {
            "description": "Invalid format or type.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing, malformed or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Company inactive or plan without API access.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found (or belongs to another company).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Incompatible state or duplicate.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Valid but unacceptable value.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/conversations/{id}/notes": {
      "post": {
        "operationId": "addNote",
        "tags": [
          "Conversations"
        ],
        "summary": "Add an internal note",
        "description": "Internal note visible in the panel only; never sent to the customer.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 4294967295
            },
            "description": "Conversation id."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NoteRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NoteResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid format or type.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing, malformed or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Company inactive or plan without API access.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found (or belongs to another company).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Valid but unacceptable value.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/conversations/{id}/media": {
      "post": {
        "operationId": "sendMedia",
        "tags": [
          "Conversations"
        ],
        "summary": "Send an attachment from a URL",
        "description": "The API downloads the https URL (max 16 MB, no redirects, private addresses rejected) and sends it natively. The file type is taken from the response Content-Type. Company limits: 1 download at a time, 10 per minute, 300 per day (429); plus the same per-conversation limits as messages.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 4294967295
            },
            "description": "Conversation id."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MediaRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MediaResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid format or type.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing, malformed or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Company inactive or plan without API access.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found (or belongs to another company).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Incompatible state or duplicate.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Valid but unacceptable value.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Delivery failed on the channel.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeliveryFailed"
                }
              }
            }
          }
        }
      }
    },
    "/users": {
      "get": {
        "operationId": "listUsers",
        "tags": [
          "Read"
        ],
        "summary": "List users",
        "description": "List users",
        "parameters": [
          {
            "name": "role",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "agent",
                "supervisor",
                "admin"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/User"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid format or type.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing, malformed or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Company inactive or plan without API access.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/channels": {
      "get": {
        "operationId": "listChannels",
        "tags": [
          "Read"
        ],
        "summary": "List WhatsApp lines and channels",
        "description": "Never returns tokens, secrets or mailbox credentials.",
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Account"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, malformed or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Company inactive or plan without API access.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/stats": {
      "get": {
        "operationId": "getStats",
        "tags": [
          "Read"
        ],
        "summary": "Statistics for a date range",
        "description": "Maximum range 92 days.",
        "parameters": [
          {
            "name": "from",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date"
            },
            "description": "YYYY-MM-DD, inclusive. Must be sent together with `to`. Default: last 30 days."
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date"
            },
            "description": "YYYY-MM-DD, inclusive."
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Stats"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid format or type.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing, malformed or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Company inactive or plan without API access.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Valid but unacceptable value.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/surveys": {
      "get": {
        "operationId": "listSurveys",
        "tags": [
          "Read"
        ],
        "summary": "List answered satisfaction surveys",
        "description": "Maximum range 366 days.",
        "parameters": [
          {
            "name": "from",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date"
            },
            "description": "YYYY-MM-DD, inclusive. Must be sent together with `to`. Default: last 30 days."
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date"
            },
            "description": "YYYY-MM-DD, inclusive."
          },
          {
            "name": "rating",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 5
            }
          },
          {
            "name": "channel",
            "in": "query",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/Channel"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Survey"
                      }
                    },
                    "total": {
                      "type": "integer"
                    },
                    "limit": {
                      "type": "integer"
                    },
                    "offset": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid format or type.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing, malformed or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Company inactive or plan without API access.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Valid but unacceptable value.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/tickets": {
      "get": {
        "operationId": "listTickets",
        "tags": [
          "Tickets"
        ],
        "summary": "List tickets",
        "description": "Newest update first. Returns 403 if the company does not have tickets enabled.",
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "open",
                "in_progress",
                "closed",
                "all"
              ]
            }
          },
          {
            "name": "priority",
            "in": "query",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/TicketPriority"
            }
          },
          {
            "name": "assigned_user_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 4294967295
            }
          },
          {
            "name": "conversation_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 4294967295
            }
          },
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 2,
              "maxLength": 100
            },
            "description": "Matches subject or contact name."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Ticket"
                      }
                    },
                    "total": {
                      "type": "integer"
                    },
                    "limit": {
                      "type": "integer"
                    },
                    "offset": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid format or type.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing, malformed or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Company inactive or plan without API access.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createTicket",
        "tags": [
          "Tickets"
        ],
        "summary": "Create a ticket",
        "description": "Tickets are internal control items. Returns 403 if the company does not have tickets enabled.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TicketCreate"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "integer"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid format or type.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing, malformed or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Company inactive or plan without API access.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found (or belongs to another company).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Valid but unacceptable value.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/tickets/{id}": {
      "get": {
        "operationId": "getTicket",
        "tags": [
          "Tickets"
        ],
        "summary": "Get a ticket with its comments",
        "description": "Returns 403 if the company does not have tickets enabled.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 4294967295
            },
            "description": "Ticket id."
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/TicketDetail"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, malformed or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Company inactive or plan without API access.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found (or belongs to another company).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "updateTicket",
        "tags": [
          "Tickets"
        ],
        "summary": "Update a ticket",
        "description": "At least one field is required. Returns 403 if the company does not have tickets enabled.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 4294967295
            },
            "description": "Ticket id."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TicketUpdate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "integer"
                        },
                        "updated": {
                          "type": "boolean",
                          "const": true
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid format or type.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing, malformed or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Company inactive or plan without API access.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found (or belongs to another company).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Valid but unacceptable value.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/tickets/{id}/comments": {
      "post": {
        "operationId": "addTicketComment",
        "tags": [
          "Tickets"
        ],
        "summary": "Add a comment to a ticket",
        "description": "Returns 403 if the company does not have tickets enabled.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 4294967295
            },
            "description": "Ticket id."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TicketCommentCreate"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "integer"
                        },
                        "ticket_id": {
                          "type": "integer"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid format or type.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing, malformed or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Company inactive or plan without API access.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found (or belongs to another company).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Valid but unacceptable value.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/quick-replies": {
      "get": {
        "operationId": "listQuickReplies",
        "tags": [
          "Configuration"
        ],
        "summary": "List quick replies",
        "description": "List quick replies",
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/QuickReply"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, malformed or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Company inactive or plan without API access.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createQuickReply",
        "tags": [
          "Configuration"
        ],
        "summary": "Create a quick reply",
        "description": "Maximum 200 quick replies per company (422).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QuickReplyCreate"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/QuickReply"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid format or type.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing, malformed or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Company inactive or plan without API access.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Valid but unacceptable value.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/quick-replies/{id}": {
      "put": {
        "operationId": "updateQuickReply",
        "tags": [
          "Configuration"
        ],
        "summary": "Update a quick reply",
        "description": "Send at least one of label, text, sort_order.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 4294967295
            },
            "description": "Quick reply id."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QuickReplyUpdate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/QuickReply"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid format or type.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing, malformed or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Company inactive or plan without API access.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found (or belongs to another company).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Valid but unacceptable value.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteQuickReply",
        "tags": [
          "Configuration"
        ],
        "summary": "Delete a quick reply",
        "description": "Delete a quick reply",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 4294967295
            },
            "description": "Quick reply id."
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Deleted"
                }
              }
            }
          },
          "401": {
            "description": "Missing, malformed or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Company inactive or plan without API access.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found (or belongs to another company).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/bans": {
      "get": {
        "operationId": "listBans",
        "tags": [
          "Configuration"
        ],
        "summary": "List blocked numbers",
        "description": "List blocked numbers",
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Ban"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, malformed or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Company inactive or plan without API access.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createBan",
        "tags": [
          "Configuration"
        ],
        "summary": "Block a number",
        "description": "Requires `\"confirm\": \"BLOQUEAR\"`.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BanCreate"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "integer"
                        },
                        "phone": {
                          "type": "string"
                        },
                        "reason": {
                          "type": [
                            "string",
                            "null"
                          ]
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid format or type.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing, malformed or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Company inactive or plan without API access.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Incompatible state or duplicate.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Valid but unacceptable value.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/bans/{id}": {
      "delete": {
        "operationId": "deleteBan",
        "tags": [
          "Configuration"
        ],
        "summary": "Unblock a number",
        "description": "Unblock a number",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 4294967295
            },
            "description": "Ban id."
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Deleted"
                }
              }
            }
          },
          "401": {
            "description": "Missing, malformed or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Company inactive or plan without API access.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found (or belongs to another company).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/business-hours": {
      "get": {
        "operationId": "getBusinessHours",
        "tags": [
          "Configuration"
        ],
        "summary": "Get business hours",
        "description": "Get business hours",
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/BusinessHours"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, malformed or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Company inactive or plan without API access.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "put": {
        "operationId": "putBusinessHours",
        "tags": [
          "Configuration"
        ],
        "summary": "Replace business hours",
        "description": "Send the 7 days; optional enabled, out_of_hours_message and timezone are updated when present.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BusinessHoursUpdate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "updated": {
                          "type": "boolean",
                          "const": true
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid format or type.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing, malformed or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Company inactive or plan without API access.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Valid but unacceptable value.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/holidays": {
      "get": {
        "operationId": "listHolidays",
        "tags": [
          "Configuration"
        ],
        "summary": "List holidays",
        "description": "List holidays",
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Holiday"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, malformed or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Company inactive or plan without API access.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createHoliday",
        "tags": [
          "Configuration"
        ],
        "summary": "Create a holiday",
        "description": "Create a holiday",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/HolidayCreate"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Holiday"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid format or type.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing, malformed or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Company inactive or plan without API access.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Incompatible state or duplicate.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/holidays/{id}": {
      "delete": {
        "operationId": "deleteHoliday",
        "tags": [
          "Configuration"
        ],
        "summary": "Delete a holiday",
        "description": "Delete a holiday",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 4294967295
            },
            "description": "Holiday id."
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Deleted"
                }
              }
            }
          },
          "401": {
            "description": "Missing, malformed or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Company inactive or plan without API access.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found (or belongs to another company).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/knowledge/sources": {
      "get": {
        "operationId": "listKnowledgeSources",
        "tags": [
          "Knowledge and AI"
        ],
        "summary": "List knowledge sources",
        "description": "List knowledge sources",
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/KnowledgeSource"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, malformed or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Company inactive or plan without API access.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "upsertKnowledgeSource",
        "tags": [
          "Knowledge and AI"
        ],
        "summary": "Create or replace a knowledge source",
        "description": "A source with the same name is replaced. Re-indexing runs later in the background (at most once every 10 minutes). Total company knowledge is capped at 100000 characters (422).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/KnowledgeSourceCreate"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "201 when the content changed, 200 when it was identical.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/KnowledgeSourceSaved"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid format or type.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing, malformed or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Company inactive or plan without API access.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Valid but unacceptable value.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/knowledge/sources/{id}": {
      "get": {
        "operationId": "getKnowledgeSource",
        "tags": [
          "Knowledge and AI"
        ],
        "summary": "Get a knowledge source with its content",
        "description": "Get a knowledge source with its content",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 4294967295
            },
            "description": "Source id."
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/KnowledgeSourceFull"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, malformed or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Company inactive or plan without API access.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found (or belongs to another company).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteKnowledgeSource",
        "tags": [
          "Knowledge and AI"
        ],
        "summary": "Delete a knowledge source",
        "description": "Delete a knowledge source",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 4294967295
            },
            "description": "Source id."
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Deleted"
                }
              }
            }
          },
          "401": {
            "description": "Missing, malformed or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Company inactive or plan without API access.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found (or belongs to another company).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/ai": {
      "get": {
        "operationId": "getAi",
        "tags": [
          "Knowledge and AI"
        ],
        "summary": "Get AI settings",
        "description": "Get AI settings",
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/AiConfig"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, malformed or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Company inactive or plan without API access.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "updateAi",
        "tags": [
          "Knowledge and AI"
        ],
        "summary": "Update AI settings",
        "description": "Turning the AI on is done with ai_mode; `ai_enabled: true` is rejected (422). 403 when the plan has no platform AI and no own key is configured, or AI is disabled for the company.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AiConfigUpdate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/AiConfig"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid format or type.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing, malformed or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Company inactive or plan without API access.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Valid but unacceptable value.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/ai/accounts": {
      "get": {
        "operationId": "listAiAccounts",
        "tags": [
          "Knowledge and AI"
        ],
        "summary": "List accounts with their AI switch",
        "description": "List accounts with their AI switch",
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Account"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, malformed or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Company inactive or plan without API access.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/ai/accounts/{kind}/{id}": {
      "patch": {
        "operationId": "updateAiAccount",
        "tags": [
          "Knowledge and AI"
        ],
        "summary": "Turn the AI on or off for one account",
        "description": "Turn the AI on or off for one account",
        "parameters": [
          {
            "name": "kind",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "line",
                "channel"
              ]
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 4294967295
            },
            "description": "Line or channel id."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AiAccountUpdate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "kind": {
                          "type": "string"
                        },
                        "id": {
                          "type": "integer"
                        },
                        "ai_enabled": {
                          "type": "boolean"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid format or type.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing, malformed or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Company inactive or plan without API access.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found (or belongs to another company).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/agenda/slots": {
      "get": {
        "operationId": "findSlots",
        "tags": [
          "Agenda"
        ],
        "summary": "Find available slots",
        "description": "Unknown query parameters are rejected (400). Returns 403 if the Agenda module is not enabled for the company.",
        "parameters": [
          {
            "name": "service_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 4294967295
            }
          },
          {
            "name": "professional_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 4294967295
            }
          },
          {
            "name": "location_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 4294967295
            }
          },
          {
            "name": "prefer_professional_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 4294967295
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date"
            },
            "description": "YYYY-MM-DD. Required when `to` is sent."
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date"
            },
            "description": "YYYY-MM-DD, inclusive; not before `from`."
          },
          {
            "name": "mode",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "next",
                "date",
                "professional"
              ],
              "default": "next"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 5,
              "default": 5
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgendaSlotList"
                }
              }
            }
          },
          "400": {
            "description": "Invalid format or type.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing, malformed or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Company inactive or plan without API access.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/agenda/appointments": {
      "post": {
        "operationId": "createAppointment",
        "tags": [
          "Agenda"
        ],
        "summary": "Book an appointment",
        "description": "Use a slot returned by GET /agenda/slots. 409 if the slot is no longer available. Returns 403 if the Agenda module is not enabled for the company.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AppointmentCreate"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Appointment"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid format or type.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing, malformed or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Company inactive or plan without API access.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found (or belongs to another company).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Incompatible state or duplicate.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/agenda/appointments/{id}": {
      "get": {
        "operationId": "getAppointment",
        "tags": [
          "Agenda"
        ],
        "summary": "Get an appointment",
        "description": "Returns 403 if the Agenda module is not enabled for the company.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 4294967295
            },
            "description": "Appointment id."
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Appointment"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid format or type.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing, malformed or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Company inactive or plan without API access.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found (or belongs to another company).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "updateAppointment",
        "tags": [
          "Agenda"
        ],
        "summary": "Confirm, cancel, mark attendance or reschedule an appointment",
        "description": "Send exactly one of `status` or `slot`. Returns 403 if the Agenda module is not enabled for the company.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 4294967295
            },
            "description": "Appointment id."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AppointmentUpdate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Appointment"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid format or type.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing, malformed or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Company inactive or plan without API access.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found (or belongs to another company).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Incompatible state or duplicate.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/agenda/clients": {
      "get": {
        "operationId": "listAgendaClients",
        "tags": [
          "Agenda"
        ],
        "summary": "List agenda clients",
        "description": "Unknown query parameters are rejected (400). Returns 403 if the Agenda module is not enabled for the company.",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 2,
              "maxLength": 100
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/AgendaClient"
                      }
                    },
                    "limit": {
                      "type": "integer"
                    },
                    "offset": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid format or type.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing, malformed or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Company inactive or plan without API access.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createAgendaClient",
        "tags": [
          "Agenda"
        ],
        "summary": "Create an agenda client",
        "description": "Returns 403 if the Agenda module is not enabled for the company.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AgendaClientCreate"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/AgendaClient"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid format or type.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing, malformed or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Company inactive or plan without API access.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Incompatible state or duplicate.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "chk_<48 hex>"
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string",
            "description": "Human-readable message (the message text is in Spanish)."
          }
        }
      },
      "Channel": {
        "type": "string",
        "enum": [
          "whatsapp",
          "instagram",
          "facebook",
          "webchat",
          "telegram",
          "email",
          "phone",
          "mercadolibre"
        ]
      },
      "ConversationStatus": {
        "type": "string",
        "enum": [
          "new",
          "open",
          "pending",
          "closed"
        ]
      },
      "ConversationSummary": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "channel": {
            "$ref": "#/components/schemas/Channel"
          },
          "status": {
            "$ref": "#/components/schemas/ConversationStatus"
          },
          "contact_phone": {
            "type": [
              "string",
              "null"
            ]
          },
          "contact_name": {
            "type": [
              "string",
              "null"
            ]
          },
          "assigned_user_id": {
            "type": [
              "integer",
              "null"
            ]
          },
          "opened_at": {
            "type": "string",
            "format": "date-time"
          },
          "last_message_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        }
      },
      "ConversationDetail": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "channel": {
            "$ref": "#/components/schemas/Channel"
          },
          "status": {
            "$ref": "#/components/schemas/ConversationStatus"
          },
          "contact_phone": {
            "type": [
              "string",
              "null"
            ]
          },
          "contact_name": {
            "type": [
              "string",
              "null"
            ]
          },
          "assigned_user_id": {
            "type": [
              "integer",
              "null"
            ]
          },
          "opened_at": {
            "type": "string",
            "format": "date-time"
          },
          "closed_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "last_message_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "contact_lang": {
            "type": [
              "string",
              "null"
            ],
            "description": "Last language detected for the customer (automatic translation)."
          }
        }
      },
      "Message": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "direction": {
            "type": "string",
            "enum": [
              "in",
              "out"
            ]
          },
          "text": {
            "type": [
              "string",
              "null"
            ]
          },
          "type": {
            "type": "string",
            "description": "Message type (e.g. text, image, audio, video, file, note)."
          },
          "media_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "Absolute URL of the attachment, if any."
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "original_text": {
            "type": [
              "string",
              "null"
            ],
            "description": "Original text when automatic translation was applied."
          },
          "translated_lang": {
            "type": [
              "string",
              "null"
            ]
          },
          "sender": {
            "type": [
              "string",
              "null"
            ],
            "description": "Name of the agent who sent it (null for customer, AI or API)."
          }
        }
      },
      "ConversationList": {
        "type": "object",
        "required": [
          "data",
          "limit",
          "offset"
        ],
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ConversationSummary"
            }
          },
          "limit": {
            "type": "integer"
          },
          "offset": {
            "type": "integer"
          }
        }
      },
      "ConversationWithMessages": {
        "type": "object",
        "required": [
          "conversation",
          "messages"
        ],
        "properties": {
          "conversation": {
            "$ref": "#/components/schemas/ConversationDetail"
          },
          "messages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Message"
            },
            "description": "Last `limit` messages, oldest first."
          }
        }
      },
      "SendTextRequest": {
        "type": "object",
        "required": [
          "text"
        ],
        "properties": {
          "text": {
            "type": "string",
            "minLength": 1,
            "maxLength": 4000,
            "description": "Trimmed; must not be empty."
          }
        }
      },
      "SendTextResponse": {
        "type": "object",
        "properties": {
          "ok": {
            "type": "boolean",
            "const": true
          },
          "message": {
            "type": "object",
            "properties": {
              "id": {
                "type": "integer"
              },
              "conversation_id": {
                "type": "integer"
              },
              "direction": {
                "type": "string",
                "const": "out"
              },
              "text": {
                "type": "string"
              },
              "ack": {
                "type": "string",
                "description": "Delivery state (e.g. sent, delivered)."
              },
              "created_at": {}
            }
          }
        }
      },
      "DeliveryFailed": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string"
          },
          "message_id": {
            "type": "integer"
          },
          "ack": {
            "type": "string",
            "const": "failed"
          }
        }
      },
      "OkResponse": {
        "type": "object",
        "properties": {
          "ok": {
            "type": "boolean",
            "const": true
          }
        }
      },
      "IdStatus": {
        "type": "object",
        "properties": {
          "data": {
            "type": "object",
            "properties": {
              "id": {
                "type": "integer"
              },
              "status": {
                "type": "string"
              },
              "assigned_user_id": {
                "type": [
                  "integer",
                  "null"
                ]
              }
            }
          }
        }
      },
      "AssignRequest": {
        "type": "object",
        "required": [
          "user_id"
        ],
        "properties": {
          "user_id": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 1,
            "maximum": 4294967295,
            "description": "User id, or null to return the conversation to the queue. The user must be active and belong to the company."
          }
        }
      },
      "NoteRequest": {
        "type": "object",
        "required": [
          "text"
        ],
        "properties": {
          "text": {
            "type": "string",
            "maxLength": 4000
          }
        }
      },
      "NoteResponse": {
        "type": "object",
        "properties": {
          "data": {
            "type": "object",
            "properties": {
              "id": {
                "type": "integer"
              },
              "conversation_id": {
                "type": "integer"
              },
              "text": {
                "type": "string"
              },
              "created_at": {}
            }
          }
        }
      },
      "MediaRequest": {
        "type": "object",
        "required": [
          "url",
          "type"
        ],
        "properties": {
          "url": {
            "type": "string",
            "maxLength": 500,
            "description": "https URL that the API downloads (max 16 MB, redirects not followed, private addresses rejected)."
          },
          "type": {
            "type": "string",
            "enum": [
              "image",
              "audio",
              "video",
              "file"
            ]
          },
          "caption": {
            "type": "string",
            "maxLength": 1000
          }
        }
      },
      "MediaResponse": {
        "type": "object",
        "properties": {
          "data": {
            "type": "object",
            "properties": {
              "id": {
                "type": "integer"
              },
              "conversation_id": {
                "type": "integer"
              },
              "direction": {
                "type": "string",
                "const": "out"
              },
              "type": {
                "type": "string"
              },
              "text": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "media_url": {
                "type": "string"
              },
              "ack": {
                "type": "string"
              },
              "created_at": {}
            }
          }
        }
      },
      "User": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "role": {
            "type": "string",
            "enum": [
              "agent",
              "supervisor",
              "admin"
            ]
          },
          "active": {
            "type": "boolean"
          },
          "online": {
            "type": "boolean"
          },
          "email": {
            "type": [
              "string",
              "null"
            ],
            "description": "Omitted for admins."
          },
          "last_login": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "Account": {
        "type": "object",
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "line",
              "channel"
            ]
          },
          "id": {
            "type": "integer"
          },
          "type": {
            "type": "string",
            "description": "whatsapp for lines; channel type otherwise."
          },
          "label": {
            "type": "string"
          },
          "detail": {
            "type": [
              "string",
              "null"
            ],
            "description": "Phone number (lines) or site URL (webchat)."
          },
          "status": {
            "type": "string"
          },
          "ai_enabled": {
            "type": "boolean"
          }
        }
      },
      "Stats": {
        "type": "object",
        "properties": {
          "from": {
            "type": "string",
            "format": "date"
          },
          "to": {
            "type": "string",
            "format": "date"
          },
          "conversations": {
            "type": "object",
            "properties": {
              "opened": {
                "type": "integer"
              },
              "closed": {
                "type": "integer"
              },
              "by_channel": {
                "type": "object",
                "additionalProperties": {
                  "type": "object",
                  "properties": {
                    "opened": {
                      "type": "integer"
                    },
                    "closed": {
                      "type": "integer"
                    }
                  }
                },
                "description": "Keyed by channel."
              }
            }
          },
          "current_by_status": {
            "type": "object",
            "properties": {
              "new": {
                "type": "integer"
              },
              "open": {
                "type": "integer"
              },
              "pending": {
                "type": "integer"
              },
              "closed": {
                "type": "integer"
              }
            }
          },
          "messages": {
            "type": "object",
            "properties": {
              "in": {
                "type": "integer"
              },
              "out": {
                "type": "integer"
              }
            }
          },
          "ai": {
            "type": "object",
            "properties": {
              "responses_used": {
                "type": "integer"
              },
              "responses_limit": {
                "type": [
                  "integer",
                  "null"
                ]
              }
            }
          }
        }
      },
      "Survey": {
        "type": "object",
        "properties": {
          "conversation_id": {
            "type": "integer"
          },
          "channel": {
            "$ref": "#/components/schemas/Channel"
          },
          "contact_name": {
            "type": [
              "string",
              "null"
            ]
          },
          "assigned_user_id": {
            "type": [
              "integer",
              "null"
            ]
          },
          "rating": {
            "type": "integer",
            "minimum": 1,
            "maximum": 5
          },
          "comment": {
            "type": [
              "string",
              "null"
            ]
          },
          "answered_at": {}
        }
      },
      "TicketStatus": {
        "type": "string",
        "enum": [
          "open",
          "in_progress",
          "closed"
        ]
      },
      "TicketPriority": {
        "type": "string",
        "enum": [
          "low",
          "normal",
          "high",
          "urgent"
        ]
      },
      "Ticket": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "subject": {
            "type": "string"
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "$ref": "#/components/schemas/TicketStatus"
          },
          "priority": {
            "$ref": "#/components/schemas/TicketPriority"
          },
          "conversation_id": {
            "type": [
              "integer",
              "null"
            ]
          },
          "contact_name": {
            "type": [
              "string",
              "null"
            ]
          },
          "contact_phone": {
            "type": [
              "string",
              "null"
            ]
          },
          "assigned_user_id": {
            "type": [
              "integer",
              "null"
            ]
          },
          "created_at": {},
          "updated_at": {},
          "closed_at": {},
          "comment_count": {
            "type": "integer",
            "description": "Only present in list responses."
          }
        }
      },
      "TicketComment": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "text": {
            "type": "string"
          },
          "internal": {
            "type": "boolean"
          },
          "author": {
            "type": "string",
            "description": "\"API\" when created through the API."
          },
          "created_at": {}
        }
      },
      "TicketDetail": {
        "allOf": [
          {
            "$ref": "#/components/schemas/Ticket"
          },
          {
            "type": "object",
            "properties": {
              "comments": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/TicketComment"
                }
              }
            }
          }
        ]
      },
      "TicketCreate": {
        "type": "object",
        "required": [
          "subject"
        ],
        "properties": {
          "subject": {
            "type": "string",
            "maxLength": 300
          },
          "description": {
            "type": "string",
            "maxLength": 10000
          },
          "priority": {
            "$ref": "#/components/schemas/TicketPriority",
            "description": "Default normal."
          },
          "contact_name": {
            "type": "string",
            "maxLength": 150
          },
          "contact_phone": {
            "type": "string",
            "maxLength": 100
          },
          "comment": {
            "type": "string",
            "maxLength": 4000,
            "description": "Initial comment."
          },
          "conversation_id": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 1,
            "maximum": 4294967295,
            "description": "Links the ticket to a conversation (leaves an internal note there)."
          },
          "assigned_user_id": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 1,
            "maximum": 4294967295
          }
        }
      },
      "TicketUpdate": {
        "type": "object",
        "minProperties": 1,
        "properties": {
          "status": {
            "$ref": "#/components/schemas/TicketStatus"
          },
          "priority": {
            "$ref": "#/components/schemas/TicketPriority"
          },
          "subject": {
            "type": "string",
            "minLength": 1,
            "maxLength": 300
          },
          "description": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 10000
          },
          "assigned_user_id": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 1,
            "maximum": 4294967295
          }
        }
      },
      "TicketCommentCreate": {
        "type": "object",
        "required": [
          "text"
        ],
        "properties": {
          "text": {
            "type": "string",
            "maxLength": 4000
          },
          "is_internal": {
            "type": "boolean",
            "description": "Default false."
          }
        }
      },
      "QuickReply": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "label": {
            "type": "string"
          },
          "text": {
            "type": "string"
          },
          "sort_order": {
            "type": "integer"
          }
        }
      },
      "QuickReplyCreate": {
        "type": "object",
        "required": [
          "label",
          "text"
        ],
        "properties": {
          "label": {
            "type": "string",
            "maxLength": 40
          },
          "text": {
            "type": "string",
            "maxLength": 4000
          },
          "sort_order": {
            "type": "integer",
            "minimum": 0,
            "maximum": 100000
          }
        }
      },
      "QuickReplyUpdate": {
        "type": "object",
        "minProperties": 1,
        "properties": {
          "label": {
            "type": "string",
            "minLength": 1,
            "maxLength": 40
          },
          "text": {
            "type": "string",
            "minLength": 1,
            "maxLength": 4000
          },
          "sort_order": {
            "type": "integer",
            "minimum": 0,
            "maximum": 100000
          }
        }
      },
      "Ban": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "phone": {
            "type": "string"
          },
          "reason": {
            "type": [
              "string",
              "null"
            ]
          },
          "created_at": {}
        }
      },
      "BanCreate": {
        "type": "object",
        "required": [
          "phone",
          "confirm"
        ],
        "properties": {
          "phone": {
            "type": "string",
            "maxLength": 50,
            "description": "Non-digits are stripped; the result must have 4 to 20 digits."
          },
          "reason": {
            "type": "string",
            "maxLength": 255
          },
          "confirm": {
            "type": "string",
            "const": "BLOQUEAR"
          }
        }
      },
      "BusinessDay": {
        "type": "object",
        "required": [
          "day_of_week",
          "is_open"
        ],
        "properties": {
          "day_of_week": {
            "type": "integer",
            "minimum": 0,
            "maximum": 6
          },
          "is_open": {
            "type": "boolean"
          },
          "open_time": {
            "type": [
              "string",
              "null"
            ],
            "description": "HH:MM or HH:MM:SS. Required when is_open is true; must be earlier than close_time."
          },
          "close_time": {
            "type": [
              "string",
              "null"
            ],
            "description": "HH:MM or HH:MM:SS. Required when is_open is true."
          }
        }
      },
      "BusinessHours": {
        "type": "object",
        "properties": {
          "enabled": {
            "type": "boolean"
          },
          "timezone": {
            "type": "string"
          },
          "out_of_hours_message": {
            "type": [
              "string",
              "null"
            ]
          },
          "hours": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BusinessDay"
            }
          }
        }
      },
      "BusinessHoursUpdate": {
        "type": "object",
        "required": [
          "hours"
        ],
        "properties": {
          "hours": {
            "type": "array",
            "minItems": 7,
            "maxItems": 7,
            "items": {
              "$ref": "#/components/schemas/BusinessDay"
            },
            "description": "Exactly 7 entries, one per day_of_week 0-6, no repeats."
          },
          "enabled": {
            "type": "boolean"
          },
          "out_of_hours_message": {
            "type": "string",
            "maxLength": 1000
          },
          "timezone": {
            "type": "string",
            "maxLength": 64,
            "description": "IANA time zone, e.g. America/Argentina/Buenos_Aires."
          }
        }
      },
      "Holiday": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "date": {
            "type": "string",
            "format": "date"
          },
          "name": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "HolidayCreate": {
        "type": "object",
        "required": [
          "date"
        ],
        "properties": {
          "date": {
            "type": "string",
            "format": "date",
            "description": "YYYY-MM-DD."
          },
          "name": {
            "type": "string",
            "maxLength": 100
          }
        }
      },
      "KnowledgeSource": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "type": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "chars": {
            "type": "integer"
          },
          "created_at": {},
          "updated_at": {}
        }
      },
      "KnowledgeSourceFull": {
        "allOf": [
          {
            "$ref": "#/components/schemas/KnowledgeSource"
          },
          {
            "type": "object",
            "properties": {
              "content": {
                "type": "string"
              }
            }
          }
        ]
      },
      "KnowledgeSourceCreate": {
        "type": "object",
        "required": [
          "name",
          "content"
        ],
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 300
          },
          "content": {
            "type": "string",
            "maxLength": 100000,
            "description": "The whole knowledge base of the company cannot exceed 100000 characters."
          }
        }
      },
      "KnowledgeSourceSaved": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "chars": {
            "type": "integer"
          },
          "changed": {
            "type": "boolean"
          },
          "distill": {
            "type": "string",
            "enum": [
              "pending",
              "not_needed"
            ]
          }
        }
      },
      "AiMode": {
        "type": "string",
        "enum": [
          "off",
          "outside_hours",
          "first_line",
          "no_agents"
        ]
      },
      "AiConfig": {
        "type": "object",
        "properties": {
          "ai_enabled": {
            "type": "boolean"
          },
          "ai_mode": {
            "$ref": "#/components/schemas/AiMode"
          },
          "prompt": {
            "type": "string"
          },
          "escalation_keyword": {
            "type": "string"
          },
          "platform_ai": {
            "type": "boolean"
          },
          "has_own_ai_key": {
            "type": "boolean"
          },
          "responses_used": {
            "type": "integer"
          },
          "responses_limit": {
            "type": [
              "integer",
              "null"
            ]
          }
        }
      },
      "AiConfigUpdate": {
        "type": "object",
        "minProperties": 1,
        "properties": {
          "ai_mode": {
            "$ref": "#/components/schemas/AiMode"
          },
          "prompt": {
            "type": "string",
            "maxLength": 20000
          },
          "escalation_keyword": {
            "type": "string",
            "maxLength": 50
          },
          "ai_enabled": {
            "type": "boolean",
            "const": false,
            "description": "Only false is accepted (shortcut for ai_mode \"off\"); true returns 422."
          }
        }
      },
      "AiAccountUpdate": {
        "type": "object",
        "required": [
          "ai_enabled"
        ],
        "properties": {
          "ai_enabled": {
            "type": "boolean"
          }
        }
      },
      "Deleted": {
        "type": "object",
        "properties": {
          "data": {
            "type": "object",
            "properties": {
              "id": {
                "type": "integer"
              },
              "deleted": {
                "type": "boolean",
                "const": true
              },
              "distill": {
                "type": "string",
                "description": "Only for knowledge sources."
              }
            }
          }
        }
      },
      "AgendaSlot": {
        "type": "object",
        "required": [
          "professional_id",
          "location_id",
          "start_at",
          "end_at"
        ],
        "properties": {
          "professional_id": {
            "type": "integer",
            "minimum": 1,
            "maximum": 4294967295
          },
          "service_id": {
            "type": "integer",
            "minimum": 1,
            "maximum": 4294967295,
            "description": "Optional; if present it must equal the request service_id."
          },
          "location_id": {
            "type": "integer",
            "minimum": 1,
            "maximum": 4294967295
          },
          "resource_id": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 1,
            "maximum": 4294967295
          },
          "start_at": {
            "type": "string",
            "format": "date-time",
            "description": "ISO 8601 with time zone offset or Z."
          },
          "end_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "additionalProperties": false,
        "description": "A slot exactly as returned by GET /agenda/slots."
      },
      "AppointmentCreate": {
        "type": "object",
        "required": [
          "client_id",
          "service_id",
          "slot"
        ],
        "additionalProperties": false,
        "properties": {
          "client_id": {
            "type": "integer",
            "minimum": 1,
            "maximum": 4294967295
          },
          "service_id": {
            "type": "integer",
            "minimum": 1,
            "maximum": 4294967295
          },
          "slot": {
            "$ref": "#/components/schemas/AgendaSlot"
          }
        }
      },
      "AppointmentUpdate": {
        "type": "object",
        "additionalProperties": false,
        "description": "Send exactly one of status or slot. service_id is only accepted with slot and must match the appointment; cancelled_reason only with status \"cancelled\".",
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "confirmed",
              "cancelled",
              "attended",
              "no_show"
            ]
          },
          "slot": {
            "$ref": "#/components/schemas/AgendaSlot"
          },
          "service_id": {
            "type": "integer",
            "minimum": 1,
            "maximum": 4294967295
          },
          "cancelled_reason": {
            "type": "string",
            "maxLength": 255
          }
        }
      },
      "Appointment": {
        "type": "object",
        "additionalProperties": true,
        "description": "Appointment object produced by the Agenda module. Its exact fields are not fixed by the route code; it includes at least service_id and status."
      },
      "AgendaClient": {
        "type": "object",
        "additionalProperties": true,
        "description": "Client record produced by the Agenda module. Exact fields are not fixed by the route code."
      },
      "AgendaSlotList": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true,
              "description": "Slot object produced by the Agenda module (same shape accepted in `slot` when booking)."
            }
          }
        }
      },
      "AgendaClientCreate": {
        "type": "object",
        "required": [
          "first_name",
          "last_name",
          "doc_number"
        ],
        "additionalProperties": false,
        "properties": {
          "first_name": {
            "type": "string",
            "maxLength": 100
          },
          "last_name": {
            "type": "string",
            "maxLength": 100
          },
          "doc_type": {
            "type": "string",
            "enum": [
              "DNI",
              "CUIT",
              "PASSPORT",
              "OTHER"
            ],
            "default": "DNI"
          },
          "doc_number": {
            "type": "string",
            "maxLength": 40
          },
          "phone": {
            "type": "string",
            "maxLength": 20,
            "pattern": "^\\+[1-9]\\d{7,14}$",
            "description": "E.164."
          },
          "email": {
            "type": "string",
            "maxLength": 254
          },
          "birth_date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date"
          },
          "insurance": {
            "type": "string",
            "maxLength": 160
          },
          "insurance_number": {
            "type": "string",
            "maxLength": 100
          },
          "notes": {
            "type": "string",
            "maxLength": 2000
          }
        }
      }
    }
  }
}
