{
  "openapi": "3.0.3",
  "info": {
    "title": "Biky Smart Chat API",
    "version": "1.0.0",
    "description": "Smart Chat is Biky's omnichannel inbox: conversations with your contacts on WhatsApp, Instagram, Facebook Messenger and other channels, attended by your agents and by the AI agent. Use this API to send messages and WhatsApp templates, find, transfer and close conversations, and receive message events on your own webhooks. Every call is checked against the account it acts on: the `appUUID` you send or, when you only send a conversation id, the account of that conversation. If your credential doesn't belong to that account, the answer is `403`. A conversation or message that doesn't exist, or that isn't in the `appUUID` you send, is not a `403`: each operation says what it answers then."
  },
  "servers": [
    {
      "url": "https://chat.keybeapi.com",
      "description": "Production"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "tags": [
    {
      "name": "Messages",
      "description": "Send messages as an agent and read the messages of a conversation."
    },
    {
      "name": "Templates",
      "description": "WhatsApp templates: the way to start a conversation or to write after the 24-hour window."
    },
    {
      "name": "Conversations",
      "description": "Find, list, transfer and close conversations (rooms) with your contacts."
    },
    {
      "name": "Webhooks",
      "description": "Receive Smart Chat message events in your own system. Register up to 10 URLs per app; Biky sends a `POST` to each one with every message that matches its filters.\n\n**Events** (`type` field of the payload)\n\n| Event | When | Enabled by |\n|---|---|---|\n| `newMessage` | A message is created in a conversation: written by the contact, an agent, the AI agent, a bot or an integration (templates included). | `newMessages` |\n| `updateMessage` | A message changes: delivery status (`sent`, `user` = delivered, `read`, `failed` with `error`), reactions, audio transcription… The previous version comes in `oldMessage`. | `updateMessages` |\n\n`senders` filters both events by `message.sender` (`user`, `advisor`, `bot`, `api`, `internal`); by default only the contact's messages (`user`) are sent. Internal `status` messages (assignments, transfers, closures) are never sent.\n\n**Payload** (`WebhookEvent`): `{ type, message, oldMessage?, room }`. `message` is a `Message` and `room` is the `Conversation` as it is when the event is delivered.\n\n**Request**: `POST` with `Content-Type: application/json`. If the webhook has a `token`, it comes in the `Authorization` header as `<authorizationType> <token>` (for example `Bearer whsec_…`), or the bare token when `authorizationType` is empty. Requests are not signed: use HTTPS, configure a `token` and check it; if you need certainty, read the message again with `GET /message`.\n\n**Delivery and retries**: answer any `2xx` within 10 seconds. If your endpoint doesn't answer in time, can't be reached, or answers `5xx` or `429`, Biky retries 30 to 60 seconds later, up to 3 attempts in total; after that the event is dropped. Other `4xx` answers are final. Delivery is at least once and not ordered: deduplicate with `type` + `message._id` + `message.updatedAt`. Each webhook is retried on its own.\n\nThe payload schema and two full examples are in the callback of `POST /v1/webhook`."
    },
    {
      "name": "Agents",
      "description": "People of your team, and the AI agent, who attend conversations."
    },
    {
      "name": "Channels",
      "description": "WhatsApp lines, Instagram account and Facebook page connected to your app."
    },
    {
      "name": "Spaces",
      "description": "Spaces (inboxes) that split conversations by line, page, team or topic."
    },
    {
      "name": "Groups",
      "description": "Labels to organize the spaces of your app; a space references its groups by `key`."
    }
  ],
  "paths": {
    "/message/adviser": {
      "post": {
        "tags": [
          "Messages"
        ],
        "operationId": "sendAgentMessage",
        "summary": "Send a message as an agent",
        "description": "Queues a message from agent `advisorId` in an existing conversation; it goes out through the conversation's channel (WhatsApp, Instagram, Messenger, SMS…). The answer is the queued message itself, without the `status`/`data` envelope: keep its `_id` to follow the delivery with `GET /message` or the `updateMessage` webhook event. Delivery is asynchronous: if the conversation is closed (`ROOM_ENDED`), belongs to another agent or WhatsApp's 24-hour window is closed, the message ends with `deliveryStatus: failed` and the reason in `error` (check `mustSendTemplate` in `GET /room/message` and send a template instead). The conversation must be in the account `appUUID`: if it doesn't exist or is in another account, it answers `404`; if it is there but your credential doesn't belong to that account, it answers `403`.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AgentMessageRequest"
              },
              "examples": {
                "text": {
                  "summary": "Text",
                  "value": {
                    "roomId": "665f1c2e8a4b3d0012ab34cd",
                    "appUUID": "app_7f3k2m9x1q",
                    "companyUUID": "cmp_4n8b2v6c1z",
                    "advisorId": "usr_3k9m2x7q",
                    "type": "text",
                    "text": "¡Hola Laura! Con gusto te ayudo. El plan anual cuesta $1.200.000.",
                    "origin": {
                      "event": "client-api",
                      "eventId": "erp-7781"
                    }
                  }
                },
                "image": {
                  "summary": "Image with caption",
                  "value": {
                    "roomId": "665f1c2e8a4b3d0012ab34cd",
                    "appUUID": "app_7f3k2m9x1q",
                    "companyUUID": "cmp_4n8b2v6c1z",
                    "advisorId": "usr_3k9m2x7q",
                    "type": "image",
                    "media": "https://cdn.example.com/planes/plan-anual.jpg",
                    "text": "Este es el detalle del plan"
                  }
                },
                "reply": {
                  "summary": "Reply to a message",
                  "value": {
                    "roomId": "665f1c2e8a4b3d0012ab34cd",
                    "appUUID": "app_7f3k2m9x1q",
                    "advisorId": "usr_3k9m2x7q",
                    "type": "text",
                    "text": "Sí, incluye soporte 24/7.",
                    "quotedMessageChannelId": "wamid.FAKE0000000000000001"
                  }
                },
                "location": {
                  "summary": "Location",
                  "value": {
                    "roomId": "665f1c2e8a4b3d0012ab34cd",
                    "appUUID": "app_7f3k2m9x1q",
                    "advisorId": "usr_3k9m2x7q",
                    "type": "location",
                    "typeOptions": {
                      "latitude": "4.6533",
                      "longitude": "-74.0836",
                      "locationName": "Tienda Ejemplo",
                      "address": "Calle 93 # 11-20, Bogotá"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Message queued (no envelope).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Message"
                },
                "example": {
                  "sender": "advisor",
                  "roomId": "665f1c2e8a4b3d0012ab34cd",
                  "appUUID": "app_7f3k2m9x1q",
                  "companyUUID": "cmp_4n8b2v6c1z",
                  "advisorId": "usr_3k9m2x7q",
                  "type": "text",
                  "text": "¡Hola Laura! Con gusto te ayudo. El plan anual cuesta $1.200.000.",
                  "origin": {
                    "event": "client-api",
                    "eventId": "erp-7781"
                  },
                  "createdAt": "2026-10-14T15:03:40.000Z",
                  "updatedAt": "2026-10-14T15:03:40.000Z",
                  "_id": "665f1c2e8a4b3d0012ab34d2"
                }
              }
            }
          },
          "400": {
            "description": "Invalid sticker (not a 512×512 WebP within WhatsApp's size limits). Nothing is queued.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "message": "El sticker debe medir 512x512 px (mide 300x300)"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/message": {
      "get": {
        "tags": [
          "Messages"
        ],
        "operationId": "getMessage",
        "summary": "Get a message",
        "description": "Returns one message of the account `appUUID`, with its current `deliveryStatus` and, if it failed, the reason in `error`. If your credential doesn't belong to that account, it answers `403`. Missing parameters, an invalid id and a message that doesn't exist or isn't in `appUUID` are all answered with `400` (not `404`).",
        "parameters": [
          {
            "name": "messageId",
            "in": "query",
            "required": true,
            "description": "Message `_id`.",
            "schema": {
              "type": "string"
            },
            "example": "665f1c2e8a4b3d0012ab34d2"
          },
          {
            "$ref": "#/components/parameters/AppUUID"
          }
        ],
        "responses": {
          "200": {
            "description": "The message.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Envelope"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/Message"
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "status": "SUCCESS",
                  "message": "",
                  "data": {
                    "_id": "665f1c2e8a4b3d0012ab34d2",
                    "appUUID": "app_7f3k2m9x1q",
                    "companyUUID": "cmp_4n8b2v6c1z",
                    "roomId": "665f1c2e8a4b3d0012ab34cd",
                    "sessionId": "ses_9x8c7v6b5n",
                    "channel": "keybe_wp",
                    "channelId": "wamid.FAKE0000000000000002",
                    "type": "text",
                    "text": "¡Hola Laura! Con gusto te ayudo. El plan anual cuesta $1.200.000.",
                    "sender": "advisor",
                    "advisorId": "usr_3k9m2x7q",
                    "userGuest": "+573001234567",
                    "userHost": "+573005550100",
                    "status": "withAdvisor",
                    "deliveryStatus": "read",
                    "delivery": {
                      "pending": "2026-10-14T15:03:40.000Z",
                      "sending": "2026-10-14T15:03:40.000Z",
                      "sent": "2026-10-14T15:03:40.000Z",
                      "user": "2026-10-14T15:03:40.000Z",
                      "read": "2026-10-14T15:04:05.000Z"
                    },
                    "inbox": "ventas",
                    "crmUserId": "665f1c2e8a4b3d0012ab3901",
                    "origin": {
                      "event": "client-api",
                      "eventId": "erp-7781"
                    },
                    "reactions": [
                      {
                        "reaction": "👍",
                        "users": [
                          "+573001234567"
                        ]
                      }
                    ],
                    "createdAt": "2026-10-14T15:03:40.000Z",
                    "updatedAt": "2026-10-14T15:04:05.000Z"
                  },
                  "statusCode": 200
                }
              }
            }
          },
          "400": {
            "description": "Missing parameters, invalid id, or a message that doesn't exist or isn't in `appUUID`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "status": "ERROR",
                  "message": "Message not found",
                  "statusCode": 400
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        }
      }
    },
    "/room/message": {
      "get": {
        "tags": [
          "Messages"
        ],
        "operationId": "listConversationMessages",
        "summary": "List the messages of a conversation",
        "description": "Returns the messages of a conversation, newest first, including internal `status` messages (assignments, transfers, closures). Paginate with `offset` (messages to skip, 0-based) and `size`. `total` is capped at `offset + size + 1`, so use it only to know whether there is another page. `mustSendTemplate` is `true` when the channel's reply window is closed (24 h on WhatsApp, 7 days on Instagram and Messenger): only a template can be sent then. A conversation that doesn't exist answers `404`; one in an account your credential doesn't belong to, `403`.",
        "parameters": [
          {
            "$ref": "#/components/parameters/RoomId"
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "description": "Messages to skip.",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            },
            "example": 0
          },
          {
            "name": "size",
            "in": "query",
            "required": false,
            "description": "Messages per page.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 15
            },
            "example": 15
          }
        ],
        "responses": {
          "200": {
            "description": "Page of messages.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Envelope"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "type": "object",
                          "properties": {
                            "messages": {
                              "type": "array",
                              "description": "Messages, newest first.",
                              "items": {
                                "$ref": "#/components/schemas/Message"
                              }
                            },
                            "total": {
                              "type": "integer",
                              "description": "Number of messages, capped at `offset + size + 1`."
                            },
                            "mustSendTemplate": {
                              "type": "boolean",
                              "description": "The reply window is closed: send a template."
                            }
                          }
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "status": "SUCCESS",
                  "message": "",
                  "data": {
                    "messages": [
                      {
                        "_id": "665f1c2e8a4b3d0012ab34d4",
                        "appUUID": "app_7f3k2m9x1q",
                        "companyUUID": "cmp_4n8b2v6c1z",
                        "roomId": "665f1c2e8a4b3d0012ab34cd",
                        "sessionId": "ses_9x8c7v6b5n",
                        "channel": "keybe_wp",
                        "type": "status",
                        "text": "Carlos ha transferido a Ana",
                        "sender": "advisor",
                        "advisorId": "usr_3k9m2x7q",
                        "userGuest": "+573001234567",
                        "userHost": "+573005550100",
                        "status": "withAdvisor",
                        "payload": {
                          "statusKeys": "CONVERSATION_TRANSFERRED_TO_ADVISER"
                        },
                        "inbox": "ventas",
                        "createdAt": "2026-10-14T15:04:05.000Z",
                        "updatedAt": "2026-10-14T15:04:05.000Z"
                      },
                      {
                        "_id": "665f1c2e8a4b3d0012ab34d2",
                        "appUUID": "app_7f3k2m9x1q",
                        "companyUUID": "cmp_4n8b2v6c1z",
                        "roomId": "665f1c2e8a4b3d0012ab34cd",
                        "sessionId": "ses_9x8c7v6b5n",
                        "channel": "keybe_wp",
                        "channelId": "wamid.FAKE0000000000000002",
                        "type": "text",
                        "text": "¡Hola Laura! Con gusto te ayudo. El plan anual cuesta $1.200.000.",
                        "sender": "advisor",
                        "advisorId": "usr_3k9m2x7q",
                        "userGuest": "+573001234567",
                        "userHost": "+573005550100",
                        "status": "withAdvisor",
                        "deliveryStatus": "read",
                        "delivery": {
                          "pending": "2026-10-14T15:03:40.000Z",
                          "sending": "2026-10-14T15:03:40.000Z",
                          "sent": "2026-10-14T15:03:40.000Z",
                          "user": "2026-10-14T15:03:40.000Z",
                          "read": "2026-10-14T15:04:05.000Z"
                        },
                        "inbox": "ventas",
                        "crmUserId": "665f1c2e8a4b3d0012ab3901",
                        "origin": {
                          "event": "client-api",
                          "eventId": "erp-7781"
                        },
                        "reactions": [
                          {
                            "reaction": "👍",
                            "users": [
                              "+573001234567"
                            ]
                          }
                        ],
                        "createdAt": "2026-10-14T15:03:40.000Z",
                        "updatedAt": "2026-10-14T15:04:05.000Z"
                      },
                      {
                        "_id": "665f1c2e8a4b3d0012ab34d1",
                        "appUUID": "app_7f3k2m9x1q",
                        "companyUUID": "cmp_4n8b2v6c1z",
                        "roomId": "665f1c2e8a4b3d0012ab34cd",
                        "sessionId": "ses_9x8c7v6b5n",
                        "channel": "keybe_wp",
                        "channelId": "wamid.FAKE0000000000000001",
                        "type": "text",
                        "text": "Hola, quiero información sobre el plan anual",
                        "sender": "user",
                        "userGuest": "+573001234567",
                        "userHost": "+573005550100",
                        "status": "withAdvisor",
                        "deliveryStatus": "read",
                        "inbox": "ventas",
                        "crmUserId": "665f1c2e8a4b3d0012ab3901",
                        "reactions": [],
                        "createdAt": "2026-10-14T15:02:11.000Z",
                        "updatedAt": "2026-10-14T15:02:11.000Z"
                      }
                    ],
                    "total": 3,
                    "mustSendTemplate": false
                  },
                  "statusCode": 200
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "The conversation doesn't exist.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "status": "ERROR",
                  "message": "Room not found",
                  "statusCode": 404
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/template": {
      "get": {
        "tags": [
          "Templates"
        ],
        "operationId": "listTemplates",
        "summary": "List the templates of a WhatsApp line",
        "description": "Returns the approved WhatsApp templates of a line, newest first. If Biky has none stored, or with `forceRefresh=1`, it first synchronizes them with the provider (slower). Always answers HTTP 200: check `status`.",
        "parameters": [
          {
            "$ref": "#/components/parameters/AppUUID"
          },
          {
            "name": "userHost",
            "in": "query",
            "required": true,
            "description": "WhatsApp line, with or without `+` (URL-encode it as `%2B`).",
            "schema": {
              "type": "string"
            },
            "example": "+573005550100"
          },
          {
            "name": "forceRefresh",
            "in": "query",
            "required": false,
            "description": "`1` = synchronize with Meta/Gupshup before answering.",
            "schema": {
              "type": "integer",
              "enum": [
                0,
                1
              ],
              "default": 0
            },
            "example": 0
          },
          {
            "name": "all",
            "in": "query",
            "required": false,
            "description": "`1` = include templates that are pending or rejected.",
            "schema": {
              "type": "integer",
              "enum": [
                0,
                1
              ],
              "default": 0
            },
            "example": 0
          },
          {
            "name": "name",
            "in": "query",
            "required": false,
            "description": "Only templates whose name contains this text (case-insensitive).",
            "schema": {
              "type": "string"
            },
            "example": "recordatorio"
          }
        ],
        "responses": {
          "200": {
            "description": "Templates of the line.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Envelope"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "type": "object",
                          "properties": {
                            "items": {
                              "type": "array",
                              "description": "Templates.",
                              "items": {
                                "$ref": "#/components/schemas/Template"
                              }
                            }
                          }
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "status": "SUCCESS",
                  "message": "",
                  "data": {
                    "items": [
                      {
                        "_id": "665f1c2e8a4b3d0012ab3c01",
                        "appUUID": "app_7f3k2m9x1q",
                        "userHost": "+573005550100",
                        "templateId": "8f14e45f-ceea-4e7a-9c2b-3a1d5e7f9b20",
                        "metaTemplateId": "1234567890123456",
                        "templateName": "recordatorio_pago",
                        "customName": "recordatorio_pago",
                        "templateMessage": "Hola {{1}}, tu pago de {{2}} vence mañana.",
                        "type": "TEXT",
                        "provider": "KB_WHATSAPP",
                        "language": "es",
                        "category": "UTILITY",
                        "status": "APPROVED",
                        "components": "[{\"type\":\"BODY\",\"text\":\"Hola {{1}}, tu pago de {{2}} vence mañana.\"}]",
                        "createdAt": "2026-03-02T16:20:45.000Z",
                        "updatedAt": "2026-10-14T15:02:11.000Z"
                      }
                    ]
                  },
                  "statusCode": 200
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        }
      }
    },
    "/message/proactivity": {
      "post": {
        "tags": [
          "Templates"
        ],
        "operationId": "sendTemplate",
        "summary": "Send a WhatsApp template",
        "description": "Sends an approved template to a contact: the way to start a conversation or to write after WhatsApp's 24-hour window. Biky validates the template and its parameters, finds or creates the conversation (and the contact), and queues the message; delivery is asynchronous, so follow `messageId` with `GET /message` or the `updateMessage` webhook event. The body depends on the template: text and media, dynamic URL button, multi-product or carousel (see the examples). Authentication templates are not retried and need a phone number in `userGuest`; the code goes once in `templateParams` (max. 15 characters).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SendTemplateRequest"
              },
              "examples": {
                "text": {
                  "summary": "Text parameters",
                  "value": {
                    "appUUID": "app_7f3k2m9x1q",
                    "companyUUID": "cmp_4n8b2v6c1z",
                    "userHost": "+573005550100",
                    "userGuest": "+573001234567",
                    "templateId": "8f14e45f-ceea-4e7a-9c2b-3a1d5e7f9b20",
                    "templateParams": [
                      "Laura",
                      "$120.000"
                    ],
                    "advisorId": "usr_3k9m2x7q",
                    "inbox": "ventas",
                    "origin": {
                      "event": "client-api",
                      "eventId": "ord-10293"
                    }
                  }
                },
                "imageHeader": {
                  "summary": "Image header",
                  "value": {
                    "appUUID": "app_7f3k2m9x1q",
                    "companyUUID": "cmp_4n8b2v6c1z",
                    "userHost": "+573005550100",
                    "userGuest": "+573001234567",
                    "templateId": "8f14e45f-ceea-4e7a-9c2b-3a1d5e7f9b20",
                    "templateParams": [
                      "Laura",
                      "$120.000"
                    ],
                    "mediaParams": [
                      "https://cdn.example.com/facturas/factura-10293.jpg"
                    ],
                    "origin": {
                      "event": "client-api",
                      "eventId": "ord-10293"
                    }
                  }
                },
                "buttons": {
                  "summary": "Dynamic URL button",
                  "value": {
                    "appUUID": "app_7f3k2m9x1q",
                    "companyUUID": "cmp_4n8b2v6c1z",
                    "userHost": "+573005550100",
                    "userGuest": "+573001234567",
                    "templateId": "8f14e45f-ceea-4e7a-9c2b-3a1d5e7f9b21",
                    "templateParams": [
                      "Laura"
                    ],
                    "buttonParams": [
                      "inv-48213"
                    ],
                    "advisorId": "usr_3k9m2x7q",
                    "origin": {
                      "event": "client-api",
                      "eventId": "inv-48213"
                    }
                  }
                },
                "multiProduct": {
                  "summary": "Multi-product",
                  "value": {
                    "appUUID": "app_7f3k2m9x1q",
                    "companyUUID": "cmp_4n8b2v6c1z",
                    "userHost": "+573005550100",
                    "userGuest": "+573001234567",
                    "templateId": "8f14e45f-ceea-4e7a-9c2b-3a1d5e7f9b22",
                    "templateParams": [],
                    "advisorId": "usr_3k9m2x7q",
                    "inbox": "ventas",
                    "mpmDetails": {
                      "catalogId": "1029384756102938",
                      "thumbnailProductRetailerId": "sku-tenis-001",
                      "sections": [
                        {
                          "title": "Running",
                          "productItems": [
                            {
                              "productRetailerId": "sku-tenis-001"
                            },
                            {
                              "productRetailerId": "sku-tenis-002"
                            }
                          ]
                        },
                        {
                          "title": "Accesorios",
                          "productItems": [
                            {
                              "productRetailerId": "sku-gorra-010"
                            }
                          ]
                        }
                      ]
                    },
                    "origin": {
                      "event": "client-api"
                    }
                  }
                },
                "carousel": {
                  "summary": "Carousel",
                  "value": {
                    "appUUID": "app_7f3k2m9x1q",
                    "companyUUID": "cmp_4n8b2v6c1z",
                    "userHost": "+573005550100",
                    "userGuest": "+573001234567",
                    "templateId": "8f14e45f-ceea-4e7a-9c2b-3a1d5e7f9b23",
                    "templateParams": [
                      "VERANO25",
                      "20%"
                    ],
                    "cardsParams": [
                      {
                        "headerCardParams": [
                          "https://cdn.example.com/promo/tenis-run-1.jpg"
                        ],
                        "bodyCardParams": [
                          "Tenis Run 1",
                          "$249.900"
                        ],
                        "buttonCardParams": [
                          [],
                          [
                            "sku-tenis-001"
                          ]
                        ]
                      },
                      {
                        "headerCardParams": [
                          "https://cdn.example.com/promo/tenis-trail-2.jpg"
                        ],
                        "bodyCardParams": [
                          "Tenis Trail 2",
                          "$289.900"
                        ],
                        "buttonCardParams": [
                          [],
                          [
                            "sku-tenis-002"
                          ]
                        ]
                      }
                    ],
                    "origin": {
                      "event": "client-api"
                    }
                  }
                },
                "authentication": {
                  "summary": "Verification code",
                  "value": {
                    "appUUID": "app_7f3k2m9x1q",
                    "companyUUID": "cmp_4n8b2v6c1z",
                    "userHost": "+573005550100",
                    "userGuest": "+573001234567",
                    "templateName": "codigo_verificacion",
                    "templateParams": [
                      "482901"
                    ],
                    "origin": {
                      "event": "client-api",
                      "generateIrrelevantResponse": true
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Template queued.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Envelope"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/SendTemplateResult"
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "status": "SUCCESS",
                  "message": "",
                  "data": {
                    "item": {
                      "success": true,
                      "message": "OK",
                      "roomId": "665f1c2e8a4b3d0012ab34cd",
                      "messageId": "665f1c2e8a4b3d0012ab34d3"
                    }
                  },
                  "statusCode": 200
                }
              }
            }
          },
          "400": {
            "description": "`userHost`, `userGuest` or the template (`templateId`/`templateName`) is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "status": "ERROR",
                  "message": "must send required params: appUUID, userHost, userGuest, templateId",
                  "statusCode": 400
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "description": "The template could not be queued; `message` says why: `Template not found`, `invalid template`, `Number of parameters does not match the expected number of params`, `It is necessary to include mediaParams since the template needs images`, `The inbox received does not belong to the brand`, `The user does not have permissions to the space sent in the payload`, `WA_OTP_TOO_LONG`, `WA_OTP_PARAMS_MISMATCH`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "status": "ERROR",
                  "message": "Number of parameters does not match the expected number of params",
                  "statusCode": 500
                }
              }
            }
          }
        }
      }
    },
    "/rooms/byId": {
      "servers": [
        {
          "url": "https://chat-api.keybeapi.com",
          "description": "Production"
        }
      ],
      "get": {
        "tags": [
          "Conversations"
        ],
        "operationId": "getConversation",
        "summary": "Get a conversation",
        "description": "Returns a conversation by its id: contact, channel, line, state, assigned agent, space (`tags[0]`) and last message. `data.room` is `null` if it doesn't exist. If the conversation is in an account your credential doesn't belong to, it answers `403`; otherwise it answers HTTP 200: check `status`.",
        "parameters": [
          {
            "$ref": "#/components/parameters/RoomId"
          }
        ],
        "responses": {
          "200": {
            "description": "The conversation.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Envelope"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "type": "object",
                          "properties": {
                            "room": {
                              "type": "object",
                              "nullable": true,
                              "description": "The conversation, or `null` if not found.",
                              "allOf": [
                                {
                                  "$ref": "#/components/schemas/Conversation"
                                }
                              ]
                            }
                          }
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "status": "SUCCESS",
                  "message": "",
                  "data": {
                    "room": {
                      "_id": "665f1c2e8a4b3d0012ab34cd",
                      "appUUID": "app_7f3k2m9x1q",
                      "companyUUID": "cmp_4n8b2v6c1z",
                      "channel": "keybe_wp",
                      "state": "withAdvisor",
                      "userGuest": "+573001234567",
                      "userHost": "+573005550100",
                      "name": "Laura Gómez",
                      "crmUserId": "665f1c2e8a4b3d0012ab3901",
                      "advisorId": "usr_3k9m2x7q",
                      "adviser": {
                        "userId": "usr_3k9m2x7q",
                        "name": "Carlos",
                        "lastName": "Ruiz",
                        "email": "carlos@example.com",
                        "status": "online",
                        "role": "agent"
                      },
                      "lastAdviserId": "usr_3k9m2x7q",
                      "tags": [
                        "ventas"
                      ],
                      "currentSesionId": "ses_9x8c7v6b5n",
                      "lastSesionId": "ses_1a2s3d4f5g",
                      "lastMessageFrom": "user",
                      "lastMessage": {
                        "_id": "665f1c2e8a4b3d0012ab34d1",
                        "type": "text",
                        "text": "Hola, quiero información sobre el plan anual",
                        "sender": "user",
                        "createdAt": "2026-10-14T15:02:11.000Z"
                      },
                      "user": {
                        "name": "Laura",
                        "lastName": "Gómez",
                        "email": "laura@example.com",
                        "phone": "+573001234567"
                      },
                      "isMassive": false,
                      "createdAt": "2026-03-02T16:20:45.000Z",
                      "updatedAt": "2026-10-14T15:02:11.000Z"
                    }
                  },
                  "statusCode": 200
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        }
      }
    },
    "/rooms/roomByUser": {
      "servers": [
        {
          "url": "https://chat-api.keybeapi.com",
          "description": "Production"
        }
      ],
      "get": {
        "tags": [
          "Conversations"
        ],
        "operationId": "findConversationByContact",
        "summary": "Find the conversation of a contact",
        "description": "Finds the conversation of a contact, either by phone and line (`userGuest` + `userHost`) or by CDP contact id (`crmUserId`). By phone and line it answers 404 when there is none; by `crmUserId` it returns `data.room: null`.",
        "parameters": [
          {
            "$ref": "#/components/parameters/AppUUID"
          },
          {
            "name": "userGuest",
            "in": "query",
            "required": false,
            "description": "Contact's number in E.164 format (with or without `+`; URL-encode `+` as `%2B`). Use it with `userHost`.",
            "schema": {
              "type": "string"
            },
            "example": "+573001234567"
          },
          {
            "name": "userHost",
            "in": "query",
            "required": false,
            "description": "Your line (with or without `+`). Use it with `userGuest`.",
            "schema": {
              "type": "string"
            },
            "example": "+573005550100"
          },
          {
            "name": "crmUserId",
            "in": "query",
            "required": false,
            "description": "Id of the contact in the CDP, as an alternative to `userGuest` + `userHost`.",
            "schema": {
              "type": "string"
            },
            "example": "665f1c2e8a4b3d0012ab3901"
          }
        ],
        "responses": {
          "200": {
            "description": "The conversation.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Envelope"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "type": "object",
                          "properties": {
                            "room": {
                              "type": "object",
                              "nullable": true,
                              "description": "The conversation, or `null` if not found.",
                              "allOf": [
                                {
                                  "$ref": "#/components/schemas/Conversation"
                                }
                              ]
                            }
                          }
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "status": "SUCCESS",
                  "message": "",
                  "data": {
                    "room": {
                      "_id": "665f1c2e8a4b3d0012ab34cd",
                      "appUUID": "app_7f3k2m9x1q",
                      "companyUUID": "cmp_4n8b2v6c1z",
                      "channel": "keybe_wp",
                      "state": "withAdvisor",
                      "userGuest": "+573001234567",
                      "userHost": "+573005550100",
                      "name": "Laura Gómez",
                      "crmUserId": "665f1c2e8a4b3d0012ab3901",
                      "advisorId": "usr_3k9m2x7q",
                      "adviser": {
                        "userId": "usr_3k9m2x7q",
                        "name": "Carlos",
                        "lastName": "Ruiz",
                        "email": "carlos@example.com",
                        "status": "online",
                        "role": "agent"
                      },
                      "lastAdviserId": "usr_3k9m2x7q",
                      "tags": [
                        "ventas"
                      ],
                      "currentSesionId": "ses_9x8c7v6b5n",
                      "lastSesionId": "ses_1a2s3d4f5g",
                      "lastMessageFrom": "user",
                      "lastMessage": {
                        "_id": "665f1c2e8a4b3d0012ab34d1",
                        "type": "text",
                        "text": "Hola, quiero información sobre el plan anual",
                        "sender": "user",
                        "createdAt": "2026-10-14T15:02:11.000Z"
                      },
                      "user": {
                        "name": "Laura",
                        "lastName": "Gómez",
                        "email": "laura@example.com",
                        "phone": "+573001234567"
                      },
                      "isMassive": false,
                      "createdAt": "2026-03-02T16:20:45.000Z",
                      "updatedAt": "2026-10-14T15:02:11.000Z"
                    }
                  },
                  "statusCode": 200
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No conversation with that contact on that line.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "status": "ERROR",
                  "message": "Error getting room: Room not found",
                  "statusCode": 404
                }
              }
            }
          },
          "500": {
            "description": "Neither `crmUserId` nor `userGuest` + `userHost` were sent.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "status": "ERROR",
                  "message": "Error getting room: invalid parameters",
                  "statusCode": 500
                }
              }
            }
          }
        }
      }
    },
    "/inbox/room": {
      "get": {
        "tags": [
          "Conversations"
        ],
        "operationId": "listConversations",
        "summary": "List conversations",
        "description": "Lists the conversations of a space as an agent sees them in the inbox, through one of the agent's filters: get `filterId` from `GET /config/filter` and `inboxId` from `GET /inbox` (or `ALL_MY_INBOX` for all the agent's spaces). Sorted by last activity; paginate with `offset` (0-based) and `limit`. `total` is exact unless counting takes too long: then it is `10000` and `isApproximateTotal` is `true`. Each conversation has `hasError: true` if one of its last 5 agent messages failed.",
        "parameters": [
          {
            "name": "inboxId",
            "in": "query",
            "required": true,
            "description": "Space `_id` (`GET /inbox`), or `ALL_MY_INBOX`.",
            "schema": {
              "type": "string"
            },
            "example": "665f1c2e8a4b3d0012ab3601"
          },
          {
            "name": "filterId",
            "in": "query",
            "required": true,
            "description": "Filter `_id` (`GET /config/filter`).",
            "schema": {
              "type": "string"
            },
            "example": "665f1c2e8a4b3d0012ab3701"
          },
          {
            "name": "userId",
            "in": "query",
            "required": true,
            "description": "`userId` of the agent whose view you want. Several, comma-separated, to combine their conversations.",
            "schema": {
              "type": "string"
            },
            "example": "usr_3k9m2x7q"
          },
          {
            "name": "search",
            "in": "query",
            "required": false,
            "description": "Contact name, WhatsApp username or phone (at least 3 characters). With `deepSearch=1`, text inside the messages.",
            "schema": {
              "type": "string"
            },
            "example": "Laura"
          },
          {
            "name": "deepSearch",
            "in": "query",
            "required": false,
            "description": "`1` = search `search` in the text of the messages instead of the contact.",
            "schema": {
              "type": "integer",
              "enum": [
                0,
                1
              ],
              "default": 0
            },
            "example": 0
          },
          {
            "name": "channels",
            "in": "query",
            "required": false,
            "description": "Comma-separated channels to include.",
            "schema": {
              "type": "string"
            },
            "example": "WHATSAPP,INSTAGRAM"
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "description": "Conversations to skip.",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            },
            "example": 0
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Conversations per page.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 10
            },
            "example": 10
          },
          {
            "name": "sort",
            "in": "query",
            "required": false,
            "description": "`-1` = most recent activity first, `1` = oldest first.",
            "schema": {
              "type": "integer",
              "enum": [
                -1,
                1
              ],
              "default": -1
            },
            "example": -1
          }
        ],
        "responses": {
          "200": {
            "description": "Page of conversations.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Envelope"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "type": "object",
                          "properties": {
                            "rooms": {
                              "type": "array",
                              "description": "Conversations.",
                              "items": {
                                "allOf": [
                                  {
                                    "$ref": "#/components/schemas/Conversation"
                                  },
                                  {
                                    "type": "object",
                                    "properties": {
                                      "hasError": {
                                        "type": "boolean",
                                        "description": "One of the last 5 agent messages failed."
                                      }
                                    }
                                  }
                                ]
                              }
                            },
                            "total": {
                              "type": "integer",
                              "description": "Conversations that match."
                            },
                            "isApproximateTotal": {
                              "type": "boolean",
                              "description": "`total` is an estimate."
                            },
                            "inboxFilter": {
                              "type": "object",
                              "description": "Internal description of the query that was run. Ignore it.",
                              "additionalProperties": true
                            }
                          }
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "status": "SUCCESS",
                  "message": "",
                  "data": {
                    "rooms": [
                      {
                        "_id": "665f1c2e8a4b3d0012ab34cd",
                        "appUUID": "app_7f3k2m9x1q",
                        "companyUUID": "cmp_4n8b2v6c1z",
                        "channel": "keybe_wp",
                        "state": "withAdvisor",
                        "userGuest": "+573001234567",
                        "userHost": "+573005550100",
                        "name": "Laura Gómez",
                        "crmUserId": "665f1c2e8a4b3d0012ab3901",
                        "advisorId": "usr_3k9m2x7q",
                        "adviser": {
                          "userId": "usr_3k9m2x7q",
                          "name": "Carlos",
                          "lastName": "Ruiz",
                          "email": "carlos@example.com",
                          "status": "online",
                          "role": "agent"
                        },
                        "lastAdviserId": "usr_3k9m2x7q",
                        "tags": [
                          "ventas"
                        ],
                        "currentSesionId": "ses_9x8c7v6b5n",
                        "lastSesionId": "ses_1a2s3d4f5g",
                        "lastMessageFrom": "user",
                        "lastMessage": {
                          "_id": "665f1c2e8a4b3d0012ab34d1",
                          "type": "text",
                          "text": "Hola, quiero información sobre el plan anual",
                          "sender": "user",
                          "createdAt": "2026-10-14T15:02:11.000Z"
                        },
                        "user": {
                          "name": "Laura",
                          "lastName": "Gómez",
                          "email": "laura@example.com",
                          "phone": "+573001234567"
                        },
                        "isMassive": false,
                        "createdAt": "2026-03-02T16:20:45.000Z",
                        "updatedAt": "2026-10-14T15:02:11.000Z",
                        "hasError": false
                      }
                    ],
                    "total": 1,
                    "isApproximateTotal": false,
                    "inboxFilter": {
                      "_id": "17604543311230.4821",
                      "appUUID": "app_7f3k2m9x1q",
                      "userId": "usr_3k9m2x7q"
                    }
                  },
                  "statusCode": 200
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "description": "Missing parameters, or the space or filter doesn't exist.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "status": "ERROR",
                  "message": "must send required params: inboxId , userId, filterId",
                  "statusCode": 500
                }
              }
            }
          },
          "504": {
            "description": "The search took too long. Narrow it down and try again.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "status": "ERROR",
                  "message": "Timeout exceeded",
                  "statusCode": 504
                }
              }
            }
          }
        }
      }
    },
    "/config/filter": {
      "get": {
        "tags": [
          "Conversations"
        ],
        "operationId": "listConversationFilters",
        "summary": "List an agent's inbox filters",
        "description": "Returns the active inbox filters of an agent (\"Todos los chats\", \"Mis Chats activos\", \"Chats sin respuesta\"…). Use a filter `_id` as `filterId` in `GET /inbox/room`. The default filters of the agent's role are created on the first call if missing, always with Spanish names.",
        "parameters": [
          {
            "$ref": "#/components/parameters/AppUUID"
          },
          {
            "name": "userId",
            "in": "query",
            "required": true,
            "description": "`userId` of the agent.",
            "schema": {
              "type": "string"
            },
            "example": "usr_3k9m2x7q"
          }
        ],
        "responses": {
          "200": {
            "description": "Filters of the agent.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Envelope"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "type": "array",
                          "description": "Filters.",
                          "items": {
                            "$ref": "#/components/schemas/ConversationFilter"
                          }
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "status": "SUCCESS",
                  "message": "",
                  "data": [
                    {
                      "_id": "665f1c2e8a4b3d0012ab3701",
                      "appUUID": "app_7f3k2m9x1q",
                      "userId": "usr_3k9m2x7q",
                      "userIds": [],
                      "name": "Todas",
                      "rules": [
                        {
                          "category": "ALL",
                          "channels": []
                        }
                      ],
                      "favorite": true,
                      "active": true,
                      "createdAt": "2026-03-02T16:20:45.000Z",
                      "updatedAt": "2026-03-02T16:20:45.000Z"
                    },
                    {
                      "_id": "665f1c2e8a4b3d0012ab3702",
                      "appUUID": "app_7f3k2m9x1q",
                      "userId": "usr_3k9m2x7q",
                      "userIds": [],
                      "name": "Mis chats",
                      "rules": [
                        {
                          "category": "MINE",
                          "channels": [
                            "WHATSAPP"
                          ]
                        }
                      ],
                      "favorite": false,
                      "active": true,
                      "createdAt": "2026-03-02T16:20:45.000Z",
                      "updatedAt": "2026-03-02T16:20:45.000Z"
                    }
                  ],
                  "statusCode": 200
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "description": "Missing parameters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "status": "ERROR",
                  "message": "must send required params, appUUID, userId",
                  "statusCode": 500
                }
              }
            }
          }
        }
      }
    },
    "/rooms/transfer": {
      "post": {
        "tags": [
          "Conversations"
        ],
        "operationId": "transferConversation",
        "summary": "Transfer a conversation",
        "description": "Moves a conversation to another agent, to another space or to the bot, and leaves a `status` message in it. Send at least one destination: `agentIdTo`, `inbox` or `transferToBot`; with `agentIdTo` and `inbox` together, the agent must belong to that space. An `agentIdFrom` with role `agent` can't move a conversation away from the AI agent during the first 24 hours of its session.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TransferConversationRequest"
              },
              "examples": {
                "toAgent": {
                  "summary": "To an agent",
                  "value": {
                    "roomId": "665f1c2e8a4b3d0012ab34cd",
                    "appUUID": "app_7f3k2m9x1q",
                    "agentIdFrom": "usr_3k9m2x7q",
                    "agentIdTo": "usr_8p4n6v2t"
                  }
                },
                "toSpace": {
                  "summary": "To a space (queue)",
                  "value": {
                    "roomId": "665f1c2e8a4b3d0012ab34cd",
                    "appUUID": "app_7f3k2m9x1q",
                    "agentIdFrom": "usr_3k9m2x7q",
                    "inbox": "soporte"
                  }
                },
                "toAgentInSpace": {
                  "summary": "To an agent of another space",
                  "value": {
                    "roomId": "665f1c2e8a4b3d0012ab34cd",
                    "appUUID": "app_7f3k2m9x1q",
                    "agentIdFrom": "usr_3k9m2x7q",
                    "agentIdTo": "usr_8p4n6v2t",
                    "inbox": "soporte"
                  }
                },
                "toBot": {
                  "summary": "To the bot",
                  "value": {
                    "roomId": "665f1c2e8a4b3d0012ab34cd",
                    "appUUID": "app_7f3k2m9x1q",
                    "agentIdFrom": "usr_3k9m2x7q",
                    "transferToBot": true
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Transferred.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                },
                "example": {
                  "status": "SUCCESS",
                  "message": "",
                  "statusCode": 200
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "description": "Not transferred; `message` says why: `Missing transfer origin`, `Missing transfer destination`, `Cant find room to transfer`, `cant find adviser to transfer`, `Advisor does not belong to the space you wish to transfer`, `Bot not configured`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "status": "ERROR",
                  "message": "Missing transfer destination",
                  "statusCode": 500
                }
              }
            }
          }
        }
      }
    },
    "/rooms/end": {
      "post": {
        "tags": [
          "Conversations"
        ],
        "operationId": "closeConversation",
        "summary": "Close a conversation",
        "description": "Closes (ends) a conversation, records who closed it and why, and leaves a `status` message in it. The next message from the contact opens a new session. Closing frees the agent, so automatic assignment runs for the app.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CloseConversationRequest"
              },
              "examples": {
                "withReason": {
                  "summary": "With a closing reason",
                  "value": {
                    "roomId": "665f1c2e8a4b3d0012ab34cd",
                    "appUUID": "app_7f3k2m9x1q",
                    "responsibleAgentId": "usr_3k9m2x7q",
                    "reason": "665f1c2e8a4b3d0012ab3a10"
                  }
                },
                "freeText": {
                  "summary": "With free text",
                  "value": {
                    "roomId": "665f1c2e8a4b3d0012ab34cd",
                    "appUUID": "app_7f3k2m9x1q",
                    "responsibleAgentId": "usr_3k9m2x7q",
                    "reason": "Venta cerrada desde el ERP"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Closed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                },
                "example": {
                  "status": "SUCCESS",
                  "message": "",
                  "statusCode": 200
                }
              }
            }
          },
          "400": {
            "description": "`roomId` is missing, or an agent with role `agent` tried to close a conversation that isn't theirs.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "status": "ERROR",
                  "message": "Advisor can not transfer",
                  "statusCode": 400
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "description": "Not closed: the conversation doesn't exist or isn't in the `appUUID` you sent, or it is already closed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "status": "ERROR",
                  "message": "The room is actually in end state",
                  "statusCode": 500
                }
              }
            }
          }
        }
      }
    },
    "/v1/webhook": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "operationId": "createWebhook",
        "summary": "Create a webhook",
        "description": "Registers a URL that will receive the app's message events (see the Webhooks section for the payload, retries and security). An app can have up to 10 webhooks, each with its own filters, and every event goes to all the webhooks it matches. The `url` must be unique in the app.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateWebhookRequest"
              },
              "example": {
                "appUUID": "app_7f3k2m9x1q",
                "url": "https://erp.example.com/biky/webhook",
                "tag": "erp",
                "senders": [
                  "user",
                  "advisor"
                ],
                "authorizationType": "Bearer",
                "token": "whsec_example_change_me"
              }
            }
          }
        },
        "callbacks": {
          "messageEvent": {
            "{$request.body#/url}": {
              "post": {
                "operationId": "receiveMessageEvent",
                "summary": "Message event sent to your webhook",
                "description": "Biky sends one `POST` per event to the webhook `url`, with `Content-Type: application/json` and, if you configured a `token`, the header `Authorization: <authorizationType> <token>`. Answer any `2xx` within 10 seconds.",
                "requestBody": {
                  "required": true,
                  "content": {
                    "application/json": {
                      "schema": {
                        "$ref": "#/components/schemas/WebhookEvent"
                      },
                      "examples": {
                        "newMessage": {
                          "summary": "New message from the contact",
                          "value": {
                            "type": "newMessage",
                            "message": {
                              "_id": "665f1c2e8a4b3d0012ab34d1",
                              "appUUID": "app_7f3k2m9x1q",
                              "companyUUID": "cmp_4n8b2v6c1z",
                              "roomId": "665f1c2e8a4b3d0012ab34cd",
                              "sessionId": "ses_9x8c7v6b5n",
                              "channel": "keybe_wp",
                              "channelId": "wamid.FAKE0000000000000001",
                              "type": "text",
                              "text": "Hola, quiero información sobre el plan anual",
                              "sender": "user",
                              "userGuest": "+573001234567",
                              "userHost": "+573005550100",
                              "status": "withAdvisor",
                              "deliveryStatus": "read",
                              "inbox": "ventas",
                              "crmUserId": "665f1c2e8a4b3d0012ab3901",
                              "reactions": [],
                              "createdAt": "2026-10-14T15:02:11.000Z",
                              "updatedAt": "2026-10-14T15:02:11.000Z"
                            },
                            "room": {
                              "_id": "665f1c2e8a4b3d0012ab34cd",
                              "appUUID": "app_7f3k2m9x1q",
                              "companyUUID": "cmp_4n8b2v6c1z",
                              "channel": "keybe_wp",
                              "state": "withAdvisor",
                              "userGuest": "+573001234567",
                              "userHost": "+573005550100",
                              "name": "Laura Gómez",
                              "crmUserId": "665f1c2e8a4b3d0012ab3901",
                              "advisorId": "usr_3k9m2x7q",
                              "adviser": {
                                "userId": "usr_3k9m2x7q",
                                "name": "Carlos",
                                "lastName": "Ruiz",
                                "email": "carlos@example.com",
                                "status": "online",
                                "role": "agent"
                              },
                              "lastAdviserId": "usr_3k9m2x7q",
                              "tags": [
                                "ventas"
                              ],
                              "currentSesionId": "ses_9x8c7v6b5n",
                              "lastSesionId": "ses_1a2s3d4f5g",
                              "lastMessageFrom": "user",
                              "lastMessage": {
                                "_id": "665f1c2e8a4b3d0012ab34d1",
                                "type": "text",
                                "text": "Hola, quiero información sobre el plan anual",
                                "sender": "user",
                                "createdAt": "2026-10-14T15:02:11.000Z"
                              },
                              "user": {
                                "name": "Laura",
                                "lastName": "Gómez",
                                "email": "laura@example.com",
                                "phone": "+573001234567"
                              },
                              "isMassive": false,
                              "createdAt": "2026-03-02T16:20:45.000Z",
                              "updatedAt": "2026-10-14T15:02:11.000Z"
                            }
                          }
                        },
                        "updateMessage": {
                          "summary": "Agent message read by the contact",
                          "value": {
                            "type": "updateMessage",
                            "message": {
                              "_id": "665f1c2e8a4b3d0012ab34d2",
                              "appUUID": "app_7f3k2m9x1q",
                              "companyUUID": "cmp_4n8b2v6c1z",
                              "roomId": "665f1c2e8a4b3d0012ab34cd",
                              "sessionId": "ses_9x8c7v6b5n",
                              "channel": "keybe_wp",
                              "channelId": "wamid.FAKE0000000000000002",
                              "type": "text",
                              "text": "¡Hola Laura! Con gusto te ayudo. El plan anual cuesta $1.200.000.",
                              "sender": "advisor",
                              "advisorId": "usr_3k9m2x7q",
                              "userGuest": "+573001234567",
                              "userHost": "+573005550100",
                              "status": "withAdvisor",
                              "deliveryStatus": "read",
                              "delivery": {
                                "pending": "2026-10-14T15:03:40.000Z",
                                "sending": "2026-10-14T15:03:40.000Z",
                                "sent": "2026-10-14T15:03:40.000Z",
                                "user": "2026-10-14T15:03:40.000Z",
                                "read": "2026-10-14T15:04:05.000Z"
                              },
                              "inbox": "ventas",
                              "crmUserId": "665f1c2e8a4b3d0012ab3901",
                              "origin": {
                                "event": "client-api",
                                "eventId": "erp-7781"
                              },
                              "createdAt": "2026-10-14T15:03:40.000Z",
                              "updatedAt": "2026-10-14T15:04:05.000Z"
                            },
                            "oldMessage": {
                              "_id": "665f1c2e8a4b3d0012ab34d2",
                              "appUUID": "app_7f3k2m9x1q",
                              "companyUUID": "cmp_4n8b2v6c1z",
                              "roomId": "665f1c2e8a4b3d0012ab34cd",
                              "sessionId": "ses_9x8c7v6b5n",
                              "channel": "keybe_wp",
                              "channelId": "wamid.FAKE0000000000000002",
                              "type": "text",
                              "text": "¡Hola Laura! Con gusto te ayudo. El plan anual cuesta $1.200.000.",
                              "sender": "advisor",
                              "advisorId": "usr_3k9m2x7q",
                              "userGuest": "+573001234567",
                              "userHost": "+573005550100",
                              "status": "withAdvisor",
                              "deliveryStatus": "user",
                              "delivery": {
                                "pending": "2026-10-14T15:03:40.000Z",
                                "sending": "2026-10-14T15:03:40.000Z",
                                "sent": "2026-10-14T15:03:40.000Z",
                                "user": "2026-10-14T15:03:40.000Z"
                              },
                              "inbox": "ventas",
                              "crmUserId": "665f1c2e8a4b3d0012ab3901",
                              "origin": {
                                "event": "client-api",
                                "eventId": "erp-7781"
                              },
                              "createdAt": "2026-10-14T15:03:40.000Z",
                              "updatedAt": "2026-10-14T15:03:40.000Z"
                            },
                            "room": {
                              "_id": "665f1c2e8a4b3d0012ab34cd",
                              "appUUID": "app_7f3k2m9x1q",
                              "companyUUID": "cmp_4n8b2v6c1z",
                              "channel": "keybe_wp",
                              "state": "withAdvisor",
                              "userGuest": "+573001234567",
                              "userHost": "+573005550100",
                              "name": "Laura Gómez",
                              "crmUserId": "665f1c2e8a4b3d0012ab3901",
                              "advisorId": "usr_3k9m2x7q",
                              "adviser": {
                                "userId": "usr_3k9m2x7q",
                                "name": "Carlos",
                                "lastName": "Ruiz",
                                "email": "carlos@example.com",
                                "status": "online",
                                "role": "agent"
                              },
                              "lastAdviserId": "usr_3k9m2x7q",
                              "tags": [
                                "ventas"
                              ],
                              "currentSesionId": "ses_9x8c7v6b5n",
                              "lastSesionId": "ses_1a2s3d4f5g",
                              "lastMessageFrom": "advisor",
                              "lastMessage": {
                                "_id": "665f1c2e8a4b3d0012ab34d1",
                                "type": "text",
                                "text": "Hola, quiero información sobre el plan anual",
                                "sender": "user",
                                "createdAt": "2026-10-14T15:02:11.000Z"
                              },
                              "user": {
                                "name": "Laura",
                                "lastName": "Gómez",
                                "email": "laura@example.com",
                                "phone": "+573001234567"
                              },
                              "isMassive": false,
                              "createdAt": "2026-03-02T16:20:45.000Z",
                              "updatedAt": "2026-10-14T15:02:11.000Z"
                            }
                          }
                        }
                      }
                    }
                  }
                },
                "responses": {
                  "200": {
                    "description": "Any `2xx` acknowledges the event."
                  },
                  "500": {
                    "description": "`5xx`, `429`, a timeout (10 s) or an unreachable host: Biky retries (3 attempts in total). Other `4xx` answers are final."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Webhook created.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Envelope"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/Webhook"
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "status": "SUCCESS",
                  "message": "",
                  "data": {
                    "_id": "665f1c2e8a4b3d0012ab3501",
                    "appUUID": "app_7f3k2m9x1q",
                    "url": "https://erp.example.com/biky/webhook",
                    "tag": "erp",
                    "newMessages": true,
                    "updateMessages": true,
                    "senders": [
                      "user",
                      "advisor"
                    ],
                    "authorizationType": "Bearer",
                    "hasToken": true,
                    "isDeleted": false,
                    "createdBy": {
                      "userId": "usr_5t7y9u1i",
                      "name": "Integración",
                      "lastname": "ERP",
                      "email": "integraciones@example.com"
                    },
                    "createdAt": "2026-03-02T16:20:45.000Z",
                    "updatedAt": "2026-03-02T16:20:45.000Z"
                  },
                  "statusCode": 201
                }
              }
            }
          },
          "400": {
            "description": "Invalid field (e.g. a private or non-HTTP `url`) or the app already has 10 webhooks.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "status": "ERROR",
                  "message": "url must point to a public host",
                  "statusCode": 400
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          }
        }
      },
      "get": {
        "tags": [
          "Webhooks"
        ],
        "operationId": "listWebhooks",
        "summary": "List webhooks",
        "description": "Returns the webhooks of the app, oldest first. The `token` is never returned: `hasToken` says whether there is one.",
        "parameters": [
          {
            "$ref": "#/components/parameters/AppUUID"
          },
          {
            "name": "tag",
            "in": "query",
            "required": false,
            "description": "Only webhooks with this `tag`.",
            "schema": {
              "type": "string"
            },
            "example": "erp"
          }
        ],
        "responses": {
          "200": {
            "description": "Webhooks of the app.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Envelope"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "type": "array",
                          "description": "Webhooks.",
                          "items": {
                            "$ref": "#/components/schemas/Webhook"
                          }
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "status": "SUCCESS",
                  "message": "",
                  "data": [
                    {
                      "_id": "665f1c2e8a4b3d0012ab3501",
                      "appUUID": "app_7f3k2m9x1q",
                      "url": "https://erp.example.com/biky/webhook",
                      "tag": "erp",
                      "newMessages": true,
                      "updateMessages": true,
                      "senders": [
                        "user",
                        "advisor"
                      ],
                      "authorizationType": "Bearer",
                      "hasToken": true,
                      "isDeleted": false,
                      "createdBy": {
                        "userId": "usr_5t7y9u1i",
                        "name": "Integración",
                        "lastname": "ERP",
                        "email": "integraciones@example.com"
                      },
                      "createdAt": "2026-03-02T16:20:45.000Z",
                      "updatedAt": "2026-03-02T16:20:45.000Z"
                    }
                  ],
                  "statusCode": 200
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        }
      }
    },
    "/v1/webhook/{id}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/WebhookId"
        }
      ],
      "get": {
        "tags": [
          "Webhooks"
        ],
        "operationId": "getWebhook",
        "summary": "Get a webhook",
        "description": "Returns one webhook of the app.",
        "parameters": [
          {
            "$ref": "#/components/parameters/AppUUID"
          }
        ],
        "responses": {
          "200": {
            "description": "The webhook.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Envelope"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/Webhook"
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "status": "SUCCESS",
                  "message": "",
                  "data": {
                    "_id": "665f1c2e8a4b3d0012ab3501",
                    "appUUID": "app_7f3k2m9x1q",
                    "url": "https://erp.example.com/biky/webhook",
                    "tag": "erp",
                    "newMessages": true,
                    "updateMessages": true,
                    "senders": [
                      "user",
                      "advisor"
                    ],
                    "authorizationType": "Bearer",
                    "hasToken": true,
                    "isDeleted": false,
                    "createdBy": {
                      "userId": "usr_5t7y9u1i",
                      "name": "Integración",
                      "lastname": "ERP",
                      "email": "integraciones@example.com"
                    },
                    "createdAt": "2026-03-02T16:20:45.000Z",
                    "updatedAt": "2026-03-02T16:20:45.000Z"
                  },
                  "statusCode": 200
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "put": {
        "tags": [
          "Webhooks"
        ],
        "operationId": "updateWebhook",
        "summary": "Update a webhook",
        "description": "Changes the fields you send; the rest stay as they are. `appUUID` goes in the body.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateWebhookRequest"
              },
              "example": {
                "appUUID": "app_7f3k2m9x1q",
                "updateMessages": false,
                "senders": [
                  "user"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated webhook.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Envelope"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/Webhook"
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "status": "SUCCESS",
                  "message": "",
                  "data": {
                    "_id": "665f1c2e8a4b3d0012ab3501",
                    "appUUID": "app_7f3k2m9x1q",
                    "url": "https://erp.example.com/biky/webhook",
                    "tag": "erp",
                    "newMessages": true,
                    "updateMessages": false,
                    "senders": [
                      "user"
                    ],
                    "authorizationType": "Bearer",
                    "hasToken": true,
                    "isDeleted": false,
                    "createdBy": {
                      "userId": "usr_5t7y9u1i",
                      "name": "Integración",
                      "lastname": "ERP",
                      "email": "integraciones@example.com"
                    },
                    "createdAt": "2026-03-02T16:20:45.000Z",
                    "updatedAt": "2026-10-14T15:02:11.000Z"
                  },
                  "statusCode": 200
                }
              }
            }
          },
          "400": {
            "description": "Invalid field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "status": "ERROR",
                  "message": "senders must be an array of strings",
                  "statusCode": 400
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          }
        }
      },
      "delete": {
        "tags": [
          "Webhooks"
        ],
        "operationId": "deleteWebhook",
        "summary": "Delete a webhook",
        "description": "Deletes a webhook: it stops receiving events, no longer counts towards the limit of 10 and its `url` can be registered again. The other webhooks of the app are not affected.",
        "parameters": [
          {
            "$ref": "#/components/parameters/AppUUID"
          }
        ],
        "responses": {
          "200": {
            "description": "Deleted.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Envelope"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "nullable": true,
                          "type": "object",
                          "description": "Always `null`."
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "status": "SUCCESS",
                  "message": "",
                  "data": null,
                  "statusCode": 200
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/adviser": {
      "get": {
        "tags": [
          "Agents"
        ],
        "operationId": "listAgents",
        "summary": "List agents",
        "description": "Without `inbox`, returns the active agents of the app (the list is cached; send `refresh=true` to read it fresh). With `inbox`, returns only the agents of that space who are online and below their conversation limit, least busy first, with their current load: the agents a conversation can be handed to right now.",
        "parameters": [
          {
            "$ref": "#/components/parameters/AppUUID"
          },
          {
            "name": "inbox",
            "in": "query",
            "required": false,
            "description": "Space key. Changes the answer to the available agents of that space.",
            "schema": {
              "type": "string"
            },
            "example": "ventas"
          },
          {
            "name": "refresh",
            "in": "query",
            "required": false,
            "description": "`true` = skip the cache.",
            "schema": {
              "type": "boolean",
              "default": false
            },
            "example": true
          },
          {
            "name": "includeFloor",
            "in": "query",
            "required": false,
            "description": "`true` = also include in-store (floor) agents, who don't attend chats.",
            "schema": {
              "type": "boolean",
              "default": false
            },
            "example": false
          }
        ],
        "responses": {
          "200": {
            "description": "Agents.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Envelope"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "oneOf": [
                            {
                              "type": "array",
                              "description": "Without `inbox`: agents of the app.",
                              "items": {
                                "$ref": "#/components/schemas/Agent"
                              }
                            },
                            {
                              "type": "array",
                              "description": "With `inbox`: available agents of the space.",
                              "items": {
                                "$ref": "#/components/schemas/AvailableAgent"
                              }
                            }
                          ]
                        }
                      }
                    }
                  ]
                },
                "examples": {
                  "all": {
                    "summary": "Agents of the app",
                    "value": {
                      "status": "SUCCESS",
                      "message": "",
                      "data": [
                        {
                          "_id": "665f1c2e8a4b3d0012ab3b01",
                          "userId": "usr_3k9m2x7q",
                          "appUUID": "app_7f3k2m9x1q",
                          "companyUUID": "cmp_4n8b2v6c1z",
                          "name": "Carlos",
                          "lastName": "Ruiz",
                          "email": "carlos@example.com",
                          "phone": "+573005550111",
                          "status": "online",
                          "role": "agent",
                          "tags": [
                            "ventas"
                          ],
                          "groups": [
                            "sedes_norte"
                          ],
                          "inactive": 0,
                          "isActiveForAutoassign": true,
                          "maxActiveConversationsNumber": 20,
                          "receiveRoomsEvenOfflineStatus": false,
                          "country": "CO",
                          "image": "",
                          "createdAt": "2026-03-02T16:20:45.000Z",
                          "updatedAt": "2026-10-14T15:02:11.000Z"
                        },
                        {
                          "_id": "665f1c2e8a4b3d0012ab3b02",
                          "userId": "usr_8p4n6v2t",
                          "appUUID": "app_7f3k2m9x1q",
                          "companyUUID": "cmp_4n8b2v6c1z",
                          "name": "Ana",
                          "lastName": "Torres",
                          "email": "ana@example.com",
                          "phone": "+573005550122",
                          "status": "offline",
                          "role": "admin",
                          "tags": [
                            "ventas",
                            "soporte"
                          ],
                          "groups": [],
                          "inactive": 0,
                          "isActiveForAutoassign": false,
                          "maxActiveConversationsNumber": 0,
                          "receiveRoomsEvenOfflineStatus": false,
                          "country": "CO",
                          "image": "",
                          "createdAt": "2026-03-02T16:20:45.000Z",
                          "updatedAt": "2026-10-14T15:02:11.000Z"
                        }
                      ],
                      "statusCode": 200
                    }
                  },
                  "available": {
                    "summary": "Available agents of a space",
                    "value": {
                      "status": "SUCCESS",
                      "message": "",
                      "data": [
                        {
                          "name": "Carlos Ruiz",
                          "advisorUserId": "usr_3k9m2x7q",
                          "roomCount": 3,
                          "email": "carlos@example.com"
                        }
                      ],
                      "statusCode": 200
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "description": "Missing `appUUID`, or the space doesn't exist or is inactive.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "status": "ERROR",
                  "message": "No inbox found for appUUID:app_7f3k2m9x1q, key:ventas",
                  "statusCode": 500
                }
              }
            }
          }
        }
      }
    },
    "/config/channels": {
      "get": {
        "tags": [
          "Channels"
        ],
        "operationId": "listChannels",
        "summary": "List connected channels",
        "description": "Returns the channels connected to the app: the Facebook page, the Instagram account and every active WhatsApp line (`whatsapp.accounts[].userHost` is the number to use as `userHost` when sending templates). Always answers HTTP 200: check `status`.",
        "parameters": [
          {
            "$ref": "#/components/parameters/AppUUID"
          }
        ],
        "responses": {
          "200": {
            "description": "Channels of the app.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Envelope"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/ChannelsConfig"
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "status": "SUCCESS",
                  "message": "",
                  "data": {
                    "facebookMessenger": {
                      "_id": "665f1c2e8a4b3d0012ab3d01",
                      "appUUID": "app_7f3k2m9x1q",
                      "companyUUID": "cmp_4n8b2v6c1z",
                      "page_id": [
                        "1122334455667788"
                      ],
                      "pageName": "Tienda Ejemplo",
                      "enable": true
                    },
                    "instagram": {
                      "_id": "665f1c2e8a4b3d0012ab3d02",
                      "appUUID": "app_7f3k2m9x1q",
                      "companyUUID": "cmp_4n8b2v6c1z",
                      "instagram_id": "17841400000000001",
                      "page_id": "1122334455667788",
                      "pageName": "Tienda Ejemplo",
                      "enable": true
                    },
                    "whatsapp": {
                      "hasWhatsappProvider": true,
                      "accounts": [
                        {
                          "provider": "KB_WHATSAPP",
                          "userHost": "+573005550100",
                          "config": {
                            "_id": "+573005550100",
                            "appUUID": "app_7f3k2m9x1q",
                            "companyUUID": "cmp_4n8b2v6c1z",
                            "name": "Tienda Ejemplo",
                            "wabaId": "1029384756000001",
                            "phoneId": "1098765432100001",
                            "verified_name": "Tienda Ejemplo",
                            "quality_rating": "GREEN",
                            "enable": true
                          }
                        }
                      ]
                    }
                  },
                  "statusCode": 200
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        }
      }
    },
    "/config/whatsapp/{appUUID}/phone/{phoneNumber}/catalog": {
      "servers": [
        {
          "url": "https://chat-api.keybeapi.com",
          "description": "Production"
        }
      ],
      "parameters": [
        {
          "name": "appUUID",
          "in": "path",
          "required": true,
          "description": "Your app's id.",
          "schema": {
            "type": "string"
          },
          "example": "app_7f3k2m9x1q"
        },
        {
          "name": "phoneNumber",
          "in": "path",
          "required": true,
          "description": "WhatsApp line, with or without `+` (URL-encode `+` as `%2B`).",
          "schema": {
            "type": "string"
          },
          "example": "573005550100"
        }
      ],
      "get": {
        "tags": [
          "Channels"
        ],
        "operationId": "listWhatsappCatalogs",
        "summary": "List the product catalogs of a WhatsApp line",
        "description": "Returns the Meta commerce catalogs of the business behind a WhatsApp line, with all their products. Use a catalog `id` as `mpmDetails.catalogId` and product `retailer_id`s as `productRetailerId` in multi-product templates. Only for lines connected through WhatsApp Cloud API (`provider: KB_WHATSAPP`).",
        "parameters": [
          {
            "name": "refresh",
            "in": "query",
            "required": false,
            "description": "`true` = read the business data from Meta again before listing.",
            "schema": {
              "type": "boolean",
              "default": false
            },
            "example": false
          }
        ],
        "responses": {
          "200": {
            "description": "Catalogs.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Envelope"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "type": "array",
                          "description": "Catalogs.",
                          "items": {
                            "$ref": "#/components/schemas/WhatsappCatalog"
                          }
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "status": "SUCCESS",
                  "message": "",
                  "data": [
                    {
                      "id": "1029384756102938",
                      "name": "Catálogo Tienda Ejemplo",
                      "vertical": "commerce",
                      "product_count": 2,
                      "business": {
                        "id": "5550001112223334",
                        "name": "Tienda Ejemplo"
                      },
                      "products": {
                        "data": [
                          {
                            "id": "7000000000000001",
                            "name": "Tenis Run 1",
                            "retailer_id": "sku-tenis-001",
                            "price": "$249.900",
                            "availability": "in stock",
                            "condition": "new",
                            "image_url": "https://cdn.example.com/catalogo/tenis-run-1.jpg",
                            "review_status": "approved"
                          },
                          {
                            "id": "7000000000000002",
                            "name": "Tenis Trail 2",
                            "retailer_id": "sku-tenis-002",
                            "price": "$289.900",
                            "availability": "in stock",
                            "condition": "new",
                            "image_url": "https://cdn.example.com/catalogo/tenis-trail-2.jpg",
                            "review_status": "approved"
                          }
                        ]
                      }
                    }
                  ],
                  "statusCode": 200
                }
              }
            }
          },
          "400": {
            "description": "The line isn't a WhatsApp Cloud API line of this app, or Meta didn't answer.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "status": "ERROR",
                  "message": "Error getting catalog: whatsapp config not found",
                  "statusCode": 400
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        }
      }
    },
    "/inbox": {
      "get": {
        "tags": [
          "Spaces"
        ],
        "operationId": "listSpaces",
        "summary": "List spaces",
        "description": "Returns the active spaces of the app. With `userId`, only the spaces that user belongs to (admins see all).",
        "parameters": [
          {
            "$ref": "#/components/parameters/AppUUID"
          },
          {
            "name": "userId",
            "in": "query",
            "required": false,
            "description": "Only the spaces of this agent.",
            "schema": {
              "type": "string"
            },
            "example": "usr_3k9m2x7q"
          }
        ],
        "responses": {
          "200": {
            "description": "Spaces.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Envelope"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "type": "array",
                          "description": "Spaces.",
                          "items": {
                            "$ref": "#/components/schemas/Space"
                          }
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "status": "SUCCESS",
                  "message": "",
                  "data": [
                    {
                      "_id": "665f1c2e8a4b3d0012ab3601",
                      "appUUID": "app_7f3k2m9x1q",
                      "key": "ventas",
                      "name": "Ventas",
                      "active": true,
                      "default": true,
                      "line": [
                        "+573005550100"
                      ],
                      "facebookPageId": [],
                      "instagramPageId": [],
                      "users": [
                        {
                          "userId": "usr_3k9m2x7q",
                          "access": "EDIT",
                          "maxActiveConversationsNumber": 20
                        },
                        {
                          "userId": "usr_8p4n6v2t",
                          "access": "DELETE",
                          "maxActiveConversationsNumber": 30
                        }
                      ],
                      "tags": [
                        "comprar",
                        "precio",
                        "cotización"
                      ],
                      "categories": [],
                      "groups": [
                        "sedes_norte"
                      ],
                      "workingHours": {
                        "message": "Te respondemos de lunes a viernes de 8:00 a 18:00.",
                        "days": [
                          {
                            "code": 1,
                            "isClosed": false,
                            "schedules": [
                              {
                                "from": "08:00",
                                "until": "18:00"
                              }
                            ]
                          },
                          {
                            "code": 0,
                            "isClosed": true,
                            "schedules": []
                          }
                        ]
                      },
                      "autoassignationType": "balanced",
                      "reassignForAdviserInactiveMinutes": 10,
                      "reassignForUserInactiveMinutesWithBot": 10,
                      "maxActiveConversationsNumberPerAdvisor": 300,
                      "createdAt": "2026-03-02T16:20:45.000Z",
                      "updatedAt": "2026-10-14T15:02:11.000Z"
                    }
                  ],
                  "statusCode": 200
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "description": "Missing `appUUID`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "status": "ERROR",
                  "message": "must send required params, appUUID",
                  "statusCode": 500
                }
              }
            }
          }
        }
      }
    },
    "/groups": {
      "servers": [
        {
          "url": "https://chat-api.keybeapi.com",
          "description": "Production"
        }
      ],
      "post": {
        "tags": [
          "Groups"
        ],
        "operationId": "createGroup",
        "summary": "Create a group",
        "description": "Creates a group. Its `key`, which spaces use to reference it, is generated from `label`. Answers the group without the `status`/`data` envelope. `appUUID` is required (`400` without it).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "label",
                  "appUUID"
                ],
                "properties": {
                  "label": {
                    "type": "string",
                    "description": "Name of the group."
                  },
                  "appUUID": {
                    "type": "string",
                    "description": "App id."
                  }
                }
              },
              "example": {
                "label": "Sedes norte",
                "appUUID": "app_7f3k2m9x1q"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Group created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Group"
                },
                "example": {
                  "_id": "665f1c2e8a4b3d0012ab3801",
                  "label": "Sedes norte",
                  "key": "sedes_norte",
                  "appUUID": "app_7f3k2m9x1q",
                  "isDeleted": false,
                  "createdAt": "2026-03-02T16:20:45.000Z",
                  "updatedAt": "2026-03-02T16:20:45.000Z",
                  "__v": 0
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "description": "Missing, invalid, expired or revoked credential.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "message": "Verify the sent token",
                  "error": "Unauthorized",
                  "statusCode": 401
                }
              }
            }
          },
          "403": {
            "description": "The credential doesn't belong to a member of this app.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "message": "No tiene permiso para esta app app_7f3k2m9x1q",
                  "error": "Forbidden",
                  "statusCode": 403
                }
              }
            }
          },
          "409": {
            "description": "A group with that label already exists.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "message": "El grupo con este label ya existe",
                  "error": "Conflict",
                  "statusCode": 409
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "Groups"
        ],
        "operationId": "listGroups",
        "summary": "List groups",
        "description": "Returns the groups of the app (without envelope). `appUUID` is required (`400` without it).",
        "parameters": [
          {
            "$ref": "#/components/parameters/AppUUID"
          }
        ],
        "responses": {
          "200": {
            "description": "Groups.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "description": "Groups.",
                  "items": {
                    "$ref": "#/components/schemas/Group"
                  }
                },
                "example": [
                  {
                    "_id": "665f1c2e8a4b3d0012ab3801",
                    "label": "Sedes norte",
                    "key": "sedes_norte",
                    "appUUID": "app_7f3k2m9x1q",
                    "isDeleted": false,
                    "createdAt": "2026-03-02T16:20:45.000Z",
                    "updatedAt": "2026-03-02T16:20:45.000Z",
                    "__v": 0
                  }
                ]
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "description": "Missing, invalid, expired or revoked credential.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "message": "Verify the sent token",
                  "error": "Unauthorized",
                  "statusCode": 401
                }
              }
            }
          },
          "403": {
            "description": "The credential doesn't belong to a member of this app.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "message": "No tiene permiso para esta app app_7f3k2m9x1q",
                  "error": "Forbidden",
                  "statusCode": 403
                }
              }
            }
          }
        }
      }
    },
    "/groups/{id}": {
      "servers": [
        {
          "url": "https://chat-api.keybeapi.com",
          "description": "Production"
        }
      ],
      "parameters": [
        {
          "$ref": "#/components/parameters/GroupId"
        },
        {
          "$ref": "#/components/parameters/AppUUID"
        }
      ],
      "get": {
        "tags": [
          "Groups"
        ],
        "operationId": "getGroup",
        "summary": "Get a group",
        "description": "Returns one group of the app (without envelope). `appUUID` is required (`400` without it).",
        "responses": {
          "200": {
            "description": "The group.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Group"
                },
                "example": {
                  "_id": "665f1c2e8a4b3d0012ab3801",
                  "label": "Sedes norte",
                  "key": "sedes_norte",
                  "appUUID": "app_7f3k2m9x1q",
                  "isDeleted": false,
                  "createdAt": "2026-03-02T16:20:45.000Z",
                  "updatedAt": "2026-03-02T16:20:45.000Z",
                  "__v": 0
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "description": "Missing, invalid, expired or revoked credential.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "message": "Verify the sent token",
                  "error": "Unauthorized",
                  "statusCode": 401
                }
              }
            }
          },
          "403": {
            "description": "The credential doesn't belong to a member of this app.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "message": "No tiene permiso para esta app app_7f3k2m9x1q",
                  "error": "Forbidden",
                  "statusCode": 403
                }
              }
            }
          },
          "404": {
            "description": "The group doesn't exist in this app.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "message": "Grupo no encontrado",
                  "error": "Not Found",
                  "statusCode": 404
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Groups"
        ],
        "operationId": "updateGroup",
        "summary": "Rename a group",
        "description": "Changes the label of a group. Its `key` doesn't change, so the spaces that use it keep working. `appUUID` is required (`400` without it).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "label"
                ],
                "properties": {
                  "label": {
                    "type": "string",
                    "description": "New name of the group."
                  }
                }
              },
              "example": {
                "label": "Sedes zona norte"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated group.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Group"
                },
                "example": {
                  "_id": "665f1c2e8a4b3d0012ab3801",
                  "label": "Sedes zona norte",
                  "key": "sedes_norte",
                  "appUUID": "app_7f3k2m9x1q",
                  "isDeleted": false,
                  "createdAt": "2026-03-02T16:20:45.000Z",
                  "updatedAt": "2026-10-14T15:02:11.000Z",
                  "__v": 0
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "description": "Missing, invalid, expired or revoked credential.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "message": "Verify the sent token",
                  "error": "Unauthorized",
                  "statusCode": 401
                }
              }
            }
          },
          "403": {
            "description": "The credential doesn't belong to a member of this app.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "message": "No tiene permiso para esta app app_7f3k2m9x1q",
                  "error": "Forbidden",
                  "statusCode": 403
                }
              }
            }
          },
          "404": {
            "description": "The group doesn't exist in this app.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "message": "Grupo no encontrado",
                  "error": "Not Found",
                  "statusCode": 404
                }
              }
            }
          },
          "409": {
            "description": "A group with that label already exists.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "message": "El grupo con este label ya existe",
                  "error": "Conflict",
                  "statusCode": 409
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Groups"
        ],
        "operationId": "deleteGroup",
        "summary": "Delete a group",
        "description": "Deletes a group. Answers 204 with no body. `appUUID` is required (`400` without it).",
        "responses": {
          "204": {
            "description": "Deleted."
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "description": "Missing, invalid, expired or revoked credential.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "message": "Verify the sent token",
                  "error": "Unauthorized",
                  "statusCode": 401
                }
              }
            }
          },
          "403": {
            "description": "The credential doesn't belong to a member of this app.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "message": "No tiene permiso para esta app app_7f3k2m9x1q",
                  "error": "Forbidden",
                  "statusCode": 403
                }
              }
            }
          },
          "404": {
            "description": "The group doesn't exist in this app.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "message": "Grupo no encontrado",
                  "error": "Not Found",
                  "statusCode": 404
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Your app's API key (Settings → API keys) or an Identity access token."
      }
    },
    "parameters": {
      "AppUUID": {
        "name": "appUUID",
        "in": "query",
        "required": true,
        "description": "Your app's id (Settings → API keys).",
        "schema": {
          "type": "string"
        },
        "example": "app_7f3k2m9x1q"
      },
      "RoomId": {
        "name": "roomId",
        "in": "query",
        "required": true,
        "description": "Conversation id.",
        "schema": {
          "type": "string"
        },
        "example": "665f1c2e8a4b3d0012ab34cd"
      },
      "WebhookId": {
        "name": "id",
        "in": "path",
        "required": true,
        "description": "Webhook `_id`, from `GET /v1/webhook`.",
        "schema": {
          "type": "string"
        },
        "example": "665f1c2e8a4b3d0012ab3501"
      },
      "GroupId": {
        "name": "id",
        "in": "path",
        "required": true,
        "description": "Group `_id`.",
        "schema": {
          "type": "string"
        },
        "example": "665f1c2e8a4b3d0012ab3801"
      }
    },
    "responses": {
      "BadRequest": {
        "description": "Missing or invalid parameters.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "status": "ERROR",
              "message": "must send required params, appUUID",
              "statusCode": 400
            }
          }
        }
      },
      "Unauthorized": {
        "description": "Missing, invalid, expired or revoked credential.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "message": "Unauthorized"
            }
          }
        }
      },
      "Forbidden": {
        "description": "The credential is valid but doesn't belong to a member of this app.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "status": "ERROR",
              "message": "No tiene permiso para esta app app_7f3k2m9x1q",
              "statusCode": 403
            }
          }
        }
      },
      "NotFound": {
        "description": "Not found in this app.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "status": "ERROR",
              "message": "webhook not found",
              "statusCode": 404
            }
          }
        }
      },
      "Conflict": {
        "description": "Duplicated.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "status": "ERROR",
              "message": "A webhook with this url already exists in the app",
              "statusCode": 409
            }
          }
        }
      },
      "ServerError": {
        "description": "The request could not be processed; `message` says why. Most validation errors of this endpoint use this status.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "status": "ERROR",
              "message": "Room not found",
              "statusCode": 500
            }
          }
        }
      }
    },
    "schemas": {
      "Envelope": {
        "type": "object",
        "description": "Envelope of most Smart Chat answers.",
        "properties": {
          "status": {
            "type": "string",
            "description": "`SUCCESS` or `ERROR`. Some endpoints answer HTTP 200 with `status: ERROR`: always check it.",
            "enum": [
              "SUCCESS",
              "ERROR"
            ]
          },
          "message": {
            "type": "string",
            "description": "Error message; empty on success."
          },
          "statusCode": {
            "type": "integer",
            "description": "HTTP status of the answer."
          }
        }
      },
      "Error": {
        "type": "object",
        "description": "Error answer. Endpoints that use the envelope return `status`, `message` and `statusCode`; the authentication layer returns only `message`, and the endpoints served by chat-api add `error`.",
        "properties": {
          "status": {
            "type": "string",
            "description": "Always `ERROR` (envelope endpoints).",
            "enum": [
              "ERROR"
            ]
          },
          "message": {
            "type": "string",
            "description": "What went wrong."
          },
          "error": {
            "type": "string",
            "description": "HTTP reason phrase (chat-api endpoints)."
          },
          "statusCode": {
            "type": "integer",
            "description": "HTTP status."
          }
        }
      },
      "Channel": {
        "type": "string",
        "description": "Channel of a conversation or message: `keybe_wp` (WhatsApp line connected through WhatsApp Cloud API), `gupshup_wp` (WhatsApp line connected through Gupshup), `instagram`, `facebookMessenger`, `sms`, `web` (web chat), `tiktok`, `voice_call`, `keybe` (internal chat between team members). The other values are legacy.",
        "enum": [
          "keybe_wp",
          "gupshup_wp",
          "whatsapp",
          "instagram",
          "facebookMessenger",
          "sms",
          "web",
          "tiktok",
          "voice_call",
          "keybe",
          "simulator",
          "wizard",
          "support",
          "smooch_wp",
          "hibot_wp",
          "rbm",
          "gmail"
        ],
        "example": "keybe_wp"
      },
      "ConversationState": {
        "type": "string",
        "description": "State of a conversation: `registered` (just created), `readyForAdvisor` (waiting in the queue of its space), `withAdvisor` (assigned to an agent or to the AI agent), `withBot` (handled by a bot), `ended` (closed), `spam`, `coldLead` (closed lead kept for follow-up).",
        "enum": [
          "registered",
          "readyForAdvisor",
          "withAdvisor",
          "withBot",
          "ended",
          "spam",
          "coldLead"
        ],
        "example": "withAdvisor"
      },
      "MessageSender": {
        "type": "string",
        "description": "Who wrote the message: `user` (the contact), `advisor` (an agent or the AI agent), `bot`, `api` (automatic messages sent by integrations) or `internal` (system notes).",
        "enum": [
          "user",
          "advisor",
          "bot",
          "api",
          "internal"
        ],
        "example": "user"
      },
      "MessageType": {
        "type": "string",
        "description": "Kind of message. Media types (`image`, `audio`, `video`, `sticker`, documents…) carry the file URL in `media`. `status` messages are internal notes about assignments, transfers and closures.",
        "enum": [
          "text",
          "image",
          "audio",
          "video",
          "sticker",
          "gif",
          "location",
          "contacts",
          "pdf",
          "doc",
          "docx",
          "xls",
          "xlsx",
          "ppt",
          "pptx",
          "mp3",
          "ogg",
          "template",
          "list",
          "suggestion",
          "order",
          "call",
          "authorize",
          "iframe",
          "others",
          "hidden",
          "status"
        ],
        "example": "text"
      },
      "DeliveryStatus": {
        "type": "string",
        "description": "Delivery status of a message sent to the contact: `pending` (queued in Biky), `sending` (handed to the provider), `sent` (accepted by the channel), `user` (delivered to the contact's device), `read`, `failed` (see `error`).",
        "enum": [
          "pending",
          "sending",
          "sent",
          "user",
          "read",
          "failed"
        ],
        "example": "read"
      },
      "MessageOrigin": {
        "type": "object",
        "description": "Where the message comes from. Use it to correlate messages with your own system.",
        "properties": {
          "event": {
            "type": "string",
            "description": "Source of the message. Use `client-api` for your integration. Biky uses `manual-proactivity`, `campaigns`, `triggers`, `internal-api` and others for its own messages.",
            "example": "client-api"
          },
          "eventId": {
            "type": "string",
            "description": "Free id from your system (order, ticket…), returned as is.",
            "example": "erp-7781"
          },
          "messageId": {
            "type": "string",
            "description": "Free message id from your system, returned as is.",
            "example": "erp-msg-551"
          },
          "generateIrrelevantResponse": {
            "type": "boolean",
            "description": "Templates only: when `true`, the contact's reply to this template doesn't open the conversation for agents (useful for notifications and verification codes).",
            "default": false
          }
        }
      },
      "Reaction": {
        "type": "object",
        "properties": {
          "reaction": {
            "type": "string",
            "description": "Emoji.",
            "example": "👍"
          },
          "users": {
            "type": "array",
            "description": "Who reacted: the agent's `userId` or the contact's `userGuest`.",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "Message": {
        "type": "object",
        "description": "A message of a conversation.",
        "properties": {
          "_id": {
            "type": "string",
            "description": "Message id."
          },
          "appUUID": {
            "type": "string",
            "description": "App id."
          },
          "companyUUID": {
            "type": "string",
            "description": "Company id."
          },
          "roomId": {
            "type": "string",
            "description": "Id of the conversation."
          },
          "sessionId": {
            "type": "string",
            "description": "Id of the conversation session (from the first message until the conversation is closed) the message belongs to."
          },
          "channel": {
            "$ref": "#/components/schemas/Channel"
          },
          "channelId": {
            "type": "string",
            "description": "Id of the message at the channel provider (for WhatsApp, the `wamid`). Use it as `quotedMessageChannelId` to reply to this message."
          },
          "type": {
            "$ref": "#/components/schemas/MessageType"
          },
          "text": {
            "type": "string",
            "description": "Text of the message, or caption of the media."
          },
          "media": {
            "type": "string",
            "description": "URL of the file for media messages.",
            "format": "uri"
          },
          "sender": {
            "$ref": "#/components/schemas/MessageSender"
          },
          "advisorId": {
            "type": "string",
            "description": "`userId` of the agent who sent the message or who had the conversation."
          },
          "adviser": {
            "$ref": "#/components/schemas/Agent"
          },
          "userGuest": {
            "type": "string",
            "description": "The contact: phone number in E.164 format for WhatsApp and SMS, or the channel's user id (Instagram, Messenger, or the WhatsApp user id when Meta hides the number)."
          },
          "userHost": {
            "type": "string",
            "description": "Your side of the conversation: the WhatsApp line, the Facebook page or the Instagram account."
          },
          "status": {
            "type": "string",
            "description": "State of the conversation when the message was saved (see `ConversationState`)."
          },
          "deliveryStatus": {
            "$ref": "#/components/schemas/DeliveryStatus"
          },
          "delivery": {
            "type": "object",
            "description": "When the message reached each delivery status.",
            "properties": {
              "pending": {
                "type": "string",
                "description": "Time of `pending`.",
                "format": "date-time"
              },
              "sending": {
                "type": "string",
                "description": "Time of `sending`.",
                "format": "date-time"
              },
              "sent": {
                "type": "string",
                "description": "Time of `sent`.",
                "format": "date-time"
              },
              "user": {
                "type": "string",
                "description": "Time of `user`.",
                "format": "date-time"
              },
              "read": {
                "type": "string",
                "description": "Time of `read`.",
                "format": "date-time"
              },
              "failed": {
                "type": "string",
                "description": "Time of `failed`.",
                "format": "date-time"
              }
            }
          },
          "error": {
            "type": "string",
            "description": "Reason for a failed delivery, e.g. `ROOM_ENDED` (the conversation was closed), `CHAT_TAKEN_BY_ANOTHER_ADVISOR`, `WA_CUSTOMER_INACTIVITY` (WhatsApp's 24-hour window is closed: send a template), `WA_USER_OPTED_OUT`, `WA_TEMPLATE_PAUSED`, `GP_NUMBER_NOT_ON_WHATSAPP`.",
            "example": "WA_CUSTOMER_INACTIVITY"
          },
          "errorCode": {
            "type": "string",
            "description": "Raw error code of the provider (Meta, Gupshup, Twilio).",
            "example": "131047"
          },
          "typeOptions": {
            "type": "object",
            "description": "Extra data that depends on `type`.",
            "properties": {
              "latitude": {
                "type": "string",
                "description": "`location`: latitude."
              },
              "longitude": {
                "type": "string",
                "description": "`location`: longitude."
              },
              "locationName": {
                "type": "string",
                "description": "`location`: name of the place."
              },
              "address": {
                "type": "string",
                "description": "`location`: address."
              },
              "audioTranscription": {
                "type": "string",
                "description": "`audio`: automatic transcription, when available."
              },
              "referral": {
                "type": "object",
                "description": "Ad or post the contact clicked to start the conversation (click-to-WhatsApp ads): `source_url`, `source_id`, `source_type`, `headline`, `body`.",
                "additionalProperties": true
              },
              "contacts": {
                "type": "array",
                "description": "`contacts`: shared contact cards.",
                "items": {
                  "type": "object",
                  "additionalProperties": true
                }
              },
              "templateData": {
                "type": "object",
                "description": "`template`: the template and parameters that were sent.",
                "additionalProperties": true
              }
            }
          },
          "quotedMessageKB": {
            "type": "object",
            "description": "Message this one replies to.",
            "properties": {
              "_id": {
                "type": "string",
                "description": "Id of the quoted message."
              },
              "type": {
                "$ref": "#/components/schemas/MessageType"
              },
              "text": {
                "type": "string",
                "description": "Text of the quoted message."
              },
              "sender": {
                "$ref": "#/components/schemas/MessageSender"
              },
              "media": {
                "type": "string",
                "description": "Media URL of the quoted message."
              },
              "channelId": {
                "type": "string",
                "description": "Provider id of the quoted message."
              }
            }
          },
          "reactions": {
            "type": "array",
            "description": "Reactions to the message.",
            "items": {
              "$ref": "#/components/schemas/Reaction"
            }
          },
          "origin": {
            "$ref": "#/components/schemas/MessageOrigin"
          },
          "payload": {
            "type": "object",
            "description": "Extra data. In `status` messages, `statusKeys` says what happened.",
            "properties": {
              "statusKeys": {
                "type": "string",
                "description": "Event of a `status` message, e.g. `CONVERSATION_TAKEN_BY_ADVISER`, `CONVERSATION_TRANSFERRED_TO_ADVISER`, `CONVERSATION_TRANSFERRED_TO_BOT`, `CONVERSATION_TRANSFERRED_TO_SPACE`, `CONVERSATION_ASK_FOR_HELP`, `CONVERSATION_ENDED`, `CONVERSATION_ENDED_IA`."
              },
              "selectedOption": {
                "type": "string",
                "description": "Closing reason of a `CONVERSATION_ENDED` message, or option chosen by the contact."
              },
              "suggestion": {
                "type": "array",
                "description": "Options offered to the contact (lists and suggestions).",
                "items": {
                  "type": "string"
                }
              }
            }
          },
          "inbox": {
            "type": "string",
            "description": "Key of the conversation's space when the message was saved."
          },
          "crmUserId": {
            "type": "string",
            "description": "Id of the contact in the CDP."
          },
          "createdAt": {
            "type": "string",
            "description": "Creation time.",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "description": "Last update.",
            "format": "date-time"
          }
        }
      },
      "Agent": {
        "type": "object",
        "description": "A person of your team who attends conversations. The AI agent is also listed as an agent.",
        "properties": {
          "_id": {
            "type": "string",
            "description": "Internal id of the agent record."
          },
          "userId": {
            "type": "string",
            "description": "Id of the user. This is the id used as `advisorId`, `agentIdTo`, `agentIdFrom` and `responsibleAgentId` in the rest of the API."
          },
          "appUUID": {
            "type": "string",
            "description": "App id."
          },
          "companyUUID": {
            "type": "string",
            "description": "Company id."
          },
          "name": {
            "type": "string",
            "description": "First name."
          },
          "lastName": {
            "type": "string",
            "description": "Last name."
          },
          "email": {
            "type": "string",
            "description": "Email.",
            "format": "email"
          },
          "phone": {
            "type": "string",
            "description": "Phone."
          },
          "image": {
            "type": "string",
            "description": "Photo URL."
          },
          "status": {
            "type": "string",
            "description": "`online` or `offline` in Smart Chat.",
            "enum": [
              "online",
              "offline"
            ]
          },
          "role": {
            "type": "string",
            "description": "Role in the app: `admin`, `coordinator`, `agent`…",
            "example": "agent"
          },
          "tags": {
            "type": "array",
            "description": "Keys of the spaces the agent works in.",
            "items": {
              "type": "string"
            }
          },
          "groups": {
            "type": "array",
            "description": "Keys of the agent's groups.",
            "items": {
              "type": "string"
            }
          },
          "inactive": {
            "type": "integer",
            "description": "`0` (or `false` in older records) = active."
          },
          "isActiveForAutoassign": {
            "type": "boolean",
            "description": "Whether the agent receives conversations through automatic assignment."
          },
          "maxActiveConversationsNumber": {
            "type": "integer",
            "description": "Maximum simultaneous conversations."
          },
          "receiveRoomsEvenOfflineStatus": {
            "type": "boolean",
            "description": "Receives assignments even when offline."
          },
          "country": {
            "type": "string",
            "description": "Country code."
          },
          "createdAt": {
            "type": "string",
            "description": "Creation time.",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "description": "Last update.",
            "format": "date-time"
          }
        }
      },
      "AvailableAgent": {
        "type": "object",
        "description": "Agent of a space who can take one more conversation right now.",
        "required": [
          "advisorUserId",
          "roomCount"
        ],
        "properties": {
          "advisorUserId": {
            "type": "string",
            "description": "`userId` of the agent."
          },
          "name": {
            "type": "string",
            "description": "Full name."
          },
          "email": {
            "type": "string",
            "description": "Email.",
            "format": "email"
          },
          "roomCount": {
            "type": "integer",
            "description": "Conversations of that space the agent has open now."
          }
        }
      },
      "Conversation": {
        "type": "object",
        "description": "A conversation (room) between your app and one contact on one line or page. Each new contact message after a closure starts a new session in the same conversation.",
        "properties": {
          "_id": {
            "type": "string",
            "description": "Conversation id (`roomId` in the rest of the API)."
          },
          "appUUID": {
            "type": "string",
            "description": "App id."
          },
          "companyUUID": {
            "type": "string",
            "description": "Company id."
          },
          "channel": {
            "$ref": "#/components/schemas/Channel"
          },
          "state": {
            "$ref": "#/components/schemas/ConversationState"
          },
          "userGuest": {
            "type": "string",
            "description": "The contact: phone number in E.164 format for WhatsApp and SMS, or the channel's user id."
          },
          "userGuestId": {
            "type": "string",
            "description": "WhatsApp user id of the contact (BSUID), when Meta sends it."
          },
          "userHost": {
            "type": "string",
            "description": "Your WhatsApp line, Facebook page or Instagram account."
          },
          "name": {
            "type": "string",
            "description": "Contact name shown in the inbox."
          },
          "username": {
            "type": "string",
            "description": "WhatsApp username of the contact, when available."
          },
          "crmUserId": {
            "type": "string",
            "description": "Id of the contact in the CDP."
          },
          "advisorId": {
            "type": "string",
            "description": "`userId` of the agent (or AI agent) who has the conversation. Empty when nobody has it."
          },
          "adviser": {
            "$ref": "#/components/schemas/Agent"
          },
          "lastAdviserId": {
            "type": "string",
            "description": "`userId` of the last agent who had it."
          },
          "closedByUserId": {
            "type": "string",
            "description": "Who closed it: an agent `userId`, or `IA` for automatic closures."
          },
          "tags": {
            "type": "array",
            "description": "Space keys. The first one is the conversation's current space.",
            "items": {
              "type": "string"
            }
          },
          "currentSesionId": {
            "type": "string",
            "description": "Id of the open session; empty when the conversation is closed."
          },
          "lastSesionId": {
            "type": "string",
            "description": "Id of the previous session."
          },
          "lastMessageFrom": {
            "$ref": "#/components/schemas/MessageSender"
          },
          "lastMessage": {
            "type": "object",
            "description": "Copy of the last message (see `Message`).",
            "additionalProperties": true
          },
          "user": {
            "type": "object",
            "description": "Snapshot of the contact from the CDP (name, email, phone…).",
            "additionalProperties": true
          },
          "isMassive": {
            "type": "boolean",
            "description": "The last activity was a bulk send the contact hasn't answered."
          },
          "createdAt": {
            "type": "string",
            "description": "Creation time.",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "description": "Last activity.",
            "format": "date-time"
          }
        }
      },
      "ConversationFilter": {
        "type": "object",
        "description": "Saved view of an agent's inbox. Its `_id` is the `filterId` of `GET /inbox/room`.",
        "properties": {
          "_id": {
            "type": "string",
            "description": "Filter id."
          },
          "appUUID": {
            "type": "string",
            "description": "App id."
          },
          "userId": {
            "type": "string",
            "description": "Agent who owns the filter."
          },
          "userIds": {
            "type": "array",
            "description": "Agents whose conversations the filter shows (empty = the owner).",
            "items": {
              "type": "string"
            }
          },
          "name": {
            "type": "string",
            "description": "Name shown in the inbox."
          },
          "rules": {
            "type": "array",
            "description": "Rules of the filter.",
            "items": {
              "type": "object",
              "properties": {
                "category": {
                  "type": "string",
                  "description": "Which conversations: `ALL`, `MINE`, `UNANSWERED`, `WAITING`, `UNASSIGNED`, `WITH_BOT`, `CLOSED_BY_ME`, `CLOSED_BY_AI`, `FAVORITE`, `SPAM`, `COLD_LEAD`, `MASSIVE`…",
                  "example": "ALL"
                },
                "channels": {
                  "type": "array",
                  "description": "Channels to include (empty = all).",
                  "items": {
                    "type": "string",
                    "enum": [
                      "WHATSAPP",
                      "FACEBOOK",
                      "INSTAGRAM",
                      "WEB",
                      "SMS"
                    ]
                  }
                }
              }
            }
          },
          "favorite": {
            "type": "boolean",
            "description": "Marked as favorite."
          },
          "active": {
            "type": "boolean",
            "description": "Active."
          },
          "createdAt": {
            "type": "string",
            "description": "Creation time.",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "description": "Last update.",
            "format": "date-time"
          }
        }
      },
      "Space": {
        "type": "object",
        "description": "A space (inbox) groups conversations by line, page, team or topic, with its own agents and rules.",
        "properties": {
          "_id": {
            "type": "string",
            "description": "Space id (the `inboxId` of `GET /inbox/room`)."
          },
          "appUUID": {
            "type": "string",
            "description": "App id."
          },
          "key": {
            "type": "string",
            "description": "Space key: the value used as `inbox` in transfers and templates, and in the conversation's `tags`."
          },
          "name": {
            "type": "string",
            "description": "Name."
          },
          "active": {
            "type": "boolean",
            "description": "Active."
          },
          "default": {
            "type": "boolean",
            "description": "Default space of the app (receives what no other space takes)."
          },
          "line": {
            "type": "array",
            "description": "WhatsApp lines whose new conversations land in this space.",
            "items": {
              "type": "string"
            }
          },
          "facebookPageId": {
            "type": "array",
            "description": "Facebook pages whose new conversations land in this space.",
            "items": {
              "type": "string"
            }
          },
          "instagramPageId": {
            "type": "array",
            "description": "Instagram accounts whose new conversations land in this space.",
            "items": {
              "type": "string"
            }
          },
          "users": {
            "type": "array",
            "description": "Agents of the space.",
            "items": {
              "type": "object",
              "properties": {
                "userId": {
                  "type": "string",
                  "description": "Agent `userId`."
                },
                "access": {
                  "type": "string",
                  "description": "Permission in the space.",
                  "enum": [
                    "VIEW",
                    "EDIT",
                    "DELETE"
                  ]
                },
                "maxActiveConversationsNumber": {
                  "type": "integer",
                  "description": "Maximum simultaneous conversations of the agent in this space."
                }
              }
            }
          },
          "tags": {
            "type": "array",
            "description": "Keywords the AI agent uses to route conversations to this space.",
            "items": {
              "type": "string"
            }
          },
          "categories": {
            "type": "array",
            "description": "Categories.",
            "items": {
              "type": "string"
            }
          },
          "groups": {
            "type": "array",
            "description": "Keys of the groups the space belongs to (see Groups).",
            "items": {
              "type": "string"
            }
          },
          "workingHours": {
            "type": "object",
            "description": "Opening hours and the message sent outside them.",
            "properties": {
              "message": {
                "type": "string",
                "description": "Message sent outside working hours."
              },
              "days": {
                "type": "array",
                "description": "Schedule per day.",
                "items": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "integer",
                      "description": "Day of the week (`0`–`6`)."
                    },
                    "isClosed": {
                      "type": "boolean",
                      "description": "Closed all day."
                    },
                    "schedules": {
                      "type": "array",
                      "description": "Opening ranges.",
                      "items": {
                        "type": "object",
                        "properties": {
                          "from": {
                            "type": "string",
                            "description": "Start, `HH:mm`."
                          },
                          "until": {
                            "type": "string",
                            "description": "End, `HH:mm`."
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "autoassignationType": {
            "type": "string",
            "description": "How conversations are distributed among agents.",
            "enum": [
              "linear",
              "balanced"
            ]
          },
          "reassignForAdviserInactiveMinutes": {
            "type": "integer",
            "description": "Minutes without an agent answer before the conversation is reassigned."
          },
          "reassignForUserInactiveMinutesWithBot": {
            "type": "integer",
            "description": "Minutes of contact inactivity with the bot before reassignment."
          },
          "maxActiveConversationsNumberPerAdvisor": {
            "type": "integer",
            "description": "Default maximum of simultaneous conversations per agent."
          },
          "createdAt": {
            "type": "string",
            "description": "Creation time.",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "description": "Last update.",
            "format": "date-time"
          }
        }
      },
      "Template": {
        "type": "object",
        "description": "WhatsApp template of a line, approved by Meta.",
        "properties": {
          "_id": {
            "type": "string",
            "description": "Internal id."
          },
          "appUUID": {
            "type": "string",
            "description": "App id."
          },
          "userHost": {
            "type": "string",
            "description": "WhatsApp line of the template."
          },
          "templateId": {
            "type": "string",
            "description": "Id to send the template with (`POST /message/proactivity`)."
          },
          "metaTemplateId": {
            "type": "string",
            "description": "Meta's template id."
          },
          "templateName": {
            "type": "string",
            "description": "Template name."
          },
          "customName": {
            "type": "string",
            "description": "Display name."
          },
          "templateMessage": {
            "type": "string",
            "description": "Body text with its variables `{{1}}`, `{{2}}`…"
          },
          "type": {
            "type": "string",
            "description": "Format: `TEXT`, `IMAGE`, `VIDEO`, `DOCUMENT`, `LOCATION`, `CAROUSEL`…",
            "example": "TEXT"
          },
          "provider": {
            "type": "string",
            "description": "How the line is connected: `KB_WHATSAPP` (WhatsApp Cloud API) or `GP_WHATSAPP` (Gupshup).",
            "enum": [
              "KB_WHATSAPP",
              "GP_WHATSAPP"
            ]
          },
          "language": {
            "type": "string",
            "description": "Language code.",
            "example": "es"
          },
          "category": {
            "type": "string",
            "description": "Meta category: `MARKETING`, `UTILITY` or `AUTHENTICATION`.",
            "example": "UTILITY"
          },
          "status": {
            "type": "string",
            "description": "Meta review status.",
            "enum": [
              "APPROVED",
              "PENDING",
              "REJECTED"
            ]
          },
          "components": {
            "type": "string",
            "description": "Meta components of the template (header, body, footer, buttons, carousel cards) as a JSON string. Tells you which parameters the template needs."
          },
          "createdAt": {
            "type": "string",
            "description": "Creation time.",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "description": "Last update.",
            "format": "date-time"
          }
        }
      },
      "TextTemplateMessage": {
        "type": "object",
        "title": "Text and media template",
        "description": "Template with variables in the body and an optional header, which can be text, media or location. Quick-reply and static buttons need no parameters. Also used for authentication (verification code) templates: send the code as the only item of `templateParams`.",
        "required": [
          "userHost",
          "userGuest"
        ],
        "properties": {
          "appUUID": {
            "type": "string",
            "description": "Your app id. Always send it (when missing, Biky infers it from `userHost` only if the caller is an agent of that app)."
          },
          "companyUUID": {
            "type": "string",
            "description": "Your company id."
          },
          "userHost": {
            "type": "string",
            "description": "Your WhatsApp line in E.164 format, as listed in `GET /config/channels` (`whatsapp.accounts[].userHost`)."
          },
          "userGuest": {
            "type": "string",
            "description": "WhatsApp number of the contact in E.164 format. Biky reuses the conversation with this contact on `userHost`, or creates it (and the contact) if it doesn't exist."
          },
          "templateId": {
            "type": "string",
            "description": "`templateId` from `GET /template` (Meta's `metaTemplateId` also works). Send `templateId` (recommended) or `templateName`."
          },
          "templateName": {
            "type": "string",
            "description": "Template name, as an alternative to `templateId`."
          },
          "templateParams": {
            "type": "array",
            "description": "Values for the body variables `{{1}}`, `{{2}}`…, in order. Must have exactly as many items as the body has variables (`[]` if none).",
            "items": {
              "type": "string"
            }
          },
          "advisorId": {
            "type": "string",
            "description": "`userId` of the agent who sends the template (`GET /adviser`). The conversation is assigned to that agent. If omitted (or not an active agent), a conversation that already has an agent keeps it; otherwise it goes to the app's AI agent or bot, or stays closed until the contact replies."
          },
          "inbox": {
            "type": "string",
            "description": "Key of the space to put the conversation in (`GET /inbox`). With `advisorId`, the agent must belong to that space."
          },
          "origin": {
            "$ref": "#/components/schemas/MessageOrigin"
          },
          "headerParams": {
            "type": "array",
            "description": "Values for the variables of a text header, in order.",
            "items": {
              "type": "string"
            }
          },
          "mediaParams": {
            "type": "array",
            "description": "Public URL of the header image, video or document. Required when the template has a media header.",
            "items": {
              "type": "string",
              "format": "uri"
            }
          },
          "locationParams": {
            "type": "object",
            "description": "Location of a `LOCATION` header. Required for those templates.",
            "required": [
              "latitude",
              "longitude"
            ],
            "properties": {
              "latitude": {
                "type": "string",
                "description": "Latitude.",
                "example": "4.6533"
              },
              "longitude": {
                "type": "string",
                "description": "Longitude.",
                "example": "-74.0836"
              },
              "name": {
                "type": "string",
                "description": "Name of the place."
              },
              "address": {
                "type": "string",
                "description": "Address."
              }
            }
          }
        },
        "additionalProperties": false
      },
      "ButtonTemplateMessage": {
        "type": "object",
        "title": "Template with a dynamic URL button",
        "description": "Template with a URL button whose link ends in a variable.",
        "required": [
          "userHost",
          "userGuest",
          "buttonParams"
        ],
        "properties": {
          "appUUID": {
            "type": "string",
            "description": "Your app id. Always send it (when missing, Biky infers it from `userHost` only if the caller is an agent of that app)."
          },
          "companyUUID": {
            "type": "string",
            "description": "Your company id."
          },
          "userHost": {
            "type": "string",
            "description": "Your WhatsApp line in E.164 format, as listed in `GET /config/channels` (`whatsapp.accounts[].userHost`)."
          },
          "userGuest": {
            "type": "string",
            "description": "WhatsApp number of the contact in E.164 format. Biky reuses the conversation with this contact on `userHost`, or creates it (and the contact) if it doesn't exist."
          },
          "templateId": {
            "type": "string",
            "description": "`templateId` from `GET /template` (Meta's `metaTemplateId` also works). Send `templateId` (recommended) or `templateName`."
          },
          "templateName": {
            "type": "string",
            "description": "Template name, as an alternative to `templateId`."
          },
          "templateParams": {
            "type": "array",
            "description": "Values for the body variables `{{1}}`, `{{2}}`…, in order. Must have exactly as many items as the body has variables (`[]` if none).",
            "items": {
              "type": "string"
            }
          },
          "advisorId": {
            "type": "string",
            "description": "`userId` of the agent who sends the template (`GET /adviser`). The conversation is assigned to that agent. If omitted (or not an active agent), a conversation that already has an agent keeps it; otherwise it goes to the app's AI agent or bot, or stays closed until the contact replies."
          },
          "inbox": {
            "type": "string",
            "description": "Key of the space to put the conversation in (`GET /inbox`). With `advisorId`, the agent must belong to that space."
          },
          "origin": {
            "$ref": "#/components/schemas/MessageOrigin"
          },
          "headerParams": {
            "type": "array",
            "description": "Values for the variables of a text header, in order.",
            "items": {
              "type": "string"
            }
          },
          "mediaParams": {
            "type": "array",
            "description": "Public URL of the header image, video or document. Required when the template has a media header.",
            "items": {
              "type": "string",
              "format": "uri"
            }
          },
          "locationParams": {
            "type": "object",
            "description": "Location of a `LOCATION` header. Required for those templates.",
            "required": [
              "latitude",
              "longitude"
            ],
            "properties": {
              "latitude": {
                "type": "string",
                "description": "Latitude.",
                "example": "4.6533"
              },
              "longitude": {
                "type": "string",
                "description": "Longitude.",
                "example": "-74.0836"
              },
              "name": {
                "type": "string",
                "description": "Name of the place."
              },
              "address": {
                "type": "string",
                "description": "Address."
              }
            }
          },
          "buttonParams": {
            "type": "array",
            "description": "Value that completes the template's dynamic URL button (the `{{1}}` at the end of its URL). In authentication templates, the code (optional: it defaults to the code in `templateParams`).",
            "items": {
              "type": "string"
            }
          }
        },
        "additionalProperties": false
      },
      "MultiProductTemplateMessage": {
        "type": "object",
        "title": "Multi-product template",
        "description": "Template with a «View items» button that opens a list of catalog products. Only for lines connected through WhatsApp Cloud API (`provider: KB_WHATSAPP`).",
        "required": [
          "userHost",
          "userGuest",
          "mpmDetails"
        ],
        "properties": {
          "appUUID": {
            "type": "string",
            "description": "Your app id. Always send it (when missing, Biky infers it from `userHost` only if the caller is an agent of that app)."
          },
          "companyUUID": {
            "type": "string",
            "description": "Your company id."
          },
          "userHost": {
            "type": "string",
            "description": "Your WhatsApp line in E.164 format, as listed in `GET /config/channels` (`whatsapp.accounts[].userHost`)."
          },
          "userGuest": {
            "type": "string",
            "description": "WhatsApp number of the contact in E.164 format. Biky reuses the conversation with this contact on `userHost`, or creates it (and the contact) if it doesn't exist."
          },
          "templateId": {
            "type": "string",
            "description": "`templateId` from `GET /template` (Meta's `metaTemplateId` also works). Send `templateId` (recommended) or `templateName`."
          },
          "templateName": {
            "type": "string",
            "description": "Template name, as an alternative to `templateId`."
          },
          "templateParams": {
            "type": "array",
            "description": "Values for the body variables `{{1}}`, `{{2}}`…, in order. Must have exactly as many items as the body has variables (`[]` if none).",
            "items": {
              "type": "string"
            }
          },
          "advisorId": {
            "type": "string",
            "description": "`userId` of the agent who sends the template (`GET /adviser`). The conversation is assigned to that agent. If omitted (or not an active agent), a conversation that already has an agent keeps it; otherwise it goes to the app's AI agent or bot, or stays closed until the contact replies."
          },
          "inbox": {
            "type": "string",
            "description": "Key of the space to put the conversation in (`GET /inbox`). With `advisorId`, the agent must belong to that space."
          },
          "origin": {
            "$ref": "#/components/schemas/MessageOrigin"
          },
          "headerParams": {
            "type": "array",
            "description": "Values for the variables of a text header, in order.",
            "items": {
              "type": "string"
            }
          },
          "mpmDetails": {
            "type": "object",
            "description": "Products of a multi-product template, from a Meta catalog linked to the line (`GET /config/whatsapp/{appUUID}/phone/{phoneNumber}/catalog`).",
            "required": [
              "catalogId",
              "thumbnailProductRetailerId",
              "sections"
            ],
            "properties": {
              "catalogId": {
                "type": "string",
                "description": "Catalog `id`."
              },
              "thumbnailProductRetailerId": {
                "type": "string",
                "description": "`retailer_id` of the product whose image is shown in the message."
              },
              "sections": {
                "type": "array",
                "description": "Sections of the product list (Meta allows up to 10 sections and 30 products).",
                "items": {
                  "type": "object",
                  "required": [
                    "title",
                    "productItems"
                  ],
                  "properties": {
                    "title": {
                      "type": "string",
                      "description": "Section title."
                    },
                    "productItems": {
                      "type": "array",
                      "description": "Products of the section.",
                      "items": {
                        "type": "object",
                        "required": [
                          "productRetailerId"
                        ],
                        "properties": {
                          "productRetailerId": {
                            "type": "string",
                            "description": "Product `retailer_id`."
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "additionalProperties": false
      },
      "CarouselTemplateMessage": {
        "type": "object",
        "title": "Carousel template",
        "description": "Template with a message bubble (`templateParams`) followed by horizontally scrollable cards, each with its own media header, body and buttons.",
        "required": [
          "userHost",
          "userGuest",
          "cardsParams"
        ],
        "properties": {
          "appUUID": {
            "type": "string",
            "description": "Your app id. Always send it (when missing, Biky infers it from `userHost` only if the caller is an agent of that app)."
          },
          "companyUUID": {
            "type": "string",
            "description": "Your company id."
          },
          "userHost": {
            "type": "string",
            "description": "Your WhatsApp line in E.164 format, as listed in `GET /config/channels` (`whatsapp.accounts[].userHost`)."
          },
          "userGuest": {
            "type": "string",
            "description": "WhatsApp number of the contact in E.164 format. Biky reuses the conversation with this contact on `userHost`, or creates it (and the contact) if it doesn't exist."
          },
          "templateId": {
            "type": "string",
            "description": "`templateId` from `GET /template` (Meta's `metaTemplateId` also works). Send `templateId` (recommended) or `templateName`."
          },
          "templateName": {
            "type": "string",
            "description": "Template name, as an alternative to `templateId`."
          },
          "templateParams": {
            "type": "array",
            "description": "Values for the body variables `{{1}}`, `{{2}}`…, in order. Must have exactly as many items as the body has variables (`[]` if none).",
            "items": {
              "type": "string"
            }
          },
          "advisorId": {
            "type": "string",
            "description": "`userId` of the agent who sends the template (`GET /adviser`). The conversation is assigned to that agent. If omitted (or not an active agent), a conversation that already has an agent keeps it; otherwise it goes to the app's AI agent or bot, or stays closed until the contact replies."
          },
          "inbox": {
            "type": "string",
            "description": "Key of the space to put the conversation in (`GET /inbox`). With `advisorId`, the agent must belong to that space."
          },
          "origin": {
            "$ref": "#/components/schemas/MessageOrigin"
          },
          "cardsParams": {
            "type": "array",
            "description": "One entry per card, in the order of the template's cards.",
            "items": {
              "type": "object",
              "properties": {
                "headerCardParams": {
                  "type": "array",
                  "description": "Public URL of the card's image or video.",
                  "items": {
                    "type": "string",
                    "format": "uri"
                  }
                },
                "bodyCardParams": {
                  "type": "array",
                  "description": "Values for the card body variables, in order.",
                  "items": {
                    "type": "string"
                  }
                },
                "buttonCardParams": {
                  "type": "array",
                  "description": "One entry per button of the card, in order: the values of that button (e.g. the suffix of a dynamic URL). Use `[]` for buttons without variables, such as quick replies.",
                  "items": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "additionalProperties": false
      },
      "SendTemplateRequest": {
        "description": "Body of `POST /message/proactivity`. Pick the shape that matches the template.",
        "oneOf": [
          {
            "$ref": "#/components/schemas/TextTemplateMessage"
          },
          {
            "$ref": "#/components/schemas/ButtonTemplateMessage"
          },
          {
            "$ref": "#/components/schemas/MultiProductTemplateMessage"
          },
          {
            "$ref": "#/components/schemas/CarouselTemplateMessage"
          }
        ]
      },
      "SendTemplateResult": {
        "type": "object",
        "properties": {
          "item": {
            "type": "object",
            "properties": {
              "success": {
                "type": "boolean",
                "description": "Always `true` when queued."
              },
              "message": {
                "type": "string",
                "description": "`OK`."
              },
              "roomId": {
                "type": "string",
                "description": "Conversation the template was sent in (new or existing)."
              },
              "messageId": {
                "type": "string",
                "description": "Id of the template message. Follow its delivery with `GET /message` or the `updateMessage` webhook event."
              }
            }
          }
        }
      },
      "AgentMessageRequest": {
        "type": "object",
        "required": [
          "roomId",
          "appUUID",
          "advisorId",
          "type"
        ],
        "properties": {
          "roomId": {
            "type": "string",
            "description": "Id of the conversation. The contact, line and channel are taken from it."
          },
          "appUUID": {
            "type": "string",
            "description": "App id."
          },
          "companyUUID": {
            "type": "string",
            "description": "Company id."
          },
          "advisorId": {
            "type": "string",
            "description": "`userId` of the agent who writes (`GET /adviser`). If the conversation is assigned to another agent, the message fails with `CHAT_TAKEN_BY_ANOTHER_ADVISOR`; if it has no agent, it is assigned to this one."
          },
          "type": {
            "type": "string",
            "description": "Kind of message. `location` uses `typeOptions`; media types use `media`. Stickers (WhatsApp only) must be 512×512 WebP files.",
            "enum": [
              "text",
              "image",
              "audio",
              "video",
              "pdf",
              "doc",
              "docx",
              "xls",
              "xlsx",
              "ppt",
              "pptx",
              "sticker",
              "location"
            ]
          },
          "text": {
            "type": "string",
            "description": "Text, or caption of the media."
          },
          "media": {
            "type": "string",
            "description": "Public URL of the file for media types.",
            "format": "uri"
          },
          "typeOptions": {
            "type": "object",
            "description": "For `type: location`.",
            "properties": {
              "latitude": {
                "type": "string",
                "description": "Latitude."
              },
              "longitude": {
                "type": "string",
                "description": "Longitude."
              },
              "locationName": {
                "type": "string",
                "description": "Name of the place."
              },
              "address": {
                "type": "string",
                "description": "Address."
              }
            }
          },
          "quotedMessageChannelId": {
            "type": "string",
            "description": "`channelId` of a message of the same conversation to reply to it (quote)."
          },
          "channel": {
            "type": "string",
            "description": "Channel of the conversation (`keybe_wp`, `gupshup_wp`, `instagram`, `facebookMessenger`…). Optional: the message always goes through the conversation's channel, but sending it lets Biky convert audio to the format of Instagram and Messenger."
          },
          "origin": {
            "$ref": "#/components/schemas/MessageOrigin"
          }
        }
      },
      "TransferConversationRequest": {
        "type": "object",
        "required": [
          "roomId",
          "agentIdFrom"
        ],
        "properties": {
          "roomId": {
            "type": "string",
            "description": "Id of the conversation."
          },
          "appUUID": {
            "type": "string",
            "description": "App id. When sent, the conversation must belong to that app (recommended)."
          },
          "agentIdFrom": {
            "type": "string",
            "description": "`userId` of the agent who performs the transfer. Must be an active agent of the app."
          },
          "agentIdTo": {
            "type": "string",
            "description": "`userId` of the agent who receives the conversation (state `withAdvisor`)."
          },
          "inbox": {
            "type": "string",
            "description": "Key of the destination space. Without `agentIdTo`, the conversation waits in that space's queue (`readyForAdvisor`). A key that doesn't exist or is inactive falls back to the app's default space."
          },
          "transferToBot": {
            "type": "boolean",
            "description": "`true` to hand the conversation to the app's bot (`withBot`). Fails if the app has no bot configured.",
            "default": false
          },
          "reason": {
            "type": "string",
            "description": "Why it is transferred.",
            "enum": [
              "ai_not_working_well",
              "customer_requested_human",
              "complex_or_urgent_issue",
              "agent_available",
              "technical_problem",
              "other"
            ]
          },
          "explanation": {
            "type": "string",
            "description": "Free text about the transfer."
          }
        }
      },
      "CloseConversationRequest": {
        "type": "object",
        "required": [
          "roomId"
        ],
        "properties": {
          "roomId": {
            "type": "string",
            "description": "Id of the conversation."
          },
          "appUUID": {
            "type": "string",
            "description": "App id. When sent, the conversation must belong to that app (recommended)."
          },
          "responsibleAgentId": {
            "type": "string",
            "description": "`userId` of the agent who closes it. Agents with role `agent` can only close their own conversations. If omitted, the closure is attributed to the agent who had the conversation, or to `IA` when nobody had it."
          },
          "reason": {
            "type": "string",
            "description": "Closing reason: the `_id` of one of the app's closing reasons (typifications, configured in Smart Chat settings), which is replaced by its label and counted in its statistics, or free text."
          }
        }
      },
      "Webhook": {
        "type": "object",
        "description": "A webhook of your app.",
        "properties": {
          "_id": {
            "type": "string",
            "description": "Webhook id."
          },
          "appUUID": {
            "type": "string",
            "description": "App id."
          },
          "url": {
            "type": "string",
            "description": "HTTPS (or HTTP) URL of a public host that receives the events. `localhost` and private IPs are rejected. Unique per app.",
            "format": "uri"
          },
          "tag": {
            "type": "string",
            "description": "Free text to tell your webhooks apart (e.g. the integration name). `GET /v1/webhook` can filter by it."
          },
          "newMessages": {
            "type": "boolean",
            "description": "Send `newMessage` events.",
            "default": true
          },
          "updateMessages": {
            "type": "boolean",
            "description": "Send `updateMessage` events.",
            "default": true
          },
          "senders": {
            "type": "array",
            "description": "Only send events of messages from these senders.",
            "items": {
              "type": "string",
              "enum": [
                "user",
                "advisor",
                "bot",
                "api",
                "internal"
              ]
            },
            "default": [
              "user"
            ]
          },
          "authorizationType": {
            "type": "string",
            "description": "Scheme Biky puts before `token` in the `Authorization` header it sends you, e.g. `Bearer`. Empty = the bare token."
          },
          "hasToken": {
            "type": "boolean",
            "description": "Whether a `token` is configured."
          },
          "isDeleted": {
            "type": "boolean",
            "description": "Always `false` in answers (deleted webhooks are not returned)."
          },
          "createdBy": {
            "type": "object",
            "description": "User (or API key owner) who created it.",
            "properties": {
              "userId": {
                "type": "string",
                "description": "User id."
              },
              "name": {
                "type": "string",
                "description": "First name."
              },
              "lastname": {
                "type": "string",
                "description": "Last name.",
                "nullable": true
              },
              "email": {
                "type": "string",
                "description": "Email.",
                "nullable": true
              }
            }
          },
          "createdAt": {
            "type": "string",
            "description": "Creation time.",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "description": "Last update.",
            "format": "date-time"
          }
        }
      },
      "CreateWebhookRequest": {
        "type": "object",
        "required": [
          "appUUID",
          "url"
        ],
        "properties": {
          "appUUID": {
            "type": "string",
            "description": "App id."
          },
          "url": {
            "type": "string",
            "description": "HTTPS (or HTTP) URL of a public host that receives the events. `localhost` and private IPs are rejected. Unique per app.",
            "format": "uri"
          },
          "tag": {
            "type": "string",
            "description": "Free text to tell your webhooks apart (e.g. the integration name). `GET /v1/webhook` can filter by it."
          },
          "newMessages": {
            "type": "boolean",
            "description": "Send `newMessage` events.",
            "default": true
          },
          "updateMessages": {
            "type": "boolean",
            "description": "Send `updateMessage` events.",
            "default": true
          },
          "senders": {
            "type": "array",
            "description": "Only send events of messages from these senders.",
            "items": {
              "type": "string",
              "enum": [
                "user",
                "advisor",
                "bot",
                "api",
                "internal"
              ]
            },
            "default": [
              "user"
            ]
          },
          "authorizationType": {
            "type": "string",
            "description": "Scheme Biky puts before `token` in the `Authorization` header it sends you, e.g. `Bearer`. Empty = the bare token."
          },
          "token": {
            "type": "string",
            "description": "Secret Biky sends you in the `Authorization` header so you can verify the request. It is stored but never returned (see `hasToken`)."
          }
        }
      },
      "UpdateWebhookRequest": {
        "type": "object",
        "required": [
          "appUUID"
        ],
        "description": "Only the fields you send change.",
        "properties": {
          "appUUID": {
            "type": "string",
            "description": "App that owns the webhook."
          },
          "url": {
            "type": "string",
            "description": "HTTPS (or HTTP) URL of a public host that receives the events. `localhost` and private IPs are rejected. Unique per app.",
            "format": "uri"
          },
          "tag": {
            "type": "string",
            "description": "Free text to tell your webhooks apart (e.g. the integration name). `GET /v1/webhook` can filter by it."
          },
          "newMessages": {
            "type": "boolean",
            "description": "Send `newMessage` events."
          },
          "updateMessages": {
            "type": "boolean",
            "description": "Send `updateMessage` events."
          },
          "senders": {
            "type": "array",
            "description": "Only send events of messages from these senders.",
            "items": {
              "type": "string",
              "enum": [
                "user",
                "advisor",
                "bot",
                "api",
                "internal"
              ]
            }
          },
          "authorizationType": {
            "type": "string",
            "description": "Scheme Biky puts before `token` in the `Authorization` header it sends you, e.g. `Bearer`. Empty = the bare token."
          },
          "token": {
            "type": "string",
            "description": "Secret Biky sends you in the `Authorization` header so you can verify the request. It is stored but never returned (see `hasToken`)."
          }
        }
      },
      "NewMessageWebhookEvent": {
        "type": "object",
        "title": "newMessage",
        "description": "A message was created in a conversation.",
        "required": [
          "type",
          "message",
          "room"
        ],
        "properties": {
          "type": {
            "type": "string",
            "description": "Event type.",
            "enum": [
              "newMessage"
            ]
          },
          "message": {
            "$ref": "#/components/schemas/Message"
          },
          "room": {
            "$ref": "#/components/schemas/Conversation"
          }
        }
      },
      "MessageUpdatedWebhookEvent": {
        "type": "object",
        "title": "updateMessage",
        "description": "A message changed (delivery status, error, reaction, transcription…).",
        "required": [
          "type",
          "message",
          "oldMessage",
          "room"
        ],
        "properties": {
          "type": {
            "type": "string",
            "description": "Event type.",
            "enum": [
              "updateMessage"
            ]
          },
          "message": {
            "$ref": "#/components/schemas/Message"
          },
          "oldMessage": {
            "$ref": "#/components/schemas/Message"
          },
          "room": {
            "$ref": "#/components/schemas/Conversation"
          }
        }
      },
      "WebhookEvent": {
        "description": "Body of the `POST` Biky sends to your webhook. `message` is the message (in `updateMessage`, its new version and `oldMessage` the previous one); `room` is the conversation as it is when the event is delivered.",
        "oneOf": [
          {
            "$ref": "#/components/schemas/NewMessageWebhookEvent"
          },
          {
            "$ref": "#/components/schemas/MessageUpdatedWebhookEvent"
          }
        ],
        "discriminator": {
          "propertyName": "type",
          "mapping": {
            "newMessage": "#/components/schemas/NewMessageWebhookEvent",
            "updateMessage": "#/components/schemas/MessageUpdatedWebhookEvent"
          }
        }
      },
      "WhatsappLine": {
        "type": "object",
        "properties": {
          "provider": {
            "type": "string",
            "description": "`KB_WHATSAPP` (WhatsApp Cloud API) or `GP_WHATSAPP` (Gupshup).",
            "enum": [
              "KB_WHATSAPP",
              "GP_WHATSAPP"
            ]
          },
          "userHost": {
            "type": "string",
            "description": "Number of the line, in E.164 format. Use it as `userHost` to send templates."
          },
          "config": {
            "type": "object",
            "description": "Public settings of the line (credentials are never returned).",
            "additionalProperties": true,
            "properties": {
              "appUUID": {
                "type": "string",
                "description": "App id."
              },
              "name": {
                "type": "string",
                "description": "Name of the line."
              },
              "wabaId": {
                "type": "string",
                "description": "WhatsApp Business Account id."
              },
              "phoneId": {
                "type": "string",
                "description": "Meta phone number id."
              },
              "verified_name": {
                "type": "string",
                "description": "Display name approved by Meta."
              },
              "quality_rating": {
                "type": "string",
                "description": "Quality rating from Meta (`GREEN`, `YELLOW`, `RED`)."
              },
              "enable": {
                "type": "boolean",
                "description": "Active."
              }
            }
          }
        }
      },
      "ChannelsConfig": {
        "type": "object",
        "properties": {
          "facebookMessenger": {
            "type": "object",
            "nullable": true,
            "additionalProperties": true,
            "description": "Connected Facebook page, or `null`.",
            "properties": {
              "page_id": {
                "type": "array",
                "description": "Page ids.",
                "items": {
                  "type": "string"
                }
              },
              "pageName": {
                "type": "string",
                "description": "Page name."
              },
              "enable": {
                "type": "boolean",
                "description": "Active."
              }
            }
          },
          "instagram": {
            "type": "object",
            "nullable": true,
            "additionalProperties": true,
            "description": "Connected Instagram account, or `null`.",
            "properties": {
              "instagram_id": {
                "type": "string",
                "description": "Instagram account id."
              },
              "page_id": {
                "type": "string",
                "description": "Linked Facebook page id."
              },
              "pageName": {
                "type": "string",
                "description": "Name."
              },
              "enable": {
                "type": "boolean",
                "description": "Active."
              }
            }
          },
          "whatsapp": {
            "type": "object",
            "properties": {
              "hasWhatsappProvider": {
                "type": "boolean",
                "description": "Whether the app has at least one WhatsApp line."
              },
              "accounts": {
                "type": "array",
                "description": "Active WhatsApp lines.",
                "items": {
                  "$ref": "#/components/schemas/WhatsappLine"
                }
              }
            }
          }
        }
      },
      "WhatsappCatalog": {
        "type": "object",
        "description": "Meta commerce catalog (fields as returned by Meta's Graph API).",
        "additionalProperties": true,
        "properties": {
          "id": {
            "type": "string",
            "description": "Catalog id: the `mpmDetails.catalogId` of multi-product templates."
          },
          "name": {
            "type": "string",
            "description": "Name."
          },
          "vertical": {
            "type": "string",
            "description": "Meta vertical."
          },
          "product_count": {
            "type": "integer",
            "description": "Number of products."
          },
          "business": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "description": "Business id."
              },
              "name": {
                "type": "string",
                "description": "Business name."
              }
            }
          },
          "products": {
            "type": "object",
            "properties": {
              "data": {
                "type": "array",
                "description": "All products of the catalog.",
                "items": {
                  "type": "object",
                  "additionalProperties": true,
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Meta product id."
                    },
                    "name": {
                      "type": "string",
                      "description": "Name."
                    },
                    "retailer_id": {
                      "type": "string",
                      "description": "Your SKU: the `productRetailerId` of multi-product templates."
                    },
                    "price": {
                      "type": "string",
                      "description": "Formatted price."
                    },
                    "availability": {
                      "type": "string",
                      "description": "Availability."
                    },
                    "condition": {
                      "type": "string",
                      "description": "Condition."
                    },
                    "image_url": {
                      "type": "string",
                      "description": "Image URL."
                    },
                    "review_status": {
                      "type": "string",
                      "description": "Meta review status."
                    }
                  }
                }
              }
            }
          }
        }
      },
      "Group": {
        "type": "object",
        "properties": {
          "_id": {
            "type": "string",
            "description": "Group id."
          },
          "label": {
            "type": "string",
            "description": "Name."
          },
          "key": {
            "type": "string",
            "description": "Identifier generated from the label when the group is created (lowercase, spaces → `_`). Spaces reference the group by this key in `groups`. Renaming the group doesn't change it."
          },
          "appUUID": {
            "type": "string",
            "description": "App id."
          },
          "isDeleted": {
            "type": "boolean",
            "description": "Always `false` in answers."
          },
          "createdAt": {
            "type": "string",
            "description": "Creation time.",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "description": "Last update.",
            "format": "date-time"
          },
          "__v": {
            "type": "integer",
            "description": "Internal version."
          }
        }
      }
    }
  }
}
