{
    "openapi": "3.0.3",
    "info": {
        "title": "WbJet API",
        "version": "1.0.0",
        "description": "Public REST API documentation for WbJet API. Authenticate all requests using a Bearer Token generated from **Developer Tools > Access Tokens** in your dashboard.\n\n### Real-time Webhooks\nBesides polling via `GET /api/chats`, `GET /api/chats/{identifier}/messages`, and `GET /api/messages/{identifier}/status`, you can also subscribe to real-time push webhooks (`message.received`, `message.sent`, `message.status.update`) under **Developer Tools > Webhooks**."
    },
    "servers": [
        {
            "url": "https://app.wbjet.com",
            "description": "Live API Server"
        }
    ],
    "tags": [
        {
            "name": "Authentication",
            "description": "Verify API key, WhatsApp connection, subscription, and wallet balance"
        },
        {
            "name": "Messages",
            "description": "Send WhatsApp text, interactive, media, and template messages"
        },
        {
            "name": "Inbox & Delivery Status",
            "description": "Read inbox conversations, chat threads, mark read, and check delivery/read receipts"
        },
        {
            "name": "Inbox CRM Controls",
            "description": "Internal CRM notes, AI bot toggle, ticket assignment, and team agents"
        },
        {
            "name": "Campaigns",
            "description": "Create bulk WhatsApp template campaigns, track stats, and inspect delivery/reply logs"
        },
        {
            "name": "Contacts",
            "description": "Search, create, read, update, delete, and label WhatsApp contacts"
        },
        {
            "name": "CRM Labels",
            "description": "Create, list, and delete contact labels/tags"
        },
        {
            "name": "Contact Groups",
            "description": "Manage contact groups for targeted messaging"
        },
        {
            "name": "Automated Replies",
            "description": "Manage keyword-based canned/automated replies"
        },
        {
            "name": "Templates",
            "description": "Retrieve approved WhatsApp message templates"
        },
        {
            "name": "Webhooks",
            "description": "Programmatically register, list, and delete webhook subscriptions"
        },
        {
            "name": "Flows & Leads",
            "description": "List FlowBuilder flows and retrieve WhatsApp Flow form submissions"
        }
    ],
    "components": {
        "securitySchemes": {
            "bearerAuth": {
                "type": "http",
                "scheme": "bearer",
                "bearerFormat": "API Token",
                "description": "Enter your API token (without the \"Bearer \" prefix)."
            }
        }
    },
    "paths": {
        "/api/verify": {
            "get": {
                "tags": [
                    "Authentication"
                ],
                "summary": "Verify API Key",
                "description": "Checks whether the provided Bearer API key is valid and the organization has an active subscription.",
                "operationId": "verifyApiKey",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "example": {
                                        "statusCode": 200,
                                        "message": "API key is valid and active"
                                    }
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Validation error / invalid input payload",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 400,
                                    "message": "The given data was invalid.",
                                    "errors": {
                                        "field": [
                                            "The field is required."
                                        ]
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Missing or invalid Bearer API token",
                        "content": {
                            "application/json": {
                                "example": {
                                    "error": "Unauthorized. Invalid Bearer Token."
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "Inactive subscription, plan limit reached, or WhatsApp not connected",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 403,
                                    "message": "Please renew or subscribe to a plan to continue!"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/api/account/status": {
            "get": {
                "tags": [
                    "Authentication"
                ],
                "summary": "Check Account, WhatsApp & Wallet Status",
                "description": "Returns organization details, WhatsApp Cloud API connection status, phone_number_id, waba_id, subscription status, and wallet balance.",
                "operationId": "accountStatus",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "example": {
                                        "statusCode": 200,
                                        "data": {
                                            "organization": {
                                                "uuid": "org-uuid",
                                                "name": "My Business",
                                                "wallet_balance": 500
                                            },
                                            "whatsapp": {
                                                "connected": true,
                                                "phone_number_id": "1234567890",
                                                "waba_id": "9876543210"
                                            },
                                            "subscription": {
                                                "is_active": true,
                                                "status": "active",
                                                "plan_name": "Pro",
                                                "valid_until": "2027-01-01 00:00:00"
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Validation error / invalid input payload",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 400,
                                    "message": "The given data was invalid.",
                                    "errors": {
                                        "field": [
                                            "The field is required."
                                        ]
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Missing or invalid Bearer API token",
                        "content": {
                            "application/json": {
                                "example": {
                                    "error": "Unauthorized. Invalid Bearer Token."
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "Inactive subscription, plan limit reached, or WhatsApp not connected",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 403,
                                    "message": "Please renew or subscribe to a plan to continue!"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/api/send": {
            "post": {
                "tags": [
                    "Messages"
                ],
                "summary": "Send Text / Interactive Message",
                "description": "Sends a WhatsApp text message or interactive reply-button message. Automatically creates a contact if the phone number does not exist yet.",
                "operationId": "sendMessage",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "example": {
                                        "statusCode": 200,
                                        "data": {
                                            "success": true,
                                            "data": {
                                                "chat": {
                                                    "uuid": "..."
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Validation error / invalid input payload",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 400,
                                    "message": "The given data was invalid.",
                                    "errors": {
                                        "field": [
                                            "The field is required."
                                        ]
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Missing or invalid Bearer API token",
                        "content": {
                            "application/json": {
                                "example": {
                                    "error": "Unauthorized. Invalid Bearer Token."
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "Inactive subscription, plan limit reached, or WhatsApp not connected",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 403,
                                    "message": "Please renew or subscribe to a plan to continue!"
                                }
                            }
                        }
                    }
                },
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "phone",
                                    "message"
                                ],
                                "properties": {
                                    "phone": {
                                        "type": "string",
                                        "description": "Recipient phone number in international E.164 format"
                                    },
                                    "message": {
                                        "type": "string",
                                        "description": "Message body text"
                                    },
                                    "header": {
                                        "type": "string",
                                        "description": "Optional interactive message header"
                                    },
                                    "footer": {
                                        "type": "string",
                                        "description": "Optional interactive message footer"
                                    },
                                    "buttons": {
                                        "type": "array",
                                        "description": "Optional quick-reply buttons (turns message into interactive buttons)",
                                        "items": {
                                            "type": "object",
                                            "properties": {
                                                "id": {
                                                    "type": "string"
                                                },
                                                "title": {
                                                    "type": "string"
                                                }
                                            }
                                        }
                                    },
                                    "first_name": {
                                        "type": "string",
                                        "description": "Optional first name when auto-creating contact"
                                    },
                                    "last_name": {
                                        "type": "string",
                                        "description": "Optional last name when auto-creating contact"
                                    },
                                    "email": {
                                        "type": "string",
                                        "description": "Optional email when auto-creating contact"
                                    }
                                }
                            },
                            "example": {
                                "phone": "+919876543210",
                                "message": "Hello John, how are you?",
                                "header": "Support Update",
                                "footer": "Reply below",
                                "buttons": [
                                    {
                                        "id": "btn_1",
                                        "title": "Fine"
                                    },
                                    {
                                        "id": "btn_2",
                                        "title": "Need Help"
                                    }
                                ]
                            }
                        }
                    }
                }
            }
        },
        "/api/send/media": {
            "post": {
                "tags": [
                    "Messages"
                ],
                "summary": "Send Media Message",
                "description": "Sends an image, video, audio, or document via WhatsApp using a public media URL. Auto-creates the contact if needed.",
                "operationId": "sendMediaMessage",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "example": {
                                        "statusCode": 200,
                                        "data": {
                                            "success": true
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Validation error / invalid input payload",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 400,
                                    "message": "The given data was invalid.",
                                    "errors": {
                                        "field": [
                                            "The field is required."
                                        ]
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Missing or invalid Bearer API token",
                        "content": {
                            "application/json": {
                                "example": {
                                    "error": "Unauthorized. Invalid Bearer Token."
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "Inactive subscription, plan limit reached, or WhatsApp not connected",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 403,
                                    "message": "Please renew or subscribe to a plan to continue!"
                                }
                            }
                        }
                    }
                },
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "phone",
                                    "media_type",
                                    "media_url",
                                    "caption",
                                    "file_name"
                                ],
                                "properties": {
                                    "phone": {
                                        "type": "string"
                                    },
                                    "media_type": {
                                        "type": "string",
                                        "enum": [
                                            "image",
                                            "video",
                                            "document",
                                            "audio"
                                        ]
                                    },
                                    "media_url": {
                                        "type": "string",
                                        "format": "uri"
                                    },
                                    "caption": {
                                        "type": "string"
                                    },
                                    "file_name": {
                                        "type": "string"
                                    },
                                    "first_name": {
                                        "type": "string"
                                    },
                                    "last_name": {
                                        "type": "string"
                                    },
                                    "email": {
                                        "type": "string"
                                    }
                                }
                            },
                            "example": {
                                "phone": "+919876543210",
                                "media_type": "image",
                                "media_url": "https://images.pexels.com/photos/276267/pexels-photo-276267.jpeg",
                                "caption": "Order receipt image",
                                "file_name": "receipt.jpg"
                            }
                        }
                    }
                }
            }
        },
        "/api/send/template": {
            "post": {
                "tags": [
                    "Messages"
                ],
                "summary": "Send Template Message",
                "description": "Sends a Meta-approved WhatsApp template message with optional header, body, and button variables.",
                "operationId": "sendTemplateMessage",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "example": {
                                        "statusCode": 200,
                                        "data": {
                                            "success": true
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Validation error / invalid input payload",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 400,
                                    "message": "The given data was invalid.",
                                    "errors": {
                                        "field": [
                                            "The field is required."
                                        ]
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Missing or invalid Bearer API token",
                        "content": {
                            "application/json": {
                                "example": {
                                    "error": "Unauthorized. Invalid Bearer Token."
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "Inactive subscription, plan limit reached, or WhatsApp not connected",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 403,
                                    "message": "Please renew or subscribe to a plan to continue!"
                                }
                            }
                        }
                    }
                },
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "phone",
                                    "template"
                                ],
                                "properties": {
                                    "phone": {
                                        "type": "string"
                                    },
                                    "first_name": {
                                        "type": "string"
                                    },
                                    "last_name": {
                                        "type": "string"
                                    },
                                    "email": {
                                        "type": "string"
                                    },
                                    "template": {
                                        "type": "object",
                                        "required": [
                                            "name",
                                            "language"
                                        ],
                                        "properties": {
                                            "name": {
                                                "type": "string",
                                                "description": "Exact template name registered in Meta"
                                            },
                                            "language": {
                                                "type": "object",
                                                "required": [
                                                    "code"
                                                ],
                                                "properties": {
                                                    "code": {
                                                        "type": "string",
                                                        "example": "en"
                                                    }
                                                }
                                            },
                                            "components": {
                                                "type": "array",
                                                "items": {
                                                    "type": "object"
                                                }
                                            }
                                        }
                                    }
                                }
                            },
                            "example": {
                                "phone": "+919876543210",
                                "template": {
                                    "name": "hello_world",
                                    "language": {
                                        "code": "en_US"
                                    },
                                    "components": [
                                        {
                                            "type": "body",
                                            "parameters": [
                                                {
                                                    "type": "text",
                                                    "text": "John"
                                                }
                                            ]
                                        }
                                    ]
                                }
                            }
                        }
                    }
                }
            }
        },
        "/api/contacts": {
            "get": {
                "tags": [
                    "Contacts"
                ],
                "summary": "Get Contact List (with Search & Group Filter)",
                "description": "Returns paginated contacts for the organization. Supports searching by name, phone, or email and filtering by group UUID.",
                "operationId": "listContacts",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "example": {
                                        "data": [
                                            {
                                                "id": 1,
                                                "uuid": "945d8b4f-a580-4743-bdfa-f0095059b37a",
                                                "first_name": "John",
                                                "last_name": "Doe",
                                                "phone": "+919876543210",
                                                "email": "john@example.com"
                                            }
                                        ],
                                        "meta": {
                                            "current_page": 1,
                                            "per_page": 10,
                                            "total": 1
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Validation error / invalid input payload",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 400,
                                    "message": "The given data was invalid.",
                                    "errors": {
                                        "field": [
                                            "The field is required."
                                        ]
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Missing or invalid Bearer API token",
                        "content": {
                            "application/json": {
                                "example": {
                                    "error": "Unauthorized. Invalid Bearer Token."
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "Inactive subscription, plan limit reached, or WhatsApp not connected",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 403,
                                    "message": "Please renew or subscribe to a plan to continue!"
                                }
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "page",
                        "in": "query",
                        "required": false,
                        "description": "Page number (minimum 1)",
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "default": 1
                        }
                    },
                    {
                        "name": "per_page",
                        "in": "query",
                        "required": false,
                        "description": "Records per page (1 to 100)",
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 100,
                            "default": 10
                        }
                    },
                    {
                        "name": "search",
                        "in": "query",
                        "required": false,
                        "description": "Search by first name, last name, phone, or email",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "group_uuid",
                        "in": "query",
                        "required": false,
                        "description": "Filter contacts belonging to a Contact Group UUID",
                        "schema": {
                            "type": "string"
                        }
                    }
                ]
            },
            "post": {
                "tags": [
                    "Contacts"
                ],
                "summary": "Add Contact",
                "description": "Creates a new contact in your organization.",
                "operationId": "storeContact",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "example": {
                                        "statusCode": 200,
                                        "id": "945d8b4f-a580-4743-bdfa-f0095059b37a",
                                        "message": "Request processed successfully"
                                    }
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Validation error / invalid input payload",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 400,
                                    "message": "The given data was invalid.",
                                    "errors": {
                                        "field": [
                                            "The field is required."
                                        ]
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Missing or invalid Bearer API token",
                        "content": {
                            "application/json": {
                                "example": {
                                    "error": "Unauthorized. Invalid Bearer Token."
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "Inactive subscription, plan limit reached, or WhatsApp not connected",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 403,
                                    "message": "Please renew or subscribe to a plan to continue!"
                                }
                            }
                        }
                    }
                },
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "first_name",
                                    "phone"
                                ],
                                "properties": {
                                    "first_name": {
                                        "type": "string"
                                    },
                                    "last_name": {
                                        "type": "string"
                                    },
                                    "phone": {
                                        "type": "string",
                                        "description": "Valid unique international phone number"
                                    },
                                    "email": {
                                        "type": "string",
                                        "format": "email"
                                    },
                                    "is_unsubscribed": {
                                        "type": "integer",
                                        "enum": [
                                            0,
                                            1
                                        ]
                                    },
                                    "street": {
                                        "type": "string"
                                    },
                                    "city": {
                                        "type": "string"
                                    },
                                    "state": {
                                        "type": "string"
                                    },
                                    "zip": {
                                        "type": "string"
                                    },
                                    "country": {
                                        "type": "string"
                                    },
                                    "group": {
                                        "type": "array",
                                        "items": {
                                            "type": "string"
                                        },
                                        "description": "Array of Contact Group UUIDs"
                                    },
                                    "metadata": {
                                        "type": "object"
                                    }
                                }
                            },
                            "example": {
                                "first_name": "John",
                                "last_name": "Doe",
                                "email": "johndoe@gmail.com",
                                "phone": "+919876543210"
                            }
                        }
                    }
                }
            }
        },
        "/api/contacts/{identifier}": {
            "get": {
                "tags": [
                    "Contacts"
                ],
                "summary": "Get Single Contact Details",
                "description": "Fetches full profile, groups, labels, ticket status, AI toggle state, and unread count using Contact UUID or phone number.",
                "operationId": "showContact",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "example": {
                                        "statusCode": 200,
                                        "message": "Request processed successfully"
                                    }
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Validation error / invalid input payload",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 400,
                                    "message": "The given data was invalid.",
                                    "errors": {
                                        "field": [
                                            "The field is required."
                                        ]
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Missing or invalid Bearer API token",
                        "content": {
                            "application/json": {
                                "example": {
                                    "error": "Unauthorized. Invalid Bearer Token."
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "Inactive subscription, plan limit reached, or WhatsApp not connected",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 403,
                                    "message": "Please renew or subscribe to a plan to continue!"
                                }
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "identifier",
                        "in": "path",
                        "required": true,
                        "description": "Contact UUID or phone number",
                        "example": "945d8b4f-a580-4743-bdfa-f0095059b37a",
                        "schema": {
                            "type": "string"
                        }
                    }
                ]
            }
        },
        "/api/contacts/{uuid}": {
            "put": {
                "tags": [
                    "Contacts"
                ],
                "summary": "Edit Contact",
                "description": "Updates an existing contact by UUID.",
                "operationId": "updateContact",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "example": {
                                        "statusCode": 200,
                                        "id": "945d8b4f-a580-4743-bdfa-f0095059b37a",
                                        "message": "Request processed successfully"
                                    }
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Validation error / invalid input payload",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 400,
                                    "message": "The given data was invalid.",
                                    "errors": {
                                        "field": [
                                            "The field is required."
                                        ]
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Missing or invalid Bearer API token",
                        "content": {
                            "application/json": {
                                "example": {
                                    "error": "Unauthorized. Invalid Bearer Token."
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "Inactive subscription, plan limit reached, or WhatsApp not connected",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 403,
                                    "message": "Please renew or subscribe to a plan to continue!"
                                }
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "uuid",
                        "in": "path",
                        "required": true,
                        "description": "UUID of the contact",
                        "example": "945d8b4f-a580-4743-bdfa-f0095059b37a",
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "phone"
                                ],
                                "properties": {
                                    "first_name": {
                                        "type": "string"
                                    },
                                    "last_name": {
                                        "type": "string"
                                    },
                                    "phone": {
                                        "type": "string"
                                    },
                                    "email": {
                                        "type": "string",
                                        "format": "email"
                                    },
                                    "is_unsubscribed": {
                                        "type": "integer",
                                        "enum": [
                                            0,
                                            1
                                        ]
                                    },
                                    "street": {
                                        "type": "string"
                                    },
                                    "city": {
                                        "type": "string"
                                    },
                                    "state": {
                                        "type": "string"
                                    },
                                    "zip": {
                                        "type": "string"
                                    },
                                    "country": {
                                        "type": "string"
                                    },
                                    "group": {
                                        "type": "array",
                                        "items": {
                                            "type": "string"
                                        }
                                    },
                                    "metadata": {
                                        "type": "object"
                                    }
                                }
                            },
                            "example": {
                                "first_name": "John",
                                "last_name": "Doe Updated",
                                "email": "johndoe@gmail.com",
                                "phone": "+919876543210"
                            }
                        }
                    }
                }
            },
            "delete": {
                "tags": [
                    "Contacts"
                ],
                "summary": "Delete Contact",
                "description": "Soft-deletes a contact by UUID.",
                "operationId": "destroyContact",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "example": {
                                        "statusCode": 200,
                                        "id": "945d8b4f-a580-4743-bdfa-f0095059b37a",
                                        "message": "Request processed successfully"
                                    }
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Validation error / invalid input payload",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 400,
                                    "message": "The given data was invalid.",
                                    "errors": {
                                        "field": [
                                            "The field is required."
                                        ]
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Missing or invalid Bearer API token",
                        "content": {
                            "application/json": {
                                "example": {
                                    "error": "Unauthorized. Invalid Bearer Token."
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "Inactive subscription, plan limit reached, or WhatsApp not connected",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 403,
                                    "message": "Please renew or subscribe to a plan to continue!"
                                }
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "uuid",
                        "in": "path",
                        "required": true,
                        "description": "UUID of the contact",
                        "example": "945d8b4f-a580-4743-bdfa-f0095059b37a",
                        "schema": {
                            "type": "string"
                        }
                    }
                ]
            }
        },
        "/api/contacts/{identifier}/labels": {
            "post": {
                "tags": [
                    "Contacts"
                ],
                "summary": "Assign / Sync Contact Labels",
                "description": "Assigns, syncs, or detaches CRM labels/tags on a contact (by Contact UUID or phone number).",
                "operationId": "syncContactLabels",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "example": {
                                        "statusCode": 200,
                                        "message": "Request processed successfully"
                                    }
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Validation error / invalid input payload",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 400,
                                    "message": "The given data was invalid.",
                                    "errors": {
                                        "field": [
                                            "The field is required."
                                        ]
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Missing or invalid Bearer API token",
                        "content": {
                            "application/json": {
                                "example": {
                                    "error": "Unauthorized. Invalid Bearer Token."
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "Inactive subscription, plan limit reached, or WhatsApp not connected",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 403,
                                    "message": "Please renew or subscribe to a plan to continue!"
                                }
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "identifier",
                        "in": "path",
                        "required": true,
                        "description": "Contact UUID or phone number",
                        "example": "945d8b4f-a580-4743-bdfa-f0095059b37a",
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "label_uuids"
                                ],
                                "properties": {
                                    "label_uuids": {
                                        "type": "array",
                                        "items": {
                                            "type": "string"
                                        }
                                    },
                                    "mode": {
                                        "type": "string",
                                        "enum": [
                                            "sync",
                                            "attach",
                                            "detach"
                                        ],
                                        "default": "sync"
                                    }
                                }
                            },
                            "example": {
                                "label_uuids": [
                                    "label-uuid-1"
                                ],
                                "mode": "attach"
                            }
                        }
                    }
                }
            }
        },
        "/api/labels": {
            "get": {
                "tags": [
                    "CRM Labels"
                ],
                "summary": "List CRM Labels",
                "description": "Returns all labels/tags configured in the organization.",
                "operationId": "listLabels",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "example": {
                                        "statusCode": 200,
                                        "message": "Request processed successfully"
                                    }
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Validation error / invalid input payload",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 400,
                                    "message": "The given data was invalid.",
                                    "errors": {
                                        "field": [
                                            "The field is required."
                                        ]
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Missing or invalid Bearer API token",
                        "content": {
                            "application/json": {
                                "example": {
                                    "error": "Unauthorized. Invalid Bearer Token."
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "Inactive subscription, plan limit reached, or WhatsApp not connected",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 403,
                                    "message": "Please renew or subscribe to a plan to continue!"
                                }
                            }
                        }
                    }
                }
            },
            "post": {
                "tags": [
                    "CRM Labels"
                ],
                "summary": "Create CRM Label",
                "description": "Creates a new CRM label/tag.",
                "operationId": "storeLabel",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "example": {
                                        "statusCode": 200,
                                        "message": "Request processed successfully"
                                    }
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Validation error / invalid input payload",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 400,
                                    "message": "The given data was invalid.",
                                    "errors": {
                                        "field": [
                                            "The field is required."
                                        ]
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Missing or invalid Bearer API token",
                        "content": {
                            "application/json": {
                                "example": {
                                    "error": "Unauthorized. Invalid Bearer Token."
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "Inactive subscription, plan limit reached, or WhatsApp not connected",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 403,
                                    "message": "Please renew or subscribe to a plan to continue!"
                                }
                            }
                        }
                    }
                },
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "name"
                                ],
                                "properties": {
                                    "name": {
                                        "type": "string"
                                    },
                                    "color": {
                                        "type": "string",
                                        "default": "#2563eb"
                                    }
                                }
                            },
                            "example": {
                                "name": "Hot Lead",
                                "color": "#16a34a"
                            }
                        }
                    }
                }
            }
        },
        "/api/labels/{uuid}": {
            "delete": {
                "tags": [
                    "CRM Labels"
                ],
                "summary": "Delete CRM Label",
                "description": "Deletes a label and detaches it from all contacts.",
                "operationId": "destroyLabel",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "example": {
                                        "statusCode": 200,
                                        "message": "Request processed successfully"
                                    }
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Validation error / invalid input payload",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 400,
                                    "message": "The given data was invalid.",
                                    "errors": {
                                        "field": [
                                            "The field is required."
                                        ]
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Missing or invalid Bearer API token",
                        "content": {
                            "application/json": {
                                "example": {
                                    "error": "Unauthorized. Invalid Bearer Token."
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "Inactive subscription, plan limit reached, or WhatsApp not connected",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 403,
                                    "message": "Please renew or subscribe to a plan to continue!"
                                }
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "uuid",
                        "in": "path",
                        "required": true,
                        "description": "UUID of the label",
                        "example": "945d8b4f-a580-4743-bdfa-f0095059b37a",
                        "schema": {
                            "type": "string"
                        }
                    }
                ]
            }
        },
        "/api/contact-groups": {
            "get": {
                "tags": [
                    "Contact Groups"
                ],
                "summary": "Get Contact Group List",
                "description": "Returns paginated contact groups.",
                "operationId": "listContactGroups",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "example": {
                                        "statusCode": 200,
                                        "message": "Request processed successfully"
                                    }
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Validation error / invalid input payload",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 400,
                                    "message": "The given data was invalid.",
                                    "errors": {
                                        "field": [
                                            "The field is required."
                                        ]
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Missing or invalid Bearer API token",
                        "content": {
                            "application/json": {
                                "example": {
                                    "error": "Unauthorized. Invalid Bearer Token."
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "Inactive subscription, plan limit reached, or WhatsApp not connected",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 403,
                                    "message": "Please renew or subscribe to a plan to continue!"
                                }
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "page",
                        "in": "query",
                        "required": false,
                        "description": "Page number (minimum 1)",
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "default": 1
                        }
                    },
                    {
                        "name": "per_page",
                        "in": "query",
                        "required": false,
                        "description": "Records per page (1 to 100)",
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 100,
                            "default": 10
                        }
                    }
                ]
            },
            "post": {
                "tags": [
                    "Contact Groups"
                ],
                "summary": "Add Contact Group",
                "description": "Creates a new contact group.",
                "operationId": "storeContactGroup",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "example": {
                                        "statusCode": 200,
                                        "id": "group-uuid",
                                        "message": "Request processed successfully"
                                    }
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Validation error / invalid input payload",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 400,
                                    "message": "The given data was invalid.",
                                    "errors": {
                                        "field": [
                                            "The field is required."
                                        ]
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Missing or invalid Bearer API token",
                        "content": {
                            "application/json": {
                                "example": {
                                    "error": "Unauthorized. Invalid Bearer Token."
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "Inactive subscription, plan limit reached, or WhatsApp not connected",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 403,
                                    "message": "Please renew or subscribe to a plan to continue!"
                                }
                            }
                        }
                    }
                },
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "name"
                                ],
                                "properties": {
                                    "name": {
                                        "type": "string"
                                    }
                                }
                            },
                            "example": {
                                "name": "Lead VIP"
                            }
                        }
                    }
                }
            }
        },
        "/api/contact-groups/{uuid}": {
            "put": {
                "tags": [
                    "Contact Groups"
                ],
                "summary": "Edit Contact Group",
                "description": "Renames an existing contact group by UUID.",
                "operationId": "updateContactGroup",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "example": {
                                        "statusCode": 200,
                                        "message": "Request processed successfully"
                                    }
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Validation error / invalid input payload",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 400,
                                    "message": "The given data was invalid.",
                                    "errors": {
                                        "field": [
                                            "The field is required."
                                        ]
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Missing or invalid Bearer API token",
                        "content": {
                            "application/json": {
                                "example": {
                                    "error": "Unauthorized. Invalid Bearer Token."
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "Inactive subscription, plan limit reached, or WhatsApp not connected",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 403,
                                    "message": "Please renew or subscribe to a plan to continue!"
                                }
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "uuid",
                        "in": "path",
                        "required": true,
                        "description": "UUID of the contact group",
                        "example": "945d8b4f-a580-4743-bdfa-f0095059b37a",
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "name"
                                ],
                                "properties": {
                                    "name": {
                                        "type": "string"
                                    }
                                }
                            },
                            "example": {
                                "name": "Lead Priority"
                            }
                        }
                    }
                }
            },
            "delete": {
                "tags": [
                    "Contact Groups"
                ],
                "summary": "Delete Contact Group",
                "description": "Deletes a contact group by UUID.",
                "operationId": "destroyContactGroup",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "example": {
                                        "statusCode": 200,
                                        "message": "Request processed successfully"
                                    }
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Validation error / invalid input payload",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 400,
                                    "message": "The given data was invalid.",
                                    "errors": {
                                        "field": [
                                            "The field is required."
                                        ]
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Missing or invalid Bearer API token",
                        "content": {
                            "application/json": {
                                "example": {
                                    "error": "Unauthorized. Invalid Bearer Token."
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "Inactive subscription, plan limit reached, or WhatsApp not connected",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 403,
                                    "message": "Please renew or subscribe to a plan to continue!"
                                }
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "uuid",
                        "in": "path",
                        "required": true,
                        "description": "UUID of the contact group",
                        "example": "945d8b4f-a580-4743-bdfa-f0095059b37a",
                        "schema": {
                            "type": "string"
                        }
                    }
                ]
            }
        },
        "/api/canned-replies": {
            "get": {
                "tags": [
                    "Automated Replies"
                ],
                "summary": "Get Automated Replies List",
                "description": "Returns paginated automated (canned) replies.",
                "operationId": "listCannedReplies",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "example": {
                                        "statusCode": 200,
                                        "message": "Request processed successfully"
                                    }
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Validation error / invalid input payload",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 400,
                                    "message": "The given data was invalid.",
                                    "errors": {
                                        "field": [
                                            "The field is required."
                                        ]
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Missing or invalid Bearer API token",
                        "content": {
                            "application/json": {
                                "example": {
                                    "error": "Unauthorized. Invalid Bearer Token."
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "Inactive subscription, plan limit reached, or WhatsApp not connected",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 403,
                                    "message": "Please renew or subscribe to a plan to continue!"
                                }
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "page",
                        "in": "query",
                        "required": false,
                        "description": "Page number (minimum 1)",
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "default": 1
                        }
                    },
                    {
                        "name": "per_page",
                        "in": "query",
                        "required": false,
                        "description": "Records per page (1 to 100)",
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 100,
                            "default": 10
                        }
                    }
                ]
            },
            "post": {
                "tags": [
                    "Automated Replies"
                ],
                "summary": "Add Automated Reply",
                "description": "Creates a keyword-triggered automated reply.",
                "operationId": "storeCannedReply",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "example": {
                                        "statusCode": 200,
                                        "message": "Request processed successfully"
                                    }
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Validation error / invalid input payload",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 400,
                                    "message": "The given data was invalid.",
                                    "errors": {
                                        "field": [
                                            "The field is required."
                                        ]
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Missing or invalid Bearer API token",
                        "content": {
                            "application/json": {
                                "example": {
                                    "error": "Unauthorized. Invalid Bearer Token."
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "Inactive subscription, plan limit reached, or WhatsApp not connected",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 403,
                                    "message": "Please renew or subscribe to a plan to continue!"
                                }
                            }
                        }
                    }
                },
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "name",
                                    "trigger",
                                    "match_criteria",
                                    "response_type",
                                    "response"
                                ],
                                "properties": {
                                    "name": {
                                        "type": "string"
                                    },
                                    "trigger": {
                                        "type": "string"
                                    },
                                    "match_criteria": {
                                        "type": "string",
                                        "enum": [
                                            "exact match",
                                            "contains"
                                        ]
                                    },
                                    "response_type": {
                                        "type": "string",
                                        "enum": [
                                            "text",
                                            "image",
                                            "audio"
                                        ]
                                    },
                                    "response": {
                                        "type": "string"
                                    }
                                }
                            },
                            "example": {
                                "name": "About Us",
                                "trigger": "what do you do?",
                                "match_criteria": "contains",
                                "response_type": "text",
                                "response": "We provide WhatsApp automation solutions."
                            }
                        }
                    }
                }
            }
        },
        "/api/canned-replies/{uuid}": {
            "put": {
                "tags": [
                    "Automated Replies"
                ],
                "summary": "Edit Automated Reply",
                "description": "Updates an automated reply by UUID.",
                "operationId": "updateCannedReply",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "example": {
                                        "statusCode": 200,
                                        "message": "Request processed successfully"
                                    }
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Validation error / invalid input payload",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 400,
                                    "message": "The given data was invalid.",
                                    "errors": {
                                        "field": [
                                            "The field is required."
                                        ]
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Missing or invalid Bearer API token",
                        "content": {
                            "application/json": {
                                "example": {
                                    "error": "Unauthorized. Invalid Bearer Token."
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "Inactive subscription, plan limit reached, or WhatsApp not connected",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 403,
                                    "message": "Please renew or subscribe to a plan to continue!"
                                }
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "uuid",
                        "in": "path",
                        "required": true,
                        "description": "UUID of the automated reply",
                        "example": "945d8b4f-a580-4743-bdfa-f0095059b37a",
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "name",
                                    "trigger",
                                    "match_criteria",
                                    "response_type",
                                    "response"
                                ],
                                "properties": {
                                    "name": {
                                        "type": "string"
                                    },
                                    "trigger": {
                                        "type": "string"
                                    },
                                    "match_criteria": {
                                        "type": "string",
                                        "enum": [
                                            "exact match",
                                            "contains"
                                        ]
                                    },
                                    "response_type": {
                                        "type": "string",
                                        "enum": [
                                            "text",
                                            "image",
                                            "audio"
                                        ]
                                    },
                                    "response": {
                                        "type": "string"
                                    }
                                }
                            },
                            "example": {
                                "name": "About Us",
                                "trigger": "what do you do?",
                                "match_criteria": "contains",
                                "response_type": "text",
                                "response": "We provide WhatsApp Business API & AI automation."
                            }
                        }
                    }
                }
            },
            "delete": {
                "tags": [
                    "Automated Replies"
                ],
                "summary": "Delete Automated Reply",
                "description": "Deletes an automated reply by UUID.",
                "operationId": "destroyCannedReply",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "example": {
                                        "statusCode": 200,
                                        "message": "Request processed successfully"
                                    }
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Validation error / invalid input payload",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 400,
                                    "message": "The given data was invalid.",
                                    "errors": {
                                        "field": [
                                            "The field is required."
                                        ]
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Missing or invalid Bearer API token",
                        "content": {
                            "application/json": {
                                "example": {
                                    "error": "Unauthorized. Invalid Bearer Token."
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "Inactive subscription, plan limit reached, or WhatsApp not connected",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 403,
                                    "message": "Please renew or subscribe to a plan to continue!"
                                }
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "uuid",
                        "in": "path",
                        "required": true,
                        "description": "UUID of the automated reply",
                        "example": "945d8b4f-a580-4743-bdfa-f0095059b37a",
                        "schema": {
                            "type": "string"
                        }
                    }
                ]
            }
        },
        "/api/templates": {
            "get": {
                "tags": [
                    "Templates"
                ],
                "summary": "List Templates",
                "description": "Returns paginated WhatsApp message templates.",
                "operationId": "listTemplates",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "example": {
                                        "statusCode": 200,
                                        "message": "Request processed successfully"
                                    }
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Validation error / invalid input payload",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 400,
                                    "message": "The given data was invalid.",
                                    "errors": {
                                        "field": [
                                            "The field is required."
                                        ]
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Missing or invalid Bearer API token",
                        "content": {
                            "application/json": {
                                "example": {
                                    "error": "Unauthorized. Invalid Bearer Token."
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "Inactive subscription, plan limit reached, or WhatsApp not connected",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 403,
                                    "message": "Please renew or subscribe to a plan to continue!"
                                }
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "page",
                        "in": "query",
                        "required": false,
                        "description": "Page number (minimum 1)",
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "default": 1
                        }
                    },
                    {
                        "name": "per_page",
                        "in": "query",
                        "required": false,
                        "description": "Records per page (1 to 100)",
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 100,
                            "default": 10
                        }
                    }
                ]
            }
        },
        "/api/chats": {
            "get": {
                "tags": [
                    "Inbox & Delivery Status"
                ],
                "summary": "List Inbox Conversations",
                "description": "Returns contacts with active chat history ordered by the most recent message, including unread count and last message preview.",
                "operationId": "listChats",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "example": {
                                        "statusCode": 200,
                                        "data": [
                                            {
                                                "uuid": "945d8b4f-a580-4743-bdfa-f0095059b37a",
                                                "first_name": "John",
                                                "last_name": "Doe",
                                                "full_name": "John Doe",
                                                "phone": "+919876543210",
                                                "email": "john@example.com",
                                                "unread_count": 2,
                                                "latest_chat_created_at": "2026-12-03 13:10:00",
                                                "last_message": {
                                                    "uuid": "chat-uuid-123",
                                                    "wam_id": "wamid.HBgMOTE5ODc2NTQzMjEwFQIAERgS...",
                                                    "type": "inbound",
                                                    "message_type": "text",
                                                    "status": "delivered",
                                                    "is_read": false,
                                                    "text": "Hi, please share pricing details",
                                                    "media": null,
                                                    "created_at": "2026-12-03 13:10:00"
                                                }
                                            }
                                        ],
                                        "meta": {
                                            "current_page": 1,
                                            "last_page": 1,
                                            "per_page": 20,
                                            "total": 1
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Validation error / invalid input payload",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 400,
                                    "message": "The given data was invalid.",
                                    "errors": {
                                        "field": [
                                            "The field is required."
                                        ]
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Missing or invalid Bearer API token",
                        "content": {
                            "application/json": {
                                "example": {
                                    "error": "Unauthorized. Invalid Bearer Token."
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "Inactive subscription, plan limit reached, or WhatsApp not connected",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 403,
                                    "message": "Please renew or subscribe to a plan to continue!"
                                }
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "page",
                        "in": "query",
                        "required": false,
                        "description": "Page number (minimum 1)",
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "default": 1
                        }
                    },
                    {
                        "name": "per_page",
                        "in": "query",
                        "required": false,
                        "description": "Records per page (1 to 100)",
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 100,
                            "default": 10
                        }
                    },
                    {
                        "name": "search",
                        "in": "query",
                        "required": false,
                        "description": "Search contacts by name, phone, or email",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "unread_only",
                        "in": "query",
                        "required": false,
                        "description": "Set true or 1 to return only conversations with unread inbound messages",
                        "schema": {
                            "type": "boolean",
                            "default": false
                        }
                    }
                ]
            }
        },
        "/api/chats/{identifier}/messages": {
            "get": {
                "tags": [
                    "Inbox & Delivery Status"
                ],
                "summary": "Read Inbox Chat Messages",
                "description": "Fetches all inbound and outbound messages for a conversation. Pass either the Contact UUID or phone number in `{identifier}`.",
                "operationId": "getChatMessages",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "example": {
                                        "statusCode": 200,
                                        "contact": {
                                            "uuid": "945d8b4f-a580-4743-bdfa-f0095059b37a",
                                            "full_name": "John Doe",
                                            "phone": "+919876543210"
                                        },
                                        "data": [
                                            {
                                                "uuid": "msg-uuid-001",
                                                "wam_id": "wamid.HBgMOTE5ODc2NTQzMjEwFQIAERgS...",
                                                "type": "inbound",
                                                "message_type": "text",
                                                "status": "delivered",
                                                "is_read": false,
                                                "text": "Hello, I want to know more",
                                                "media": null,
                                                "created_at": "2026-12-03 13:10:00"
                                            }
                                        ],
                                        "meta": {
                                            "current_page": 1,
                                            "last_page": 1,
                                            "per_page": 50,
                                            "total": 1
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Validation error / invalid input payload",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 400,
                                    "message": "The given data was invalid.",
                                    "errors": {
                                        "field": [
                                            "The field is required."
                                        ]
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Missing or invalid Bearer API token",
                        "content": {
                            "application/json": {
                                "example": {
                                    "error": "Unauthorized. Invalid Bearer Token."
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "Inactive subscription, plan limit reached, or WhatsApp not connected",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 403,
                                    "message": "Please renew or subscribe to a plan to continue!"
                                }
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "identifier",
                        "in": "path",
                        "required": true,
                        "description": "Contact UUID (e.g. 945d8b4f-...) or phone number (e.g. +919876543210)",
                        "example": "945d8b4f-a580-4743-bdfa-f0095059b37a",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "page",
                        "in": "query",
                        "required": false,
                        "description": "Page number (minimum 1)",
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "default": 1
                        }
                    },
                    {
                        "name": "per_page",
                        "in": "query",
                        "required": false,
                        "description": "Records per page (1 to 100)",
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 100,
                            "default": 10
                        }
                    },
                    {
                        "name": "type",
                        "in": "query",
                        "required": false,
                        "description": "Filter messages by direction",
                        "schema": {
                            "type": "string",
                            "enum": [
                                "inbound",
                                "outbound"
                            ]
                        }
                    },
                    {
                        "name": "order",
                        "in": "query",
                        "required": false,
                        "description": "Sort direction (desc = newest first, asc = oldest first)",
                        "schema": {
                            "type": "string",
                            "enum": [
                                "desc",
                                "asc"
                            ],
                            "default": "desc"
                        }
                    },
                    {
                        "name": "mark_as_read",
                        "in": "query",
                        "required": false,
                        "description": "Set true or 1 to mark all unread inbound messages as read",
                        "schema": {
                            "type": "boolean",
                            "default": false
                        }
                    }
                ]
            }
        },
        "/api/chats/{identifier}/read": {
            "post": {
                "tags": [
                    "Inbox & Delivery Status"
                ],
                "summary": "Mark Inbox Chat as Read",
                "description": "Marks all unread inbound messages for the given Contact UUID or phone number as read.",
                "operationId": "markChatAsRead",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "example": {
                                        "statusCode": 200,
                                        "contact_uuid": "945d8b4f-a580-4743-bdfa-f0095059b37a",
                                        "updated_count": 2,
                                        "message": "Messages marked as read."
                                    }
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Validation error / invalid input payload",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 400,
                                    "message": "The given data was invalid.",
                                    "errors": {
                                        "field": [
                                            "The field is required."
                                        ]
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Missing or invalid Bearer API token",
                        "content": {
                            "application/json": {
                                "example": {
                                    "error": "Unauthorized. Invalid Bearer Token."
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "Inactive subscription, plan limit reached, or WhatsApp not connected",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 403,
                                    "message": "Please renew or subscribe to a plan to continue!"
                                }
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "identifier",
                        "in": "path",
                        "required": true,
                        "description": "Contact UUID or phone number",
                        "example": "945d8b4f-a580-4743-bdfa-f0095059b37a",
                        "schema": {
                            "type": "string"
                        }
                    }
                ]
            }
        },
        "/api/messages": {
            "get": {
                "tags": [
                    "Inbox & Delivery Status"
                ],
                "summary": "List Recent Messages (Filter by Status / Direction)",
                "description": "Lists recent inbound/outbound messages across your organization. Useful for polling new inbound replies (`type=inbound`) or failed deliveries (`status=failed`).",
                "operationId": "listMessages",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "example": {
                                        "statusCode": 200,
                                        "message": "Request processed successfully"
                                    }
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Validation error / invalid input payload",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 400,
                                    "message": "The given data was invalid.",
                                    "errors": {
                                        "field": [
                                            "The field is required."
                                        ]
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Missing or invalid Bearer API token",
                        "content": {
                            "application/json": {
                                "example": {
                                    "error": "Unauthorized. Invalid Bearer Token."
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "Inactive subscription, plan limit reached, or WhatsApp not connected",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 403,
                                    "message": "Please renew or subscribe to a plan to continue!"
                                }
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "page",
                        "in": "query",
                        "required": false,
                        "description": "Page number (minimum 1)",
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "default": 1
                        }
                    },
                    {
                        "name": "per_page",
                        "in": "query",
                        "required": false,
                        "description": "Records per page (1 to 100)",
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 100,
                            "default": 10
                        }
                    },
                    {
                        "name": "type",
                        "in": "query",
                        "required": false,
                        "description": "Filter by inbound or outbound",
                        "schema": {
                            "type": "string",
                            "enum": [
                                "inbound",
                                "outbound"
                            ]
                        }
                    },
                    {
                        "name": "status",
                        "in": "query",
                        "required": false,
                        "description": "Filter by delivery status (e.g. sent, delivered, read, failed, accepted)",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "contact_uuid",
                        "in": "query",
                        "required": false,
                        "description": "Filter by Contact UUID",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "phone",
                        "in": "query",
                        "required": false,
                        "description": "Filter by phone number",
                        "schema": {
                            "type": "string"
                        }
                    }
                ]
            }
        },
        "/api/messages/{identifier}/status": {
            "get": {
                "tags": [
                    "Inbox & Delivery Status"
                ],
                "summary": "Check Message Delivery Status",
                "description": "Returns the current delivery status (`sent`, `delivered`, `read`, `failed`), any WhatsApp failure reason, and full status transition history. Pass either the message `uuid` or WhatsApp `wam_id` returned when sending.",
                "operationId": "getMessageStatus",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "example": {
                                        "statusCode": 200,
                                        "data": {
                                            "uuid": "msg-uuid-001",
                                            "wam_id": "wamid.HBgMOTE5ODc2NTQzMjEwFQIAERgS...",
                                            "type": "outbound",
                                            "status": "read",
                                            "is_read": false,
                                            "created_at": "2026-12-03 13:05:00",
                                            "errors": null,
                                            "contact": {
                                                "uuid": "945d8b4f-a580-4743-bdfa-f0095059b37a",
                                                "full_name": "John Doe",
                                                "phone": "+919876543210"
                                            },
                                            "status_history": [
                                                {
                                                    "status": "sent",
                                                    "timestamp": "2026-12-03 13:05:01",
                                                    "errors": null
                                                },
                                                {
                                                    "status": "delivered",
                                                    "timestamp": "2026-12-03 13:05:03",
                                                    "errors": null
                                                },
                                                {
                                                    "status": "read",
                                                    "timestamp": "2026-12-03 13:05:15",
                                                    "errors": null
                                                }
                                            ]
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Validation error / invalid input payload",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 400,
                                    "message": "The given data was invalid.",
                                    "errors": {
                                        "field": [
                                            "The field is required."
                                        ]
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Missing or invalid Bearer API token",
                        "content": {
                            "application/json": {
                                "example": {
                                    "error": "Unauthorized. Invalid Bearer Token."
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "Inactive subscription, plan limit reached, or WhatsApp not connected",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 403,
                                    "message": "Please renew or subscribe to a plan to continue!"
                                }
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "identifier",
                        "in": "path",
                        "required": true,
                        "description": "Chat UUID or WhatsApp Message ID (`wamid...`)",
                        "example": "wamid.HBgMOTE5ODc2NTQzMjEwFQIAERgS...",
                        "schema": {
                            "type": "string"
                        }
                    }
                ]
            }
        },
        "/api/chats/{identifier}/notes": {
            "get": {
                "tags": [
                    "Inbox CRM Controls"
                ],
                "summary": "List Internal Chat Notes",
                "description": "Fetches internal team notes added to a contact conversation.",
                "operationId": "listChatNotes",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "example": {
                                        "statusCode": 200,
                                        "message": "Request processed successfully"
                                    }
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Validation error / invalid input payload",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 400,
                                    "message": "The given data was invalid.",
                                    "errors": {
                                        "field": [
                                            "The field is required."
                                        ]
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Missing or invalid Bearer API token",
                        "content": {
                            "application/json": {
                                "example": {
                                    "error": "Unauthorized. Invalid Bearer Token."
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "Inactive subscription, plan limit reached, or WhatsApp not connected",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 403,
                                    "message": "Please renew or subscribe to a plan to continue!"
                                }
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "identifier",
                        "in": "path",
                        "required": true,
                        "description": "Contact UUID or phone number",
                        "example": "945d8b4f-a580-4743-bdfa-f0095059b37a",
                        "schema": {
                            "type": "string"
                        }
                    }
                ]
            },
            "post": {
                "tags": [
                    "Inbox CRM Controls"
                ],
                "summary": "Add Internal Chat Note",
                "description": "Adds an internal CRM note on a contact timeline (not sent to WhatsApp user).",
                "operationId": "storeChatNote",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "example": {
                                        "statusCode": 200,
                                        "message": "Request processed successfully"
                                    }
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Validation error / invalid input payload",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 400,
                                    "message": "The given data was invalid.",
                                    "errors": {
                                        "field": [
                                            "The field is required."
                                        ]
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Missing or invalid Bearer API token",
                        "content": {
                            "application/json": {
                                "example": {
                                    "error": "Unauthorized. Invalid Bearer Token."
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "Inactive subscription, plan limit reached, or WhatsApp not connected",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 403,
                                    "message": "Please renew or subscribe to a plan to continue!"
                                }
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "identifier",
                        "in": "path",
                        "required": true,
                        "description": "Contact UUID or phone number",
                        "example": "945d8b4f-a580-4743-bdfa-f0095059b37a",
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "notes"
                                ],
                                "properties": {
                                    "notes": {
                                        "type": "string"
                                    }
                                }
                            },
                            "example": {
                                "notes": "Customer requested callback after 5 PM IST."
                            }
                        }
                    }
                }
            }
        },
        "/api/chats/{identifier}/ai": {
            "post": {
                "tags": [
                    "Inbox CRM Controls"
                ],
                "summary": "Toggle AI Assistant for Contact",
                "description": "Enables or disables automatic IntelliReply AI responses for a specific contact (useful for human agent handover).",
                "operationId": "toggleContactAi",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "example": {
                                        "statusCode": 200,
                                        "message": "Request processed successfully"
                                    }
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Validation error / invalid input payload",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 400,
                                    "message": "The given data was invalid.",
                                    "errors": {
                                        "field": [
                                            "The field is required."
                                        ]
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Missing or invalid Bearer API token",
                        "content": {
                            "application/json": {
                                "example": {
                                    "error": "Unauthorized. Invalid Bearer Token."
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "Inactive subscription, plan limit reached, or WhatsApp not connected",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 403,
                                    "message": "Please renew or subscribe to a plan to continue!"
                                }
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "identifier",
                        "in": "path",
                        "required": true,
                        "description": "Contact UUID or phone number",
                        "example": "945d8b4f-a580-4743-bdfa-f0095059b37a",
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "enabled"
                                ],
                                "properties": {
                                    "enabled": {
                                        "type": "boolean"
                                    }
                                }
                            },
                            "example": {
                                "enabled": false
                            }
                        }
                    }
                }
            }
        },
        "/api/chats/{identifier}/ticket": {
            "post": {
                "tags": [
                    "Inbox CRM Controls"
                ],
                "summary": "Update Ticket Status / Assign Agent",
                "description": "Marks a conversation ticket as `open` or `closed` and/or assigns it to a team agent (`user_id` from `GET /api/team`).",
                "operationId": "updateChatTicket",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "example": {
                                        "statusCode": 200,
                                        "message": "Request processed successfully"
                                    }
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Validation error / invalid input payload",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 400,
                                    "message": "The given data was invalid.",
                                    "errors": {
                                        "field": [
                                            "The field is required."
                                        ]
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Missing or invalid Bearer API token",
                        "content": {
                            "application/json": {
                                "example": {
                                    "error": "Unauthorized. Invalid Bearer Token."
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "Inactive subscription, plan limit reached, or WhatsApp not connected",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 403,
                                    "message": "Please renew or subscribe to a plan to continue!"
                                }
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "identifier",
                        "in": "path",
                        "required": true,
                        "description": "Contact UUID or phone number",
                        "example": "945d8b4f-a580-4743-bdfa-f0095059b37a",
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "status": {
                                        "type": "string",
                                        "enum": [
                                            "open",
                                            "closed"
                                        ]
                                    },
                                    "assigned_to_user_id": {
                                        "type": "integer",
                                        "nullable": true
                                    }
                                }
                            },
                            "example": {
                                "status": "open",
                                "assigned_to_user_id": 1
                            }
                        }
                    }
                }
            }
        },
        "/api/team": {
            "get": {
                "tags": [
                    "Inbox CRM Controls"
                ],
                "summary": "List Team Agents",
                "description": "Lists all team members in your organization along with their `user_id` and role for ticket assignment.",
                "operationId": "listTeamAgents",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "example": {
                                        "statusCode": 200,
                                        "message": "Request processed successfully"
                                    }
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Validation error / invalid input payload",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 400,
                                    "message": "The given data was invalid.",
                                    "errors": {
                                        "field": [
                                            "The field is required."
                                        ]
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Missing or invalid Bearer API token",
                        "content": {
                            "application/json": {
                                "example": {
                                    "error": "Unauthorized. Invalid Bearer Token."
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "Inactive subscription, plan limit reached, or WhatsApp not connected",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 403,
                                    "message": "Please renew or subscribe to a plan to continue!"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/api/campaigns": {
            "get": {
                "tags": [
                    "Campaigns"
                ],
                "summary": "List Campaigns & Stats",
                "description": "Returns paginated WhatsApp campaigns with sent, delivered, read, failed, clicked, skipped, and replied statistics.",
                "operationId": "listCampaigns",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "example": {
                                        "statusCode": 200,
                                        "message": "Request processed successfully"
                                    }
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Validation error / invalid input payload",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 400,
                                    "message": "The given data was invalid.",
                                    "errors": {
                                        "field": [
                                            "The field is required."
                                        ]
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Missing or invalid Bearer API token",
                        "content": {
                            "application/json": {
                                "example": {
                                    "error": "Unauthorized. Invalid Bearer Token."
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "Inactive subscription, plan limit reached, or WhatsApp not connected",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 403,
                                    "message": "Please renew or subscribe to a plan to continue!"
                                }
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "page",
                        "in": "query",
                        "required": false,
                        "description": "Page number (minimum 1)",
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "default": 1
                        }
                    },
                    {
                        "name": "per_page",
                        "in": "query",
                        "required": false,
                        "description": "Records per page (1 to 100)",
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 100,
                            "default": 10
                        }
                    },
                    {
                        "name": "search",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "status",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "enum": [
                                "scheduled",
                                "ongoing",
                                "completed",
                                "failed"
                            ]
                        }
                    }
                ]
            },
            "post": {
                "tags": [
                    "Campaigns"
                ],
                "summary": "Create / Schedule Campaign",
                "description": "Creates and launches (or schedules) a bulk WhatsApp template campaign to all contacts, a specific group UUID, or comma-separated phone numbers.",
                "operationId": "storeCampaign",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "example": {
                                        "statusCode": 200,
                                        "message": "Request processed successfully"
                                    }
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Validation error / invalid input payload",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 400,
                                    "message": "The given data was invalid.",
                                    "errors": {
                                        "field": [
                                            "The field is required."
                                        ]
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Missing or invalid Bearer API token",
                        "content": {
                            "application/json": {
                                "example": {
                                    "error": "Unauthorized. Invalid Bearer Token."
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "Inactive subscription, plan limit reached, or WhatsApp not connected",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 403,
                                    "message": "Please renew or subscribe to a plan to continue!"
                                }
                            }
                        }
                    }
                },
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "name",
                                    "template_uuid",
                                    "contacts"
                                ],
                                "properties": {
                                    "name": {
                                        "type": "string"
                                    },
                                    "template_uuid": {
                                        "type": "string",
                                        "description": "Template UUID from GET /api/templates"
                                    },
                                    "contacts": {
                                        "type": "string",
                                        "description": "\"all\", \"comma\", or a Contact Group UUID"
                                    },
                                    "bulk_number": {
                                        "type": "string",
                                        "description": "Required when contacts is \"comma\" (comma-separated phones)"
                                    },
                                    "scheduled_at": {
                                        "type": "string",
                                        "format": "date-time",
                                        "description": "Optional schedule datetime (omit to send immediately)"
                                    },
                                    "header": {
                                        "type": "object"
                                    },
                                    "body": {
                                        "type": "object"
                                    },
                                    "buttons": {
                                        "type": "array",
                                        "items": {
                                            "type": "object"
                                        }
                                    }
                                }
                            },
                            "example": {
                                "name": "Diwali Offer Broadcast",
                                "template_uuid": "template-uuid-here",
                                "contacts": "comma",
                                "bulk_number": "+919876543210,+919811112222"
                            }
                        }
                    }
                }
            }
        },
        "/api/campaigns/{uuid}": {
            "get": {
                "tags": [
                    "Campaigns"
                ],
                "summary": "Get Single Campaign Stats",
                "description": "Returns summary statistics and delivery/reply metrics for a specific campaign.",
                "operationId": "showCampaign",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "example": {
                                        "statusCode": 200,
                                        "message": "Request processed successfully"
                                    }
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Validation error / invalid input payload",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 400,
                                    "message": "The given data was invalid.",
                                    "errors": {
                                        "field": [
                                            "The field is required."
                                        ]
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Missing or invalid Bearer API token",
                        "content": {
                            "application/json": {
                                "example": {
                                    "error": "Unauthorized. Invalid Bearer Token."
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "Inactive subscription, plan limit reached, or WhatsApp not connected",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 403,
                                    "message": "Please renew or subscribe to a plan to continue!"
                                }
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "uuid",
                        "in": "path",
                        "required": true,
                        "description": "UUID of the campaign",
                        "example": "945d8b4f-a580-4743-bdfa-f0095059b37a",
                        "schema": {
                            "type": "string"
                        }
                    }
                ]
            }
        },
        "/api/campaigns/{uuid}/logs": {
            "get": {
                "tags": [
                    "Campaigns"
                ],
                "summary": "Get Campaign Logs & Replies",
                "description": "Returns recipient-by-recipient delivery status, reply indicator (`has_replied`), and latest reply text. Filter by `status=replied` to get everyone who replied.",
                "operationId": "getCampaignLogs",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "example": {
                                        "statusCode": 200,
                                        "message": "Request processed successfully"
                                    }
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Validation error / invalid input payload",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 400,
                                    "message": "The given data was invalid.",
                                    "errors": {
                                        "field": [
                                            "The field is required."
                                        ]
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Missing or invalid Bearer API token",
                        "content": {
                            "application/json": {
                                "example": {
                                    "error": "Unauthorized. Invalid Bearer Token."
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "Inactive subscription, plan limit reached, or WhatsApp not connected",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 403,
                                    "message": "Please renew or subscribe to a plan to continue!"
                                }
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "uuid",
                        "in": "path",
                        "required": true,
                        "description": "UUID of the campaign",
                        "example": "945d8b4f-a580-4743-bdfa-f0095059b37a",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "page",
                        "in": "query",
                        "required": false,
                        "description": "Page number (minimum 1)",
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "default": 1
                        }
                    },
                    {
                        "name": "per_page",
                        "in": "query",
                        "required": false,
                        "description": "Records per page (1 to 100)",
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 100,
                            "default": 10
                        }
                    },
                    {
                        "name": "status",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "enum": [
                                "all",
                                "pending",
                                "sent",
                                "delivered",
                                "read",
                                "replied",
                                "clicked",
                                "failed"
                            ],
                            "default": "all"
                        }
                    },
                    {
                        "name": "search",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "string"
                        }
                    }
                ]
            }
        },
        "/api/webhooks": {
            "get": {
                "tags": [
                    "Webhooks"
                ],
                "summary": "List Configured Webhooks",
                "description": "Lists all registered webhook URLs and their subscribed events along with all supported event names.",
                "operationId": "listWebhooks",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "example": {
                                        "statusCode": 200,
                                        "message": "Request processed successfully"
                                    }
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Validation error / invalid input payload",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 400,
                                    "message": "The given data was invalid.",
                                    "errors": {
                                        "field": [
                                            "The field is required."
                                        ]
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Missing or invalid Bearer API token",
                        "content": {
                            "application/json": {
                                "example": {
                                    "error": "Unauthorized. Invalid Bearer Token."
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "Inactive subscription, plan limit reached, or WhatsApp not connected",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 403,
                                    "message": "Please renew or subscribe to a plan to continue!"
                                }
                            }
                        }
                    }
                }
            },
            "post": {
                "tags": [
                    "Webhooks"
                ],
                "summary": "Register Webhook URL",
                "description": "Registers a webhook callback URL for real-time events such as `message.received`, `message.sent`, and `message.status.update`.",
                "operationId": "storeWebhook",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "example": {
                                        "statusCode": 200,
                                        "message": "Request processed successfully"
                                    }
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Validation error / invalid input payload",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 400,
                                    "message": "The given data was invalid.",
                                    "errors": {
                                        "field": [
                                            "The field is required."
                                        ]
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Missing or invalid Bearer API token",
                        "content": {
                            "application/json": {
                                "example": {
                                    "error": "Unauthorized. Invalid Bearer Token."
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "Inactive subscription, plan limit reached, or WhatsApp not connected",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 403,
                                    "message": "Please renew or subscribe to a plan to continue!"
                                }
                            }
                        }
                    }
                },
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "url",
                                    "events"
                                ],
                                "properties": {
                                    "url": {
                                        "type": "string",
                                        "format": "uri"
                                    },
                                    "events": {
                                        "type": "array",
                                        "items": {
                                            "type": "string"
                                        }
                                    }
                                }
                            },
                            "example": {
                                "url": "https://your-crm.example.com/webhooks/wbjet",
                                "events": [
                                    "message.received",
                                    "message.status.update"
                                ]
                            }
                        }
                    }
                }
            }
        },
        "/api/webhooks/{uuid}": {
            "delete": {
                "tags": [
                    "Webhooks"
                ],
                "summary": "Delete Webhook",
                "description": "Removes a registered webhook subscription by UUID.",
                "operationId": "destroyWebhook",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "example": {
                                        "statusCode": 200,
                                        "message": "Request processed successfully"
                                    }
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Validation error / invalid input payload",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 400,
                                    "message": "The given data was invalid.",
                                    "errors": {
                                        "field": [
                                            "The field is required."
                                        ]
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Missing or invalid Bearer API token",
                        "content": {
                            "application/json": {
                                "example": {
                                    "error": "Unauthorized. Invalid Bearer Token."
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "Inactive subscription, plan limit reached, or WhatsApp not connected",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 403,
                                    "message": "Please renew or subscribe to a plan to continue!"
                                }
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "uuid",
                        "in": "path",
                        "required": true,
                        "description": "UUID of the webhook",
                        "example": "945d8b4f-a580-4743-bdfa-f0095059b37a",
                        "schema": {
                            "type": "string"
                        }
                    }
                ]
            }
        },
        "/api/flows": {
            "get": {
                "tags": [
                    "Flows & Leads"
                ],
                "summary": "List Automation Flows",
                "description": "Lists FlowBuilder automation flows and execution counts.",
                "operationId": "listFlows",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "example": {
                                        "statusCode": 200,
                                        "message": "Request processed successfully"
                                    }
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Validation error / invalid input payload",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 400,
                                    "message": "The given data was invalid.",
                                    "errors": {
                                        "field": [
                                            "The field is required."
                                        ]
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Missing or invalid Bearer API token",
                        "content": {
                            "application/json": {
                                "example": {
                                    "error": "Unauthorized. Invalid Bearer Token."
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "Inactive subscription, plan limit reached, or WhatsApp not connected",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 403,
                                    "message": "Please renew or subscribe to a plan to continue!"
                                }
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "page",
                        "in": "query",
                        "required": false,
                        "description": "Page number (minimum 1)",
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "default": 1
                        }
                    },
                    {
                        "name": "per_page",
                        "in": "query",
                        "required": false,
                        "description": "Records per page (1 to 100)",
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 100,
                            "default": 10
                        }
                    },
                    {
                        "name": "status",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "enum": [
                                "active",
                                "inactive"
                            ]
                        }
                    }
                ]
            }
        },
        "/api/flow-submissions": {
            "get": {
                "tags": [
                    "Flows & Leads"
                ],
                "summary": "List WhatsApp Flow Form Submissions",
                "description": "Retrieves submitted WhatsApp Flow form responses and associated contact details.",
                "operationId": "listFlowSubmissions",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "example": {
                                        "statusCode": 200,
                                        "message": "Request processed successfully"
                                    }
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Validation error / invalid input payload",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 400,
                                    "message": "The given data was invalid.",
                                    "errors": {
                                        "field": [
                                            "The field is required."
                                        ]
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Missing or invalid Bearer API token",
                        "content": {
                            "application/json": {
                                "example": {
                                    "error": "Unauthorized. Invalid Bearer Token."
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "Inactive subscription, plan limit reached, or WhatsApp not connected",
                        "content": {
                            "application/json": {
                                "example": {
                                    "statusCode": 403,
                                    "message": "Please renew or subscribe to a plan to continue!"
                                }
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "page",
                        "in": "query",
                        "required": false,
                        "description": "Page number (minimum 1)",
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "default": 1
                        }
                    },
                    {
                        "name": "per_page",
                        "in": "query",
                        "required": false,
                        "description": "Records per page (1 to 100)",
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 100,
                            "default": 10
                        }
                    },
                    {
                        "name": "flow_id",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "form_name",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "search",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "string"
                        }
                    }
                ]
            }
        }
    }
}