{
  "openapi": "3.0.3",
  "info": {
    "title": "Cekat Open API",
    "version": "1.0.0"
  },
  "servers": null,
  "security": null,
  "components": {
    "schemas": {
      "Error": {
        "type": "object",
        "description": "Error body returned by the `/templates` endpoints.",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "status_code": {
            "type": "integer"
          },
          "error": {
            "type": "object",
            "properties": {
              "message": {
                "type": "string"
              }
            }
          }
        }
      },
      "ApiError": {
        "type": "object",
        "description": "Error body returned by the `/api/...` endpoints.",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "message": {
            "type": "string"
          },
          "statusCode": {
            "type": "integer"
          },
          "error": {
            "type": "object",
            "properties": {
              "message": {
                "type": "string"
              }
            }
          },
          "correlationId": {
            "type": "string",
            "description": "Request ID. Include it when contacting Cekat support."
          }
        }
      },
      "RateLimitError": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string"
          }
        }
      },
      "Pagination": {
        "type": "object",
        "properties": {
          "current_page": {
            "type": "integer"
          },
          "total_page": {
            "type": "integer"
          },
          "total_items": {
            "type": "integer"
          }
        }
      },
      "TemplateInbox": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "type": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "business_id": {
            "type": "string",
            "format": "uuid"
          }
        }
      },
      "Inbox": {
        "type": "object",
        "description": "A connected channel (inbox).",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "Inbox ID. Use it as `inbox_id` in other endpoints."
          },
          "business_id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "phone_number": {
            "type": "string",
            "nullable": true,
            "description": "The channel's phone number, for WhatsApp inboxes."
          },
          "type": {
            "type": "string",
            "description": "Channel type.",
            "enum": [
              "whatsapp",
              "whatsapp_mobile",
              "livechat",
              "instagram",
              "messenger",
              "tokopedia",
              "shopee",
              "custom_api",
              "instagram_comment",
              "facebook_comment",
              "email",
              "tiktok_business_messaging",
              "google_play_review"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "inactive",
              "processing"
            ]
          },
          "is_whatsapp_coexistence": {
            "type": "boolean",
            "nullable": true,
            "description": "True when the WhatsApp number is also used in the WhatsApp Business app (coexistence)."
          },
          "auto_reassign": {
            "type": "boolean",
            "nullable": true
          },
          "ai_agent_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "description": "AI agent assigned to the inbox, if any."
          },
          "ai_agent_name": {
            "type": "string",
            "nullable": true
          },
          "flow_mode": {
            "type": "boolean",
            "nullable": true,
            "description": "True when the inbox replies with a flow instead of an AI agent."
          },
          "flow_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "flow_name": {
            "type": "string",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "description": "Creation time. ISO 8601 UTC with `version=2026-05-22` or later; otherwise Asia/Jakarta local time without an offset."
          }
        }
      },
      "Template": {
        "type": "object",
        "description": "A WhatsApp message template. Additional fields may be present.",
        "additionalProperties": true,
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "Cekat's internal template ID."
          },
          "created_at": {
            "type": "string",
            "description": "Creation time. See **Versioning** for the format."
          },
          "wa_template_id": {
            "type": "string",
            "description": "Meta's template ID. Use this value to send, delete, or run a campaign with the template."
          },
          "name": {
            "type": "string"
          },
          "category": {
            "type": "string",
            "enum": [
              "AUTHENTICATION",
              "MARKETING",
              "UTILITY"
            ]
          },
          "language": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "description": "Meta review status, for example `APPROVED`, `PENDING`, or `REJECTED`. Only `APPROVED` templates can be sent."
          },
          "body": {
            "type": "string"
          },
          "body_placeholder": {
            "type": "array",
            "nullable": true,
            "description": "Sample values for the body variables, as submitted to Meta.",
            "items": {
              "type": "string"
            }
          },
          "header_type": {
            "type": "string",
            "nullable": true,
            "enum": [
              "TEXT",
              "DOCUMENT",
              "IMAGE",
              "VIDEO",
              null
            ]
          },
          "header": {
            "type": "string",
            "nullable": true,
            "description": "Header text, for templates with a text header."
          },
          "file_url": {
            "type": "string",
            "nullable": true,
            "description": "URL of the header media, for templates with a media header."
          },
          "footer": {
            "type": "string",
            "nullable": true
          },
          "buttons": {
            "type": "array",
            "nullable": true,
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "inbox_id": {
            "type": "string",
            "format": "uuid"
          },
          "business_id": {
            "type": "string",
            "format": "uuid"
          },
          "inbox": {
            "$ref": "#/components/schemas/TemplateInbox"
          }
        }
      },
      "RecipientList": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "total_contacts": {
            "type": "integer",
            "description": "Number of contacts imported into the list so far."
          }
        }
      },
      "CampaignListItem": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "Campaign ID."
          },
          "campaign_name": {
            "type": "string"
          },
          "inbox_id": {
            "type": "string",
            "format": "uuid"
          },
          "inbox_name": {
            "type": "string"
          },
          "template_id": {
            "type": "string",
            "format": "uuid",
            "description": "Cekat's internal template ID. This is not the `wa_template_id` used when creating a campaign."
          },
          "template_name": {
            "type": "string"
          },
          "template_category": {
            "type": "string"
          },
          "recipient_list_id": {
            "type": "string",
            "format": "uuid"
          },
          "recipient_list_name": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "scheduled",
              "processing",
              "completed",
              "partially completed",
              "failed"
            ]
          },
          "send_at": {
            "type": "string",
            "format": "date-time",
            "description": "When the campaign starts (or started) sending."
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "total_recipient": {
            "type": "integer",
            "description": "Number of recipients the campaign targets."
          },
          "total": {
            "type": "integer",
            "description": "Number of campaign messages created so far."
          },
          "sent": {
            "type": "integer",
            "description": "Messages whose latest status is `sent`."
          },
          "delivered": {
            "type": "integer",
            "description": "Messages whose latest status is `delivered` (not yet read)."
          },
          "read": {
            "type": "integer",
            "description": "Messages whose latest status is `read`."
          },
          "failed": {
            "type": "integer",
            "description": "Messages that failed to send."
          },
          "replied": {
            "type": "integer",
            "description": "Recipients who replied after receiving the message."
          },
          "buttonClicked": {
            "type": "integer",
            "description": "Recipients who tapped a template button."
          },
          "agentReplied": {
            "type": "integer",
            "description": "Conversations where an agent replied after the campaign message."
          }
        }
      },
      "CampaignMessage": {
        "type": "object",
        "description": "One recipient's campaign message and what happened to it. Empty strings mean \"not available\".",
        "properties": {
          "id": {
            "type": "string",
            "description": "Message ID."
          },
          "campaign_id": {
            "type": "string",
            "format": "uuid"
          },
          "campaign_name": {
            "type": "string"
          },
          "conversation_id": {
            "type": "string"
          },
          "phone_number": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "message": {
            "type": "string",
            "description": "The text that was sent, with variables filled in."
          },
          "media_type": {
            "type": "string"
          },
          "media_url": {
            "type": "string"
          },
          "template_category": {
            "type": "string"
          },
          "sent_by": {
            "type": "string"
          },
          "sent_by_name": {
            "type": "string"
          },
          "sent_by_type": {
            "type": "string"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "date_sent": {
            "type": "string",
            "description": "When the message was sent; empty if it has not been sent."
          },
          "last_status": {
            "type": "string",
            "description": "Latest delivery status, for example `sent`, `delivered`, `read`, or `failed`."
          },
          "last_status_at": {
            "type": "string"
          },
          "sent": {
            "type": "boolean"
          },
          "delivered": {
            "type": "boolean"
          },
          "read": {
            "type": "boolean"
          },
          "failed": {
            "type": "boolean"
          },
          "error": {
            "type": "string",
            "description": "Failure reason when `failed` is true."
          },
          "replied": {
            "type": "boolean"
          },
          "is_replied": {
            "type": "boolean",
            "description": "Same as `replied`."
          },
          "button_clicked": {
            "type": "boolean"
          },
          "agent_replied": {
            "type": "boolean"
          },
          "first_reply_id": {
            "type": "string"
          },
          "first_reply_message": {
            "type": "string"
          },
          "first_reply_sent_by": {
            "type": "string"
          },
          "first_reply_sent_by_name": {
            "type": "string"
          },
          "first_reply_media_url": {
            "type": "string"
          },
          "first_reply_media_type": {
            "type": "string"
          },
          "first_reply_created_at": {
            "type": "string"
          }
        }
      },
      "CampaignMessageLegacy": {
        "type": "object",
        "additionalProperties": true,
        "properties": {
          "id": {
            "type": "string"
          },
          "campaign_id": {
            "type": "string",
            "format": "uuid"
          },
          "conversation_id": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "description": "Latest delivery status, for example `sent`, `delivered`, `read`, or `failed`."
          },
          "created_at": {
            "type": "string",
            "description": "ISO 8601 UTC with `version=2026-05-22` or later; otherwise `YYYY-MM-DD HH:mm:ss` in Asia/Jakarta time."
          },
          "media_type": {
            "type": "string"
          },
          "media_url": {
            "type": "string",
            "nullable": true
          },
          "sent_by": {
            "type": "string"
          },
          "sent_by_name": {
            "type": "string"
          },
          "sent_by_type": {
            "type": "string"
          },
          "additional_data": {
            "type": "object",
            "additionalProperties": true,
            "description": "Includes the recipient as `to_phone` and `to_name`."
          },
          "error": {
            "nullable": true
          },
          "is_replied": {
            "type": "boolean"
          },
          "first_reply": {
            "type": "object",
            "nullable": true,
            "properties": {
              "id": {
                "type": "string"
              },
              "message": {
                "type": "string"
              },
              "created_at": {
                "type": "string"
              },
              "media_type": {
                "type": "string"
              },
              "media_url": {
                "type": "string",
                "nullable": true
              },
              "sent_by": {
                "type": "string"
              },
              "sent_by_name": {
                "type": "string"
              }
            }
          },
          "business_id": {
            "type": "string",
            "format": "uuid"
          }
        }
      },
      "SentMessage": {
        "type": "object",
        "additionalProperties": true,
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "Message ID."
          },
          "message": {
            "type": "string",
            "description": "The text that was sent, with variables filled in."
          },
          "conversation_id": {
            "type": "string",
            "format": "uuid"
          },
          "status": {
            "type": "string",
            "enum": [
              "sent",
              "failed"
            ]
          },
          "error": {
            "type": "string",
            "nullable": true,
            "description": "Why the message failed, when `status` is `failed`."
          },
          "platform_mid": {
            "type": "string",
            "nullable": true,
            "description": "WhatsApp message ID returned by Meta."
          },
          "media_type": {
            "type": "string"
          },
          "media_url": {
            "type": "string",
            "nullable": true
          },
          "is_template": {
            "type": "boolean"
          },
          "template_id": {
            "type": "string",
            "description": "The template's `wa_template_id`."
          },
          "template_category": {
            "type": "string"
          },
          "sent_by": {
            "type": "string",
            "description": "ID of the agent the message is sent as."
          },
          "sent_by_name": {
            "type": "string"
          },
          "sent_by_type": {
            "type": "string"
          },
          "additional_data": {
            "type": "object",
            "nullable": true,
            "additionalProperties": true,
            "description": "Billing details for the message."
          },
          "business_id": {
            "type": "string",
            "format": "uuid"
          }
        }
      },
      "TemplateBilling": {
        "type": "object",
        "additionalProperties": true,
        "properties": {
          "billing_mode": {
            "type": "string",
            "description": "How the message is billed, for example `credit_card` or `credit_line_prepaid`."
          },
          "is_balance_locked": {
            "type": "boolean",
            "description": "True when balance was reserved for this message."
          },
          "estimated_price": {
            "type": "number"
          },
          "currency_code": {
            "type": "string"
          },
          "to_country_code": {
            "type": "string",
            "nullable": true
          },
          "template_id": {
            "type": "string"
          },
          "template_category": {
            "type": "string"
          },
          "inbox_id": {
            "type": "string",
            "format": "uuid"
          },
          "wa_business_id": {
            "type": "string",
            "nullable": true
          },
          "billing_settlement_status": {
            "type": "string",
            "nullable": true
          },
          "billing_lock_reference_type": {
            "type": "string",
            "nullable": true
          },
          "billing_lock_reference_id": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "CrmConflictError": {
        "type": "object",
        "description": "Returned when the email or phone number already belongs to another contact.",
        "properties": {
          "statusCode": {
            "type": "integer"
          },
          "error": {
            "type": "object",
            "properties": {
              "phone_error": {
                "type": "string"
              },
              "email_error": {
                "type": "string"
              },
              "contact_id": {
                "type": "string",
                "format": "uuid",
                "description": "The existing contact with this email, when the email conflicts."
              },
              "contact_name": {
                "type": "string"
              }
            }
          }
        }
      },
      "NamedRef": {
        "type": "object",
        "nullable": true,
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          }
        }
      },
      "ContactListItem": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "contact_name": {
            "type": "string"
          },
          "email": {
            "type": "string",
            "nullable": true
          },
          "phone_number": {
            "type": "string",
            "nullable": true
          },
          "platform_id": {
            "type": "string",
            "nullable": true,
            "description": "The contact's ID on its channel (for example a WhatsApp business-scoped user ID)."
          },
          "username": {
            "type": "string",
            "nullable": true
          },
          "platform": {
            "type": "string",
            "description": "Channel type, for example `whatsapp` or `instagram`."
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "additional_data": {
            "type": "object",
            "nullable": true,
            "additionalProperties": true
          },
          "inboxes": {
            "type": "array",
            "description": "Inboxes the contact has conversations in.",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid"
                },
                "name": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "Contact": {
        "type": "object",
        "description": "A contact with its standard fields, relations and custom property values. Additional fields may be present.",
        "additionalProperties": true,
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "display_name": {
            "type": "string"
          },
          "phone_number": {
            "type": "string",
            "nullable": true
          },
          "country_code": {
            "type": "string",
            "nullable": true
          },
          "email": {
            "type": "string",
            "nullable": true
          },
          "type": {
            "type": "string",
            "description": "Channel the contact came from, for example `whatsapp`."
          },
          "platform_id": {
            "type": "string",
            "nullable": true
          },
          "note": {
            "type": "string",
            "nullable": true
          },
          "additional_data": {
            "type": "object",
            "nullable": true,
            "additionalProperties": true
          },
          "stage_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "agent_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "description": "The contact owner's agent ID."
          },
          "company_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "created_by_name": {
            "type": "string"
          },
          "business": {
            "$ref": "#/components/schemas/NamedRef"
          },
          "stage": {
            "$ref": "#/components/schemas/NamedRef"
          },
          "agent": {
            "$ref": "#/components/schemas/NamedRef"
          },
          "pipeline_status": {
            "$ref": "#/components/schemas/NamedRef"
          },
          "company": {
            "type": "object",
            "nullable": true,
            "additionalProperties": true
          },
          "conversations": {
            "type": "array",
            "description": "The contact's conversations, one per inbox.",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "crm_column": {
            "type": "object",
            "description": "Custom property values, keyed by property (column) name.",
            "additionalProperties": true
          }
        }
      },
      "CrmColumnLabel": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Label ID. Use it as the value for `select` and `dropdown` columns."
          },
          "name": {
            "type": "string"
          },
          "color": {
            "type": "string"
          }
        }
      },
      "CrmColumn": {
        "type": "object",
        "description": "A board column (field) or contact property.",
        "additionalProperties": true,
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "board_id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "enum": [
              "text",
              "long_text",
              "email",
              "phone",
              "number",
              "timeline",
              "date",
              "checkbox",
              "select",
              "dropdown",
              "file",
              "files",
              "reference",
              "references",
              "agents",
              "contacts",
              "conversation",
              "order",
              "orders",
              "companies",
              "subscriptions",
              "item_deals"
            ]
          },
          "settings": {
            "type": "object",
            "additionalProperties": true,
            "description": "Type-specific settings. `select` and `dropdown` columns list their options in `labels`.",
            "properties": {
              "labels": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/CrmColumnLabel"
                }
              }
            }
          },
          "default_value": {
            "type": "string",
            "nullable": true
          },
          "is_required": {
            "type": "boolean"
          },
          "is_visible": {
            "type": "boolean"
          },
          "is_unique": {
            "type": "boolean"
          },
          "read_only": {
            "type": "boolean"
          },
          "position": {
            "type": "number"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        }
      },
      "CrmGroup": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "board_id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "color": {
            "type": "string",
            "nullable": true
          },
          "position": {
            "type": "number"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "CrmBoard": {
        "type": "object",
        "additionalProperties": true,
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "business_id": {
            "type": "string",
            "format": "uuid"
          },
          "icon": {
            "type": "string",
            "nullable": true
          },
          "item_display": {
            "type": "string",
            "nullable": true
          },
          "column_name": {
            "type": "string",
            "description": "Label used for the item name column, for example `Item` or `Deal`."
          },
          "visibility": {
            "type": "string",
            "enum": [
              "public",
              "private",
              "restricted"
            ]
          },
          "position": {
            "type": "number"
          },
          "type": {
            "type": "string"
          },
          "created_by": {
            "nullable": true,
            "description": "The board's creator. An agent ID in the board list, and an object with `id` and `name` in the board details."
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        }
      },
      "CrmBoardDetail": {
        "allOf": [
          {
            "$ref": "#/components/schemas/CrmBoard"
          },
          {
            "type": "object",
            "properties": {
              "crm_groups": {
                "type": "array",
                "nullable": true,
                "items": {
                  "$ref": "#/components/schemas/CrmGroup"
                }
              },
              "crm_columns": {
                "type": "array",
                "nullable": true,
                "items": {
                  "$ref": "#/components/schemas/CrmColumn"
                }
              },
              "crm_board_views": {
                "type": "array",
                "nullable": true,
                "items": {
                  "type": "object",
                  "additionalProperties": true
                }
              },
              "agent_ids": {
                "type": "array",
                "description": "Agents the board is shared with.",
                "items": {
                  "$ref": "#/components/schemas/NamedRef"
                }
              },
              "role_ids": {
                "type": "array",
                "description": "Roles the board is shared with.",
                "items": {
                  "$ref": "#/components/schemas/NamedRef"
                }
              }
            }
          }
        ]
      },
      "CrmItem": {
        "type": "object",
        "description": "A board item. Each column's value appears as an extra field named after the column.",
        "additionalProperties": true,
        "properties": {
          "item_id": {
            "type": "string",
            "format": "uuid"
          },
          "item_name": {
            "type": "string"
          },
          "group_id": {
            "type": "string",
            "format": "uuid"
          },
          "group_name": {
            "type": "string"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "created_by": {
            "description": "The agent who created the item, when known.",
            "nullable": true
          }
        }
      },
      "CrmItemWriteResult": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string",
            "enum": [
              "success",
              "success_with_failures"
            ],
            "description": "`success_with_failures` when some column values were rejected. The item is still saved."
          },
          "failed": {
            "type": "array",
            "description": "Column values that were not saved.",
            "items": {
              "type": "object",
              "properties": {
                "column_name": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                }
              }
            }
          },
          "data": {
            "$ref": "#/components/schemas/CrmItem"
          }
        }
      },
      "QnaDocument": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "question": {
            "type": "string"
          },
          "answer": {
            "type": "string"
          },
          "ai_agent_id": {
            "type": "string",
            "format": "uuid"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        }
      },
      "LegacyInbox": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "business_id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "phone_number": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "type": "string"
          },
          "type": {
            "type": "string"
          },
          "image_url": {
            "type": "string",
            "nullable": true
          },
          "ai_agent_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "ai_agent": {
            "type": "object",
            "nullable": true,
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "name": {
                "type": "string"
              },
              "plugin_type": {
                "type": "string",
                "nullable": true
              }
            }
          }
        }
      },
      "ChatMessage": {
        "type": "object",
        "description": "A message in a conversation. Additional fields may be present.",
        "additionalProperties": true,
        "properties": {
          "id": {
            "type": "string"
          },
          "conversation_id": {
            "type": "string",
            "format": "uuid"
          },
          "message": {
            "type": "string",
            "nullable": true
          },
          "sent_by": {
            "type": "string",
            "nullable": true,
            "description": "ID of the sender (agent, AI agent, contact or `system`)."
          },
          "sent_by_name": {
            "type": "string",
            "nullable": true
          },
          "sent_by_type": {
            "type": "string",
            "description": "Who sent the message, for example `user` (the contact), `agent`, `api` or `system`."
          },
          "media_type": {
            "type": "string",
            "nullable": true
          },
          "media_url": {
            "type": "string",
            "nullable": true
          },
          "platform_mid": {
            "type": "string",
            "nullable": true,
            "description": "The channel's message ID, for example the WhatsApp message ID."
          },
          "status": {
            "type": "string",
            "nullable": true,
            "description": "Delivery status, for example `sent`, `delivered`, `read` or `failed`."
          },
          "is_template": {
            "type": "boolean",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "description": "ISO 8601 UTC with `version=2026-05-22` or later; otherwise `YYYY-MM-DD HH:mm:ss` in Asia/Jakarta time."
          },
          "updated_at": {
            "type": "string",
            "nullable": true
          },
          "chat_credits_used": {
            "type": "number",
            "nullable": true,
            "description": "AI credits used to generate the message, for AI replies."
          },
          "location": {
            "type": "object",
            "nullable": true,
            "additionalProperties": true
          },
          "action": {
            "type": "object",
            "nullable": true,
            "additionalProperties": true
          },
          "additional_data": {
            "type": "object",
            "nullable": true,
            "additionalProperties": true,
            "description": "Extra data, such as the ad referral for messages that came from a click-to-WhatsApp ad."
          },
          "contact": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "display_name": {
                "type": "string"
              },
              "phone_number": {
                "type": "string",
                "nullable": true
              },
              "platform_id": {
                "type": "string",
                "nullable": true
              },
              "username": {
                "type": "string",
                "nullable": true
              },
              "type": {
                "type": "string"
              }
            }
          },
          "inbox": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "business_id": {
                "type": "string",
                "format": "uuid"
              },
              "name": {
                "type": "string"
              },
              "phone_number": {
                "type": "string",
                "nullable": true
              },
              "type": {
                "type": "string"
              }
            }
          }
        }
      },
      "MessageSnippet": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        }
      },
      "ConversationListItem": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "stage_status": {
            "type": "string",
            "enum": [
              "open",
              "pending",
              "assigned",
              "resolved"
            ]
          },
          "inbox_id": {
            "type": "string",
            "format": "uuid"
          },
          "inbox_name": {
            "type": "string"
          },
          "platform_type": {
            "type": "string"
          },
          "contact_id": {
            "type": "string",
            "format": "uuid"
          },
          "contact_name": {
            "type": "string"
          },
          "contact_phone": {
            "type": "string",
            "nullable": true
          },
          "contact_platform_id": {
            "type": "string",
            "nullable": true
          },
          "contact_username": {
            "type": "string",
            "nullable": true
          },
          "handled_by_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "description": "The human agent handling the conversation."
          },
          "handled_by_name": {
            "type": "string",
            "nullable": true
          },
          "resolved_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "resolved_by_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "resolved_by_name": {
            "type": "string",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "notes": {
            "type": "string",
            "nullable": true,
            "description": "The contact's notes."
          },
          "additional_data": {
            "type": "object",
            "nullable": true,
            "additionalProperties": true
          },
          "labels": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid"
                },
                "name": {
                  "type": "string"
                }
              }
            }
          },
          "first_message": {
            "type": "object",
            "properties": {
              "message": {
                "type": "string"
              }
            }
          },
          "last_message": {
            "$ref": "#/components/schemas/MessageSnippet"
          }
        }
      },
      "ConversationDetail": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "stage_status": {
            "type": "string",
            "enum": [
              "open",
              "pending",
              "assigned",
              "resolved"
            ]
          },
          "notes": {
            "type": "string",
            "nullable": true
          },
          "labels": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid"
                },
                "name": {
                  "type": "string"
                },
                "color": {
                  "type": "string"
                }
              }
            }
          },
          "pipeline": {
            "type": "object",
            "nullable": true,
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "name": {
                "type": "string"
              }
            }
          },
          "collaborators": {
            "type": "array",
            "description": "Agents added to the conversation as collaborators.",
            "items": {
              "$ref": "#/components/schemas/NamedRef"
            }
          },
          "inbox_id": {
            "type": "string",
            "format": "uuid"
          },
          "inbox_name": {
            "type": "string"
          },
          "platform_type": {
            "type": "string"
          },
          "contact_id": {
            "type": "string",
            "format": "uuid"
          },
          "contact_name": {
            "type": "string"
          },
          "contact_phone": {
            "type": "string",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "resolved_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "handled_by_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "handled_by_name": {
            "type": "string",
            "nullable": true
          },
          "resolved_by_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "resolved_by_name": {
            "type": "string",
            "nullable": true
          },
          "additional_data": {
            "type": "object",
            "nullable": true,
            "additionalProperties": true
          },
          "first_message": {
            "type": "object",
            "properties": {
              "message": {
                "type": "string"
              }
            }
          },
          "last_message": {
            "type": "object",
            "properties": {
              "message": {
                "type": "string"
              },
              "created_at": {
                "type": "string",
                "format": "date-time",
                "nullable": true
              },
              "sent_by_type": {
                "type": "string",
                "description": "Who sent the last message."
              }
            }
          },
          "last_message_by_human": {
            "type": "object",
            "nullable": true,
            "description": "The last message sent by a human agent, if any.",
            "properties": {
              "message": {
                "type": "string"
              },
              "created_at": {
                "type": "string",
                "format": "date-time"
              },
              "sent_by_type": {
                "type": "string"
              }
            }
          }
        }
      },
      "Agent": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "email": {
            "type": "string"
          },
          "role": {
            "type": "string"
          },
          "is_online": {
            "type": "boolean"
          },
          "created_at": {
            "type": "string",
            "description": "Creation time in Asia/Jakarta local time, without an offset."
          },
          "division": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/NamedRef"
            }
          }
        }
      },
      "AgentV2": {
        "type": "object",
        "description": "An agent. Includes `chat` when `module=chat`, and `crm` otherwise.",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "email": {
            "type": "string"
          },
          "is_verified": {
            "type": "boolean",
            "description": "False when the agent hasn't verified their email yet."
          },
          "chat": {
            "type": "object",
            "properties": {
              "role": {
                "type": "string",
                "nullable": true
              },
              "is_active": {
                "type": "boolean"
              },
              "divisions": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": true
                }
              },
              "inboxes": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "crm": {
            "type": "object",
            "properties": {
              "is_active": {
                "type": "boolean"
              },
              "authority": {
                "type": "string",
                "nullable": true
              },
              "role": {
                "type": "object",
                "nullable": true,
                "additionalProperties": true
              }
            }
          }
        }
      },
      "OrderProduct": {
        "type": "object",
        "additionalProperties": true,
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "product_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "product_name": {
            "type": "string"
          },
          "quantity": {
            "type": "integer"
          },
          "price": {
            "type": "number"
          }
        }
      },
      "Invoice": {
        "type": "object",
        "additionalProperties": true,
        "properties": {
          "id": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "PENDING",
              "PAID",
              "EXPIRED",
              "SETTLED"
            ]
          },
          "amount": {
            "type": "number"
          },
          "payment_link": {
            "type": "string",
            "nullable": true,
            "description": "Xendit payment link, for `xendit` orders."
          },
          "pdf_link": {
            "type": "string",
            "nullable": true,
            "description": "Invoice PDF, or your own invoice URL for `custom` orders."
          },
          "is_sent": {
            "type": "boolean",
            "nullable": true
          },
          "expiry_date": {
            "type": "string",
            "nullable": true
          },
          "paid_at": {
            "type": "string",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "Order": {
        "type": "object",
        "description": "An order with its contact, products and invoices. Additional fields may be present.",
        "additionalProperties": true,
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "order_number": {
            "type": "integer"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "order_status": {
            "type": "string",
            "enum": [
              "pending",
              "processing",
              "shipping",
              "cancelled",
              "completed"
            ]
          },
          "payment_method": {
            "type": "string",
            "enum": [
              "manual",
              "xendit",
              "custom"
            ]
          },
          "subtotal": {
            "type": "number"
          },
          "discount": {
            "type": "number"
          },
          "shipping_fee": {
            "type": "number"
          },
          "vat": {
            "type": "number"
          },
          "grand_total": {
            "type": "number"
          },
          "currency": {
            "type": "string",
            "nullable": true
          },
          "address": {
            "type": "string",
            "nullable": true
          },
          "notes": {
            "type": "string",
            "nullable": true
          },
          "contact_id": {
            "type": "string",
            "format": "uuid"
          },
          "conversation_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "contact": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "display_name": {
                "type": "string"
              },
              "phone_number": {
                "type": "string",
                "nullable": true
              },
              "email": {
                "type": "string",
                "nullable": true
              }
            }
          },
          "cekat_orders_products": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/OrderProduct"
            }
          },
          "invoices": {
            "type": "array",
            "description": "The order's invoices, newest first.",
            "items": {
              "$ref": "#/components/schemas/Invoice"
            }
          }
        }
      },
      "TicketFieldValue": {
        "type": "object",
        "properties": {
          "field_name": {
            "type": "string",
            "description": "The field's name from the ticket template."
          },
          "field_value": {
            "description": "The value. Its format depends on the field type."
          }
        }
      },
      "Ticket": {
        "type": "object",
        "description": "A ticket. List responses also include the template, products and conversation. Additional fields may be present.",
        "additionalProperties": true,
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "public_ticket_id": {
            "type": "integer",
            "description": "The ticket number shown in Cekat."
          },
          "board_id": {
            "type": "string",
            "format": "uuid"
          },
          "ticket_template_id": {
            "type": "string",
            "format": "uuid"
          },
          "title": {
            "type": "string"
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "type": "string",
            "description": "A status ID from the board's `statuses`, or `done`."
          },
          "priority": {
            "type": "integer",
            "enum": [
              0,
              1,
              2,
              3
            ],
            "description": "0 Low, 1 Medium, 2 High, 3 Urgent."
          },
          "field_values": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TicketFieldValue"
            }
          },
          "assigned_to": {
            "type": "array",
            "description": "Agent IDs assigned to the ticket.",
            "items": {
              "type": "string"
            }
          },
          "attachments": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "conversation_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "created_by": {
            "type": "string",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "TicketBoard": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "Board ID. Use it as `board_id`."
          },
          "business_id": {
            "type": "string",
            "format": "uuid"
          },
          "board_name": {
            "type": "string"
          },
          "statuses": {
            "type": "array",
            "description": "The board's statuses. Use a status `id` when creating or updating tickets.",
            "items": {
              "type": "object",
              "additionalProperties": true,
              "properties": {
                "id": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                }
              }
            }
          },
          "default_template_id": {
            "type": "string",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "TicketTemplate": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "Template ID. Use it as `ticket_template_id`."
          },
          "name": {
            "type": "string"
          },
          "board_id": {
            "type": "string",
            "format": "uuid"
          },
          "type": {
            "type": "string",
            "nullable": true
          },
          "default_status": {
            "type": "string",
            "nullable": true,
            "description": "Status used when a ticket is created without one."
          },
          "default_priority": {
            "type": "integer",
            "nullable": true,
            "description": "Priority used when a ticket is created without one."
          },
          "fields": {
            "type": "array",
            "nullable": true,
            "description": "The template's custom fields. Send values for them in `field_values`, using each field's name.",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "business_id": {
            "type": "string",
            "format": "uuid"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "PageLimitPagination": {
        "type": "object",
        "properties": {
          "page": {
            "type": "integer"
          },
          "limit": {
            "type": "integer"
          },
          "total_data": {
            "type": "integer"
          },
          "total_pages": {
            "type": "integer"
          }
        }
      }
    },
    "securitySchemes": {
      "CekatApiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "api_key",
        "description": "Your business's Cekat API key, from **Settings → Developers & API** in the Cekat dashboard (https://chat.cekat.ai/developers?section=apikeys). Available on the Business and Enterprise plans."
      },
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "The same Cekat API key, sent as `Authorization: Bearer YOUR_API_KEY`. Accepted only by endpoints under `/api/...`."
      }
    },
    "parameters": {
      "StartDate": {
        "name": "start_date",
        "in": "query",
        "required": false,
        "description": "Only include items created on or after this date (`YYYY-MM-DD`). Cannot be combined with `start_datetime`.",
        "schema": {
          "type": "string",
          "format": "date"
        }
      },
      "EndDate": {
        "name": "end_date",
        "in": "query",
        "required": false,
        "description": "Only include items created on or before the end of this date (`YYYY-MM-DD`). Cannot be combined with `end_datetime`.",
        "schema": {
          "type": "string",
          "format": "date"
        }
      },
      "StartDatetime": {
        "name": "start_datetime",
        "in": "query",
        "required": false,
        "description": "Only include items created at or after this time (`YYYY-MM-DDTHH:mm:ss`, optional offset such as `+07:00` or `Z`). Cannot be combined with `start_date`.",
        "schema": {
          "type": "string"
        }
      },
      "EndDatetime": {
        "name": "end_datetime",
        "in": "query",
        "required": false,
        "description": "Only include items created at or before this time (`YYYY-MM-DDTHH:mm:ss`, optional offset). Cannot be combined with `end_date`.",
        "schema": {
          "type": "string"
        }
      },
      "UserTimezone": {
        "name": "X-User-Timezone",
        "in": "header",
        "required": false,
        "description": "IANA time zone used to read date filters that have no offset. Defaults to `Asia/Jakarta`.",
        "schema": {
          "type": "string"
        }
      },
      "Version": {
        "name": "version",
        "in": "query",
        "required": false,
        "description": "Response format version in `YYYY-MM-DD` format. Use `2026-05-22` or later to get `created_at` as an ISO 8601 UTC timestamp.",
        "schema": {
          "type": "string",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
        }
      }
    },
    "responses": {
      "ApiBadRequest": {
        "description": "The request is invalid.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ApiError"
            }
          }
        }
      },
      "ApiUnauthorized": {
        "description": "The API key is missing or invalid.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ApiError"
            }
          }
        }
      },
      "TooManyRequests": {
        "description": "Rate limit exceeded. Wait and retry.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/RateLimitError"
            }
          }
        }
      },
      "ApiNotFound": {
        "description": "The resource was not found or does not belong to your business.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ApiError"
            }
          }
        }
      },
      "Unauthorized": {
        "description": "The API key is missing or invalid.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "NotFound": {
        "description": "The resource was not found.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "ServiceUnavailable": {
        "description": "A dependency is temporarily unavailable. Retry later.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ApiError"
            }
          }
        }
      }
    }
  },
  "tags": [
    {
      "name": "Settings",
      "description": "Read your business's agents (team members)."
    },
    {
      "name": "Tickets",
      "description": "Create, list and update support tickets and the products attached to them.\n\nBefore creating tickets, call `GET /api/ticket_settings` to get your ticket boards (each board's `id` is the `board_id`) and their status IDs, and `GET /api/ticket_templates` to get the templates for each board and their fields.\n\nPriority is a number: `0` Low, `1` Medium, `2` High, `3` Urgent. Status is a status `id` from the board's `statuses`, or `done`.\n"
    },
    {
      "name": "Message",
      "description": "Read the messages in your conversations and send WhatsApp messages from the API.\n\nTo start a new conversation, or to message a contact who hasn't written to you in the last 24 hours, use an approved template with `POST /templates/send`. WhatsApp only allows free-form messages (`POST /messages/whatsapp`) within 24 hours of the contact's last message.\n"
    },
    {
      "name": "Connected Platforms",
      "description": "Each connected channel is an inbox. Use an inbox's `id` as `inbox_id` in other endpoints, for example to create or send WhatsApp templates."
    },
    {
      "name": "Broadcast",
      "description": "Use these endpoints to manage WhatsApp message templates, upload recipient lists, and run broadcast campaigns.\n\n## Typical flow\n1. **Create a template** with `POST /templates`. Meta reviews it; its `status` starts as `PENDING`.\n2. **Check approval** with `GET /api/templates`. Only templates with `status: APPROVED` can be sent. If you created or edited templates directly in Meta, call `POST /templates/sync` first to copy them into Cekat.\n3. **Send to one contact** with `POST /templates/send`, or continue below to send to many.\n4. **Upload a recipient list** with `POST /api/recipients`. Contacts are imported in the background; poll `GET /api/recipients` until the list's `total_contacts` matches the number returned by the upload.\n5. **Create a campaign** with `POST /api/campaigns`, using the template's `wa_template_id` as `template_id`. Leave out `schedule_at` to send right away.\n6. **Track results** with `GET /api/campaigns` for totals and `GET /api/v2/campaigns/{id}/messages` for each recipient's delivery status and replies.\n\nEvery step needs the `inbox_id` of a connected WhatsApp inbox. Get it from `GET /api/inboxes` (the `id` of an inbox whose `type` is `whatsapp`).\n"
    },
    {
      "name": "Conversation",
      "description": "A conversation is the chat thread between one contact and one of your inboxes. Use these endpoints to list conversations, read one in detail, see which human agent handled each one, and change the AI agent that replies."
    },
    {
      "name": "Contact",
      "description": "Contacts are the people your business talks to. Each contact has standard fields (name, phone number, email, and so on) plus **custom properties** that you define as columns on your contact board.\n\n## Custom properties\n1. Call `GET /api/crm/contact/filter-fields` or `GET /api/crm/contact/{id}/property` to see the available properties and their column IDs and types.\n2. Read a contact's values from `crm_column` in `GET /api/crm/contact/{contact_id}`. Values are keyed by property name.\n3. Write values with `PUT /api/crm/contact/{id}/property`, or with `values` when creating a contact.\n4. Create new properties with `POST /api/crm/contact/property`.\n"
    },
    {
      "name": "Board",
      "description": "A board is a custom CRM table, such as a deals pipeline. It has **groups** (sections), **columns** (fields), and **items** (rows).\n\n## Item values\nWhen you create or update an item, send each column value as a top-level field named after the column, for example `{\"item_name\": \"Deal A\", \"Status\": \"1\", \"Amount\": 2500000}`. Get column names, types and select options from `GET /api/crm/boards/{id}`.\n\n| Column type | Value format |\n| --- | --- |\n| `text`, `long_text`, `phone` | String |\n| `email` | Email address string |\n| `number` | Number (numeric strings are accepted) |\n| `date` | ISO 8601 date-time with time zone, for example `2026-10-20T09:00:00+07:00` |\n| `timeline` | `{\"from\": \"<ISO date-time>\", \"to\": \"<ISO date-time>\"}` |\n| `checkbox` | `true` or `false` |\n| `select` | One label `id` from the column's `settings.labels` |\n| `dropdown` | Array of label `id`s from the column's `settings.labels` |\n| `agents` | Array of agent IDs |\n| `contacts`, `companies`, `orders`, `subscriptions`, `references` | Array of IDs of those records |\n| `conversation` | Conversation ID |\n| `files` | Array of `{\"file_name\", \"file_url\", \"file_type\"}` objects |\n\nA value that fails validation does not fail the whole request: the item is still saved, `message` is `success_with_failures`, and each rejected value is listed in `failed`.\n"
    },
    {
      "name": "AI",
      "description": "Manage your AI agents' Q&A knowledge, test AI replies, and manage the OrderOnline integration."
    },
    {
      "name": "Orders",
      "description": "Create and manage orders and their invoices. Each order belongs to a contact; Cekat creates the contact if it doesn't exist yet.\n\n| Payment method | Invoice |\n| --- | --- |\n| `manual` | A PDF invoice with your bank account details. Requires `bank_account_number` of a payment bank account set up in Cekat. |\n| `xendit` | A Xendit payment link and PDF invoice. Requires Xendit to be connected. |\n| `custom` | Your own invoice, given as `custom_invoice_url`. |\n\nOrder statuses are `pending`, `processing`, `shipping`, `cancelled` and `completed`. Payment statuses are `PENDING`, `PAID`, `EXPIRED` and `SETTLED`.\n"
    }
  ],
  "paths": {
    "/api/agents": {
      "get": {
        "tags": [
          "Settings"
        ],
        "operationId": "ListAgents",
        "summary": "List agents",
        "description": "Lists your agents (team members), newest first, with their role, online status and divisions. Use `GET /api/agents/v2` to search, sort, or filter by Chat or CRM access.",
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 1
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 10
            }
          },
          {
            "$ref": "#/components/parameters/StartDate"
          },
          {
            "$ref": "#/components/parameters/EndDate"
          },
          {
            "$ref": "#/components/parameters/StartDatetime"
          },
          {
            "$ref": "#/components/parameters/EndDatetime"
          },
          {
            "$ref": "#/components/parameters/UserTimezone"
          }
        ],
        "responses": {
          "200": {
            "description": "A page of agents.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Agent"
                      }
                    },
                    "metadata": {
                      "type": "object",
                      "properties": {
                        "pagination": {
                          "$ref": "#/components/schemas/Pagination"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/ApiBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/ApiUnauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/api/agents/v2": {
      "get": {
        "tags": [
          "Settings"
        ],
        "operationId": "ListAgentsV2",
        "summary": "List agents (v2)",
        "description": "Lists agents with search, sorting, and Chat or CRM access filters. With `module=chat`, each agent includes their Chat role, divisions and inboxes; otherwise their CRM access.",
        "parameters": [
          {
            "name": "search",
            "in": "query",
            "required": false,
            "description": "Matches name or email.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "module",
            "in": "query",
            "required": false,
            "description": "Only agents with access to this module.",
            "schema": {
              "type": "string",
              "enum": [
                "chat",
                "crm"
              ]
            }
          },
          {
            "name": "is_active_other",
            "in": "query",
            "required": false,
            "description": "With `module=chat`, send `crm` to exclude agents who also have CRM access; with `module=crm`, send `chat` to exclude agents who also have Chat access.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sort_by",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "created_at",
                "name",
                "email",
                "is_online"
              ],
              "default": "created_at"
            }
          },
          {
            "name": "sort_order",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "asc",
                "desc"
              ],
              "default": "desc"
            }
          },
          {
            "name": "page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 1
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 20
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A page of agents.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/AgentV2"
                      }
                    },
                    "pagination": {
                      "type": "object",
                      "properties": {
                        "page": {
                          "type": "integer"
                        },
                        "limit": {
                          "type": "integer"
                        },
                        "total": {
                          "type": "integer"
                        },
                        "total_pages": {
                          "type": "integer"
                        }
                      }
                    },
                    "authority_counts": {
                      "type": "object",
                      "description": "With `module=crm`, the number of agents per CRM authority level.",
                      "additionalProperties": {
                        "type": "integer"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "`module`, `sort_by`, `sort_order`, `page` or `limit` is invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/ApiUnauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/api/ticket_settings": {
      "get": {
        "tags": [
          "Tickets"
        ],
        "operationId": "ListTicketBoards",
        "summary": "List ticket boards",
        "description": "Lists your ticket boards with their statuses. Use a board's `id` as `board_id`, and its status IDs when creating or updating tickets.",
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 1
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000,
              "default": 100
            }
          },
          {
            "name": "sort_direction",
            "in": "query",
            "required": false,
            "description": "Sort by creation date.",
            "schema": {
              "type": "string",
              "enum": [
                "asc",
                "desc"
              ],
              "default": "desc"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A page of boards.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/TicketBoard"
                      }
                    },
                    "metadata": {
                      "type": "object",
                      "properties": {
                        "pagination": {
                          "$ref": "#/components/schemas/PageLimitPagination"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/ApiBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/ApiUnauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/api/tickets/create": {
      "post": {
        "tags": [
          "Tickets"
        ],
        "operationId": "CreateTicket",
        "summary": "Create a ticket",
        "description": "Creates a ticket on a board from one of the board's templates. `status` and `priority` default to the template's defaults. If the template has a product field, send the products in `products`.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "title",
                  "board_id",
                  "ticket_template_id"
                ],
                "properties": {
                  "title": {
                    "type": "string"
                  },
                  "board_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "ticket_template_id": {
                    "type": "string",
                    "format": "uuid",
                    "description": "Must belong to `board_id`."
                  },
                  "description": {
                    "type": "string"
                  },
                  "status": {
                    "type": "string",
                    "description": "A status ID from the board. Defaults to the template's default status."
                  },
                  "priority": {
                    "type": "integer",
                    "enum": [
                      0,
                      1,
                      2,
                      3
                    ],
                    "description": "Defaults to the template's default priority."
                  },
                  "field_values": {
                    "type": "array",
                    "description": "Values for the template's fields.",
                    "items": {
                      "$ref": "#/components/schemas/TicketFieldValue"
                    }
                  },
                  "assigned_to": {
                    "type": "array",
                    "description": "Agent IDs to assign.",
                    "items": {
                      "type": "string"
                    }
                  },
                  "conversation_id": {
                    "type": "string",
                    "format": "uuid",
                    "description": "Link the ticket to a conversation."
                  },
                  "attachments": {
                    "type": "array",
                    "description": "Attachment URLs.",
                    "items": {
                      "type": "string"
                    }
                  },
                  "products": {
                    "type": "array",
                    "description": "Products, for templates with a product field.",
                    "items": {
                      "type": "object",
                      "properties": {
                        "product_id": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "quantity": {
                          "type": "integer"
                        },
                        "adjusted_price": {
                          "type": "number"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Ticket created.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/Ticket"
                    },
                    "labels": {
                      "description": "Labels added to the linked conversation by the template, if any."
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "A required field is missing, the template doesn't belong to the board, no status or priority could be set, or a field value or product is invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/ApiUnauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/api/ticket_templates": {
      "get": {
        "tags": [
          "Tickets"
        ],
        "operationId": "ListTicketTemplates",
        "summary": "List ticket templates",
        "description": "Lists your ticket templates with their fields, default status and priority, and board.",
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 1
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000,
              "default": 100
            }
          },
          {
            "name": "sort_direction",
            "in": "query",
            "required": false,
            "description": "Sort by creation date.",
            "schema": {
              "type": "string",
              "enum": [
                "asc",
                "desc"
              ],
              "default": "desc"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A page of templates.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/TicketTemplate"
                      }
                    },
                    "metadata": {
                      "type": "object",
                      "properties": {
                        "pagination": {
                          "$ref": "#/components/schemas/PageLimitPagination"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/ApiBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/ApiUnauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/api/tickets/{id}": {
      "put": {
        "tags": [
          "Tickets"
        ],
        "operationId": "UpdateTicket",
        "summary": "Update a ticket",
        "description": "Updates a ticket. Send only the fields you want to change. `field_values` updates only the fields you include and keeps the others.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "title": {
                    "type": "string"
                  },
                  "description": {
                    "type": "string"
                  },
                  "status": {
                    "type": "string",
                    "description": "A status ID from the ticket's board, or `done`."
                  },
                  "priority": {
                    "type": "integer",
                    "enum": [
                      0,
                      1,
                      2,
                      3
                    ]
                  },
                  "field_values": {
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/TicketFieldValue"
                    }
                  },
                  "assigned_to": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "attachments": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "conversation_id": {
                    "type": "string",
                    "format": "uuid"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Ticket updated. `log` lists the changes recorded in the ticket history.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/Ticket"
                    },
                    "log": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "additionalProperties": true
                      }
                    },
                    "labels": {
                      "description": "Labels added to the linked conversation, if any."
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "The status isn't on the ticket's board, or a field value is invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/ApiUnauthorized"
          },
          "404": {
            "$ref": "#/components/responses/ApiNotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/api/tickets/list": {
      "post": {
        "tags": [
          "Tickets"
        ],
        "operationId": "ListTickets",
        "summary": "List tickets",
        "description": "Lists tickets with search, filters and sorting. Each ticket includes its template, products and conversation.",
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "board_id": {
                    "type": "string",
                    "format": "uuid",
                    "description": "Only tickets on this board."
                  },
                  "search": {
                    "type": "string",
                    "description": "Matches the ticket title."
                  },
                  "filters": {
                    "type": "object",
                    "properties": {
                      "status": {
                        "type": "array",
                        "description": "Status IDs, and/or `done`.",
                        "items": {
                          "type": "string"
                        }
                      },
                      "priority": {
                        "type": "array",
                        "items": {
                          "type": "integer"
                        }
                      },
                      "assigned_to": {
                        "type": "array",
                        "description": "Agent IDs. Matches tickets assigned to all of them.",
                        "items": {
                          "type": "string"
                        }
                      },
                      "created_by": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      },
                      "conversation_id": {
                        "type": "string",
                        "format": "uuid"
                      },
                      "session_id": {
                        "type": "string"
                      },
                      "contact_id": {
                        "type": "string",
                        "format": "uuid"
                      },
                      "company_id": {
                        "type": "string",
                        "format": "uuid"
                      },
                      "created_start_date": {
                        "type": "string",
                        "format": "date-time"
                      },
                      "created_end_date": {
                        "type": "string",
                        "format": "date-time"
                      }
                    }
                  },
                  "sorts": {
                    "type": "object",
                    "properties": {
                      "field": {
                        "type": "string",
                        "enum": [
                          "created_at",
                          "updated_at",
                          "title",
                          "priority",
                          "status"
                        ]
                      },
                      "direction": {
                        "type": "string",
                        "enum": [
                          "asc",
                          "desc"
                        ]
                      }
                    }
                  },
                  "page": {
                    "type": "integer",
                    "minimum": 1,
                    "default": 1
                  },
                  "limit": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 1000,
                    "default": 100
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "A page of tickets.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Ticket"
                      }
                    },
                    "metadata": {
                      "type": "object",
                      "properties": {
                        "pagination": {
                          "$ref": "#/components/schemas/PageLimitPagination"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "`page`, `limit` or `sorts` is invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/ApiUnauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/api/tickets/products": {
      "post": {
        "tags": [
          "Tickets"
        ],
        "operationId": "AddTicketProduct",
        "summary": "Add a product to a ticket",
        "description": "Adds a product to a ticket and lowers the product's stock by the quantity.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "product_id",
                  "ticket_id",
                  "quantity",
                  "adjusted_price"
                ],
                "properties": {
                  "product_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "ticket_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "quantity": {
                    "type": "integer",
                    "minimum": 1
                  },
                  "adjusted_price": {
                    "type": "number",
                    "exclusiveMinimum": true,
                    "minimum": 0,
                    "description": "The price for this ticket."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Product added.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "additionalProperties": true
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "A field is missing or invalid, or the ticket belongs to another business.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/ApiUnauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/api/tickets/products/{id}": {
      "put": {
        "tags": [
          "Tickets"
        ],
        "operationId": "UpdateTicketProduct",
        "summary": "Update a ticket product",
        "description": "Changes the quantity or price of a product on a ticket. Changing the quantity adjusts the product's stock by the difference.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The ticket product ID.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "quantity": {
                    "type": "integer",
                    "minimum": 1
                  },
                  "adjusted_price": {
                    "type": "number",
                    "exclusiveMinimum": true,
                    "minimum": 0
                  }
                }
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Product updated.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "additionalProperties": true
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "`quantity` or `adjusted_price` is invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/ApiUnauthorized"
          },
          "404": {
            "description": "The ticket product was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/messages/whatsapp": {
      "post": {
        "tags": [
          "Message"
        ],
        "operationId": "SendWhatsAppMessage",
        "summary": "Send a WhatsApp message",
        "description": "Sends a free-form WhatsApp message in an existing conversation. WhatsApp only delivers these within 24 hours of the contact's last message; outside that window, send a template with `POST /templates/send`.\n\nThe message is queued and the response returns right away with `status: sent`. Check delivery later with `GET /messages/{message_id}`.\n\n| `media_type` | What to send |\n| --- | --- |\n| `text` | `message` |\n| `image`, `video`, `document` | `file_url` (the type is also detected from the file extension), with `message` as the caption |\n| `location` | `location` with `latitude` and `longitude`, plus optional `name` and `address` |\n| `button` | `message` and `action.buttons`: 1 to 3 buttons, each `{\"type\": \"reply\", \"reply\": {\"id\", \"title\"}}`; titles up to 20 characters |\n| `list` | `message` and `action` with `button` (up to 20 characters) and `sections`: up to 10 sections, each with a `title` (up to 24 characters) and up to 10 `rows` of `{\"id\", \"title\", \"description\"}` |\n| `cta_url` | `message` and `action` `{\"name\": \"cta_url\", \"parameters\": {\"display_text\", \"url\"}}`; `display_text` up to 20 characters |\n\n`header` (`{\"text\"}` or `{\"file_url\"}`) and `footer` (text) are optional for `button`, `list` and `cta_url` messages.\n",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "conversation_id"
                ],
                "properties": {
                  "conversation_id": {
                    "type": "string",
                    "format": "uuid",
                    "description": "A WhatsApp conversation."
                  },
                  "message": {
                    "type": "string",
                    "description": "Message text, or the caption for media."
                  },
                  "media_type": {
                    "type": "string",
                    "default": "text",
                    "enum": [
                      "text",
                      "image",
                      "video",
                      "document",
                      "location",
                      "button",
                      "list",
                      "cta_url"
                    ]
                  },
                  "file_url": {
                    "type": "string",
                    "format": "uri",
                    "description": "Public URL of the image, video or document to send."
                  },
                  "header": {
                    "type": "object",
                    "properties": {
                      "text": {
                        "type": "string"
                      },
                      "file_url": {
                        "type": "string",
                        "format": "uri"
                      }
                    }
                  },
                  "footer": {
                    "type": "string"
                  },
                  "action": {
                    "type": "object",
                    "additionalProperties": true,
                    "description": "Buttons, list or link, depending on `media_type`."
                  },
                  "location": {
                    "type": "object",
                    "properties": {
                      "latitude": {
                        "type": "number"
                      },
                      "longitude": {
                        "type": "number"
                      },
                      "name": {
                        "type": "string"
                      },
                      "address": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Message queued for sending.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "status_code": {
                      "type": "integer"
                    },
                    "data": {
                      "$ref": "#/components/schemas/ChatMessage"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "The message is invalid, contains a blocked phrase, the contact is blocked, or the conversation has no WhatsApp number.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "description": "The conversation was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/messages/{message_id}": {
      "get": {
        "tags": [
          "Message"
        ],
        "operationId": "GetMessage",
        "summary": "Get a message",
        "description": "Returns one message by its ID.",
        "parameters": [
          {
            "name": "message_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The message.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "status_code": {
                      "type": "integer"
                    },
                    "data": {
                      "$ref": "#/components/schemas/ChatMessage"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "description": "No message with this ID belongs to your business.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/api/messages": {
      "get": {
        "tags": [
          "Message"
        ],
        "operationId": "ListMessages",
        "summary": "List messages",
        "description": "Lists messages across your business, or in one conversation, with each message's contact and inbox.\n\n**Without date filters, only today's messages are returned** (in your `X-User-Timezone`, default Asia/Jakarta). With only a start date, results run to the end of today.\n",
        "parameters": [
          {
            "name": "conversation_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 1
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 2000,
              "default": 100
            }
          },
          {
            "name": "sort_order",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "asc",
                "desc"
              ],
              "default": "desc"
            }
          },
          {
            "name": "is_ads",
            "in": "query",
            "required": false,
            "description": "`true` to return only contact messages that came from a click-to-WhatsApp ad.",
            "schema": {
              "type": "boolean",
              "default": false
            }
          },
          {
            "name": "is_template",
            "in": "query",
            "required": false,
            "description": "`true` for template messages only, `false` to exclude them.",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "$ref": "#/components/parameters/StartDate"
          },
          {
            "$ref": "#/components/parameters/EndDate"
          },
          {
            "$ref": "#/components/parameters/StartDatetime"
          },
          {
            "$ref": "#/components/parameters/EndDatetime"
          },
          {
            "$ref": "#/components/parameters/Version"
          },
          {
            "$ref": "#/components/parameters/UserTimezone"
          }
        ],
        "responses": {
          "200": {
            "description": "A page of messages.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ChatMessage"
                      }
                    },
                    "metadata": {
                      "type": "object",
                      "properties": {
                        "pagination": {
                          "type": "object",
                          "properties": {
                            "current_page": {
                              "type": "integer"
                            },
                            "current_items": {
                              "type": "integer"
                            },
                            "total_page": {
                              "type": "integer"
                            },
                            "total_items": {
                              "type": "integer"
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "A filter is invalid, or `limit` is above 2000.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/ApiUnauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/api/messages/lock-balance": {
      "post": {
        "tags": [
          "Message"
        ],
        "operationId": "ReserveServiceMessageBalance",
        "summary": "Check or reserve service-message balance",
        "description": "Returns the billing details for sending one free-form WhatsApp message in a conversation and, on prepaid credit-line inboxes, reserves the cost against `message_id`.\n\n`POST /messages/whatsapp` already does this for you, so you only need this endpoint if you send WhatsApp messages through your own integration and bill through Cekat.\n",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "message_id",
                  "conversation_id"
                ],
                "properties": {
                  "message_id": {
                    "type": "string",
                    "format": "uuid",
                    "description": "Your unique ID for the message. The reservation is tied to it."
                  },
                  "conversation_id": {
                    "type": "string",
                    "format": "uuid"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Billing details for the message.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "additionalProperties": true
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "A field is missing or invalid, the conversation is not on WhatsApp, or there isn't enough balance.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/ApiUnauthorized"
          },
          "404": {
            "description": "The conversation was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/messages": {
      "get": {
        "tags": [
          "Message"
        ],
        "operationId": "ListConversationMessages",
        "summary": "List messages in a conversation",
        "description": "Lists every message in one conversation, newest first. Use `GET /api/messages` to search across conversations or by date.",
        "parameters": [
          {
            "name": "conversation_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 1
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 1000
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The conversation's messages.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "status_code": {
                      "type": "integer"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ChatMessage"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "`conversation_id` is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "description": "The conversation was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/api/messages/summary/ai_credits": {
      "get": {
        "tags": [
          "Message"
        ],
        "operationId": "GetAiCreditSummary",
        "summary": "Get AI credit usage",
        "description": "Totals the AI replies, AI credits used, and conversations they were in, for a date range or one conversation. Without date filters, all time is included.",
        "parameters": [
          {
            "name": "conversation_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "$ref": "#/components/parameters/StartDate"
          },
          {
            "$ref": "#/components/parameters/EndDate"
          },
          {
            "$ref": "#/components/parameters/StartDatetime"
          },
          {
            "$ref": "#/components/parameters/EndDatetime"
          },
          {
            "$ref": "#/components/parameters/UserTimezone"
          }
        ],
        "responses": {
          "200": {
            "description": "The usage totals.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "total_ai_messages": {
                          "type": "integer"
                        },
                        "total_ai_credits_used": {
                          "type": "number"
                        },
                        "total_conversations": {
                          "type": "integer"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/ApiBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/ApiUnauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/api/inboxes": {
      "get": {
        "tags": [
          "Connected Platforms"
        ],
        "operationId": "ListInboxes",
        "summary": "List inboxes",
        "description": "Lists the channels connected to your business (WhatsApp, Instagram, Messenger, live chat and others), newest first. Deleted inboxes are not included.",
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 1
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 10
            }
          },
          {
            "$ref": "#/components/parameters/StartDate"
          },
          {
            "$ref": "#/components/parameters/EndDate"
          },
          {
            "$ref": "#/components/parameters/StartDatetime"
          },
          {
            "$ref": "#/components/parameters/EndDatetime"
          },
          {
            "$ref": "#/components/parameters/Version"
          },
          {
            "$ref": "#/components/parameters/UserTimezone"
          }
        ],
        "responses": {
          "200": {
            "description": "A page of inboxes.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Inbox"
                      }
                    },
                    "metadata": {
                      "type": "object",
                      "properties": {
                        "pagination": {
                          "$ref": "#/components/schemas/Pagination"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/ApiBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/ApiUnauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/inboxes": {
      "get": {
        "tags": [
          "Connected Platforms"
        ],
        "operationId": "ListInboxesLegacy",
        "summary": "List inboxes (legacy)",
        "deprecated": true,
        "description": "Older inbox list without pagination, kept for existing integrations. It includes deleted inboxes unless `include_deleted=false`. New integrations should use `GET /api/inboxes`.",
        "parameters": [
          {
            "name": "include_deleted",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "true",
                "false"
              ],
              "default": "true"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "All inboxes.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "status_code": {
                      "type": "integer"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/LegacyInbox"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "`include_deleted` is not `true` or `false`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/templates": {
      "post": {
        "tags": [
          "Broadcast"
        ],
        "operationId": "CreateTemplate",
        "summary": "Create a template",
        "description": "Creates a WhatsApp message template on the inbox's WhatsApp Business Account and submits it to Meta for review. The new template usually starts with `status: PENDING`; check `GET /api/templates` to see when it becomes `APPROVED`.\n\n- Template names must follow Meta's rules: lowercase letters, numbers and underscores.\n- Use `{{1}}`, `{{2}}`, and so on for variables in `body`, and send one sample value per variable in `body_placeholder`. Meta uses the samples during review.\n- Attach an image as `file` to give the template an image header.\n- Meta may change the category if it does not match the content.\n",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "name",
                  "category",
                  "language",
                  "body",
                  "inbox_id"
                ],
                "properties": {
                  "name": {
                    "type": "string",
                    "maxLength": 512,
                    "description": "Template name, using lowercase letters, numbers and underscores."
                  },
                  "category": {
                    "type": "string",
                    "enum": [
                      "AUTHENTICATION",
                      "MARKETING",
                      "UTILITY"
                    ]
                  },
                  "language": {
                    "type": "string",
                    "description": "Meta language code. Supported codes: Afrikaans (af), Albanian (sq), Arabic (ar), Azerbaijani (az), Bengali (bn), Bulgarian (bg), Catalan (ca), Chinese (CHN: zh_CN; HKG: zh_HK; TAI: zh_TW), Croatian (hr), Czech (cs), Danish (da), Dutch (nl), English (en), English (UK: en_GB; US: en_US), Estonian (et), Filipino (fil), Finnish (fi), French (fr), Georgian (ka), German (de), Greek (el), Gujarati (gu), Hausa (ha), Hebrew (he), Hindi (hi), Hungarian (hu), Indonesian (id), Irish (ga), Italian (it), Japanese (ja), Kannada (kn), Kazakh (kk), Kinyarwanda (rw_RW), Korean (ko), Kyrgyz (Kyrgyzstan: ky_KG), Lao (lo), Latvian (lv), Lithuanian (lt), Macedonian (mk), Malay (ms), Malayalam (ml), Marathi (mr), Norwegian (nb), Persian (fa), Polish (pl), Portuguese (BR: pt_BR; POR: pt_PT), Punjabi (pa), Romanian (ro), Russian (ru), Serbian (sr), Slovak (sk), Slovenian (sl), Spanish (es), Spanish (ARG: es_AR; SPA: es_ES; MEX: es_MX), Swahili (sw), Swedish (sv), Tamil (ta), Telugu (te), Thai (th), Turkish (tr), Ukrainian (uk), Urdu (ur), Uzbek (uz), Vietnamese (vi), and Zulu (zu)."
                  },
                  "body": {
                    "type": "string",
                    "maxLength": 1024,
                    "description": "Message text. Use `{{1}}`, `{{2}}`, and so on for variables."
                  },
                  "inbox_id": {
                    "type": "string",
                    "format": "uuid",
                    "description": "ID of a connected WhatsApp inbox."
                  },
                  "body_placeholder": {
                    "type": "string",
                    "description": "JSON array of sample values, one per body variable, in order. Required when `body` contains variables."
                  },
                  "file": {
                    "type": "string",
                    "format": "binary",
                    "description": "Optional header image (JPEG or PNG)."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Template created and submitted to Meta.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "status_code": {
                      "type": "integer"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Template"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "A field is missing or invalid, the inbox is not a WhatsApp inbox, or Meta rejected the template. `error.message` explains why.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "description": "The inbox was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/api/campaigns": {
      "post": {
        "tags": [
          "Broadcast"
        ],
        "operationId": "CreateCampaign",
        "summary": "Create a campaign",
        "description": "Sends an approved template to every contact in a recipient list, now or at a scheduled time. Messages go out in batches of 20.\n\nThe campaign is created with `status: processing` (sending now) or `status: scheduled`. Track it with `GET /api/campaigns` and `GET /api/v2/campaigns/{id}/messages`. Carousel templates are not supported.\n",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "campaign_name",
                  "inbox_id",
                  "recipient_list_id",
                  "template_id"
                ],
                "properties": {
                  "campaign_name": {
                    "type": "string"
                  },
                  "inbox_id": {
                    "type": "string",
                    "format": "uuid",
                    "description": "The WhatsApp inbox that sends the campaign. It must own the template."
                  },
                  "recipient_list_id": {
                    "type": "string",
                    "format": "uuid",
                    "description": "ID from `POST /api/recipients` or `GET /api/recipients`."
                  },
                  "template_id": {
                    "type": "string",
                    "description": "The template's `wa_template_id`."
                  },
                  "template_body_variables": {
                    "type": "array",
                    "description": "One value per body variable, in order. The count must match the template's highest variable number, and values cannot be empty.\nUse `name` or `phone_number` to insert each recipient's own name or number.\n",
                    "items": {
                      "type": "string"
                    }
                  },
                  "schedule_at": {
                    "type": "string",
                    "format": "date-time",
                    "description": "When to start sending, as an ISO 8601 date-time in the future (for example `2026-10-20T09:00:00+07:00`). Leave out to send immediately."
                  },
                  "label_id": {
                    "type": "string",
                    "format": "uuid",
                    "description": "Optional label added to each recipient's conversation. Follow-ups set up for this label in the inbox also run."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Campaign created and queued.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "format": "uuid",
                          "description": "Campaign ID."
                        },
                        "campaign_name": {
                          "type": "string"
                        },
                        "status": {
                          "type": "string",
                          "enum": [
                            "processing",
                            "scheduled"
                          ]
                        },
                        "created_at": {
                          "type": "string",
                          "format": "date-time"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/ApiBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/ApiUnauthorized"
          },
          "422": {
            "description": "A required field is missing, the inbox, template or recipient list was not found, the inbox is not WhatsApp, the variables don't match the template, or `schedule_at` is invalid or in the past.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "503": {
            "description": "The campaign was saved but could not be queued, and has been marked `failed`. Create it again.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "Broadcast"
        ],
        "operationId": "ListCampaigns",
        "summary": "List campaigns",
        "description": "Lists your campaigns, newest first, with delivery and engagement totals for each.",
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 1
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 10
            }
          },
          {
            "$ref": "#/components/parameters/StartDate"
          },
          {
            "$ref": "#/components/parameters/EndDate"
          },
          {
            "$ref": "#/components/parameters/StartDatetime"
          },
          {
            "$ref": "#/components/parameters/EndDatetime"
          },
          {
            "$ref": "#/components/parameters/UserTimezone"
          }
        ],
        "responses": {
          "200": {
            "description": "A page of campaigns.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/CampaignListItem"
                      }
                    },
                    "metadata": {
                      "type": "object",
                      "properties": {
                        "pagination": {
                          "$ref": "#/components/schemas/Pagination"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/ApiBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/ApiUnauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/api/campaigns/{id}/messages": {
      "get": {
        "tags": [
          "Broadcast"
        ],
        "operationId": "ListCampaignMessages",
        "summary": "List campaign messages",
        "deprecated": true,
        "description": "Older version of campaign details, kept for existing integrations. Returns raw campaign messages plus a status breakdown. New integrations should use `GET /api/v2/campaigns/{id}/messages`.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Campaign ID.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "page",
            "in": "query",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "$ref": "#/components/parameters/Version"
          }
        ],
        "responses": {
          "200": {
            "description": "A page of campaign messages and status totals.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/CampaignMessageLegacy"
                      }
                    },
                    "metadata": {
                      "type": "object",
                      "properties": {
                        "pagination": {
                          "type": "object",
                          "properties": {
                            "current_page": {
                              "type": "integer"
                            },
                            "total_page": {
                              "type": "integer"
                            },
                            "limit_per_page": {
                              "type": "integer"
                            },
                            "total_items": {
                              "type": "integer"
                            }
                          }
                        },
                        "metrics": {
                          "type": "object",
                          "description": "`total_data`, `total_replied`, and one `total_<status>` count per message status present (for example `total_sent`, `total_read`).",
                          "additionalProperties": {
                            "type": "integer"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "`version` is not in `YYYY-MM-DD` format.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/ApiUnauthorized"
          },
          "404": {
            "$ref": "#/components/responses/ApiNotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/api/recipients": {
      "get": {
        "tags": [
          "Broadcast"
        ],
        "operationId": "ListRecipientLists",
        "summary": "List recipient lists",
        "description": "Lists your recipient lists, newest first, with the number of contacts in each.",
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 1
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 500,
              "default": 10
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A page of recipient lists.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/RecipientList"
                      }
                    },
                    "metadata": {
                      "type": "object",
                      "properties": {
                        "pagination": {
                          "$ref": "#/components/schemas/Pagination"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/ApiBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/ApiUnauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      },
      "post": {
        "tags": [
          "Broadcast"
        ],
        "operationId": "UploadRecipientList",
        "summary": "Upload a recipient list",
        "description": "Creates a recipient list from a CSV or XLSX file, for use in campaigns.\n\n**File format**\n- The first row must be headers and include `phone_number` and `name`. Other columns are saved as extra recipient data.\n- Up to 5,000 contacts, 100 columns and 10 MB. Only the first worksheet is read.\n- Phone numbers: non-digits are removed and a leading `0` becomes `62`. Rows with fewer than 7 digits are skipped, and duplicate numbers are kept once.\n\nContacts are imported in the background. Poll `GET /api/recipients` until `total_contacts` for the list matches the `total_contacts` returned here before creating a campaign.\n",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "name",
                  "file"
                ],
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "Name of the recipient list."
                  },
                  "file": {
                    "type": "string",
                    "format": "binary",
                    "description": "CSV or XLSX file (`.csv` or `.xlsx`)."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "List created; contacts are being imported.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "$ref": "#/components/schemas/RecipientList"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/ApiUnauthorized"
          },
          "413": {
            "description": "The file is larger than 10 MB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "The name or file is missing, or the file is invalid (wrong type, missing headers, no valid contacts, or too many rows or columns).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        }
      }
    },
    "/api/templates/lock-balance": {
      "post": {
        "tags": [
          "Broadcast"
        ],
        "operationId": "ReserveTemplateMessageBalance",
        "summary": "Check or reserve template-message balance",
        "description": "Returns the billing details for sending one template message to a phone number and, on prepaid credit-line inboxes, reserves the estimated cost against `message_id`.\n\n`POST /templates/send` and campaigns already do this for you, so you only need this endpoint if you send templates through your own WhatsApp integration and bill through Cekat. Calling it with the same `message_id` again returns the existing reservation.\n",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "message_id",
                  "phone_number",
                  "inbox_id",
                  "wa_template_id"
                ],
                "properties": {
                  "message_id": {
                    "type": "string",
                    "description": "Your unique ID for the message. The reservation is tied to it."
                  },
                  "phone_number": {
                    "type": "string",
                    "description": "Recipient's number, digits only with country code. Used to price the message."
                  },
                  "inbox_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "wa_template_id": {
                    "type": "string"
                  },
                  "conversation_id": {
                    "type": "string",
                    "format": "uuid",
                    "description": "Optional conversation to bill against. Found from the phone number if left out."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Billing details for the message.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "$ref": "#/components/schemas/TemplateBilling"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "A required field is missing or invalid, or there is not enough balance.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/ApiUnauthorized"
          },
          "404": {
            "description": "The template or inbox was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/templates/{wa_template_id}": {
      "delete": {
        "tags": [
          "Broadcast"
        ],
        "operationId": "DeleteTemplate",
        "summary": "Delete a template",
        "description": "Deletes a template from Meta and from Cekat. Scheduled campaigns that use the template will fail when they run.",
        "parameters": [
          {
            "name": "wa_template_id",
            "in": "path",
            "required": true,
            "description": "The template's `wa_template_id`.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Template deleted.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "status_code": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "The template's inbox is not a WhatsApp inbox, or Meta refused the deletion.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "description": "No template with this ID belongs to your business.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/templates/sync": {
      "post": {
        "tags": [
          "Broadcast"
        ],
        "operationId": "SyncTemplates",
        "summary": "Synchronize templates",
        "description": "Copies the inbox's templates from Meta into Cekat. Use it after creating or editing templates directly in Meta, or to refresh approval statuses. New templates are added and templates whose status changed are updated.",
        "parameters": [
          {
            "name": "inbox_id",
            "in": "query",
            "required": true,
            "description": "ID of a connected WhatsApp inbox.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Templates synchronized.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "status_code": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "`inbox_id` is missing or the inbox is not a WhatsApp inbox.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/templates/send": {
      "post": {
        "tags": [
          "Broadcast"
        ],
        "operationId": "SendTemplate",
        "summary": "Send a template",
        "description": "Sends an approved WhatsApp template to one phone number. Cekat creates the contact and conversation if they don't exist yet.\n\n**Check `success` in the body, not only the HTTP status.** If Meta rejects the message (for example, an invalid number or insufficient balance), the endpoint still returns HTTP 200, with `success: false`, `status_code: 400`, `data.status: failed`, and the reason in `data.error`.\n",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "wa_template_id",
                  "inbox_id",
                  "phone_number"
                ],
                "properties": {
                  "wa_template_id": {
                    "type": "string",
                    "description": "The template's `wa_template_id`. The template must be `APPROVED`."
                  },
                  "inbox_id": {
                    "type": "string",
                    "format": "uuid",
                    "description": "The WhatsApp inbox that owns the template and sends the message."
                  },
                  "phone_number": {
                    "type": "string",
                    "description": "Recipient's number, digits only with country code."
                  },
                  "phone_name": {
                    "type": "string",
                    "description": "Contact name to save if the contact is new. Defaults to the phone number."
                  },
                  "template_body_variables": {
                    "type": "array",
                    "description": "One value per body variable, in order (`{{1}}`, `{{2}}`, ...). The count must match the template. Send `[]` for templates without variables.",
                    "items": {
                      "type": "string"
                    }
                  },
                  "otp_code": {
                    "type": "string",
                    "maxLength": 15,
                    "description": "One-time code, for `AUTHENTICATION` templates only."
                  },
                  "file_url": {
                    "type": "string",
                    "format": "uri",
                    "description": "Header media URL to use instead of the template's default, for templates with a media header."
                  },
                  "assign_agent_id": {
                    "type": "string",
                    "format": "uuid",
                    "description": "Optional agent ID. The conversation is assigned to this agent after sending."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The message was processed. Check `success` to see whether it was sent.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "description": "False when Meta rejected the message."
                    },
                    "status_code": {
                      "type": "integer",
                      "description": "200 when sent, 400 when the message failed."
                    },
                    "data": {
                      "$ref": "#/components/schemas/SentMessage"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "A required field is missing, the template is not approved, the variable count does not match, or the message contains a blocked phrase.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "description": "The inbox or template was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/api/v2/campaigns/{id}/messages": {
      "get": {
        "tags": [
          "Broadcast"
        ],
        "operationId": "GetCampaignDetailsV2",
        "summary": "Get campaign details",
        "description": "Lists every recipient's message in a campaign, newest first, with delivery status, failure reason, and whether they replied or tapped a button. Recommended over `GET /api/campaigns/{id}/messages`.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Campaign ID.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 1
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 20
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A page of campaign messages.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/CampaignMessage"
                      }
                    },
                    "metadata": {
                      "type": "object",
                      "properties": {
                        "pagination": {
                          "type": "object",
                          "properties": {
                            "current_page": {
                              "type": "integer"
                            },
                            "total_page": {
                              "type": "integer"
                            },
                            "limit_per_page": {
                              "type": "integer"
                            },
                            "total_items": {
                              "type": "integer"
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "`page` or `limit` is out of range.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/ApiUnauthorized"
          },
          "404": {
            "$ref": "#/components/responses/ApiNotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/api/templates": {
      "get": {
        "tags": [
          "Broadcast"
        ],
        "operationId": "ListTemplates",
        "summary": "List templates",
        "description": "Lists your business's WhatsApp templates across all inboxes, newest first.",
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 1
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Templates per page.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 1000
            }
          },
          {
            "$ref": "#/components/parameters/StartDate"
          },
          {
            "$ref": "#/components/parameters/EndDate"
          },
          {
            "$ref": "#/components/parameters/StartDatetime"
          },
          {
            "$ref": "#/components/parameters/EndDatetime"
          },
          {
            "$ref": "#/components/parameters/Version"
          },
          {
            "$ref": "#/components/parameters/UserTimezone"
          }
        ],
        "responses": {
          "200": {
            "description": "A page of templates.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Template"
                      }
                    },
                    "metadata": {
                      "type": "object",
                      "properties": {
                        "pagination": {
                          "type": "object",
                          "properties": {
                            "current_page": {
                              "type": "integer"
                            },
                            "total_page": {
                              "type": "integer"
                            },
                            "total_data": {
                              "type": "integer",
                              "description": "Total number of templates."
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/ApiBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/ApiUnauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/api/agent_assignments": {
      "get": {
        "tags": [
          "Conversation"
        ],
        "operationId": "ListAgentAssignments",
        "summary": "List agent assignments",
        "description": "Lists conversations currently handled by a human agent, newest first, with the agent and when they were assigned.",
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 1
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 10
            }
          },
          {
            "$ref": "#/components/parameters/StartDate"
          },
          {
            "$ref": "#/components/parameters/EndDate"
          },
          {
            "$ref": "#/components/parameters/StartDatetime"
          },
          {
            "$ref": "#/components/parameters/EndDatetime"
          },
          {
            "$ref": "#/components/parameters/UserTimezone"
          }
        ],
        "responses": {
          "200": {
            "description": "A page of assignments. Date filters apply to when the conversation was created.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "conversation_id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "created_at": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "contact_id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "contact_name": {
                            "type": "string"
                          },
                          "handled_by_agent_id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "handled_by_agent_name": {
                            "type": "string"
                          },
                          "inbox_name": {
                            "type": "string"
                          },
                          "stage_status": {
                            "type": "string"
                          },
                          "assigned_at": {
                            "type": "string",
                            "format": "date-time",
                            "nullable": true
                          }
                        }
                      }
                    },
                    "metadata": {
                      "type": "object",
                      "properties": {
                        "pagination": {
                          "$ref": "#/components/schemas/Pagination"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/ApiBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/ApiUnauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/api/conversations/{conversation_id}": {
      "put": {
        "tags": [
          "Conversation"
        ],
        "operationId": "UpdateConversation",
        "summary": "Update a conversation",
        "description": "Changes which AI agent replies in a conversation, and whether it stays assigned after the conversation is resolved. Each change adds a system note to the conversation.",
        "parameters": [
          {
            "name": "conversation_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "assigned_ai_agent": {
                    "type": "string",
                    "format": "uuid",
                    "description": "ID of the AI agent to assign."
                  },
                  "keep_assigned_ai_agent_on_resolve": {
                    "type": "boolean",
                    "description": "Keep the AI agent assigned after the conversation is resolved. Not allowed on inboxes that use a flow."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Conversation updated.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "additionalProperties": true,
                      "description": "The updated conversation record."
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "The AI agent was not found, `keep_assigned_ai_agent_on_resolve` is not a boolean, or the inbox uses a flow.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/ApiUnauthorized"
          },
          "404": {
            "$ref": "#/components/responses/ApiNotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      },
      "get": {
        "tags": [
          "Conversation"
        ],
        "operationId": "GetConversation",
        "summary": "Get a conversation",
        "description": "Returns a conversation with its labels, pipeline stage, collaborators, and the last message from the contact side and from a human agent.",
        "parameters": [
          {
            "name": "conversation_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The conversation.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "$ref": "#/components/schemas/ConversationDetail"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/ApiBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/ApiUnauthorized"
          },
          "404": {
            "$ref": "#/components/responses/ApiNotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/api/conversations": {
      "get": {
        "tags": [
          "Conversation"
        ],
        "operationId": "ListConversations",
        "summary": "List conversations",
        "description": "Lists conversations, most recently active first, with the contact, handling agent, labels, and first and last messages.\n\nThis list uses cursor pagination. To get the next page, send `metadata.next_cursor.cursor_id` and `metadata.next_cursor.cursor_ts` from the previous response. Stop when `data` is empty.\n",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 20
            }
          },
          {
            "name": "cursor_id",
            "in": "query",
            "required": false,
            "description": "`next_cursor.cursor_id` from the previous page.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "cursor_ts",
            "in": "query",
            "required": false,
            "description": "`next_cursor.cursor_ts` from the previous page.",
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/StartDate"
          },
          {
            "$ref": "#/components/parameters/EndDate"
          },
          {
            "$ref": "#/components/parameters/StartDatetime"
          },
          {
            "$ref": "#/components/parameters/EndDatetime"
          },
          {
            "$ref": "#/components/parameters/UserTimezone"
          }
        ],
        "responses": {
          "200": {
            "description": "A page of conversations.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ConversationListItem"
                      }
                    },
                    "metadata": {
                      "type": "object",
                      "properties": {
                        "next_cursor": {
                          "type": "object",
                          "properties": {
                            "cursor_id": {
                              "type": "string",
                              "nullable": true
                            },
                            "cursor_ts": {
                              "type": "string",
                              "nullable": true
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "A filter is invalid, or `limit` is above 100.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/ApiUnauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/api/crm/contact/{contact_id}": {
      "get": {
        "tags": [
          "Contact"
        ],
        "operationId": "GetContact",
        "summary": "Get a contact",
        "description": "Returns a contact with its owner, stage, company, conversations, and custom property values (`crm_column`).",
        "parameters": [
          {
            "name": "contact_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The contact.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/Contact"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/ApiUnauthorized"
          },
          "404": {
            "description": "No contact with this ID belongs to your business.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      },
      "put": {
        "tags": [
          "Contact"
        ],
        "operationId": "UpdateContact",
        "summary": "Update a contact",
        "description": "Updates a contact's standard fields and labels. Send only the fields you want to change. To change custom property values, use `PUT /api/crm/contact/{id}/property`.",
        "parameters": [
          {
            "name": "contact_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "display_name": {
                    "type": "string"
                  },
                  "phone_number": {
                    "type": "string"
                  },
                  "email": {
                    "type": "string",
                    "format": "email"
                  },
                  "note": {
                    "type": "string"
                  },
                  "additional_data": {
                    "type": "object",
                    "additionalProperties": true,
                    "description": "Replaces the contact's additional data."
                  },
                  "company_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "stage_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "contact_owner_id": {
                    "type": "string",
                    "format": "uuid",
                    "description": "Agent ID of the new contact owner. The agent must be active."
                  },
                  "label_ids": {
                    "type": "array",
                    "description": "Contact label IDs to add.",
                    "items": {
                      "type": "string",
                      "format": "uuid"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The updated contact.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/Contact"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/ApiBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/ApiUnauthorized"
          },
          "404": {
            "description": "The contact, company, stage, owner or label was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "409": {
            "description": "The new phone number or email already belongs to another contact.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CrmConflictError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/api/crm/contact/board": {
      "get": {
        "tags": [
          "Contact"
        ],
        "operationId": "GetContactBoard",
        "summary": "Get the contact board",
        "description": "Returns the ID of your business's contact board. Use it as `boardId` to read contact property definitions with the board endpoints.",
        "responses": {
          "200": {
            "description": "The contact board.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "format": "uuid"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/ApiUnauthorized"
          },
          "404": {
            "$ref": "#/components/responses/ApiNotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/api/contacts": {
      "get": {
        "tags": [
          "Contact"
        ],
        "operationId": "ListContacts",
        "summary": "List contacts",
        "description": "Lists your contacts, newest first, with the inboxes they have talked to you through. Only contacts with at least one conversation in an active inbox are included. Use `POST /api/crm/contact/search` to filter by fields or custom properties.",
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 1
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 10
            }
          },
          {
            "$ref": "#/components/parameters/StartDate"
          },
          {
            "$ref": "#/components/parameters/EndDate"
          },
          {
            "$ref": "#/components/parameters/StartDatetime"
          },
          {
            "$ref": "#/components/parameters/EndDatetime"
          },
          {
            "$ref": "#/components/parameters/UserTimezone"
          }
        ],
        "responses": {
          "200": {
            "description": "A page of contacts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ContactListItem"
                      }
                    },
                    "metadata": {
                      "type": "object",
                      "properties": {
                        "pagination": {
                          "$ref": "#/components/schemas/Pagination"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/ApiBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/ApiUnauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/api/crm/contact/property": {
      "post": {
        "tags": [
          "Contact"
        ],
        "operationId": "CreateContactProperty",
        "summary": "Create a contact property",
        "description": "Adds a custom property (column) to your contacts. If the name is already used, a number is added to make it unique.\n\nFor `select` and `dropdown`, list the options in `settings.labels`; if you leave them out, three placeholder labels are created. Accounts that haven't moved to the new contact table can only create `text`, `number`, `select`, `date` and `checkbox` properties.\n",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "name",
                  "type"
                ],
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "type": {
                    "type": "string",
                    "enum": [
                      "text",
                      "long_text",
                      "email",
                      "phone",
                      "number",
                      "date",
                      "timeline",
                      "checkbox",
                      "select",
                      "dropdown",
                      "conversation",
                      "agents",
                      "contacts",
                      "companies",
                      "subscriptions",
                      "orders",
                      "references"
                    ]
                  },
                  "settings": {
                    "type": "object",
                    "additionalProperties": true,
                    "properties": {
                      "labels": {
                        "type": "array",
                        "description": "Options for `select` and `dropdown` properties.",
                        "items": {
                          "$ref": "#/components/schemas/CrmColumnLabel"
                        }
                      }
                    }
                  },
                  "is_required": {
                    "type": "boolean",
                    "default": false
                  },
                  "is_visible": {
                    "type": "boolean",
                    "default": true
                  },
                  "is_unique": {
                    "type": "boolean",
                    "default": false
                  },
                  "read_only": {
                    "type": "boolean",
                    "default": false
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Property created.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/CrmColumn"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "The name or type is missing or not allowed, or the settings are invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/ApiUnauthorized"
          },
          "404": {
            "$ref": "#/components/responses/ApiNotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/api/crm/contact/search": {
      "post": {
        "tags": [
          "Contact"
        ],
        "operationId": "SearchContacts",
        "summary": "Search contacts",
        "description": "Finds contacts that match a filter on standard fields, custom properties, or additional fields. Results are sorted by most recently updated.\n\nCall `GET /api/crm/contact/filter-fields` first: it lists every field you can filter on, with its `field_category`, `id`, `type`, and allowed `operations`. Leave out `filter` to list all contacts.\n",
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "page": {
                    "type": "integer",
                    "minimum": 1,
                    "default": 1
                  },
                  "limit": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 200,
                    "default": 200
                  },
                  "filter": {
                    "type": "object",
                    "required": [
                      "condition",
                      "criteria"
                    ],
                    "properties": {
                      "condition": {
                        "type": "string",
                        "enum": [
                          "AND",
                          "OR"
                        ]
                      },
                      "criteria": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "required": [
                            "field_category",
                            "field_id",
                            "operator",
                            "value"
                          ],
                          "properties": {
                            "field_category": {
                              "type": "string",
                              "enum": [
                                "primary",
                                "crm_column",
                                "additional_field"
                              ]
                            },
                            "field_id": {
                              "type": "string",
                              "description": "The field's `id` from `GET /api/crm/contact/filter-fields`."
                            },
                            "operator": {
                              "type": "string",
                              "description": "One of the field's `operations`, for example `is`, `contains`, `before`, `after`, `on_or_before`, or `on_or_after`."
                            },
                            "value": {
                              "description": "Value to compare against."
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Matching contacts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "contacts": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/Contact"
                          }
                        },
                        "filter": {
                          "type": "object",
                          "nullable": true,
                          "additionalProperties": true,
                          "description": "The filter you sent."
                        },
                        "pagination": {
                          "type": "object",
                          "properties": {
                            "page": {
                              "type": "integer"
                            },
                            "limit": {
                              "type": "integer"
                            },
                            "total_items": {
                              "type": "integer"
                            },
                            "total_pages": {
                              "type": "integer"
                            },
                            "has_next_page": {
                              "type": "boolean"
                            },
                            "has_previous_page": {
                              "type": "boolean"
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "The filter, page or limit is invalid, or an operator is not allowed for the field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/ApiUnauthorized"
          },
          "404": {
            "$ref": "#/components/responses/ApiNotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/api/crm/contact/filter-fields": {
      "get": {
        "tags": [
          "Contact"
        ],
        "operationId": "GetContactFilterFields",
        "summary": "Get contact filter fields",
        "description": "Lists every field you can use in `POST /api/crm/contact/search`, including standard fields, custom properties, and additional fields, with the operators each one supports.",
        "responses": {
          "200": {
            "description": "Filterable fields.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "field_category": {
                            "type": "string",
                            "enum": [
                              "primary",
                              "crm_column",
                              "additional_field"
                            ]
                          },
                          "filter_key": {
                            "type": "string"
                          },
                          "id": {
                            "type": "string",
                            "description": "Use as `field_id` in a search."
                          },
                          "name": {
                            "type": "string"
                          },
                          "type": {
                            "type": "string"
                          },
                          "operations": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "options": {
                            "type": "array",
                            "description": "Allowed values, for select fields.",
                            "items": {
                              "type": "string"
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/ApiUnauthorized"
          },
          "404": {
            "$ref": "#/components/responses/ApiNotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/api/crm/contact/{id}/property": {
      "put": {
        "tags": [
          "Contact"
        ],
        "operationId": "UpdateContactProperties",
        "summary": "Update contact properties",
        "description": "Sets custom property values on a contact. Send one entry per property; each `type` must match the property's type, and each `value` is an object whose key depends on the type:\n\n| Type | `value` |\n| --- | --- |\n| `text`, `long_text`, `email`, `phone` | `{\"text\": \"...\"}` |\n| `number` | `{\"number\": 10}` |\n| `checkbox` | `{\"checked\": true}` |\n| `date` | `{\"date\": \"2026-10-20T09:00:00+07:00\"}` |\n| `timeline` | `{\"from\": \"<ISO date-time>\", \"to\": \"<ISO date-time>\"}` |\n| `select` | `{\"label_id\": \"0\"}` |\n| `dropdown` | `{\"label_ids\": [\"0\", \"1\"]}` |\n| `agents`, `contacts`, `companies`, `subscriptions`, `orders`, `references` | `{\"ids\": [\"...\"]}` |\n| `conversation` | `{\"id\": \"...\"}` |\n\nText values can be up to 255 characters and long text up to 500 words.\n",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Contact ID.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "properties"
                ],
                "properties": {
                  "properties": {
                    "type": "array",
                    "minItems": 1,
                    "items": {
                      "type": "object",
                      "required": [
                        "column_id",
                        "type",
                        "value"
                      ],
                      "properties": {
                        "column_id": {
                          "type": "string",
                          "format": "uuid",
                          "description": "The property's `id`."
                        },
                        "type": {
                          "type": "string",
                          "description": "The property's type. Must match the column."
                        },
                        "value": {
                          "type": "object",
                          "additionalProperties": true
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The properties that were updated.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "column_id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "data": {
                            "type": "object",
                            "nullable": true,
                            "description": "The stored value record, or null if the value was cleared.",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "contact_id": {
                                "type": "string"
                              },
                              "created_at": {
                                "type": "string"
                              },
                              "updated_at": {
                                "type": "string",
                                "nullable": true
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "The body is invalid, a type doesn't match its column, a value is missing its key, or a property type is not supported.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/ApiUnauthorized"
          },
          "404": {
            "description": "The contact or a property was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      },
      "get": {
        "tags": [
          "Contact"
        ],
        "operationId": "ListContactProperties",
        "summary": "Get contact properties",
        "description": "Lists the custom properties (columns) that can be set on the contact, with each one's `id`, `type` and options. Use the `id` and `type` when updating values. The contact's current values are in `crm_column` from `GET /api/crm/contact/{contact_id}`.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Contact ID.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Contact property definitions.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/CrmColumn"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/ApiUnauthorized"
          },
          "404": {
            "$ref": "#/components/responses/ApiNotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/api/crm/contact": {
      "post": {
        "tags": [
          "Contact"
        ],
        "operationId": "CreateContact",
        "summary": "Create a contact",
        "description": "Creates a contact. Phone numbers and email addresses must be unique within your business; a duplicate returns `409` with the existing contact's details.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "display_name",
                  "phone_number"
                ],
                "properties": {
                  "display_name": {
                    "type": "string"
                  },
                  "phone_number": {
                    "type": "string",
                    "description": "7 to 15 digits including the country code, optionally starting with `+`. Must not start with `0`."
                  },
                  "email": {
                    "type": "string",
                    "format": "email"
                  },
                  "note": {
                    "type": "string"
                  },
                  "additional_data": {
                    "type": "object",
                    "additionalProperties": true,
                    "description": "Free-form extra data saved on the contact."
                  },
                  "company_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "stage_id": {
                    "type": "string",
                    "format": "uuid",
                    "description": "Pipeline stage ID."
                  },
                  "contact_owner_id": {
                    "type": "string",
                    "format": "uuid",
                    "description": "Agent ID of the contact owner. The agent must be active."
                  },
                  "label_ids": {
                    "type": "array",
                    "description": "Contact label IDs to add.",
                    "items": {
                      "type": "string",
                      "format": "uuid"
                    }
                  },
                  "values": {
                    "type": "array",
                    "description": "Custom property values. Columns with a default value are filled in automatically when left out.",
                    "items": {
                      "type": "object",
                      "required": [
                        "column_id"
                      ],
                      "properties": {
                        "column_id": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "value": {
                          "description": "The value, in the format for the column's type. See **Board** for value formats."
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Contact created.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Contact"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "A required field is missing, the phone number is invalid, or a value is invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/ApiUnauthorized"
          },
          "404": {
            "description": "The company, stage, owner or label was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "409": {
            "description": "The phone number or email already belongs to a contact.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CrmConflictError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/api/crm/boards/{boardId}/items/{itemId}": {
      "put": {
        "tags": [
          "Board"
        ],
        "operationId": "UpdateCrmBoardItem",
        "summary": "Update a CRM board item",
        "description": "Updates an item's name and column values. Send only what you want to change, with column values as top-level fields named after each column (see **Board** for value formats).",
        "parameters": [
          {
            "name": "boardId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "itemId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "item_name": {
                    "type": "string"
                  }
                },
                "additionalProperties": {
                  "description": "Column values, keyed by column name."
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Item updated. Check `failed` for values that were not saved.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CrmItemWriteResult"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/ApiBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/ApiUnauthorized"
          },
          "404": {
            "description": "The board or item was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      },
      "get": {
        "tags": [
          "Board"
        ],
        "operationId": "GetCrmBoardItem",
        "summary": "Get a CRM board item",
        "description": "Returns one item with all its column values.",
        "parameters": [
          {
            "name": "boardId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "itemId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The item.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/CrmItem"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/ApiUnauthorized"
          },
          "404": {
            "description": "The board or item was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/api/crm/boards/{boardId}/items": {
      "delete": {
        "tags": [
          "Board"
        ],
        "operationId": "DeleteCrmBoardItems",
        "summary": "Delete CRM board items",
        "description": "Permanently deletes one or more items and their files from a board. If any ID is not found, nothing is deleted.",
        "parameters": [
          {
            "name": "boardId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "item_ids"
                ],
                "properties": {
                  "item_ids": {
                    "type": "array",
                    "minItems": 1,
                    "items": {
                      "type": "string",
                      "format": "uuid"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Items deleted. `data` lists the deleted items as they were.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/CrmItem"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "`item_ids` is missing or empty.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/ApiUnauthorized"
          },
          "404": {
            "description": "One or more items were not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      },
      "post": {
        "tags": [
          "Board"
        ],
        "operationId": "CreateCrmBoardItem",
        "summary": "Create a CRM board item",
        "description": "Adds an item to a board. Send column values as top-level fields named after each column (see **Board** for value formats). Columns with a default value are filled in when left out.",
        "parameters": [
          {
            "name": "boardId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "item_name"
                ],
                "properties": {
                  "item_name": {
                    "type": "string"
                  },
                  "group_id": {
                    "type": "string",
                    "format": "uuid",
                    "description": "Group to add the item to. Defaults to the board's first group."
                  }
                },
                "additionalProperties": {
                  "description": "Column values, keyed by column name."
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Item created. Check `failed` for values that were not saved.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CrmItemWriteResult"
                }
              }
            }
          },
          "400": {
            "description": "`item_name` is missing or empty.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/ApiUnauthorized"
          },
          "404": {
            "description": "The board or group was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      },
      "get": {
        "tags": [
          "Board"
        ],
        "operationId": "ListCrmBoardItems",
        "summary": "List CRM board items (page-based)",
        "deprecated": true,
        "description": "Older page-based version of `GET /api/crm/v2/boards/{boardId}/items`, kept for existing integrations. It has no filters or sorting. New integrations should use the v2 endpoint.",
        "parameters": [
          {
            "name": "boardId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 1
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000,
              "default": 200
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A page of items.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/CrmItem"
                      }
                    },
                    "hasMore": {
                      "type": "boolean",
                      "description": "True when the page is full, so there may be more items."
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/ApiBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/ApiUnauthorized"
          },
          "404": {
            "$ref": "#/components/responses/ApiNotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/api/crm/boards/{boardId}/columns/by-name": {
      "post": {
        "tags": [
          "Board"
        ],
        "operationId": "GetCrmColumnByName",
        "summary": "Get a CRM column by name",
        "description": "Looks up a board column by its exact name, for when you know the name but not the ID.",
        "parameters": [
          {
            "name": "boardId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "name"
                ],
                "properties": {
                  "name": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The column.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/CrmColumn"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/ApiBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/ApiUnauthorized"
          },
          "404": {
            "description": "The board or column was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/api/crm/boards": {
      "get": {
        "tags": [
          "Board"
        ],
        "operationId": "ListCrmBoards",
        "summary": "List CRM boards",
        "description": "Lists your custom CRM boards in sidebar order. The contact board is not included; use `GET /api/crm/contact/board` for it.",
        "responses": {
          "200": {
            "description": "Your boards.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/CrmBoard"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/ApiUnauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/api/crm/boards/{boardId}": {
      "get": {
        "tags": [
          "Board"
        ],
        "operationId": "GetCrmBoard",
        "summary": "Get a CRM board",
        "description": "Returns a board with its groups and columns, in display order. Use it to find column names, types, and select options before reading or writing items.",
        "parameters": [
          {
            "name": "boardId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The board.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/CrmBoardDetail"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/ApiUnauthorized"
          },
          "404": {
            "$ref": "#/components/responses/ApiNotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/api/crm/v2/boards/{boardId}/items": {
      "get": {
        "tags": [
          "Board"
        ],
        "operationId": "ListCrmBoardItemsV2",
        "summary": "List CRM board items",
        "description": "Lists a board's items with cursor pagination, search, date filters and sorting. Recommended over `GET /api/crm/boards/{boardId}/items`.\n\nTo get the next page, send the `nextCursor` from the previous response as `cursor`, with the same `sort_by` and `sort_direction`. Stop when `hasMore` is false. Date filters use whole days in Asia/Jakarta time (UTC+7).\n",
        "parameters": [
          {
            "name": "boardId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 100
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "The `nextCursor` value from the previous page.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sort_by",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "name",
                "created_at",
                "updated_at"
              ],
              "default": "updated_at"
            }
          },
          {
            "name": "sort_direction",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "asc",
                "desc"
              ],
              "default": "asc"
            }
          },
          {
            "name": "search",
            "in": "query",
            "required": false,
            "description": "Only items whose name contains this text (case-insensitive).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "created_by",
            "in": "query",
            "required": false,
            "description": "Only items created by this agent ID.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "created_at",
            "in": "query",
            "required": false,
            "description": "Only items created on this day (`YYYY-MM-DD`). Cannot be combined with `created_at_from` or `created_at_to`.",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "created_at_from",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "created_at_to",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "updated_at",
            "in": "query",
            "required": false,
            "description": "Only items updated on this day (`YYYY-MM-DD`). Cannot be combined with `updated_at_from` or `updated_at_to`.",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "updated_at_from",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "updated_at_to",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A page of items.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/CrmItem"
                      }
                    },
                    "hasMore": {
                      "type": "boolean"
                    },
                    "nextCursor": {
                      "type": "string",
                      "nullable": true,
                      "description": "Pass as `cursor` to get the next page. Null on the last page."
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "A parameter is invalid, or the cursor doesn't match `sort_by` or `sort_direction`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/ApiUnauthorized"
          },
          "404": {
            "$ref": "#/components/responses/ApiNotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/api/crm/boards/{boardId}/columns/{columnId}": {
      "get": {
        "tags": [
          "Board"
        ],
        "operationId": "GetCrmColumn",
        "summary": "Get a CRM column",
        "description": "Returns one column of a board, including its type and select options. Also works on the contact board for contact properties.",
        "parameters": [
          {
            "name": "boardId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "columnId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The column.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/CrmColumn"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/ApiUnauthorized"
          },
          "404": {
            "description": "The board or column was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/api/crm/boards/{boardId}/items/search": {
      "post": {
        "tags": [
          "Board"
        ],
        "operationId": "SearchCrmBoardItems",
        "summary": "Search CRM board items",
        "description": "Finds items on a board that match one or more conditions. `column_name` is a column's name, or `item_name`, `__created_at__` or `__updated_at__` for the built-in fields.\n\n| Field type | Operators |\n| --- | --- |\n| `item_name` | `equals`, `not_equals`, `contains`, `not_contains`, `starts_with`, `ends_with` |\n| Text, email, phone, select, conversation | `is_empty`, `is_not_empty`, `equals`, `not_equals`, `contains`, `not_contains`, `starts_with`, `ends_with` |\n| Number | `is_empty`, `is_not_empty`, `equals`, `not_equals`, `greater_than`, `less_than`, `greater_than_or_equal`, `less_than_or_equal` |\n| Checkbox | `is_empty`, `is_not_empty`, `is_true`, `is_false` |\n| Date | `is_empty`, `is_not_empty`, `start_date`, `end_date` |\n| Timeline | `is_empty`, `is_not_empty`, `from_start_date`, `from_end_date`, `to_start_date`, `to_end_date` |\n| Multi-value (dropdown, agents, contacts, and so on) | `is_empty`, `is_not_empty`, `equals`, `not_equals`, `contains`, `not_contains` |\n\n`is_empty`, `is_not_empty`, `is_true` and `is_false` don't need a `value`.\n",
        "parameters": [
          {
            "name": "boardId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "page",
                  "limit",
                  "search"
                ],
                "properties": {
                  "page": {
                    "type": "integer",
                    "minimum": 1
                  },
                  "limit": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 1000
                  },
                  "condition": {
                    "type": "string",
                    "enum": [
                      "AND",
                      "OR"
                    ],
                    "description": "Required when `search` has more than one condition."
                  },
                  "search": {
                    "type": "array",
                    "minItems": 1,
                    "items": {
                      "type": "object",
                      "required": [
                        "column_name",
                        "operator"
                      ],
                      "properties": {
                        "column_name": {
                          "type": "string"
                        },
                        "operator": {
                          "type": "string"
                        },
                        "value": {
                          "description": "Value to compare against."
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Matching items.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/CrmItem"
                      }
                    },
                    "hasMore": {
                      "type": "boolean",
                      "description": "True when the page is full, so there may be more results."
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "The search is invalid, a column doesn't exist, or an operator is not allowed for the column's type.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/ApiUnauthorized"
          },
          "404": {
            "$ref": "#/components/responses/ApiNotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/api/documents": {
      "delete": {
        "tags": [
          "AI"
        ],
        "operationId": "DeleteQnaDocuments",
        "summary": "Delete Q&A documents",
        "description": "Removes Q&A pairs from your AI agents' knowledge. IDs that don't exist are ignored.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "ids"
                ],
                "properties": {
                  "ids": {
                    "type": "array",
                    "minItems": 1,
                    "items": {
                      "type": "string",
                      "format": "uuid"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Q&A deleted. `data.ids` lists what was deleted.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "ids": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "question": {
                                "type": "string"
                              },
                              "answer": {
                                "type": "string"
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "`ids` is missing or empty.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/ApiUnauthorized"
          },
          "404": {
            "description": "None of the IDs were found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      },
      "post": {
        "tags": [
          "AI"
        ],
        "operationId": "CreateQnaDocuments",
        "summary": "Create Q&A documents",
        "description": "Adds question-and-answer pairs to an AI agent's knowledge. Pairs that already exist with the same question and answer, and items missing a question or answer, are skipped. New pairs are processed for the AI agent to use.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "ai_agent_id",
                  "qna"
                ],
                "properties": {
                  "ai_agent_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "qna": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "required": [
                        "question",
                        "answer"
                      ],
                      "properties": {
                        "question": {
                          "type": "string"
                        },
                        "answer": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Nothing new to add; every pair already exists.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "ids": {
                          "type": "array",
                          "items": {
                            "type": "object"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "201": {
            "description": "Q&A added.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "ids": {
                          "type": "array",
                          "description": "The Q&A pairs that were added, with their new IDs.",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "question": {
                                "type": "string"
                              },
                              "answer": {
                                "type": "string"
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "`ai_agent_id` or `qna` is missing, or `qna` is not an array.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/ApiUnauthorized"
          },
          "404": {
            "description": "The AI agent was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      },
      "get": {
        "tags": [
          "AI"
        ],
        "operationId": "ListQnaDocuments",
        "summary": "List Q&A documents",
        "description": "Lists the question-and-answer pairs in your AI agents' knowledge, newest first.",
        "parameters": [
          {
            "name": "ai_agent_id",
            "in": "query",
            "required": false,
            "description": "Only Q&A for this AI agent.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 1
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A page of Q&A documents.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/QnaDocument"
                      }
                    },
                    "metadata": {
                      "type": "object",
                      "properties": {
                        "pagination": {
                          "type": "object",
                          "properties": {
                            "page": {
                              "type": "integer"
                            },
                            "limit": {
                              "type": "integer"
                            },
                            "total": {
                              "type": "integer"
                            },
                            "total_pages": {
                              "type": "integer"
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/ApiBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/ApiUnauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/integrations/delete": {
      "delete": {
        "tags": [
          "AI"
        ],
        "operationId": "DeleteIntegration",
        "summary": "Delete the OrderOnline integration",
        "description": "Disconnects your business's OrderOnline integration. Returns the deleted integration, or no `data` if none was connected.",
        "responses": {
          "200": {
            "description": "Integration removed.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "nullable": true,
                      "additionalProperties": true
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/api/ai_response/beta": {
      "post": {
        "tags": [
          "AI"
        ],
        "operationId": "GenerateAiResponse",
        "summary": "Generate an AI response (beta)",
        "description": "Runs one of your AI agents on a chat history you provide and returns its reply, without sending anything to a contact. Use it to test an AI agent or to generate replies for your own channel.\n\nThe history must end with a message from the user. Each reply reports the AI credits it used. This endpoint is in beta and may change.\n",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "ai_agent_id",
                  "messages"
                ],
                "properties": {
                  "ai_agent_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "messages": {
                    "type": "array",
                    "description": "The chat history, oldest first. The last message must be from the user.",
                    "items": {
                      "type": "object",
                      "properties": {
                        "role": {
                          "type": "string",
                          "enum": [
                            "user",
                            "assistant"
                          ]
                        },
                        "message": {
                          "type": "string"
                        },
                        "created_at": {
                          "type": "string",
                          "format": "date-time"
                        }
                      }
                    }
                  },
                  "chat_data": {
                    "type": "object",
                    "additionalProperties": true,
                    "description": "Data the AI agent collected earlier in this chat. Send back the `chat_data` from the previous response to continue the same chat."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The AI agent's reply.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "messages": {
                      "type": "array",
                      "description": "The reply, plus system notes when the AI agent ran tools.",
                      "items": {
                        "type": "object",
                        "properties": {
                          "role": {
                            "type": "string",
                            "enum": [
                              "assistant",
                              "system"
                            ]
                          },
                          "content": {
                            "type": "string"
                          },
                          "credits_used": {
                            "type": "number",
                            "description": "AI credits used for this reply."
                          }
                        }
                      }
                    },
                    "chat_data": {
                      "type": "object",
                      "additionalProperties": true
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "`ai_agent_id` is missing, `messages` is not an array, or there is no user message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/ApiUnauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "502": {
            "description": "The AI service is unavailable. Retry later.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/integrations": {
      "get": {
        "tags": [
          "AI"
        ],
        "operationId": "GetIntegration",
        "summary": "Get the OrderOnline integration",
        "description": "Returns your business's OrderOnline integration, or an empty object if none is connected.",
        "responses": {
          "200": {
            "description": "The integration, or `{}`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "status_code": {
                      "type": "integer"
                    },
                    "data": {
                      "type": "object",
                      "additionalProperties": true,
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "partner_code": {
                          "type": "string"
                        },
                        "business_id": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "created_at": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "user_data": {
                          "type": "object",
                          "additionalProperties": true
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/api/orders": {
      "post": {
        "tags": [
          "Orders"
        ],
        "operationId": "CreateOrder",
        "summary": "Create an order",
        "description": "Creates an order and its invoice. Identify the customer with `conversation_id`, `contact_id` or `phone_number`; if no contact matches, a new one is created from `phone_number` and `display_name`.\n\nFor each product, send a `product_id` from your catalog (its catalog name and price are used) or a `product_name` and `price` for a custom item. The grand total (subtotal − discount + shipping fee + VAT) must be between 1 and 9,999,999,999.\n",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "payment_method",
                  "orders_products"
                ],
                "properties": {
                  "payment_method": {
                    "type": "string",
                    "enum": [
                      "manual",
                      "xendit",
                      "custom"
                    ]
                  },
                  "orders_products": {
                    "type": "array",
                    "minItems": 1,
                    "items": {
                      "type": "object",
                      "properties": {
                        "product_id": {
                          "type": "string",
                          "format": "uuid",
                          "description": "A catalog product. Leave out for a custom item."
                        },
                        "product_name": {
                          "type": "string",
                          "description": "Name of a custom item."
                        },
                        "price": {
                          "type": "number",
                          "description": "Price of a custom item."
                        },
                        "quantity": {
                          "type": "integer",
                          "default": 1
                        }
                      }
                    }
                  },
                  "conversation_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "contact_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "phone_number": {
                    "type": "string"
                  },
                  "display_name": {
                    "type": "string",
                    "description": "Required with `phone_number` when the contact is new."
                  },
                  "email": {
                    "type": "string",
                    "format": "email"
                  },
                  "bank_account_number": {
                    "type": "string",
                    "description": "Required for `manual`. A payment bank account set up in Cekat."
                  },
                  "custom_invoice_url": {
                    "type": "string",
                    "format": "uri",
                    "description": "Required for `custom`."
                  },
                  "discount": {
                    "type": "number",
                    "minimum": 0,
                    "default": 0
                  },
                  "shipping_fee": {
                    "type": "number",
                    "minimum": 0,
                    "default": 0
                  },
                  "vat": {
                    "type": "number",
                    "minimum": 0,
                    "default": 0
                  },
                  "address": {
                    "type": "string"
                  },
                  "notes": {
                    "type": "string"
                  },
                  "id": {
                    "type": "string",
                    "format": "uuid",
                    "description": "Optional order ID (UUID v4) to use instead of a generated one."
                  },
                  "created_at": {
                    "type": "string",
                    "format": "date-time",
                    "description": "Optional order date, for importing past orders."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Order and invoice created.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/Order"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "A required field is missing, or a value is out of range.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/ApiUnauthorized"
          },
          "404": {
            "description": "The bank account was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      },
      "get": {
        "tags": [
          "Orders"
        ],
        "operationId": "ListOrders",
        "summary": "List orders",
        "description": "Lists orders with filters, search and sorting.",
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 1
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000,
              "default": 100
            }
          },
          {
            "name": "order_status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "pending",
                "processing",
                "shipping",
                "cancelled",
                "completed"
              ]
            }
          },
          {
            "name": "payment_status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "PENDING",
                "PAID",
                "EXPIRED",
                "SETTLED"
              ]
            }
          },
          {
            "name": "inbox_id",
            "in": "query",
            "required": false,
            "description": "Only orders from conversations in this inbox.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "search",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sort_field",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "created_at",
                "order_number",
                "subtotal"
              ],
              "default": "created_at"
            }
          },
          {
            "name": "sort_direction",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "asc",
                "desc"
              ],
              "default": "desc"
            }
          },
          {
            "$ref": "#/components/parameters/StartDate"
          },
          {
            "$ref": "#/components/parameters/EndDate"
          },
          {
            "$ref": "#/components/parameters/StartDatetime"
          },
          {
            "$ref": "#/components/parameters/EndDatetime"
          },
          {
            "$ref": "#/components/parameters/UserTimezone"
          }
        ],
        "responses": {
          "200": {
            "description": "A page of orders.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "orders": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/Order"
                          }
                        },
                        "pagination": {
                          "type": "object",
                          "properties": {
                            "page": {
                              "type": "integer"
                            },
                            "limit": {
                              "type": "integer"
                            },
                            "total_items": {
                              "type": "integer"
                            },
                            "total_pages": {
                              "type": "integer"
                            }
                          }
                        },
                        "filters": {
                          "type": "object",
                          "additionalProperties": true,
                          "description": "The filters that were applied."
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "A filter value is invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/ApiUnauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/api/orders/{id}": {
      "put": {
        "tags": [
          "Orders"
        ],
        "operationId": "UpdateOrder",
        "summary": "Update an order",
        "description": "Updates an order's status, payment status, address, notes, or invoice. Send only the fields you want to change. `changed` in the response lists what changed, with old and new values.\n\nCancelling an order with a pending invoice expires the invoice (and its Xendit payment link). Payment status can't be set by hand for Xendit orders.\n",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "order_status": {
                    "type": "string",
                    "enum": [
                      "pending",
                      "processing",
                      "shipping",
                      "cancelled",
                      "completed"
                    ]
                  },
                  "payment_status": {
                    "type": "string",
                    "enum": [
                      "pending",
                      "paid",
                      "expired"
                    ]
                  },
                  "invoice_is_sent": {
                    "type": "boolean"
                  },
                  "address": {
                    "type": "string"
                  },
                  "notes": {
                    "type": "string"
                  },
                  "custom_invoice_url": {
                    "type": "string",
                    "format": "uri",
                    "description": "Only for `custom` orders."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Order updated.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/Order"
                    },
                    "changed": {
                      "type": "object",
                      "description": "Each changed field with `old_value` and `new_value`.",
                      "additionalProperties": {
                        "type": "object",
                        "properties": {
                          "old_value": {},
                          "new_value": {}
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "A value is invalid, or the change is not allowed for this payment method.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/ApiUnauthorized"
          },
          "404": {
            "$ref": "#/components/responses/ApiNotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      },
      "get": {
        "tags": [
          "Orders"
        ],
        "operationId": "GetOrder",
        "summary": "Get an order",
        "description": "Returns an order with its contact, conversation, products, invoices and bank account.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The order.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/Order"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/ApiUnauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    }
  }
}