{
  "info": {
    "title": "Messajo API",
    "version": "dev",
    "description": "Messajo's REST API for WhatsApp, Instagram and Messenger, built on Meta's official APIs. It has two layers: the unified API (`/v1/*`), the same for all three channels, and the Meta mirror routes (`/v1/whatsapp/{connection_id}/*`), which pass through the Graph API format. Every call authenticates with an API key in the `Authorization: Bearer` header. Guides, concepts and examples: https://docs.messajo.com.",
    "contact": {
      "url": "https://docs.messajo.com"
    }
  },
  "servers": [
    {
      "url": "https://api.messajo.com/v1",
      "description": "Messajo Cloud"
    }
  ],
  "tags": [
    {
      "name": "account",
      "description": "Account: the organization and the API key of the call."
    },
    {
      "name": "destinations",
      "description": "Destinations: where Messajo sends events (signed webhooks)."
    },
    {
      "name": "deliveries",
      "description": "Deliveries: each attempt to take an event to a destination, with redelivery."
    },
    {
      "name": "events",
      "description": "Events: what happened on the connections, in the same envelope destinations receive (30 days)."
    },
    {
      "name": "logs",
      "description": "Logs: messages and API calls from the last 30 days."
    },
    {
      "name": "connections",
      "description": "Connections: the connected numbers, their health, profile and username."
    },
    {
      "name": "messages",
      "description": "Messages: sending through the unified API and marking as read."
    },
    {
      "name": "templates",
      "description": "Templates: WhatsApp message templates approved by Meta."
    },
    {
      "name": "media",
      "description": "Media: files to send, download and share through a temporary link."
    },
    {
      "name": "connection-links",
      "description": "Connection links: public pages for an outside person to connect a number."
    },
    {
      "name": "whatsapp-mirror",
      "description": "Meta mirror: the WhatsApp Graph API passed through with the connection's token."
    },
    {
      "name": "messaging-profile",
      "description": "Messaging profile: ice breakers, persistent menu and welcome messages for Instagram and Messenger."
    },
    {
      "name": "comments",
      "description": "Instagram comments and mentions: list, reply, reply in Direct, hide and delete."
    },
    {
      "name": "posts",
      "description": "Instagram posts: list, detail and publishing quota."
    },
    {
      "name": "insights",
      "description": "Instagram insights: account and per-post metrics."
    },
    {
      "name": "publications",
      "description": "Instagram publications: photo, video, carousel, Reels and Stories, now or scheduled."
    },
    {
      "name": "instagram-mirror",
      "description": "Meta mirror: the Instagram Graph API passed through with the account's token."
    },
    {
      "name": "messenger-mirror",
      "description": "Meta mirror: the Messenger Graph API passed through with the Page's token."
    },
    {
      "name": "history",
      "description": "History: stored conversations, contacts and messages, with filters and cursor pagination."
    },
    {
      "name": "campaigns",
      "description": "Campaigns: bulk sending of WhatsApp templates to a list, with scheduling and reports."
    },
    {
      "name": "calls",
      "description": "WhatsApp calls (Calling API, signaling only): log, actions, call permission and number settings."
    },
    {
      "name": "groups",
      "description": "WhatsApp groups (Groups API): create, invite, moderate participants and join requests."
    },
    {
      "name": "flows",
      "description": "WhatsApp Flows: create, edit the JSON, publish, deprecate and preview, with the data exchange endpoint hosted by Messajo."
    },
    {
      "name": "commerce",
      "description": "WhatsApp commerce: catalogs, products, cart settings and orders with Pix, payment link or boleto."
    },
    {
      "name": "usage",
      "description": "Usage and Meta costs"
    }
  ],
  "security": [
    {
      "apiKey": []
    }
  ],
  "components": {
    "securitySchemes": {
      "apiKey": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "mj_…",
        "description": "API key created in the dashboard (Settings → API keys), sent as `Authorization: Bearer mj_…`. The key carries permissions and, optionally, the list of connections it may use."
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "description": "Single error body: every API error has this shape.",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "code",
              "message",
              "meta_code",
              "retryable",
              "request_id",
              "docs_url"
            ],
            "properties": {
              "code": {
                "type": "string",
                "enum": [
                  "validation_failed",
                  "missing_api_key",
                  "invalid_api_key",
                  "api_key_expired",
                  "api_key_disabled",
                  "unauthenticated",
                  "billing_required",
                  "org_restricted",
                  "org_suspended",
                  "forbidden",
                  "insufficient_permissions",
                  "connection_not_allowed",
                  "organization_key_required",
                  "two_factor_required",
                  "two_factor_mandatory",
                  "no_active_organization",
                  "last_owner",
                  "slug_taken",
                  "org_limit_reached",
                  "reauth_failed",
                  "account_delete_blocked",
                  "not_found",
                  "conflict",
                  "rate_limited",
                  "internal_error",
                  "service_unavailable",
                  "missing_signature",
                  "invalid_signature",
                  "invalid_payload",
                  "payload_too_large",
                  "channel_not_configured",
                  "idempotency_key_reused",
                  "idempotency_in_progress",
                  "destination_url_not_allowed",
                  "destination_limit_reached",
                  "destination_paused",
                  "outside_service_window",
                  "recipient_unavailable",
                  "marketing_limit_reached",
                  "pair_rate_limited",
                  "meta_rate_limited",
                  "template_error",
                  "policy_blocked",
                  "connection_needs_reconnect",
                  "meta_payment_required",
                  "recipient_not_allowed",
                  "media_error",
                  "number_not_registered",
                  "username_not_eligible",
                  "meta_invalid_parameter",
                  "meta_unavailable",
                  "meta_unknown_outcome",
                  "meta_error",
                  "connection_not_active",
                  "connection_restricted",
                  "connection_disabled",
                  "connection_disconnected",
                  "connection_pending",
                  "pin_invalid",
                  "pin_attempts_exhausted",
                  "secret_rotation_pending",
                  "notification_type_locked",
                  "connection_rate_limited",
                  "account_flagged",
                  "signup_code_invalid",
                  "signup_scope_mismatch",
                  "signup_session_expired",
                  "signup_incomplete",
                  "system_user_assignment_failed",
                  "connection_already_exists",
                  "waba_owned_by_other_org",
                  "invitation_invalid",
                  "reconnect_mismatch",
                  "coex_not_on_business_app",
                  "link_invalid",
                  "link_expired",
                  "link_used",
                  "link_locked",
                  "link_password_required",
                  "link_password_invalid",
                  "mirror_path_blocked",
                  "media_too_large",
                  "media_type_not_supported",
                  "voice_conversion_failed",
                  "template_not_found",
                  "coex_not_supported",
                  "instagram_account_not_professional",
                  "instagram_scope_missing",
                  "oauth_state_invalid",
                  "messenger_no_pages",
                  "messenger_page_not_granted",
                  "type_not_supported_by_channel",
                  "tag_not_supported_by_channel",
                  "human_agent_window_closed",
                  "human_agent_not_approved",
                  "meta_permission_denied",
                  "private_reply_window_closed",
                  "private_reply_already_sent",
                  "comment_not_found",
                  "comment_not_owned",
                  "publication_not_editable",
                  "publication_media_invalid",
                  "media_url_not_public",
                  "media_url_expired",
                  "publishing_limit_reached",
                  "container_timeout",
                  "insights_not_available",
                  "welcome_flow_in_use",
                  "signed_request_invalid",
                  "data_deletion_not_found",
                  "invalid_cursor",
                  "retention_out_of_range",
                  "campaign_channel_not_supported",
                  "campaign_template_not_approved",
                  "campaign_template_mapping_invalid",
                  "campaign_not_editable",
                  "campaign_invalid_state",
                  "campaign_no_recipients",
                  "campaign_too_many_recipients",
                  "campaign_import_in_progress",
                  "campaign_schedule_invalid",
                  "spend_cap_reached",
                  "meta_spam_rate_limited",
                  "destination_type_disabled",
                  "no_client_connected",
                  "ws_ticket_invalid",
                  "ws_session_limit",
                  "data_request_in_progress",
                  "data_request_limit",
                  "data_export_expired",
                  "calling_not_supported_in_coex",
                  "calling_not_enabled",
                  "call_not_found",
                  "call_invalid_state",
                  "call_sdp_invalid",
                  "call_sdp_mismatch",
                  "call_permission_required",
                  "call_rate_limited",
                  "call_error",
                  "group_not_supported",
                  "group_not_found",
                  "group_not_active",
                  "group_participant_limit",
                  "group_message_type_not_supported",
                  "flow_not_found",
                  "flow_not_editable",
                  "flow_invalid_json",
                  "flow_handler_required",
                  "flow_key_not_uploaded",
                  "flow_error",
                  "catalog_not_found",
                  "catalog_not_linked",
                  "product_not_found",
                  "commerce_permission_missing",
                  "order_not_found",
                  "order_invalid_transition",
                  "order_reference_taken",
                  "order_totals_mismatch",
                  "payment_not_available",
                  "otp_template_invalid",
                  "body_too_large"
                ],
                "description": "Stable error code. Each code has a section at https://docs.messajo.com/errors."
              },
              "message": {
                "type": "string",
                "description": "Short message in English, for logs. Do not show it to end users: translate by `code`."
              },
              "meta_code": {
                "type": [
                  "integer",
                  "null"
                ],
                "description": "Error code returned by Meta, when the error came from it; otherwise `null`."
              },
              "retryable": {
                "type": "boolean",
                "description": "`true` when repeating the same call later may succeed."
              },
              "request_id": {
                "type": "string",
                "description": "Request ID, the same as the `X-Request-Id` header."
              },
              "docs_url": {
                "type": "string",
                "format": "uri",
                "description": "Link to the code's explanation in the docs."
              },
              "retry_after_ms": {
                "type": "integer",
                "description": "Only on `rate_limited`: how long to wait, in milliseconds, before retrying."
              },
              "details": {
                "type": "array",
                "description": "Only on `validation_failed` (one item per invalid field) and `destination_url_not_allowed` (the reason in `message`).",
                "items": {
                  "type": "object",
                  "required": [
                    "path",
                    "message"
                  ],
                  "properties": {
                    "path": {
                      "type": "string",
                      "description": "Path of the invalid field, e.g. `to` or `items[0].id`."
                    },
                    "message": {
                      "type": "string",
                      "description": "What is wrong with the field."
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "headers": {
      "X-Request-Id": {
        "description": "Unique request ID. Give it to support to find the call in the logs.",
        "schema": {
          "type": "string"
        }
      },
      "X-RateLimit-Limit": {
        "description": "Requests allowed per minute for this key.",
        "schema": {
          "type": "integer"
        }
      },
      "X-RateLimit-Remaining": {
        "description": "Requests left in the current window.",
        "schema": {
          "type": "integer"
        }
      },
      "X-RateLimit-Reset": {
        "description": "When the current window resets (Unix epoch, in seconds).",
        "schema": {
          "type": "integer"
        }
      },
      "Retry-After": {
        "description": "Seconds to wait before retrying the call.",
        "schema": {
          "type": "integer"
        }
      }
    },
    "parameters": {
      "IdempotencyKey": {
        "name": "Idempotency-Key",
        "in": "header",
        "required": false,
        "description": "Unique key (8–255 characters `A-Z a-z 0-9 . _ : -`) to repeat a `POST` without duplicate effects. Valid for 24 h per organization, method and path: the same key with the same body returns the stored response (header `Idempotent-Replayed: true`); with another body, `422 idempotency_key_reused`; while the first one runs, `409 idempotency_in_progress`.",
        "schema": {
          "type": "string",
          "pattern": "^[A-Za-z0-9._:-]{8,255}$"
        }
      }
    },
    "responses": {
      "BadRequest": {
        "description": "Invalid input (`validation_failed`): see `details`.",
        "headers": {
          "X-Request-Id": {
            "$ref": "#/components/headers/X-Request-Id"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Unauthorized": {
        "description": "Missing, invalid, expired or disabled key (`missing_api_key`, `invalid_api_key`, `api_key_expired`, `api_key_disabled`).",
        "headers": {
          "X-Request-Id": {
            "$ref": "#/components/headers/X-Request-Id"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Forbidden": {
        "description": "The key lacks the required permission or may not use this connection (`insufficient_permissions`, `connection_not_allowed`).",
        "headers": {
          "X-Request-Id": {
            "$ref": "#/components/headers/X-Request-Id"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "NotFound": {
        "description": "The resource does not exist or does not belong to the organization (`not_found`).",
        "headers": {
          "X-Request-Id": {
            "$ref": "#/components/headers/X-Request-Id"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "RateLimited": {
        "description": "The key's rate limit was reached (`rate_limited`): wait `Retry-After` seconds.",
        "headers": {
          "X-Request-Id": {
            "$ref": "#/components/headers/X-Request-Id"
          },
          "Retry-After": {
            "$ref": "#/components/headers/Retry-After"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Conflict": {
        "description": "Conflict with the current state (`idempotency_in_progress`, `destination_limit_reached`, `destination_paused`).",
        "headers": {
          "X-Request-Id": {
            "$ref": "#/components/headers/X-Request-Id"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Unprocessable": {
        "description": "The `Idempotency-Key` was already used with another body (`idempotency_key_reused`).",
        "headers": {
          "X-Request-Id": {
            "$ref": "#/components/headers/X-Request-Id"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "InternalError": {
        "description": "Unexpected server error (`internal_error`). You may retry; if it persists, report the `request_id`.",
        "headers": {
          "X-Request-Id": {
            "$ref": "#/components/headers/X-Request-Id"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    }
  },
  "openapi": "3.1.1",
  "paths": {
    "/me": {
      "get": {
        "operationId": "getMe",
        "summary": "Get the current key",
        "description": "Returns the organization that owns the key and the key's own data (permissions, allowed connections, expiration). Useful to test a key and find out what it can do. Permission: any valid key.",
        "tags": [
          "account"
        ],
        "responses": {
          "200": {
            "description": "The organization and the key used in the call.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "organization": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "description": "Organization ID.",
                          "examples": [
                            "Kq3vT9xZ2mWb7LpR4nYc8sDf1gHj6aEu"
                          ]
                        },
                        "name": {
                          "type": "string",
                          "description": "Organization name.",
                          "examples": [
                            "Acme"
                          ]
                        },
                        "slug": {
                          "type": "string",
                          "description": "Short organization identifier, used in URLs.",
                          "examples": [
                            "acme"
                          ]
                        }
                      },
                      "required": [
                        "id",
                        "name",
                        "slug"
                      ],
                      "description": "Organization that owns the key."
                    },
                    "api_key": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "description": "Key ID.",
                          "examples": [
                            "Zt5rB8wQ1nXc4LmV7pYd2sGf9hJk3aRe"
                          ]
                        },
                        "name": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ],
                          "description": "Name given to the key in the dashboard.",
                          "examples": [
                            "production"
                          ]
                        },
                        "start": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ],
                          "description": "Start of the key, to recognize it without exposing the secret.",
                          "examples": [
                            "mj_A1b2c3d"
                          ]
                        },
                        "permissions": {
                          "type": "array",
                          "items": {
                            "enum": [
                              "send",
                              "read",
                              "templates",
                              "commerce",
                              "admin"
                            ],
                            "type": "string"
                          },
                          "description": "Key permissions: `send`, `read`, `templates` or `admin` (includes the others).",
                          "examples": [
                            [
                              "read"
                            ]
                          ]
                        },
                        "connection_ids": {
                          "anyOf": [
                            {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            {
                              "type": "null"
                            }
                          ],
                          "description": "Connections the key may use; `null` = every connection of the organization.",
                          "examples": [
                            null
                          ]
                        },
                        "kind": {
                          "enum": [
                            "org",
                            "connection"
                          ],
                          "type": "string",
                          "description": "Key kind: `org` (whole organization) or `connection` (bound to one connection).",
                          "examples": [
                            "org"
                          ]
                        },
                        "connection_id": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ],
                          "description": "Connection the key is bound to; `null` for organization keys.",
                          "examples": [
                            null
                          ]
                        },
                        "connection": {
                          "anyOf": [
                            {
                              "type": "object",
                              "properties": {
                                "id": {
                                  "type": "string"
                                },
                                "channel": {
                                  "type": "string"
                                },
                                "label": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                }
                              },
                              "required": [
                                "id",
                                "channel",
                                "label"
                              ]
                            },
                            {
                              "type": "null"
                            }
                          ],
                          "description": "Connection the key is bound to (`id`, `channel`, `label`); `null` for organization keys.",
                          "examples": [
                            null
                          ]
                        },
                        "expires_at": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ],
                          "description": "Expiration date (ISO 8601, UTC); `null` = never expires.",
                          "examples": [
                            "2027-01-01T00:00:00.000Z"
                          ]
                        }
                      },
                      "required": [
                        "id",
                        "name",
                        "start",
                        "permissions",
                        "connection_ids",
                        "kind",
                        "connection_id",
                        "connection",
                        "expires_at"
                      ],
                      "description": "The key used in the call."
                    },
                    "request_id": {
                      "type": "string",
                      "description": "ID of this request, the same as the `X-Request-Id` header.",
                      "examples": [
                        "req_0193a1b2c3d47e8f9a0b1c2d3e4f5a6b"
                      ]
                    }
                  },
                  "required": [
                    "organization",
                    "api_key",
                    "request_id"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/destinations": {
      "get": {
        "operationId": "listDestinations",
        "summary": "List destinations",
        "description": "Lists the organization's event destinations. A key restricted to connections only sees destinations restricted to them. Permission: `admin`.",
        "tags": [
          "destinations"
        ],
        "responses": {
          "200": {
            "description": "The organization's destinations.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "description": "Destination ID.",
                            "examples": [
                              "dst_0193a1b2c3d47e8f9a0b1c2d3e4f5a6b"
                            ]
                          },
                          "type": {
                            "enum": [
                              "webhook",
                              "rabbitmq",
                              "sqs",
                              "kafka",
                              "websocket"
                            ],
                            "type": "string",
                            "description": "Destination type: `webhook` (default), `rabbitmq`, `sqs`, `kafka` or `websocket`. A type disabled on the server → `422 destination_type_disabled`. Cannot change after creation."
                          },
                          "label": {
                            "type": "string",
                            "description": "Destination name, so you can recognize it.",
                            "examples": [
                              "CRM"
                            ]
                          },
                          "url": {
                            "type": "string",
                            "description": "`https` URL that receives the events by `POST`.",
                            "examples": [
                              "https://example.com/webhooks/messajo"
                            ]
                          },
                          "headers": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "name": {
                                  "type": "string",
                                  "description": "Header name."
                                },
                                "value_last4": {
                                  "type": "string",
                                  "description": "Last 4 characters of the header value."
                                }
                              },
                              "required": [
                                "name",
                                "value_last4"
                              ]
                            },
                            "description": "Custom headers sent on every delivery (up to 20). They cannot override the `Messajo-*` headers."
                          },
                          "format": {
                            "enum": [
                              "normalized",
                              "meta"
                            ],
                            "type": "string",
                            "description": "Format of `data`: `normalized` (the same on all three channels) or `meta` (Meta's original item, when there is one)."
                          },
                          "event_types": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            },
                            "description": "Event type patterns: exact type (`message.received`), family (`message.*`) or `*`.",
                            "examples": [
                              [
                                "message.*"
                              ]
                            ]
                          },
                          "connection_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Connection that owns the destination (`con_…`); `null` = organization-wide destination, which receives events from every connection. Cannot change after creation."
                          },
                          "connection_ids": {
                            "anyOf": [
                              {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Deprecated: use `connection_id`. Accepts `null` or a single connection; more than one → `400 validation_failed`. In responses it is derived from `connection_id` (`[id]` or `null`)."
                          },
                          "status": {
                            "enum": [
                              "active",
                              "paused",
                              "auto_paused"
                            ],
                            "type": "string",
                            "description": "`active`, `paused` (manual) or `auto_paused` (failing for 24 h in a row)."
                          },
                          "paused_reason": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Pause reason (`manual` or `failing`); `null` while active."
                          },
                          "secret_last4": {
                            "type": "string",
                            "description": "Last 4 characters of the current signing secret."
                          },
                          "previous_secret_expires_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Until when the previous secret also signs (ISO 8601, UTC); `null` = no previous secret.",
                            "examples": [
                              null
                            ]
                          },
                          "failing_since": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Since when deliveries have been failing nonstop (ISO 8601, UTC); `null` = no ongoing failure.",
                            "examples": [
                              null
                            ]
                          },
                          "last_success_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Last successful delivery (ISO 8601, UTC); updated at most every 30 s.",
                            "examples": [
                              null
                            ]
                          },
                          "last_failure_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Last failed delivery (ISO 8601, UTC).",
                            "examples": [
                              null
                            ]
                          },
                          "created_at": {
                            "type": "string",
                            "description": "Creation date (ISO 8601, UTC)."
                          },
                          "updated_at": {
                            "type": "string",
                            "description": "Last change date (ISO 8601, UTC)."
                          },
                          "config": {
                            "type": "object",
                            "propertyNames": {
                              "type": "string"
                            },
                            "additionalProperties": {},
                            "description": "Type block, without secrets (passwords become `password_last4`). `{}` for webhooks and when the type is disabled."
                          },
                          "connected_clients": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "WebSocket clients connected right now; `null` for types other than `websocket`."
                          }
                        },
                        "required": [
                          "id",
                          "type",
                          "label",
                          "url",
                          "headers",
                          "format",
                          "event_types",
                          "connection_id",
                          "connection_ids",
                          "status",
                          "paused_reason",
                          "secret_last4",
                          "previous_secret_expires_at",
                          "failing_since",
                          "last_success_at",
                          "last_failure_at",
                          "created_at",
                          "updated_at",
                          "config",
                          "connected_clients"
                        ]
                      },
                      "description": "Page items, newest first."
                    },
                    "next_cursor": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Cursor for the next page; `null` when there are no more items."
                    }
                  },
                  "required": [
                    "data",
                    "next_cursor"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "createDestination",
        "summary": "Create destination",
        "description": "Creates a webhook destination. The URL must be public `https` (internal addresses are refused with `destination_url_not_allowed`). The signing secret comes only in this response: store it. At most 20 destinations per organization. With a connection key, `connection_id` defaults to the key's connection; `connection_id: null` (global) requires an organization key (`organization_key_required`). Permission: `admin`. Other types (`rabbitmq`, `sqs`, `kafka`, `websocket`) go in the field named after the type, when enabled on the server; otherwise `422 destination_type_disabled`.",
        "tags": [
          "destinations"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "label": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100,
                    "description": "Destination name, so you can recognize it."
                  },
                  "url": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 2048,
                    "description": "`https` URL that receives the events by `POST`."
                  },
                  "headers": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "name": {
                          "type": "string",
                          "description": "Header name."
                        },
                        "value": {
                          "type": "string",
                          "maxLength": 4096,
                          "description": "Header value. Stored encrypted and never returned in full."
                        }
                      },
                      "required": [
                        "name",
                        "value"
                      ]
                    },
                    "description": "Custom headers sent on every delivery (up to 20). They cannot override the `Messajo-*` headers."
                  },
                  "format": {
                    "enum": [
                      "normalized",
                      "meta"
                    ],
                    "type": "string",
                    "description": "Format of `data`: `normalized` (the same on all three channels) or `meta` (Meta's original item, when there is one)."
                  },
                  "event_types": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Event type patterns: exact type (`message.received`), family (`message.*`) or `*`."
                  },
                  "connection_ids": {
                    "anyOf": [
                      {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      },
                      {
                        "type": "null"
                      }
                    ],
                    "description": "Deprecated: use `connection_id`. Accepts `null` or a single connection; more than one → `400 validation_failed`. In responses it is derived from `connection_id` (`[id]` or `null`)."
                  },
                  "type": {
                    "enum": [
                      "webhook",
                      "rabbitmq",
                      "sqs",
                      "kafka",
                      "websocket"
                    ],
                    "type": "string",
                    "default": "webhook",
                    "description": "Destination type: `webhook` (default), `rabbitmq`, `sqs`, `kafka` or `websocket`. A type disabled on the server → `422 destination_type_disabled`. Cannot change after creation."
                  },
                  "connection_id": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ],
                    "description": "Connection that owns the destination (`con_…`); `null` = organization-wide destination, which receives events from every connection. Cannot change after creation."
                  },
                  "rabbitmq": {
                    "type": "object",
                    "properties": {
                      "url": {
                        "type": "string",
                        "minLength": 1
                      },
                      "exchange": {
                        "type": "string",
                        "maxLength": 255
                      },
                      "routing_key": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 255,
                        "default": "messajo.{type}"
                      },
                      "persistent": {
                        "type": "boolean",
                        "default": true
                      }
                    },
                    "required": [
                      "url",
                      "exchange"
                    ],
                    "description": "Only with `type: rabbitmq`: `url` (`amqps://user:password@host:5671/vhost`), `exchange`, `routing_key` (default `messajo.{type}`) and `persistent` (default `true`)."
                  },
                  "sqs": {
                    "type": "object",
                    "properties": {
                      "queue_url": {
                        "type": "string",
                        "minLength": 1
                      },
                      "region": {
                        "type": "string",
                        "pattern": "^[a-z]{2}(-[a-z]+)+-\\d+$"
                      },
                      "access_key_id": {
                        "type": "string",
                        "minLength": 1
                      },
                      "secret_access_key": {
                        "type": "string",
                        "minLength": 1
                      },
                      "session_token": {
                        "type": "string",
                        "minLength": 1
                      },
                      "message_group_id": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 255,
                        "default": "{connection}"
                      }
                    },
                    "required": [
                      "queue_url",
                      "region",
                      "access_key_id",
                      "secret_access_key"
                    ],
                    "description": "Only with `type: sqs`: `queue_url`, `region`, `access_key_id`, `secret_access_key`, optional `session_token` and `message_group_id` (`.fifo` queues, default `{connection}`)."
                  },
                  "kafka": {
                    "type": "object",
                    "properties": {
                      "brokers": {
                        "type": "array",
                        "minItems": 1,
                        "maxItems": 10,
                        "items": {
                          "type": "string",
                          "minLength": 1
                        }
                      },
                      "topic": {
                        "type": "string",
                        "pattern": "^[a-zA-Z0-9._-]{1,249}$"
                      },
                      "ssl": {
                        "type": "boolean",
                        "default": true
                      },
                      "sasl": {
                        "anyOf": [
                          {
                            "type": "object",
                            "properties": {
                              "mechanism": {
                                "enum": [
                                  "plain",
                                  "scram-sha-256",
                                  "scram-sha-512"
                                ],
                                "type": "string"
                              },
                              "username": {
                                "type": "string",
                                "minLength": 1
                              },
                              "password": {
                                "type": "string",
                                "minLength": 1
                              }
                            },
                            "required": [
                              "mechanism",
                              "username",
                              "password"
                            ]
                          },
                          {
                            "type": "null"
                          }
                        ],
                        "default": null
                      },
                      "key": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 255,
                        "default": "{connection}"
                      },
                      "client_id": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 255,
                        "default": "messajo"
                      }
                    },
                    "required": [
                      "brokers",
                      "topic"
                    ],
                    "description": "Only with `type: kafka`: `brokers` (up to 10), `topic`, `ssl` (default `true`), `sasl` (`plain`, `scram-sha-256` or `scram-sha-512`), `key` (default `{connection}`) and `client_id`."
                  },
                  "websocket": {
                    "type": "object",
                    "additionalProperties": false,
                    "description": "Only with `type: websocket`: empty object. Events arrive on `GET /v1/ws` and the client confirms each one with `ack`."
                  }
                },
                "required": [
                  "label",
                  "format",
                  "event_types"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The created destination, with the signing secret.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Destination ID.",
                      "examples": [
                        "dst_0193a1b2c3d47e8f9a0b1c2d3e4f5a6b"
                      ]
                    },
                    "type": {
                      "enum": [
                        "webhook",
                        "rabbitmq",
                        "sqs",
                        "kafka",
                        "websocket"
                      ],
                      "type": "string",
                      "description": "Destination type: `webhook` (default), `rabbitmq`, `sqs`, `kafka` or `websocket`. A type disabled on the server → `422 destination_type_disabled`. Cannot change after creation."
                    },
                    "label": {
                      "type": "string",
                      "description": "Destination name, so you can recognize it.",
                      "examples": [
                        "CRM"
                      ]
                    },
                    "url": {
                      "type": "string",
                      "description": "`https` URL that receives the events by `POST`.",
                      "examples": [
                        "https://example.com/webhooks/messajo"
                      ]
                    },
                    "headers": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "name": {
                            "type": "string",
                            "description": "Header name."
                          },
                          "value_last4": {
                            "type": "string",
                            "description": "Last 4 characters of the header value."
                          }
                        },
                        "required": [
                          "name",
                          "value_last4"
                        ]
                      },
                      "description": "Custom headers sent on every delivery (up to 20). They cannot override the `Messajo-*` headers."
                    },
                    "format": {
                      "enum": [
                        "normalized",
                        "meta"
                      ],
                      "type": "string",
                      "description": "Format of `data`: `normalized` (the same on all three channels) or `meta` (Meta's original item, when there is one)."
                    },
                    "event_types": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      },
                      "description": "Event type patterns: exact type (`message.received`), family (`message.*`) or `*`.",
                      "examples": [
                        [
                          "message.*"
                        ]
                      ]
                    },
                    "connection_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Connection that owns the destination (`con_…`); `null` = organization-wide destination, which receives events from every connection. Cannot change after creation."
                    },
                    "connection_ids": {
                      "anyOf": [
                        {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Deprecated: use `connection_id`. Accepts `null` or a single connection; more than one → `400 validation_failed`. In responses it is derived from `connection_id` (`[id]` or `null`)."
                    },
                    "status": {
                      "enum": [
                        "active",
                        "paused",
                        "auto_paused"
                      ],
                      "type": "string",
                      "description": "`active`, `paused` (manual) or `auto_paused` (failing for 24 h in a row)."
                    },
                    "paused_reason": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Pause reason (`manual` or `failing`); `null` while active."
                    },
                    "secret_last4": {
                      "type": "string",
                      "description": "Last 4 characters of the current signing secret."
                    },
                    "previous_secret_expires_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Until when the previous secret also signs (ISO 8601, UTC); `null` = no previous secret.",
                      "examples": [
                        null
                      ]
                    },
                    "failing_since": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Since when deliveries have been failing nonstop (ISO 8601, UTC); `null` = no ongoing failure.",
                      "examples": [
                        null
                      ]
                    },
                    "last_success_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Last successful delivery (ISO 8601, UTC); updated at most every 30 s.",
                      "examples": [
                        null
                      ]
                    },
                    "last_failure_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Last failed delivery (ISO 8601, UTC).",
                      "examples": [
                        null
                      ]
                    },
                    "created_at": {
                      "type": "string",
                      "description": "Creation date (ISO 8601, UTC)."
                    },
                    "updated_at": {
                      "type": "string",
                      "description": "Last change date (ISO 8601, UTC)."
                    },
                    "config": {
                      "type": "object",
                      "propertyNames": {
                        "type": "string"
                      },
                      "additionalProperties": {},
                      "description": "Type block, without secrets (passwords become `password_last4`). `{}` for webhooks and when the type is disabled."
                    },
                    "connected_clients": {
                      "anyOf": [
                        {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "WebSocket clients connected right now; `null` for types other than `websocket`."
                    },
                    "secret": {
                      "type": "string",
                      "description": "Signing secret (`whsec_…`). Only shown in this response: store it to verify `Messajo-Signature`."
                    }
                  },
                  "required": [
                    "id",
                    "type",
                    "label",
                    "url",
                    "headers",
                    "format",
                    "event_types",
                    "connection_id",
                    "connection_ids",
                    "status",
                    "paused_reason",
                    "secret_last4",
                    "previous_secret_expires_at",
                    "failing_since",
                    "last_success_at",
                    "last_failure_at",
                    "created_at",
                    "updated_at",
                    "config",
                    "connected_clients",
                    "secret"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ]
      }
    },
    "/destinations/{id}": {
      "get": {
        "operationId": "getDestination",
        "summary": "Get destination",
        "description": "Returns a destination. Custom header values come masked. Permission: `admin`.",
        "tags": [
          "destinations"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Destination ID."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The destination.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Destination ID.",
                      "examples": [
                        "dst_0193a1b2c3d47e8f9a0b1c2d3e4f5a6b"
                      ]
                    },
                    "type": {
                      "enum": [
                        "webhook",
                        "rabbitmq",
                        "sqs",
                        "kafka",
                        "websocket"
                      ],
                      "type": "string",
                      "description": "Destination type: `webhook` (default), `rabbitmq`, `sqs`, `kafka` or `websocket`. A type disabled on the server → `422 destination_type_disabled`. Cannot change after creation."
                    },
                    "label": {
                      "type": "string",
                      "description": "Destination name, so you can recognize it.",
                      "examples": [
                        "CRM"
                      ]
                    },
                    "url": {
                      "type": "string",
                      "description": "`https` URL that receives the events by `POST`.",
                      "examples": [
                        "https://example.com/webhooks/messajo"
                      ]
                    },
                    "headers": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "name": {
                            "type": "string",
                            "description": "Header name."
                          },
                          "value_last4": {
                            "type": "string",
                            "description": "Last 4 characters of the header value."
                          }
                        },
                        "required": [
                          "name",
                          "value_last4"
                        ]
                      },
                      "description": "Custom headers sent on every delivery (up to 20). They cannot override the `Messajo-*` headers."
                    },
                    "format": {
                      "enum": [
                        "normalized",
                        "meta"
                      ],
                      "type": "string",
                      "description": "Format of `data`: `normalized` (the same on all three channels) or `meta` (Meta's original item, when there is one)."
                    },
                    "event_types": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      },
                      "description": "Event type patterns: exact type (`message.received`), family (`message.*`) or `*`.",
                      "examples": [
                        [
                          "message.*"
                        ]
                      ]
                    },
                    "connection_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Connection that owns the destination (`con_…`); `null` = organization-wide destination, which receives events from every connection. Cannot change after creation."
                    },
                    "connection_ids": {
                      "anyOf": [
                        {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Deprecated: use `connection_id`. Accepts `null` or a single connection; more than one → `400 validation_failed`. In responses it is derived from `connection_id` (`[id]` or `null`)."
                    },
                    "status": {
                      "enum": [
                        "active",
                        "paused",
                        "auto_paused"
                      ],
                      "type": "string",
                      "description": "`active`, `paused` (manual) or `auto_paused` (failing for 24 h in a row)."
                    },
                    "paused_reason": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Pause reason (`manual` or `failing`); `null` while active."
                    },
                    "secret_last4": {
                      "type": "string",
                      "description": "Last 4 characters of the current signing secret."
                    },
                    "previous_secret_expires_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Until when the previous secret also signs (ISO 8601, UTC); `null` = no previous secret.",
                      "examples": [
                        null
                      ]
                    },
                    "failing_since": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Since when deliveries have been failing nonstop (ISO 8601, UTC); `null` = no ongoing failure.",
                      "examples": [
                        null
                      ]
                    },
                    "last_success_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Last successful delivery (ISO 8601, UTC); updated at most every 30 s.",
                      "examples": [
                        null
                      ]
                    },
                    "last_failure_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Last failed delivery (ISO 8601, UTC).",
                      "examples": [
                        null
                      ]
                    },
                    "created_at": {
                      "type": "string",
                      "description": "Creation date (ISO 8601, UTC)."
                    },
                    "updated_at": {
                      "type": "string",
                      "description": "Last change date (ISO 8601, UTC)."
                    },
                    "config": {
                      "type": "object",
                      "propertyNames": {
                        "type": "string"
                      },
                      "additionalProperties": {},
                      "description": "Type block, without secrets (passwords become `password_last4`). `{}` for webhooks and when the type is disabled."
                    },
                    "connected_clients": {
                      "anyOf": [
                        {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "WebSocket clients connected right now; `null` for types other than `websocket`."
                    }
                  },
                  "required": [
                    "id",
                    "type",
                    "label",
                    "url",
                    "headers",
                    "format",
                    "event_types",
                    "connection_id",
                    "connection_ids",
                    "status",
                    "paused_reason",
                    "secret_last4",
                    "previous_secret_expires_at",
                    "failing_since",
                    "last_success_at",
                    "last_failure_at",
                    "created_at",
                    "updated_at",
                    "config",
                    "connected_clients"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "patch": {
        "operationId": "updateDestination",
        "summary": "Update destination",
        "description": "Changes the fields sent; missing ones stay as they are. The secret does not change here: use `rotate-secret`. Permission: `admin`.",
        "tags": [
          "destinations"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Destination ID."
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "label": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100,
                    "description": "Destination name, so you can recognize it."
                  },
                  "url": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 2048,
                    "description": "`https` URL that receives the events by `POST`."
                  },
                  "headers": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "name": {
                          "type": "string",
                          "description": "Header name."
                        },
                        "value": {
                          "type": "string",
                          "maxLength": 4096,
                          "description": "Header value. Stored encrypted and never returned in full."
                        }
                      },
                      "required": [
                        "name",
                        "value"
                      ]
                    },
                    "description": "Custom headers sent on every delivery (up to 20). They cannot override the `Messajo-*` headers."
                  },
                  "format": {
                    "enum": [
                      "normalized",
                      "meta"
                    ],
                    "type": "string",
                    "description": "Format of `data`: `normalized` (the same on all three channels) or `meta` (Meta's original item, when there is one)."
                  },
                  "event_types": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Event type patterns: exact type (`message.received`), family (`message.*`) or `*`."
                  },
                  "connection_id": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ],
                    "description": "Connection that owns the destination (`con_…`); `null` = organization-wide destination, which receives events from every connection. Cannot change after creation."
                  },
                  "connection_ids": {
                    "anyOf": [
                      {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      },
                      {
                        "type": "null"
                      }
                    ],
                    "description": "Deprecated: use `connection_id`. Accepts `null` or a single connection; more than one → `400 validation_failed`. In responses it is derived from `connection_id` (`[id]` or `null`)."
                  },
                  "rabbitmq": {
                    "type": "object",
                    "properties": {
                      "url": {
                        "type": "string",
                        "minLength": 1
                      },
                      "exchange": {
                        "type": "string",
                        "maxLength": 255
                      },
                      "routing_key": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 255,
                        "default": "messajo.{type}"
                      },
                      "persistent": {
                        "type": "boolean",
                        "default": true
                      }
                    },
                    "required": [
                      "url",
                      "exchange"
                    ],
                    "description": "Only with `type: rabbitmq`: `url` (`amqps://user:password@host:5671/vhost`), `exchange`, `routing_key` (default `messajo.{type}`) and `persistent` (default `true`)."
                  },
                  "sqs": {
                    "type": "object",
                    "properties": {
                      "queue_url": {
                        "type": "string",
                        "minLength": 1
                      },
                      "region": {
                        "type": "string",
                        "pattern": "^[a-z]{2}(-[a-z]+)+-\\d+$"
                      },
                      "access_key_id": {
                        "type": "string",
                        "minLength": 1
                      },
                      "secret_access_key": {
                        "type": "string",
                        "minLength": 1
                      },
                      "session_token": {
                        "type": "string",
                        "minLength": 1
                      },
                      "message_group_id": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 255,
                        "default": "{connection}"
                      }
                    },
                    "required": [
                      "queue_url",
                      "region",
                      "access_key_id",
                      "secret_access_key"
                    ],
                    "description": "Only with `type: sqs`: `queue_url`, `region`, `access_key_id`, `secret_access_key`, optional `session_token` and `message_group_id` (`.fifo` queues, default `{connection}`)."
                  },
                  "kafka": {
                    "type": "object",
                    "properties": {
                      "brokers": {
                        "type": "array",
                        "minItems": 1,
                        "maxItems": 10,
                        "items": {
                          "type": "string",
                          "minLength": 1
                        }
                      },
                      "topic": {
                        "type": "string",
                        "pattern": "^[a-zA-Z0-9._-]{1,249}$"
                      },
                      "ssl": {
                        "type": "boolean",
                        "default": true
                      },
                      "sasl": {
                        "anyOf": [
                          {
                            "type": "object",
                            "properties": {
                              "mechanism": {
                                "enum": [
                                  "plain",
                                  "scram-sha-256",
                                  "scram-sha-512"
                                ],
                                "type": "string"
                              },
                              "username": {
                                "type": "string",
                                "minLength": 1
                              },
                              "password": {
                                "type": "string",
                                "minLength": 1
                              }
                            },
                            "required": [
                              "mechanism",
                              "username",
                              "password"
                            ]
                          },
                          {
                            "type": "null"
                          }
                        ],
                        "default": null
                      },
                      "key": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 255,
                        "default": "{connection}"
                      },
                      "client_id": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 255,
                        "default": "messajo"
                      }
                    },
                    "required": [
                      "brokers",
                      "topic"
                    ],
                    "description": "Only with `type: kafka`: `brokers` (up to 10), `topic`, `ssl` (default `true`), `sasl` (`plain`, `scram-sha-256` or `scram-sha-512`), `key` (default `{connection}`) and `client_id`."
                  },
                  "websocket": {
                    "type": "object",
                    "additionalProperties": false,
                    "description": "Only with `type: websocket`: empty object. Events arrive on `GET /v1/ws` and the client confirms each one with `ack`."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The updated destination.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Destination ID.",
                      "examples": [
                        "dst_0193a1b2c3d47e8f9a0b1c2d3e4f5a6b"
                      ]
                    },
                    "type": {
                      "enum": [
                        "webhook",
                        "rabbitmq",
                        "sqs",
                        "kafka",
                        "websocket"
                      ],
                      "type": "string",
                      "description": "Destination type: `webhook` (default), `rabbitmq`, `sqs`, `kafka` or `websocket`. A type disabled on the server → `422 destination_type_disabled`. Cannot change after creation."
                    },
                    "label": {
                      "type": "string",
                      "description": "Destination name, so you can recognize it.",
                      "examples": [
                        "CRM"
                      ]
                    },
                    "url": {
                      "type": "string",
                      "description": "`https` URL that receives the events by `POST`.",
                      "examples": [
                        "https://example.com/webhooks/messajo"
                      ]
                    },
                    "headers": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "name": {
                            "type": "string",
                            "description": "Header name."
                          },
                          "value_last4": {
                            "type": "string",
                            "description": "Last 4 characters of the header value."
                          }
                        },
                        "required": [
                          "name",
                          "value_last4"
                        ]
                      },
                      "description": "Custom headers sent on every delivery (up to 20). They cannot override the `Messajo-*` headers."
                    },
                    "format": {
                      "enum": [
                        "normalized",
                        "meta"
                      ],
                      "type": "string",
                      "description": "Format of `data`: `normalized` (the same on all three channels) or `meta` (Meta's original item, when there is one)."
                    },
                    "event_types": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      },
                      "description": "Event type patterns: exact type (`message.received`), family (`message.*`) or `*`.",
                      "examples": [
                        [
                          "message.*"
                        ]
                      ]
                    },
                    "connection_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Connection that owns the destination (`con_…`); `null` = organization-wide destination, which receives events from every connection. Cannot change after creation."
                    },
                    "connection_ids": {
                      "anyOf": [
                        {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Deprecated: use `connection_id`. Accepts `null` or a single connection; more than one → `400 validation_failed`. In responses it is derived from `connection_id` (`[id]` or `null`)."
                    },
                    "status": {
                      "enum": [
                        "active",
                        "paused",
                        "auto_paused"
                      ],
                      "type": "string",
                      "description": "`active`, `paused` (manual) or `auto_paused` (failing for 24 h in a row)."
                    },
                    "paused_reason": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Pause reason (`manual` or `failing`); `null` while active."
                    },
                    "secret_last4": {
                      "type": "string",
                      "description": "Last 4 characters of the current signing secret."
                    },
                    "previous_secret_expires_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Until when the previous secret also signs (ISO 8601, UTC); `null` = no previous secret.",
                      "examples": [
                        null
                      ]
                    },
                    "failing_since": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Since when deliveries have been failing nonstop (ISO 8601, UTC); `null` = no ongoing failure.",
                      "examples": [
                        null
                      ]
                    },
                    "last_success_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Last successful delivery (ISO 8601, UTC); updated at most every 30 s.",
                      "examples": [
                        null
                      ]
                    },
                    "last_failure_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Last failed delivery (ISO 8601, UTC).",
                      "examples": [
                        null
                      ]
                    },
                    "created_at": {
                      "type": "string",
                      "description": "Creation date (ISO 8601, UTC)."
                    },
                    "updated_at": {
                      "type": "string",
                      "description": "Last change date (ISO 8601, UTC)."
                    },
                    "config": {
                      "type": "object",
                      "propertyNames": {
                        "type": "string"
                      },
                      "additionalProperties": {},
                      "description": "Type block, without secrets (passwords become `password_last4`). `{}` for webhooks and when the type is disabled."
                    },
                    "connected_clients": {
                      "anyOf": [
                        {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "WebSocket clients connected right now; `null` for types other than `websocket`."
                    }
                  },
                  "required": [
                    "id",
                    "type",
                    "label",
                    "url",
                    "headers",
                    "format",
                    "event_types",
                    "connection_id",
                    "connection_ids",
                    "status",
                    "paused_reason",
                    "secret_last4",
                    "previous_secret_expires_at",
                    "failing_since",
                    "last_success_at",
                    "last_failure_at",
                    "created_at",
                    "updated_at",
                    "config",
                    "connected_clients"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "operationId": "deleteDestination",
        "summary": "Delete destination",
        "description": "Deletes the destination and its delivery history. Permission: `admin`.",
        "tags": [
          "destinations"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Destination ID."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Deletion confirmation.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Destination ID."
                    },
                    "deleted": {
                      "const": true,
                      "description": "Always `true`."
                    }
                  },
                  "required": [
                    "id",
                    "deleted"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/destinations/{id}/rotate-secret": {
      "post": {
        "operationId": "rotateDestinationSecret",
        "summary": "Rotate secret",
        "description": "Generates a new signing secret. The previous one keeps signing alongside for `keep_previous_hours` (0 to 72, default 24), so you can switch without losing deliveries. Permission: `admin`.",
        "tags": [
          "destinations"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Destination ID."
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "keep_previous_hours": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 72,
                    "default": 24,
                    "description": "For how many hours the previous secret keeps signing (0 to 72)."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The new secret and until when the previous one is valid.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "secret": {
                      "type": "string",
                      "description": "Signing secret (`whsec_…`). Only shown in this response: store it to verify `Messajo-Signature`."
                    },
                    "previous_secret_expires_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Until when the previous secret also signs (ISO 8601, UTC); `null` = no previous secret.",
                      "examples": [
                        null
                      ]
                    }
                  },
                  "required": [
                    "secret",
                    "previous_secret_expires_at"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/destinations/{id}/pause": {
      "post": {
        "operationId": "pauseDestination",
        "summary": "Pause destination",
        "description": "Stops delivering to the destination. New events create deliveries failed with `destination_paused`, which can be redelivered later. Permission: `admin`.",
        "tags": [
          "destinations"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Destination ID."
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "description": "The paused destination.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Destination ID.",
                      "examples": [
                        "dst_0193a1b2c3d47e8f9a0b1c2d3e4f5a6b"
                      ]
                    },
                    "type": {
                      "enum": [
                        "webhook",
                        "rabbitmq",
                        "sqs",
                        "kafka",
                        "websocket"
                      ],
                      "type": "string",
                      "description": "Destination type: `webhook` (default), `rabbitmq`, `sqs`, `kafka` or `websocket`. A type disabled on the server → `422 destination_type_disabled`. Cannot change after creation."
                    },
                    "label": {
                      "type": "string",
                      "description": "Destination name, so you can recognize it.",
                      "examples": [
                        "CRM"
                      ]
                    },
                    "url": {
                      "type": "string",
                      "description": "`https` URL that receives the events by `POST`.",
                      "examples": [
                        "https://example.com/webhooks/messajo"
                      ]
                    },
                    "headers": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "name": {
                            "type": "string",
                            "description": "Header name."
                          },
                          "value_last4": {
                            "type": "string",
                            "description": "Last 4 characters of the header value."
                          }
                        },
                        "required": [
                          "name",
                          "value_last4"
                        ]
                      },
                      "description": "Custom headers sent on every delivery (up to 20). They cannot override the `Messajo-*` headers."
                    },
                    "format": {
                      "enum": [
                        "normalized",
                        "meta"
                      ],
                      "type": "string",
                      "description": "Format of `data`: `normalized` (the same on all three channels) or `meta` (Meta's original item, when there is one)."
                    },
                    "event_types": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      },
                      "description": "Event type patterns: exact type (`message.received`), family (`message.*`) or `*`.",
                      "examples": [
                        [
                          "message.*"
                        ]
                      ]
                    },
                    "connection_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Connection that owns the destination (`con_…`); `null` = organization-wide destination, which receives events from every connection. Cannot change after creation."
                    },
                    "connection_ids": {
                      "anyOf": [
                        {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Deprecated: use `connection_id`. Accepts `null` or a single connection; more than one → `400 validation_failed`. In responses it is derived from `connection_id` (`[id]` or `null`)."
                    },
                    "status": {
                      "enum": [
                        "active",
                        "paused",
                        "auto_paused"
                      ],
                      "type": "string",
                      "description": "`active`, `paused` (manual) or `auto_paused` (failing for 24 h in a row)."
                    },
                    "paused_reason": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Pause reason (`manual` or `failing`); `null` while active."
                    },
                    "secret_last4": {
                      "type": "string",
                      "description": "Last 4 characters of the current signing secret."
                    },
                    "previous_secret_expires_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Until when the previous secret also signs (ISO 8601, UTC); `null` = no previous secret.",
                      "examples": [
                        null
                      ]
                    },
                    "failing_since": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Since when deliveries have been failing nonstop (ISO 8601, UTC); `null` = no ongoing failure.",
                      "examples": [
                        null
                      ]
                    },
                    "last_success_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Last successful delivery (ISO 8601, UTC); updated at most every 30 s.",
                      "examples": [
                        null
                      ]
                    },
                    "last_failure_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Last failed delivery (ISO 8601, UTC).",
                      "examples": [
                        null
                      ]
                    },
                    "created_at": {
                      "type": "string",
                      "description": "Creation date (ISO 8601, UTC)."
                    },
                    "updated_at": {
                      "type": "string",
                      "description": "Last change date (ISO 8601, UTC)."
                    },
                    "config": {
                      "type": "object",
                      "propertyNames": {
                        "type": "string"
                      },
                      "additionalProperties": {},
                      "description": "Type block, without secrets (passwords become `password_last4`). `{}` for webhooks and when the type is disabled."
                    },
                    "connected_clients": {
                      "anyOf": [
                        {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "WebSocket clients connected right now; `null` for types other than `websocket`."
                    }
                  },
                  "required": [
                    "id",
                    "type",
                    "label",
                    "url",
                    "headers",
                    "format",
                    "event_types",
                    "connection_id",
                    "connection_ids",
                    "status",
                    "paused_reason",
                    "secret_last4",
                    "previous_secret_expires_at",
                    "failing_since",
                    "last_success_at",
                    "last_failure_at",
                    "created_at",
                    "updated_at",
                    "config",
                    "connected_clients"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/destinations/{id}/resume": {
      "post": {
        "operationId": "resumeDestination",
        "summary": "Resume destination",
        "description": "Starts delivering to the destination again (also after an automatic pause). Permission: `admin`.",
        "tags": [
          "destinations"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Destination ID."
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "description": "The active destination.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Destination ID.",
                      "examples": [
                        "dst_0193a1b2c3d47e8f9a0b1c2d3e4f5a6b"
                      ]
                    },
                    "type": {
                      "enum": [
                        "webhook",
                        "rabbitmq",
                        "sqs",
                        "kafka",
                        "websocket"
                      ],
                      "type": "string",
                      "description": "Destination type: `webhook` (default), `rabbitmq`, `sqs`, `kafka` or `websocket`. A type disabled on the server → `422 destination_type_disabled`. Cannot change after creation."
                    },
                    "label": {
                      "type": "string",
                      "description": "Destination name, so you can recognize it.",
                      "examples": [
                        "CRM"
                      ]
                    },
                    "url": {
                      "type": "string",
                      "description": "`https` URL that receives the events by `POST`.",
                      "examples": [
                        "https://example.com/webhooks/messajo"
                      ]
                    },
                    "headers": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "name": {
                            "type": "string",
                            "description": "Header name."
                          },
                          "value_last4": {
                            "type": "string",
                            "description": "Last 4 characters of the header value."
                          }
                        },
                        "required": [
                          "name",
                          "value_last4"
                        ]
                      },
                      "description": "Custom headers sent on every delivery (up to 20). They cannot override the `Messajo-*` headers."
                    },
                    "format": {
                      "enum": [
                        "normalized",
                        "meta"
                      ],
                      "type": "string",
                      "description": "Format of `data`: `normalized` (the same on all three channels) or `meta` (Meta's original item, when there is one)."
                    },
                    "event_types": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      },
                      "description": "Event type patterns: exact type (`message.received`), family (`message.*`) or `*`.",
                      "examples": [
                        [
                          "message.*"
                        ]
                      ]
                    },
                    "connection_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Connection that owns the destination (`con_…`); `null` = organization-wide destination, which receives events from every connection. Cannot change after creation."
                    },
                    "connection_ids": {
                      "anyOf": [
                        {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Deprecated: use `connection_id`. Accepts `null` or a single connection; more than one → `400 validation_failed`. In responses it is derived from `connection_id` (`[id]` or `null`)."
                    },
                    "status": {
                      "enum": [
                        "active",
                        "paused",
                        "auto_paused"
                      ],
                      "type": "string",
                      "description": "`active`, `paused` (manual) or `auto_paused` (failing for 24 h in a row)."
                    },
                    "paused_reason": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Pause reason (`manual` or `failing`); `null` while active."
                    },
                    "secret_last4": {
                      "type": "string",
                      "description": "Last 4 characters of the current signing secret."
                    },
                    "previous_secret_expires_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Until when the previous secret also signs (ISO 8601, UTC); `null` = no previous secret.",
                      "examples": [
                        null
                      ]
                    },
                    "failing_since": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Since when deliveries have been failing nonstop (ISO 8601, UTC); `null` = no ongoing failure.",
                      "examples": [
                        null
                      ]
                    },
                    "last_success_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Last successful delivery (ISO 8601, UTC); updated at most every 30 s.",
                      "examples": [
                        null
                      ]
                    },
                    "last_failure_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Last failed delivery (ISO 8601, UTC).",
                      "examples": [
                        null
                      ]
                    },
                    "created_at": {
                      "type": "string",
                      "description": "Creation date (ISO 8601, UTC)."
                    },
                    "updated_at": {
                      "type": "string",
                      "description": "Last change date (ISO 8601, UTC)."
                    },
                    "config": {
                      "type": "object",
                      "propertyNames": {
                        "type": "string"
                      },
                      "additionalProperties": {},
                      "description": "Type block, without secrets (passwords become `password_last4`). `{}` for webhooks and when the type is disabled."
                    },
                    "connected_clients": {
                      "anyOf": [
                        {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "WebSocket clients connected right now; `null` for types other than `websocket`."
                    }
                  },
                  "required": [
                    "id",
                    "type",
                    "label",
                    "url",
                    "headers",
                    "format",
                    "event_types",
                    "connection_id",
                    "connection_ids",
                    "status",
                    "paused_reason",
                    "secret_last4",
                    "previous_secret_expires_at",
                    "failing_since",
                    "last_success_at",
                    "last_failure_at",
                    "created_at",
                    "updated_at",
                    "config",
                    "connected_clients"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/destinations/{id}/test": {
      "post": {
        "operationId": "testDestination",
        "summary": "Test destination",
        "description": "Sends a `destination.test` event to the destination now and waits for the response (up to 10 s, no retries). Works with a paused destination. Permission: `admin`.",
        "tags": [
          "destinations"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Destination ID."
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "description": "The test delivery, with the result.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Delivery ID.",
                      "examples": [
                        "dlv_0193a1b2c3d47e8f9a0b1c2d3e4f5a6b"
                      ]
                    },
                    "destination_id": {
                      "type": "string",
                      "description": "Destination of the delivery."
                    },
                    "event_id": {
                      "type": "string",
                      "description": "Delivered event."
                    },
                    "event_type": {
                      "type": "string",
                      "description": "Event type.",
                      "examples": [
                        "message.received"
                      ]
                    },
                    "status": {
                      "enum": [
                        "pending",
                        "retrying",
                        "succeeded",
                        "failed",
                        "canceled",
                        "held"
                      ],
                      "type": "string",
                      "description": "`pending`, `retrying` (will try again), `succeeded`, `failed` or `held` (organization suspended)."
                    },
                    "attempts": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "Attempts made so far."
                    },
                    "next_attempt_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Next attempt (ISO 8601, UTC); `null` if there will be no other."
                    },
                    "last_attempt_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Last attempt (ISO 8601, UTC)."
                    },
                    "last_status_code": {
                      "anyOf": [
                        {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "HTTP status of the destination's last response; `null` without a response (network, timeout)."
                    },
                    "last_error": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Reason for the last failure."
                    },
                    "last_duration_ms": {
                      "anyOf": [
                        {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Duration of the last attempt, in milliseconds."
                    },
                    "redelivery_of": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Original delivery, when this one is a redelivery."
                    },
                    "created_at": {
                      "type": "string",
                      "description": "Creation date (ISO 8601, UTC)."
                    },
                    "succeeded_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "When the delivery succeeded (ISO 8601, UTC)."
                    },
                    "failed_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "When the delivery failed for good (ISO 8601, UTC)."
                    }
                  },
                  "required": [
                    "id",
                    "destination_id",
                    "event_id",
                    "event_type",
                    "status",
                    "attempts",
                    "next_attempt_at",
                    "last_attempt_at",
                    "last_status_code",
                    "last_error",
                    "last_duration_ms",
                    "redelivery_of",
                    "created_at",
                    "succeeded_at",
                    "failed_at"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/destinations/{id}/redeliver-failed": {
      "post": {
        "operationId": "redeliverFailedDeliveries",
        "summary": "Redeliver failures",
        "description": "Redelivers the destination's failed deliveries in the range, up to 1000 per call (`has_more` says if any are left). The destination must be active. Permission: `admin`.",
        "tags": [
          "destinations"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Destination ID."
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "since": {
                    "type": "string",
                    "format": "date-time",
                    "description": "Start of the range (ISO 8601)."
                  },
                  "until": {
                    "type": "string",
                    "format": "date-time",
                    "description": "End of the range (ISO 8601); missing = now."
                  }
                },
                "required": [
                  "since"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "How many deliveries were queued again.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "queued": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "Deliveries queued again in this call."
                    },
                    "has_more": {
                      "type": "boolean",
                      "description": "`true` if failures are left in the range: call again."
                    }
                  },
                  "required": [
                    "queued",
                    "has_more"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/destinations/{id}/ws-tickets": {
      "post": {
        "operationId": "createWebSocketTicket",
        "summary": "Create WebSocket ticket",
        "description": "Generates a single-use ticket, valid for 60 s, to open `GET /v1/ws?ticket=…` on an active `websocket` destination (browsers without an `Authorization` header). Permission: `read`.",
        "tags": [
          "destinations"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Destination ID."
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "201": {
            "description": "The ticket and the connection URL.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ticket": {
                      "type": "string",
                      "description": "Single-use ticket (`wst_…`), valid for 60 s."
                    },
                    "url": {
                      "type": "string",
                      "description": "URL ready to open the WebSocket with the ticket."
                    },
                    "expires_at": {
                      "type": "string",
                      "description": "When the ticket expires (ISO 8601, UTC)."
                    }
                  },
                  "required": [
                    "ticket",
                    "url",
                    "expires_at"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/deliveries": {
      "get": {
        "operationId": "listDeliveries",
        "summary": "List deliveries",
        "description": "Lists event deliveries to destinations (30 days), newest first. Permission: `read`.",
        "tags": [
          "deliveries"
        ],
        "parameters": [
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "Next page cursor: the `next_cursor` of the previous response."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50,
              "description": "Items per page, from 1 to 100 (default 50)."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "destination_id",
            "in": "query",
            "schema": {
              "type": "string",
              "description": "Destination of the delivery."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "enum": [
                "pending",
                "retrying",
                "succeeded",
                "failed",
                "canceled",
                "held"
              ],
              "type": "string",
              "description": "`pending`, `retrying` (will try again), `succeeded`, `failed` or `held` (organization suspended)."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "event_type",
            "in": "query",
            "schema": {
              "type": "string",
              "description": "Event type."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "since",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time",
              "description": "Only deliveries created from this date on (ISO 8601)."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "until",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time",
              "description": "Only deliveries created up to this date (ISO 8601)."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          }
        ],
        "responses": {
          "200": {
            "description": "The deliveries.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "description": "Delivery ID.",
                            "examples": [
                              "dlv_0193a1b2c3d47e8f9a0b1c2d3e4f5a6b"
                            ]
                          },
                          "destination_id": {
                            "type": "string",
                            "description": "Destination of the delivery."
                          },
                          "event_id": {
                            "type": "string",
                            "description": "Delivered event."
                          },
                          "event_type": {
                            "type": "string",
                            "description": "Event type.",
                            "examples": [
                              "message.received"
                            ]
                          },
                          "status": {
                            "enum": [
                              "pending",
                              "retrying",
                              "succeeded",
                              "failed",
                              "canceled",
                              "held"
                            ],
                            "type": "string",
                            "description": "`pending`, `retrying` (will try again), `succeeded`, `failed` or `held` (organization suspended)."
                          },
                          "attempts": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991,
                            "description": "Attempts made so far."
                          },
                          "next_attempt_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Next attempt (ISO 8601, UTC); `null` if there will be no other."
                          },
                          "last_attempt_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Last attempt (ISO 8601, UTC)."
                          },
                          "last_status_code": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "HTTP status of the destination's last response; `null` without a response (network, timeout)."
                          },
                          "last_error": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Reason for the last failure."
                          },
                          "last_duration_ms": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Duration of the last attempt, in milliseconds."
                          },
                          "redelivery_of": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Original delivery, when this one is a redelivery."
                          },
                          "created_at": {
                            "type": "string",
                            "description": "Creation date (ISO 8601, UTC)."
                          },
                          "succeeded_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "When the delivery succeeded (ISO 8601, UTC)."
                          },
                          "failed_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "When the delivery failed for good (ISO 8601, UTC)."
                          }
                        },
                        "required": [
                          "id",
                          "destination_id",
                          "event_id",
                          "event_type",
                          "status",
                          "attempts",
                          "next_attempt_at",
                          "last_attempt_at",
                          "last_status_code",
                          "last_error",
                          "last_duration_ms",
                          "redelivery_of",
                          "created_at",
                          "succeeded_at",
                          "failed_at"
                        ]
                      },
                      "description": "Page items, newest first."
                    },
                    "next_cursor": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Cursor for the next page; `null` when there are no more items."
                    }
                  },
                  "required": [
                    "data",
                    "next_cursor"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/deliveries/{id}": {
      "get": {
        "operationId": "getDelivery",
        "summary": "Get delivery",
        "description": "Returns a delivery with the log of its last 20 attempts. Permission: `read`.",
        "tags": [
          "deliveries"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Delivery ID."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The delivery and its attempts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Delivery ID.",
                      "examples": [
                        "dlv_0193a1b2c3d47e8f9a0b1c2d3e4f5a6b"
                      ]
                    },
                    "destination_id": {
                      "type": "string",
                      "description": "Destination of the delivery."
                    },
                    "event_id": {
                      "type": "string",
                      "description": "Delivered event."
                    },
                    "event_type": {
                      "type": "string",
                      "description": "Event type.",
                      "examples": [
                        "message.received"
                      ]
                    },
                    "status": {
                      "enum": [
                        "pending",
                        "retrying",
                        "succeeded",
                        "failed",
                        "canceled",
                        "held"
                      ],
                      "type": "string",
                      "description": "`pending`, `retrying` (will try again), `succeeded`, `failed` or `held` (organization suspended)."
                    },
                    "attempts": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "Attempts made so far."
                    },
                    "next_attempt_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Next attempt (ISO 8601, UTC); `null` if there will be no other."
                    },
                    "last_attempt_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Last attempt (ISO 8601, UTC)."
                    },
                    "last_status_code": {
                      "anyOf": [
                        {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "HTTP status of the destination's last response; `null` without a response (network, timeout)."
                    },
                    "last_error": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Reason for the last failure."
                    },
                    "last_duration_ms": {
                      "anyOf": [
                        {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Duration of the last attempt, in milliseconds."
                    },
                    "redelivery_of": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Original delivery, when this one is a redelivery."
                    },
                    "created_at": {
                      "type": "string",
                      "description": "Creation date (ISO 8601, UTC)."
                    },
                    "succeeded_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "When the delivery succeeded (ISO 8601, UTC)."
                    },
                    "failed_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "When the delivery failed for good (ISO 8601, UTC)."
                    },
                    "attempt_log": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "n": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991,
                            "description": "Attempt number (1 = first)."
                          },
                          "at": {
                            "type": "string",
                            "description": "When the attempt was made (ISO 8601, UTC)."
                          },
                          "status_code": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "HTTP status of the response; `null` without a response."
                          },
                          "duration_ms": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Attempt duration, in milliseconds."
                          },
                          "error": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Failure reason; `null` on success."
                          },
                          "response_excerpt": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Start of the response body (up to 1 KiB)."
                          }
                        },
                        "required": [
                          "n",
                          "at",
                          "status_code",
                          "duration_ms",
                          "error",
                          "response_excerpt"
                        ]
                      },
                      "description": "Last 20 attempts."
                    }
                  },
                  "required": [
                    "id",
                    "destination_id",
                    "event_id",
                    "event_type",
                    "status",
                    "attempts",
                    "next_attempt_at",
                    "last_attempt_at",
                    "last_status_code",
                    "last_error",
                    "last_duration_ms",
                    "redelivery_of",
                    "created_at",
                    "succeeded_at",
                    "failed_at",
                    "attempt_log"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/deliveries/{id}/redeliver": {
      "post": {
        "operationId": "redeliverDelivery",
        "summary": "Redeliver delivery",
        "description": "Creates a new delivery of the same event to the same destination. The destination must be active. Permission: `admin`.",
        "tags": [
          "deliveries"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Delivery ID."
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "201": {
            "description": "The new delivery.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Delivery ID.",
                      "examples": [
                        "dlv_0193a1b2c3d47e8f9a0b1c2d3e4f5a6b"
                      ]
                    },
                    "destination_id": {
                      "type": "string",
                      "description": "Destination of the delivery."
                    },
                    "event_id": {
                      "type": "string",
                      "description": "Delivered event."
                    },
                    "event_type": {
                      "type": "string",
                      "description": "Event type.",
                      "examples": [
                        "message.received"
                      ]
                    },
                    "status": {
                      "enum": [
                        "pending",
                        "retrying",
                        "succeeded",
                        "failed",
                        "canceled",
                        "held"
                      ],
                      "type": "string",
                      "description": "`pending`, `retrying` (will try again), `succeeded`, `failed` or `held` (organization suspended)."
                    },
                    "attempts": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "Attempts made so far."
                    },
                    "next_attempt_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Next attempt (ISO 8601, UTC); `null` if there will be no other."
                    },
                    "last_attempt_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Last attempt (ISO 8601, UTC)."
                    },
                    "last_status_code": {
                      "anyOf": [
                        {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "HTTP status of the destination's last response; `null` without a response (network, timeout)."
                    },
                    "last_error": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Reason for the last failure."
                    },
                    "last_duration_ms": {
                      "anyOf": [
                        {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Duration of the last attempt, in milliseconds."
                    },
                    "redelivery_of": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Original delivery, when this one is a redelivery."
                    },
                    "created_at": {
                      "type": "string",
                      "description": "Creation date (ISO 8601, UTC)."
                    },
                    "succeeded_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "When the delivery succeeded (ISO 8601, UTC)."
                    },
                    "failed_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "When the delivery failed for good (ISO 8601, UTC)."
                    }
                  },
                  "required": [
                    "id",
                    "destination_id",
                    "event_id",
                    "event_type",
                    "status",
                    "attempts",
                    "next_attempt_at",
                    "last_attempt_at",
                    "last_status_code",
                    "last_error",
                    "last_duration_ms",
                    "redelivery_of",
                    "created_at",
                    "succeeded_at",
                    "failed_at"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/events": {
      "get": {
        "operationId": "listEvents",
        "summary": "List events",
        "description": "Lists events from the last 30 days in the same envelope destinations receive. A key restricted to connections only sees their events. Permission: `read`.",
        "tags": [
          "events"
        ],
        "parameters": [
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "Next page cursor: the `next_cursor` of the previous response."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50,
              "description": "Items per page, from 1 to 100 (default 50)."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "type",
            "in": "query",
            "schema": {
              "type": "string",
              "description": "Event type, e.g. `message.received`."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "connection_id",
            "in": "query",
            "schema": {
              "type": "string",
              "description": "Only events of this connection."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "since",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time",
              "description": "Only events stored from this date on (ISO 8601)."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "format",
            "in": "query",
            "schema": {
              "enum": [
                "normalized",
                "meta"
              ],
              "type": "string",
              "default": "normalized",
              "description": "Format of `data`: `normalized` (default) or `meta`."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          }
        ],
        "responses": {
          "200": {
            "description": "The events.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "description": "Event ID (same as the `Messajo-Event-Id` header).",
                            "examples": [
                              "evt_0193a1b2c3d47e8f9a0b1c2d3e4f5a6b"
                            ]
                          },
                          "type": {
                            "type": "string",
                            "description": "Event type, e.g. `message.received`.",
                            "examples": [
                              "message.received"
                            ]
                          },
                          "format": {
                            "enum": [
                              "normalized",
                              "meta"
                            ],
                            "type": "string",
                            "description": "Format used in `data`. An event without a Meta item (e.g. `message.sent`) comes `normalized` even when `meta` is requested."
                          },
                          "org": {
                            "type": "string",
                            "description": "Organization of the event."
                          },
                          "connection": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Connection of the event; `null` on organization events (e.g. `destination.test`)."
                          },
                          "channel": {
                            "anyOf": [
                              {
                                "enum": [
                                  "whatsapp",
                                  "instagram",
                                  "messenger"
                                ],
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Connection channel: `whatsapp`, `instagram` or `messenger`; `null` on organization events."
                          },
                          "timestamp": {
                            "type": "string",
                            "description": "When the fact happened (ISO 8601, UTC)."
                          },
                          "sequence": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Event order in the conversation (grows by 1); `null` on events outside a conversation."
                          },
                          "data": {
                            "description": "Event data, in the `format` format."
                          }
                        },
                        "required": [
                          "id",
                          "type",
                          "format",
                          "org",
                          "connection",
                          "channel",
                          "timestamp",
                          "sequence"
                        ]
                      },
                      "description": "Page items, newest first."
                    },
                    "next_cursor": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Cursor for the next page; `null` when there are no more items."
                    }
                  },
                  "required": [
                    "data",
                    "next_cursor"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/events/{id}": {
      "get": {
        "operationId": "getEvent",
        "summary": "Get event",
        "description": "Returns an event in the delivery envelope, in the requested format. Permission: `read`.",
        "tags": [
          "events"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Event ID (same as the `Messajo-Event-Id` header)."
            }
          },
          {
            "name": "format",
            "in": "query",
            "schema": {
              "enum": [
                "normalized",
                "meta"
              ],
              "type": "string",
              "default": "normalized",
              "description": "Format of `data`: `normalized` (default) or `meta`."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          }
        ],
        "responses": {
          "200": {
            "description": "The event.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Event ID (same as the `Messajo-Event-Id` header).",
                      "examples": [
                        "evt_0193a1b2c3d47e8f9a0b1c2d3e4f5a6b"
                      ]
                    },
                    "type": {
                      "type": "string",
                      "description": "Event type, e.g. `message.received`.",
                      "examples": [
                        "message.received"
                      ]
                    },
                    "format": {
                      "enum": [
                        "normalized",
                        "meta"
                      ],
                      "type": "string",
                      "description": "Format used in `data`. An event without a Meta item (e.g. `message.sent`) comes `normalized` even when `meta` is requested."
                    },
                    "org": {
                      "type": "string",
                      "description": "Organization of the event."
                    },
                    "connection": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Connection of the event; `null` on organization events (e.g. `destination.test`)."
                    },
                    "channel": {
                      "anyOf": [
                        {
                          "enum": [
                            "whatsapp",
                            "instagram",
                            "messenger"
                          ],
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Connection channel: `whatsapp`, `instagram` or `messenger`; `null` on organization events."
                    },
                    "timestamp": {
                      "type": "string",
                      "description": "When the fact happened (ISO 8601, UTC)."
                    },
                    "sequence": {
                      "anyOf": [
                        {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Event order in the conversation (grows by 1); `null` on events outside a conversation."
                    },
                    "data": {
                      "description": "Event data, in the `format` format."
                    }
                  },
                  "required": [
                    "id",
                    "type",
                    "format",
                    "org",
                    "connection",
                    "channel",
                    "timestamp",
                    "sequence"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/logs/messages": {
      "get": {
        "operationId": "listMessageLogs",
        "summary": "Message log",
        "description": "Lists messages received and sent in the last 30 days, without the content. A `since` older than 30 days returns `validation_failed`. Permission: `read`.",
        "tags": [
          "logs"
        ],
        "parameters": [
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "Next page cursor: the `next_cursor` of the previous response."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50,
              "description": "Items per page, from 1 to 100 (default 50)."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "connection_id",
            "in": "query",
            "schema": {
              "type": "string",
              "description": "Message connection."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "direction",
            "in": "query",
            "schema": {
              "enum": [
                "inbound",
                "outbound"
              ],
              "type": "string",
              "description": "`inbound` (received) or `outbound` (sent)."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "enum": [
                "received",
                "queued",
                "sent",
                "delivered",
                "read",
                "played",
                "failed",
                "deleted"
              ],
              "type": "string",
              "description": "Current message status."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "type",
            "in": "query",
            "schema": {
              "type": "string",
              "description": "Content type, e.g. `text`, `image`."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "since",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time",
              "description": "Start of the range (ISO 8601), at most 30 days ago; default = 30 days ago."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "until",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time",
              "description": "End of the range (ISO 8601); default = now."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          }
        ],
        "responses": {
          "200": {
            "description": "The messages.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "description": "Message ID."
                          },
                          "created_at": {
                            "type": "string",
                            "description": "When the message was stored (ISO 8601, UTC)."
                          },
                          "connection_id": {
                            "type": "string",
                            "description": "Message connection."
                          },
                          "conversation_id": {
                            "type": "string",
                            "description": "Message conversation."
                          },
                          "contact_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Conversation contact."
                          },
                          "direction": {
                            "enum": [
                              "inbound",
                              "outbound"
                            ],
                            "type": "string",
                            "description": "`inbound` (received) or `outbound` (sent)."
                          },
                          "source": {
                            "enum": [
                              "customer",
                              "api",
                              "business_app",
                              "history",
                              "campaign"
                            ],
                            "type": "string",
                            "description": "Source: `customer`, `api`, `business_app`, `history` or `campaign`."
                          },
                          "type": {
                            "type": "string",
                            "description": "Content type, e.g. `text`, `image`."
                          },
                          "status": {
                            "enum": [
                              "received",
                              "queued",
                              "sent",
                              "delivered",
                              "read",
                              "played",
                              "failed",
                              "deleted"
                            ],
                            "type": "string",
                            "description": "Current message status."
                          },
                          "external_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Message ID at Meta."
                          },
                          "occurred_at": {
                            "type": "string",
                            "description": "When Meta recorded the message (ISO 8601, UTC)."
                          },
                          "status_updated_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Last status change (ISO 8601, UTC)."
                          }
                        },
                        "required": [
                          "id",
                          "created_at",
                          "connection_id",
                          "conversation_id",
                          "contact_id",
                          "direction",
                          "source",
                          "type",
                          "status",
                          "external_id",
                          "occurred_at",
                          "status_updated_at"
                        ]
                      },
                      "description": "Page items, newest first."
                    },
                    "next_cursor": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Cursor for the next page; `null` when there are no more items."
                    }
                  },
                  "required": [
                    "data",
                    "next_cursor"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/logs/api-requests": {
      "get": {
        "operationId": "listApiRequestLogs",
        "summary": "API call log",
        "description": "Lists calls to `/v1` made with the organization's keys in the last 30 days. A key restricted to connections only sees its own calls. Permission: `read`.",
        "tags": [
          "logs"
        ],
        "parameters": [
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "Next page cursor: the `next_cursor` of the previous response."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50,
              "description": "Items per page, from 1 to 100 (default 50)."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "api_key_id",
            "in": "query",
            "schema": {
              "type": "string",
              "description": "Key used in the call."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "status_class",
            "in": "query",
            "schema": {
              "enum": [
                "2xx",
                "4xx",
                "5xx"
              ],
              "type": "string",
              "description": "Only calls with status `2xx`, `4xx` or `5xx`."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "since",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time",
              "description": "Start of the range (ISO 8601), at most 30 days ago; default = 30 days ago."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "until",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time",
              "description": "End of the range (ISO 8601); default = now."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          }
        ],
        "responses": {
          "200": {
            "description": "The calls.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "description": "Record ID."
                          },
                          "api_key_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Key used in the call."
                          },
                          "request_id": {
                            "type": "string",
                            "description": "Request ID (`X-Request-Id` header)."
                          },
                          "method": {
                            "type": "string",
                            "description": "HTTP method."
                          },
                          "path": {
                            "type": "string",
                            "description": "Called path, without the query."
                          },
                          "status": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991,
                            "description": "HTTP status of the response."
                          },
                          "duration_ms": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991,
                            "description": "Duration, in milliseconds."
                          },
                          "error_code": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Error code, when the call failed."
                          },
                          "idempotency_key": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "`Idempotency-Key` sent, if any."
                          },
                          "ip": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Source IP."
                          },
                          "user_agent": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Client User-Agent."
                          },
                          "created_at": {
                            "type": "string",
                            "description": "When the call was made (ISO 8601, UTC)."
                          }
                        },
                        "required": [
                          "id",
                          "api_key_id",
                          "request_id",
                          "method",
                          "path",
                          "status",
                          "duration_ms",
                          "error_code",
                          "idempotency_key",
                          "ip",
                          "user_agent",
                          "created_at"
                        ]
                      },
                      "description": "Page items, newest first."
                    },
                    "next_cursor": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Cursor for the next page; `null` when there are no more items."
                    }
                  },
                  "required": [
                    "data",
                    "next_cursor"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/connections": {
      "get": {
        "operationId": "listConnections",
        "summary": "List connections",
        "description": "Lists the organization's connections (WhatsApp numbers and, in later phases, Instagram and Messenger accounts), newest first, with the channel data. A key bound to connections only sees its own. Permission: `read`.",
        "tags": [
          "connections"
        ],
        "parameters": [
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "Next page cursor: the `next_cursor` of the previous response."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50,
              "description": "Items per page, from 1 to 100 (default 50)."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "enum": [
                "pending",
                "active",
                "needs_reconnect",
                "restricted",
                "disabled",
                "disconnected"
              ],
              "type": "string",
              "description": "Only connections with this status."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          }
        ],
        "responses": {
          "200": {
            "description": "A page of connections.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "description": "Connection ID (`con_…`).",
                            "examples": [
                              "con_0193a1b2c3d47e8f9a0b1c2d3e4f5a6b"
                            ]
                          },
                          "channel": {
                            "enum": [
                              "whatsapp",
                              "instagram",
                              "messenger"
                            ],
                            "type": "string",
                            "description": "Channel: `whatsapp`, `instagram` or `messenger`."
                          },
                          "status": {
                            "enum": [
                              "pending",
                              "active",
                              "needs_reconnect",
                              "restricted",
                              "disabled",
                              "disconnected"
                            ],
                            "type": "string",
                            "description": "Status: `pending`, `active`, `restricted`, `needs_reconnect`, `banned` or `disconnected`."
                          },
                          "status_reason": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Reason for the current status, when there is one."
                          },
                          "label": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Name the organization gave the connection."
                          },
                          "external_id": {
                            "type": "string",
                            "description": "ID at Meta (on WhatsApp, the `phone_number_id`)."
                          },
                          "external_label": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Label from Meta, e.g. the formatted number."
                          },
                          "mode": {
                            "anyOf": [
                              {
                                "enum": [
                                  "coex",
                                  "api_only"
                                ],
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "WhatsApp mode: `coex` (coexistence with the app) or `api_only`."
                          },
                          "send_rate_mps": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Messages per second Messajo lets out through this connection."
                          },
                          "connected_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "When the connection became active (ISO 8601, UTC)."
                          },
                          "last_webhook_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Last webhook received (ISO 8601, UTC); updated at most every 30 s."
                          },
                          "created_at": {
                            "type": "string",
                            "description": "When the connection was created (ISO 8601, UTC)."
                          },
                          "updated_at": {
                            "type": "string",
                            "description": "Last change (ISO 8601, UTC)."
                          },
                          "whatsapp": {
                            "anyOf": [
                              {
                                "type": "object",
                                "properties": {
                                  "phone_number_id": {
                                    "type": "string",
                                    "description": "Number ID at Meta."
                                  },
                                  "messaging_account_id": {
                                    "type": "string",
                                    "description": "WhatsApp Business account (WABA) of the number."
                                  },
                                  "mode": {
                                    "enum": [
                                      "coex",
                                      "api_only"
                                    ],
                                    "type": "string",
                                    "description": "WhatsApp mode: `coex` (coexistence with the app) or `api_only`."
                                  },
                                  "display_phone_number": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ],
                                    "description": "Number as Meta displays it."
                                  },
                                  "verified_name": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ],
                                    "description": "Approved display name."
                                  },
                                  "quality_rating": {
                                    "type": "string",
                                    "description": "Quality: `GREEN`, `YELLOW`, `RED` or `UNKNOWN`."
                                  },
                                  "messaging_limit": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ],
                                    "description": "Meta messaging limit tier, e.g. `TIER_2K`."
                                  },
                                  "throughput_level": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ],
                                    "description": "Throughput level: `STANDARD`, `HIGH` or `NOT_APPLICABLE`."
                                  },
                                  "send_rate_mps": {
                                    "anyOf": [
                                      {
                                        "type": "integer",
                                        "minimum": -9007199254740991,
                                        "maximum": 9007199254740991
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ],
                                    "description": "Messages per second Messajo lets out through this connection."
                                  },
                                  "can_send_message": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ],
                                    "description": "Whether Meta allows sending: `AVAILABLE`, `LIMITED` or `BLOCKED`."
                                  },
                                  "restriction": {
                                    "anyOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "types": {
                                            "type": "array",
                                            "items": {
                                              "type": "string"
                                            },
                                            "description": "Restriction types reported by Meta."
                                          },
                                          "until": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ],
                                            "description": "Until when it applies (ISO 8601), if Meta said."
                                          },
                                          "remediation": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ],
                                            "description": "What to do to lift the restriction."
                                          }
                                        },
                                        "required": [
                                          "types",
                                          "until",
                                          "remediation"
                                        ]
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ],
                                    "description": "Active account restriction; `null` when there is none."
                                  },
                                  "register_status": {
                                    "type": "string",
                                    "description": "Cloud API registration: `not_needed`, `pending`, `registered` or `failed`."
                                  },
                                  "contacts_sync_status": {
                                    "type": "string",
                                    "description": "Coexistence contacts sync."
                                  },
                                  "history_sync_status": {
                                    "type": "string",
                                    "description": "Coexistence history sync."
                                  },
                                  "history_sync_progress": {
                                    "anyOf": [
                                      {
                                        "type": "integer",
                                        "minimum": -9007199254740991,
                                        "maximum": 9007199254740991
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ],
                                    "description": "History progress, from 0 to 100."
                                  },
                                  "username": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ],
                                    "description": "WhatsApp username."
                                  }
                                },
                                "required": [
                                  "phone_number_id",
                                  "messaging_account_id",
                                  "mode",
                                  "display_phone_number",
                                  "verified_name",
                                  "quality_rating",
                                  "messaging_limit",
                                  "throughput_level",
                                  "send_rate_mps",
                                  "can_send_message",
                                  "restriction",
                                  "register_status",
                                  "contacts_sync_status",
                                  "history_sync_status",
                                  "history_sync_progress",
                                  "username"
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "WhatsApp data; `null` on other channels."
                          },
                          "instagram": {
                            "anyOf": [
                              {
                                "type": "object",
                                "properties": {
                                  "ig_user_id": {
                                    "type": "string",
                                    "description": "ID of the Instagram professional account (`ig_user_id`)."
                                  },
                                  "username": {
                                    "type": "string",
                                    "description": "Account username (@)."
                                  },
                                  "name": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ],
                                    "description": "Account display name."
                                  },
                                  "account_type": {
                                    "type": "string",
                                    "description": "Account type: `BUSINESS` or `MEDIA_CREATOR`. Unified-login connections report `BUSINESS` until item 2-20."
                                  },
                                  "scopes": {
                                    "type": "array",
                                    "items": {
                                      "type": "string"
                                    },
                                    "description": "Permissions granted by Meta."
                                  },
                                  "missing_scopes": {
                                    "type": "array",
                                    "items": {
                                      "type": "string"
                                    },
                                    "description": "Instagram permissions not granted; features that need them answer `403 instagram_scope_missing` until you reconnect."
                                  },
                                  "token_expires_at": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ],
                                    "description": "When the token expires (ISO 8601, UTC). Always null for Instagram: the token does not expire."
                                  },
                                  "token_refreshed_at": {
                                    "type": "string",
                                    "description": "When the current token was issued, at connect or reconnect (ISO 8601, UTC)."
                                  },
                                  "followers_count": {
                                    "anyOf": [
                                      {
                                        "type": "integer",
                                        "minimum": -9007199254740991,
                                        "maximum": 9007199254740991
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ],
                                    "description": "Followers at the last read."
                                  },
                                  "publishing_quota": {
                                    "anyOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "quota_usage": {
                                            "type": "integer",
                                            "minimum": -9007199254740991,
                                            "maximum": 9007199254740991,
                                            "description": "Publications made in the quota window."
                                          },
                                          "quota_total": {
                                            "type": "integer",
                                            "minimum": -9007199254740991,
                                            "maximum": 9007199254740991,
                                            "description": "Publications allowed in the window."
                                          },
                                          "quota_duration_s": {
                                            "type": "integer",
                                            "minimum": -9007199254740991,
                                            "maximum": 9007199254740991,
                                            "description": "Window length, in seconds."
                                          },
                                          "checked_at": {
                                            "type": "string",
                                            "description": "When the quota was read (ISO 8601, UTC)."
                                          }
                                        },
                                        "required": [
                                          "quota_usage",
                                          "quota_total",
                                          "quota_duration_s",
                                          "checked_at"
                                        ]
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ],
                                    "description": "Publishing quota at the last health check; `null` without the publishing permission."
                                  }
                                },
                                "required": [
                                  "ig_user_id",
                                  "username",
                                  "name",
                                  "account_type",
                                  "scopes",
                                  "missing_scopes",
                                  "token_expires_at",
                                  "token_refreshed_at",
                                  "followers_count",
                                  "publishing_quota"
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Instagram data; `null` on other channels."
                          },
                          "messenger": {
                            "anyOf": [
                              {
                                "type": "object",
                                "properties": {
                                  "page_id": {
                                    "type": "string",
                                    "description": "Facebook Page ID."
                                  },
                                  "page_name": {
                                    "type": "string",
                                    "description": "Page name."
                                  },
                                  "page_category": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ],
                                    "description": "Page category."
                                  },
                                  "tasks": {
                                    "type": "array",
                                    "items": {
                                      "type": "string"
                                    },
                                    "description": "Tasks the connecting user has on the Page (`MESSAGING`, `MANAGE`…)."
                                  },
                                  "scopes": {
                                    "type": "array",
                                    "items": {
                                      "type": "string"
                                    },
                                    "description": "Permissions granted by Meta."
                                  }
                                },
                                "required": [
                                  "page_id",
                                  "page_name",
                                  "page_category",
                                  "tasks",
                                  "scopes"
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Facebook Page data (Messenger); `null` on other channels."
                          }
                        },
                        "required": [
                          "id",
                          "channel",
                          "status",
                          "status_reason",
                          "label",
                          "external_id",
                          "external_label",
                          "mode",
                          "send_rate_mps",
                          "connected_at",
                          "last_webhook_at",
                          "created_at",
                          "updated_at",
                          "whatsapp",
                          "instagram",
                          "messenger"
                        ]
                      },
                      "description": "Page items, newest first."
                    },
                    "next_cursor": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Cursor for the next page; `null` when there are no more items."
                    }
                  },
                  "required": [
                    "data",
                    "next_cursor"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/connections/{id}": {
      "get": {
        "operationId": "getConnection",
        "summary": "Get a connection",
        "description": "Returns the connection with status, mode, send rate and, on WhatsApp, quality, messaging limit, restrictions and the state of the registration and of the coexistence sync. Permission: `read`.",
        "tags": [
          "connections"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Connection ID (`con_…`)."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The connection.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Connection ID (`con_…`).",
                      "examples": [
                        "con_0193a1b2c3d47e8f9a0b1c2d3e4f5a6b"
                      ]
                    },
                    "channel": {
                      "enum": [
                        "whatsapp",
                        "instagram",
                        "messenger"
                      ],
                      "type": "string",
                      "description": "Channel: `whatsapp`, `instagram` or `messenger`."
                    },
                    "status": {
                      "enum": [
                        "pending",
                        "active",
                        "needs_reconnect",
                        "restricted",
                        "disabled",
                        "disconnected"
                      ],
                      "type": "string",
                      "description": "Status: `pending`, `active`, `restricted`, `needs_reconnect`, `banned` or `disconnected`."
                    },
                    "status_reason": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Reason for the current status, when there is one."
                    },
                    "label": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Name the organization gave the connection."
                    },
                    "external_id": {
                      "type": "string",
                      "description": "ID at Meta (on WhatsApp, the `phone_number_id`)."
                    },
                    "external_label": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Label from Meta, e.g. the formatted number."
                    },
                    "mode": {
                      "anyOf": [
                        {
                          "enum": [
                            "coex",
                            "api_only"
                          ],
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "WhatsApp mode: `coex` (coexistence with the app) or `api_only`."
                    },
                    "send_rate_mps": {
                      "anyOf": [
                        {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Messages per second Messajo lets out through this connection."
                    },
                    "connected_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "When the connection became active (ISO 8601, UTC)."
                    },
                    "last_webhook_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Last webhook received (ISO 8601, UTC); updated at most every 30 s."
                    },
                    "created_at": {
                      "type": "string",
                      "description": "When the connection was created (ISO 8601, UTC)."
                    },
                    "updated_at": {
                      "type": "string",
                      "description": "Last change (ISO 8601, UTC)."
                    },
                    "whatsapp": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "phone_number_id": {
                              "type": "string",
                              "description": "Number ID at Meta."
                            },
                            "messaging_account_id": {
                              "type": "string",
                              "description": "WhatsApp Business account (WABA) of the number."
                            },
                            "mode": {
                              "enum": [
                                "coex",
                                "api_only"
                              ],
                              "type": "string",
                              "description": "WhatsApp mode: `coex` (coexistence with the app) or `api_only`."
                            },
                            "display_phone_number": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Number as Meta displays it."
                            },
                            "verified_name": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Approved display name."
                            },
                            "quality_rating": {
                              "type": "string",
                              "description": "Quality: `GREEN`, `YELLOW`, `RED` or `UNKNOWN`."
                            },
                            "messaging_limit": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Meta messaging limit tier, e.g. `TIER_2K`."
                            },
                            "throughput_level": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Throughput level: `STANDARD`, `HIGH` or `NOT_APPLICABLE`."
                            },
                            "send_rate_mps": {
                              "anyOf": [
                                {
                                  "type": "integer",
                                  "minimum": -9007199254740991,
                                  "maximum": 9007199254740991
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Messages per second Messajo lets out through this connection."
                            },
                            "can_send_message": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Whether Meta allows sending: `AVAILABLE`, `LIMITED` or `BLOCKED`."
                            },
                            "restriction": {
                              "anyOf": [
                                {
                                  "type": "object",
                                  "properties": {
                                    "types": {
                                      "type": "array",
                                      "items": {
                                        "type": "string"
                                      },
                                      "description": "Restriction types reported by Meta."
                                    },
                                    "until": {
                                      "anyOf": [
                                        {
                                          "type": "string"
                                        },
                                        {
                                          "type": "null"
                                        }
                                      ],
                                      "description": "Until when it applies (ISO 8601), if Meta said."
                                    },
                                    "remediation": {
                                      "anyOf": [
                                        {
                                          "type": "string"
                                        },
                                        {
                                          "type": "null"
                                        }
                                      ],
                                      "description": "What to do to lift the restriction."
                                    }
                                  },
                                  "required": [
                                    "types",
                                    "until",
                                    "remediation"
                                  ]
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Active account restriction; `null` when there is none."
                            },
                            "register_status": {
                              "type": "string",
                              "description": "Cloud API registration: `not_needed`, `pending`, `registered` or `failed`."
                            },
                            "contacts_sync_status": {
                              "type": "string",
                              "description": "Coexistence contacts sync."
                            },
                            "history_sync_status": {
                              "type": "string",
                              "description": "Coexistence history sync."
                            },
                            "history_sync_progress": {
                              "anyOf": [
                                {
                                  "type": "integer",
                                  "minimum": -9007199254740991,
                                  "maximum": 9007199254740991
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "History progress, from 0 to 100."
                            },
                            "username": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "WhatsApp username."
                            }
                          },
                          "required": [
                            "phone_number_id",
                            "messaging_account_id",
                            "mode",
                            "display_phone_number",
                            "verified_name",
                            "quality_rating",
                            "messaging_limit",
                            "throughput_level",
                            "send_rate_mps",
                            "can_send_message",
                            "restriction",
                            "register_status",
                            "contacts_sync_status",
                            "history_sync_status",
                            "history_sync_progress",
                            "username"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "WhatsApp data; `null` on other channels."
                    },
                    "instagram": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "ig_user_id": {
                              "type": "string",
                              "description": "ID of the Instagram professional account (`ig_user_id`)."
                            },
                            "username": {
                              "type": "string",
                              "description": "Account username (@)."
                            },
                            "name": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Account display name."
                            },
                            "account_type": {
                              "type": "string",
                              "description": "Account type: `BUSINESS` or `MEDIA_CREATOR`. Unified-login connections report `BUSINESS` until item 2-20."
                            },
                            "scopes": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              },
                              "description": "Permissions granted by Meta."
                            },
                            "missing_scopes": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              },
                              "description": "Instagram permissions not granted; features that need them answer `403 instagram_scope_missing` until you reconnect."
                            },
                            "token_expires_at": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "When the token expires (ISO 8601, UTC). Always null for Instagram: the token does not expire."
                            },
                            "token_refreshed_at": {
                              "type": "string",
                              "description": "When the current token was issued, at connect or reconnect (ISO 8601, UTC)."
                            },
                            "followers_count": {
                              "anyOf": [
                                {
                                  "type": "integer",
                                  "minimum": -9007199254740991,
                                  "maximum": 9007199254740991
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Followers at the last read."
                            },
                            "publishing_quota": {
                              "anyOf": [
                                {
                                  "type": "object",
                                  "properties": {
                                    "quota_usage": {
                                      "type": "integer",
                                      "minimum": -9007199254740991,
                                      "maximum": 9007199254740991,
                                      "description": "Publications made in the quota window."
                                    },
                                    "quota_total": {
                                      "type": "integer",
                                      "minimum": -9007199254740991,
                                      "maximum": 9007199254740991,
                                      "description": "Publications allowed in the window."
                                    },
                                    "quota_duration_s": {
                                      "type": "integer",
                                      "minimum": -9007199254740991,
                                      "maximum": 9007199254740991,
                                      "description": "Window length, in seconds."
                                    },
                                    "checked_at": {
                                      "type": "string",
                                      "description": "When the quota was read (ISO 8601, UTC)."
                                    }
                                  },
                                  "required": [
                                    "quota_usage",
                                    "quota_total",
                                    "quota_duration_s",
                                    "checked_at"
                                  ]
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Publishing quota at the last health check; `null` without the publishing permission."
                            }
                          },
                          "required": [
                            "ig_user_id",
                            "username",
                            "name",
                            "account_type",
                            "scopes",
                            "missing_scopes",
                            "token_expires_at",
                            "token_refreshed_at",
                            "followers_count",
                            "publishing_quota"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Instagram data; `null` on other channels."
                    },
                    "messenger": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "page_id": {
                              "type": "string",
                              "description": "Facebook Page ID."
                            },
                            "page_name": {
                              "type": "string",
                              "description": "Page name."
                            },
                            "page_category": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Page category."
                            },
                            "tasks": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              },
                              "description": "Tasks the connecting user has on the Page (`MESSAGING`, `MANAGE`…)."
                            },
                            "scopes": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              },
                              "description": "Permissions granted by Meta."
                            }
                          },
                          "required": [
                            "page_id",
                            "page_name",
                            "page_category",
                            "tasks",
                            "scopes"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Facebook Page data (Messenger); `null` on other channels."
                    }
                  },
                  "required": [
                    "id",
                    "channel",
                    "status",
                    "status_reason",
                    "label",
                    "external_id",
                    "external_label",
                    "mode",
                    "send_rate_mps",
                    "connected_at",
                    "last_webhook_at",
                    "created_at",
                    "updated_at",
                    "whatsapp",
                    "instagram",
                    "messenger"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "patch": {
        "operationId": "updateConnection",
        "summary": "Rename a connection",
        "description": "Changes the name the organization gives the connection (nothing changes at Meta). Permission: `admin`.",
        "tags": [
          "connections"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Connection ID (`con_…`)."
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "label": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100,
                    "description": "Name the organization gave the connection."
                  }
                },
                "required": [
                  "label"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The updated connection.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Connection ID (`con_…`).",
                      "examples": [
                        "con_0193a1b2c3d47e8f9a0b1c2d3e4f5a6b"
                      ]
                    },
                    "channel": {
                      "enum": [
                        "whatsapp",
                        "instagram",
                        "messenger"
                      ],
                      "type": "string",
                      "description": "Channel: `whatsapp`, `instagram` or `messenger`."
                    },
                    "status": {
                      "enum": [
                        "pending",
                        "active",
                        "needs_reconnect",
                        "restricted",
                        "disabled",
                        "disconnected"
                      ],
                      "type": "string",
                      "description": "Status: `pending`, `active`, `restricted`, `needs_reconnect`, `banned` or `disconnected`."
                    },
                    "status_reason": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Reason for the current status, when there is one."
                    },
                    "label": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Name the organization gave the connection."
                    },
                    "external_id": {
                      "type": "string",
                      "description": "ID at Meta (on WhatsApp, the `phone_number_id`)."
                    },
                    "external_label": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Label from Meta, e.g. the formatted number."
                    },
                    "mode": {
                      "anyOf": [
                        {
                          "enum": [
                            "coex",
                            "api_only"
                          ],
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "WhatsApp mode: `coex` (coexistence with the app) or `api_only`."
                    },
                    "send_rate_mps": {
                      "anyOf": [
                        {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Messages per second Messajo lets out through this connection."
                    },
                    "connected_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "When the connection became active (ISO 8601, UTC)."
                    },
                    "last_webhook_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Last webhook received (ISO 8601, UTC); updated at most every 30 s."
                    },
                    "created_at": {
                      "type": "string",
                      "description": "When the connection was created (ISO 8601, UTC)."
                    },
                    "updated_at": {
                      "type": "string",
                      "description": "Last change (ISO 8601, UTC)."
                    },
                    "whatsapp": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "phone_number_id": {
                              "type": "string",
                              "description": "Number ID at Meta."
                            },
                            "messaging_account_id": {
                              "type": "string",
                              "description": "WhatsApp Business account (WABA) of the number."
                            },
                            "mode": {
                              "enum": [
                                "coex",
                                "api_only"
                              ],
                              "type": "string",
                              "description": "WhatsApp mode: `coex` (coexistence with the app) or `api_only`."
                            },
                            "display_phone_number": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Number as Meta displays it."
                            },
                            "verified_name": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Approved display name."
                            },
                            "quality_rating": {
                              "type": "string",
                              "description": "Quality: `GREEN`, `YELLOW`, `RED` or `UNKNOWN`."
                            },
                            "messaging_limit": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Meta messaging limit tier, e.g. `TIER_2K`."
                            },
                            "throughput_level": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Throughput level: `STANDARD`, `HIGH` or `NOT_APPLICABLE`."
                            },
                            "send_rate_mps": {
                              "anyOf": [
                                {
                                  "type": "integer",
                                  "minimum": -9007199254740991,
                                  "maximum": 9007199254740991
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Messages per second Messajo lets out through this connection."
                            },
                            "can_send_message": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Whether Meta allows sending: `AVAILABLE`, `LIMITED` or `BLOCKED`."
                            },
                            "restriction": {
                              "anyOf": [
                                {
                                  "type": "object",
                                  "properties": {
                                    "types": {
                                      "type": "array",
                                      "items": {
                                        "type": "string"
                                      },
                                      "description": "Restriction types reported by Meta."
                                    },
                                    "until": {
                                      "anyOf": [
                                        {
                                          "type": "string"
                                        },
                                        {
                                          "type": "null"
                                        }
                                      ],
                                      "description": "Until when it applies (ISO 8601), if Meta said."
                                    },
                                    "remediation": {
                                      "anyOf": [
                                        {
                                          "type": "string"
                                        },
                                        {
                                          "type": "null"
                                        }
                                      ],
                                      "description": "What to do to lift the restriction."
                                    }
                                  },
                                  "required": [
                                    "types",
                                    "until",
                                    "remediation"
                                  ]
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Active account restriction; `null` when there is none."
                            },
                            "register_status": {
                              "type": "string",
                              "description": "Cloud API registration: `not_needed`, `pending`, `registered` or `failed`."
                            },
                            "contacts_sync_status": {
                              "type": "string",
                              "description": "Coexistence contacts sync."
                            },
                            "history_sync_status": {
                              "type": "string",
                              "description": "Coexistence history sync."
                            },
                            "history_sync_progress": {
                              "anyOf": [
                                {
                                  "type": "integer",
                                  "minimum": -9007199254740991,
                                  "maximum": 9007199254740991
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "History progress, from 0 to 100."
                            },
                            "username": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "WhatsApp username."
                            }
                          },
                          "required": [
                            "phone_number_id",
                            "messaging_account_id",
                            "mode",
                            "display_phone_number",
                            "verified_name",
                            "quality_rating",
                            "messaging_limit",
                            "throughput_level",
                            "send_rate_mps",
                            "can_send_message",
                            "restriction",
                            "register_status",
                            "contacts_sync_status",
                            "history_sync_status",
                            "history_sync_progress",
                            "username"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "WhatsApp data; `null` on other channels."
                    },
                    "instagram": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "ig_user_id": {
                              "type": "string",
                              "description": "ID of the Instagram professional account (`ig_user_id`)."
                            },
                            "username": {
                              "type": "string",
                              "description": "Account username (@)."
                            },
                            "name": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Account display name."
                            },
                            "account_type": {
                              "type": "string",
                              "description": "Account type: `BUSINESS` or `MEDIA_CREATOR`. Unified-login connections report `BUSINESS` until item 2-20."
                            },
                            "scopes": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              },
                              "description": "Permissions granted by Meta."
                            },
                            "missing_scopes": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              },
                              "description": "Instagram permissions not granted; features that need them answer `403 instagram_scope_missing` until you reconnect."
                            },
                            "token_expires_at": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "When the token expires (ISO 8601, UTC). Always null for Instagram: the token does not expire."
                            },
                            "token_refreshed_at": {
                              "type": "string",
                              "description": "When the current token was issued, at connect or reconnect (ISO 8601, UTC)."
                            },
                            "followers_count": {
                              "anyOf": [
                                {
                                  "type": "integer",
                                  "minimum": -9007199254740991,
                                  "maximum": 9007199254740991
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Followers at the last read."
                            },
                            "publishing_quota": {
                              "anyOf": [
                                {
                                  "type": "object",
                                  "properties": {
                                    "quota_usage": {
                                      "type": "integer",
                                      "minimum": -9007199254740991,
                                      "maximum": 9007199254740991,
                                      "description": "Publications made in the quota window."
                                    },
                                    "quota_total": {
                                      "type": "integer",
                                      "minimum": -9007199254740991,
                                      "maximum": 9007199254740991,
                                      "description": "Publications allowed in the window."
                                    },
                                    "quota_duration_s": {
                                      "type": "integer",
                                      "minimum": -9007199254740991,
                                      "maximum": 9007199254740991,
                                      "description": "Window length, in seconds."
                                    },
                                    "checked_at": {
                                      "type": "string",
                                      "description": "When the quota was read (ISO 8601, UTC)."
                                    }
                                  },
                                  "required": [
                                    "quota_usage",
                                    "quota_total",
                                    "quota_duration_s",
                                    "checked_at"
                                  ]
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Publishing quota at the last health check; `null` without the publishing permission."
                            }
                          },
                          "required": [
                            "ig_user_id",
                            "username",
                            "name",
                            "account_type",
                            "scopes",
                            "missing_scopes",
                            "token_expires_at",
                            "token_refreshed_at",
                            "followers_count",
                            "publishing_quota"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Instagram data; `null` on other channels."
                    },
                    "messenger": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "page_id": {
                              "type": "string",
                              "description": "Facebook Page ID."
                            },
                            "page_name": {
                              "type": "string",
                              "description": "Page name."
                            },
                            "page_category": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Page category."
                            },
                            "tasks": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              },
                              "description": "Tasks the connecting user has on the Page (`MESSAGING`, `MANAGE`…)."
                            },
                            "scopes": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              },
                              "description": "Permissions granted by Meta."
                            }
                          },
                          "required": [
                            "page_id",
                            "page_name",
                            "page_category",
                            "tasks",
                            "scopes"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Facebook Page data (Messenger); `null` on other channels."
                    }
                  },
                  "required": [
                    "id",
                    "channel",
                    "status",
                    "status_reason",
                    "label",
                    "external_id",
                    "external_label",
                    "mode",
                    "send_rate_mps",
                    "connected_at",
                    "last_webhook_at",
                    "created_at",
                    "updated_at",
                    "whatsapp",
                    "instagram",
                    "messenger"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/connections/{id}/disconnect": {
      "post": {
        "operationId": "disconnectConnection",
        "summary": "Disconnect",
        "description": "Disconnects the connection: the credential is revoked, webhooks stop arriving and the number leaves billing. In API-only mode, `deregister: true` also removes the number from the Cloud API. Failures on Meta's side do not block the disconnection and come back in `warnings`. Permission: `admin`. Requires an organization key.",
        "tags": [
          "connections"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Connection ID (`con_…`)."
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "deregister": {
                    "type": "boolean",
                    "description": "API only: also removes the number from the Cloud API."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The disconnected connection.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Connection ID (`con_…`).",
                      "examples": [
                        "con_0193a1b2c3d47e8f9a0b1c2d3e4f5a6b"
                      ]
                    },
                    "channel": {
                      "enum": [
                        "whatsapp",
                        "instagram",
                        "messenger"
                      ],
                      "type": "string",
                      "description": "Channel: `whatsapp`, `instagram` or `messenger`."
                    },
                    "status": {
                      "enum": [
                        "pending",
                        "active",
                        "needs_reconnect",
                        "restricted",
                        "disabled",
                        "disconnected"
                      ],
                      "type": "string",
                      "description": "Status: `pending`, `active`, `restricted`, `needs_reconnect`, `banned` or `disconnected`."
                    },
                    "status_reason": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Reason for the current status, when there is one."
                    },
                    "label": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Name the organization gave the connection."
                    },
                    "external_id": {
                      "type": "string",
                      "description": "ID at Meta (on WhatsApp, the `phone_number_id`)."
                    },
                    "external_label": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Label from Meta, e.g. the formatted number."
                    },
                    "mode": {
                      "anyOf": [
                        {
                          "enum": [
                            "coex",
                            "api_only"
                          ],
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "WhatsApp mode: `coex` (coexistence with the app) or `api_only`."
                    },
                    "send_rate_mps": {
                      "anyOf": [
                        {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Messages per second Messajo lets out through this connection."
                    },
                    "connected_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "When the connection became active (ISO 8601, UTC)."
                    },
                    "last_webhook_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Last webhook received (ISO 8601, UTC); updated at most every 30 s."
                    },
                    "created_at": {
                      "type": "string",
                      "description": "When the connection was created (ISO 8601, UTC)."
                    },
                    "updated_at": {
                      "type": "string",
                      "description": "Last change (ISO 8601, UTC)."
                    },
                    "whatsapp": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "phone_number_id": {
                              "type": "string",
                              "description": "Number ID at Meta."
                            },
                            "messaging_account_id": {
                              "type": "string",
                              "description": "WhatsApp Business account (WABA) of the number."
                            },
                            "mode": {
                              "enum": [
                                "coex",
                                "api_only"
                              ],
                              "type": "string",
                              "description": "WhatsApp mode: `coex` (coexistence with the app) or `api_only`."
                            },
                            "display_phone_number": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Number as Meta displays it."
                            },
                            "verified_name": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Approved display name."
                            },
                            "quality_rating": {
                              "type": "string",
                              "description": "Quality: `GREEN`, `YELLOW`, `RED` or `UNKNOWN`."
                            },
                            "messaging_limit": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Meta messaging limit tier, e.g. `TIER_2K`."
                            },
                            "throughput_level": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Throughput level: `STANDARD`, `HIGH` or `NOT_APPLICABLE`."
                            },
                            "send_rate_mps": {
                              "anyOf": [
                                {
                                  "type": "integer",
                                  "minimum": -9007199254740991,
                                  "maximum": 9007199254740991
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Messages per second Messajo lets out through this connection."
                            },
                            "can_send_message": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Whether Meta allows sending: `AVAILABLE`, `LIMITED` or `BLOCKED`."
                            },
                            "restriction": {
                              "anyOf": [
                                {
                                  "type": "object",
                                  "properties": {
                                    "types": {
                                      "type": "array",
                                      "items": {
                                        "type": "string"
                                      },
                                      "description": "Restriction types reported by Meta."
                                    },
                                    "until": {
                                      "anyOf": [
                                        {
                                          "type": "string"
                                        },
                                        {
                                          "type": "null"
                                        }
                                      ],
                                      "description": "Until when it applies (ISO 8601), if Meta said."
                                    },
                                    "remediation": {
                                      "anyOf": [
                                        {
                                          "type": "string"
                                        },
                                        {
                                          "type": "null"
                                        }
                                      ],
                                      "description": "What to do to lift the restriction."
                                    }
                                  },
                                  "required": [
                                    "types",
                                    "until",
                                    "remediation"
                                  ]
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Active account restriction; `null` when there is none."
                            },
                            "register_status": {
                              "type": "string",
                              "description": "Cloud API registration: `not_needed`, `pending`, `registered` or `failed`."
                            },
                            "contacts_sync_status": {
                              "type": "string",
                              "description": "Coexistence contacts sync."
                            },
                            "history_sync_status": {
                              "type": "string",
                              "description": "Coexistence history sync."
                            },
                            "history_sync_progress": {
                              "anyOf": [
                                {
                                  "type": "integer",
                                  "minimum": -9007199254740991,
                                  "maximum": 9007199254740991
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "History progress, from 0 to 100."
                            },
                            "username": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "WhatsApp username."
                            }
                          },
                          "required": [
                            "phone_number_id",
                            "messaging_account_id",
                            "mode",
                            "display_phone_number",
                            "verified_name",
                            "quality_rating",
                            "messaging_limit",
                            "throughput_level",
                            "send_rate_mps",
                            "can_send_message",
                            "restriction",
                            "register_status",
                            "contacts_sync_status",
                            "history_sync_status",
                            "history_sync_progress",
                            "username"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "WhatsApp data; `null` on other channels."
                    },
                    "instagram": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "ig_user_id": {
                              "type": "string",
                              "description": "ID of the Instagram professional account (`ig_user_id`)."
                            },
                            "username": {
                              "type": "string",
                              "description": "Account username (@)."
                            },
                            "name": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Account display name."
                            },
                            "account_type": {
                              "type": "string",
                              "description": "Account type: `BUSINESS` or `MEDIA_CREATOR`. Unified-login connections report `BUSINESS` until item 2-20."
                            },
                            "scopes": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              },
                              "description": "Permissions granted by Meta."
                            },
                            "missing_scopes": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              },
                              "description": "Instagram permissions not granted; features that need them answer `403 instagram_scope_missing` until you reconnect."
                            },
                            "token_expires_at": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "When the token expires (ISO 8601, UTC). Always null for Instagram: the token does not expire."
                            },
                            "token_refreshed_at": {
                              "type": "string",
                              "description": "When the current token was issued, at connect or reconnect (ISO 8601, UTC)."
                            },
                            "followers_count": {
                              "anyOf": [
                                {
                                  "type": "integer",
                                  "minimum": -9007199254740991,
                                  "maximum": 9007199254740991
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Followers at the last read."
                            },
                            "publishing_quota": {
                              "anyOf": [
                                {
                                  "type": "object",
                                  "properties": {
                                    "quota_usage": {
                                      "type": "integer",
                                      "minimum": -9007199254740991,
                                      "maximum": 9007199254740991,
                                      "description": "Publications made in the quota window."
                                    },
                                    "quota_total": {
                                      "type": "integer",
                                      "minimum": -9007199254740991,
                                      "maximum": 9007199254740991,
                                      "description": "Publications allowed in the window."
                                    },
                                    "quota_duration_s": {
                                      "type": "integer",
                                      "minimum": -9007199254740991,
                                      "maximum": 9007199254740991,
                                      "description": "Window length, in seconds."
                                    },
                                    "checked_at": {
                                      "type": "string",
                                      "description": "When the quota was read (ISO 8601, UTC)."
                                    }
                                  },
                                  "required": [
                                    "quota_usage",
                                    "quota_total",
                                    "quota_duration_s",
                                    "checked_at"
                                  ]
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Publishing quota at the last health check; `null` without the publishing permission."
                            }
                          },
                          "required": [
                            "ig_user_id",
                            "username",
                            "name",
                            "account_type",
                            "scopes",
                            "missing_scopes",
                            "token_expires_at",
                            "token_refreshed_at",
                            "followers_count",
                            "publishing_quota"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Instagram data; `null` on other channels."
                    },
                    "messenger": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "page_id": {
                              "type": "string",
                              "description": "Facebook Page ID."
                            },
                            "page_name": {
                              "type": "string",
                              "description": "Page name."
                            },
                            "page_category": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Page category."
                            },
                            "tasks": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              },
                              "description": "Tasks the connecting user has on the Page (`MESSAGING`, `MANAGE`…)."
                            },
                            "scopes": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              },
                              "description": "Permissions granted by Meta."
                            }
                          },
                          "required": [
                            "page_id",
                            "page_name",
                            "page_category",
                            "tasks",
                            "scopes"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Facebook Page data (Messenger); `null` on other channels."
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      },
                      "description": "Failures on Meta's side that did not block the disconnection."
                    }
                  },
                  "required": [
                    "id",
                    "channel",
                    "status",
                    "status_reason",
                    "label",
                    "external_id",
                    "external_label",
                    "mode",
                    "send_rate_mps",
                    "connected_at",
                    "last_webhook_at",
                    "created_at",
                    "updated_at",
                    "whatsapp",
                    "instagram",
                    "messenger",
                    "warnings"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/connections/{id}/api-keys": {
      "get": {
        "operationId": "listConnectionApiKeys",
        "summary": "List a connection's keys",
        "description": "Lists the API keys bound to this connection (organization keys are not shown). Permission: `admin`. Requires an organization key.",
        "tags": [
          "connections"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Connection identifier."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The connection's keys.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "description": "Key identifier."
                          },
                          "name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Key name (up to 32 characters)."
                          },
                          "start": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Visible start of the key, to identify it."
                          },
                          "permissions": {
                            "type": "array",
                            "items": {
                              "enum": [
                                "send",
                                "read",
                                "templates",
                                "commerce",
                                "admin"
                              ],
                              "type": "string"
                            },
                            "description": "Key permissions (`admin` implies the others)."
                          },
                          "enabled": {
                            "type": "boolean",
                            "description": "Whether the key is active."
                          },
                          "expires_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "When the key expires; `null` = never."
                          },
                          "created_at": {
                            "type": "string",
                            "description": "When the key was created."
                          }
                        },
                        "required": [
                          "id",
                          "name",
                          "start",
                          "permissions",
                          "enabled",
                          "expires_at",
                          "created_at"
                        ]
                      },
                      "description": "The connection's keys."
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "createConnectionApiKey",
        "summary": "Create a connection key",
        "description": "Creates a key bound to this connection (prefix `mjc_`): it sends without `connection_id` and cannot reach organization routes. The secret (`key`) appears only in this response. Permission: `admin`. Requires an organization key.",
        "tags": [
          "connections"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Connection identifier."
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 32,
                    "description": "Key name (up to 32 characters)."
                  },
                  "permissions": {
                    "type": "array",
                    "minItems": 1,
                    "items": {
                      "enum": [
                        "send",
                        "read",
                        "templates",
                        "commerce",
                        "admin"
                      ],
                      "type": "string"
                    },
                    "description": "Key permissions (`admin` implies the others)."
                  },
                  "expires_in_days": {
                    "anyOf": [
                      {
                        "type": "null"
                      },
                      {
                        "const": 30
                      },
                      {
                        "const": 90
                      },
                      {
                        "const": 180
                      },
                      {
                        "const": 365
                      }
                    ],
                    "default": null,
                    "description": "Validity in days (`null` = never expires). Accepted values: 30, 90, 180 or 365."
                  },
                  "rate_per_minute": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 6000,
                    "default": 600,
                    "description": "The key's request limit per minute."
                  }
                },
                "required": [
                  "name",
                  "permissions"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The created key, with its secret.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Key identifier."
                    },
                    "name": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Key name (up to 32 characters)."
                    },
                    "start": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Visible start of the key, to identify it."
                    },
                    "permissions": {
                      "type": "array",
                      "items": {
                        "enum": [
                          "send",
                          "read",
                          "templates",
                          "commerce",
                          "admin"
                        ],
                        "type": "string"
                      },
                      "description": "Key permissions (`admin` implies the others)."
                    },
                    "enabled": {
                      "type": "boolean",
                      "description": "Whether the key is active."
                    },
                    "expires_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "When the key expires; `null` = never."
                    },
                    "created_at": {
                      "type": "string",
                      "description": "When the key was created."
                    },
                    "key": {
                      "type": "string",
                      "description": "The key secret. Shown only on creation: store it."
                    }
                  },
                  "required": [
                    "id",
                    "name",
                    "start",
                    "permissions",
                    "enabled",
                    "expires_at",
                    "created_at",
                    "key"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api-keys/{id}": {
      "delete": {
        "operationId": "deleteApiKey",
        "summary": "Delete an API key",
        "description": "Deletes the API key (organization or connection) and it stops working immediately. Permission: `admin`. Requires an organization key; a key bound to connections only reaches keys inside them.",
        "tags": [
          "connections"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Key identifier."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The deleted key.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Key identifier."
                    },
                    "deleted": {
                      "const": true,
                      "description": "Always `true`."
                    }
                  },
                  "required": [
                    "id",
                    "deleted"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api-keys/{id}/rotate": {
      "post": {
        "operationId": "rotateApiKey",
        "summary": "Rotate an API key",
        "description": "Creates a new key with the same name, permissions, scope and limit, and keeps the old one for `grace` (`24h`, default, or `now`, expires immediately). The new secret (`key`) appears only in this response. Permission: `admin`. Requires an organization key.",
        "tags": [
          "connections"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Key identifier."
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "grace": {
                    "enum": [
                      "now",
                      "24h"
                    ],
                    "type": "string",
                    "default": "24h",
                    "description": "Grace period for the old key: `24h` (default) or `now`."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The new key, with its secret.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Key identifier."
                    },
                    "name": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Key name (up to 32 characters)."
                    },
                    "start": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Visible start of the key, to identify it."
                    },
                    "permissions": {
                      "type": "array",
                      "items": {
                        "enum": [
                          "send",
                          "read",
                          "templates",
                          "commerce",
                          "admin"
                        ],
                        "type": "string"
                      },
                      "description": "Key permissions (`admin` implies the others)."
                    },
                    "enabled": {
                      "type": "boolean",
                      "description": "Whether the key is active."
                    },
                    "expires_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "When the key expires; `null` = never."
                    },
                    "created_at": {
                      "type": "string",
                      "description": "When the key was created."
                    },
                    "key": {
                      "type": "string",
                      "description": "The key secret. Shown only on creation: store it."
                    },
                    "previous_key_expires_at": {
                      "type": "string",
                      "description": "When the old key stops working (ISO 8601, UTC)."
                    }
                  },
                  "required": [
                    "id",
                    "name",
                    "start",
                    "permissions",
                    "enabled",
                    "expires_at",
                    "created_at",
                    "key",
                    "previous_key_expires_at"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/connections/{id}/refresh-health": {
      "post": {
        "operationId": "refreshConnectionHealth",
        "summary": "Refresh health",
        "description": "Reads the number's quality, messaging limit, throughput and `can_send_message` from Meta now (Messajo already does this every 15 minutes). An invalid token marks the connection as `needs_reconnect`. Permission: `admin`.",
        "tags": [
          "connections"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Connection ID (`con_…`)."
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "description": "The connection with the new reading.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Connection ID (`con_…`).",
                      "examples": [
                        "con_0193a1b2c3d47e8f9a0b1c2d3e4f5a6b"
                      ]
                    },
                    "channel": {
                      "enum": [
                        "whatsapp",
                        "instagram",
                        "messenger"
                      ],
                      "type": "string",
                      "description": "Channel: `whatsapp`, `instagram` or `messenger`."
                    },
                    "status": {
                      "enum": [
                        "pending",
                        "active",
                        "needs_reconnect",
                        "restricted",
                        "disabled",
                        "disconnected"
                      ],
                      "type": "string",
                      "description": "Status: `pending`, `active`, `restricted`, `needs_reconnect`, `banned` or `disconnected`."
                    },
                    "status_reason": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Reason for the current status, when there is one."
                    },
                    "label": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Name the organization gave the connection."
                    },
                    "external_id": {
                      "type": "string",
                      "description": "ID at Meta (on WhatsApp, the `phone_number_id`)."
                    },
                    "external_label": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Label from Meta, e.g. the formatted number."
                    },
                    "mode": {
                      "anyOf": [
                        {
                          "enum": [
                            "coex",
                            "api_only"
                          ],
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "WhatsApp mode: `coex` (coexistence with the app) or `api_only`."
                    },
                    "send_rate_mps": {
                      "anyOf": [
                        {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Messages per second Messajo lets out through this connection."
                    },
                    "connected_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "When the connection became active (ISO 8601, UTC)."
                    },
                    "last_webhook_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Last webhook received (ISO 8601, UTC); updated at most every 30 s."
                    },
                    "created_at": {
                      "type": "string",
                      "description": "When the connection was created (ISO 8601, UTC)."
                    },
                    "updated_at": {
                      "type": "string",
                      "description": "Last change (ISO 8601, UTC)."
                    },
                    "whatsapp": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "phone_number_id": {
                              "type": "string",
                              "description": "Number ID at Meta."
                            },
                            "messaging_account_id": {
                              "type": "string",
                              "description": "WhatsApp Business account (WABA) of the number."
                            },
                            "mode": {
                              "enum": [
                                "coex",
                                "api_only"
                              ],
                              "type": "string",
                              "description": "WhatsApp mode: `coex` (coexistence with the app) or `api_only`."
                            },
                            "display_phone_number": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Number as Meta displays it."
                            },
                            "verified_name": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Approved display name."
                            },
                            "quality_rating": {
                              "type": "string",
                              "description": "Quality: `GREEN`, `YELLOW`, `RED` or `UNKNOWN`."
                            },
                            "messaging_limit": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Meta messaging limit tier, e.g. `TIER_2K`."
                            },
                            "throughput_level": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Throughput level: `STANDARD`, `HIGH` or `NOT_APPLICABLE`."
                            },
                            "send_rate_mps": {
                              "anyOf": [
                                {
                                  "type": "integer",
                                  "minimum": -9007199254740991,
                                  "maximum": 9007199254740991
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Messages per second Messajo lets out through this connection."
                            },
                            "can_send_message": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Whether Meta allows sending: `AVAILABLE`, `LIMITED` or `BLOCKED`."
                            },
                            "restriction": {
                              "anyOf": [
                                {
                                  "type": "object",
                                  "properties": {
                                    "types": {
                                      "type": "array",
                                      "items": {
                                        "type": "string"
                                      },
                                      "description": "Restriction types reported by Meta."
                                    },
                                    "until": {
                                      "anyOf": [
                                        {
                                          "type": "string"
                                        },
                                        {
                                          "type": "null"
                                        }
                                      ],
                                      "description": "Until when it applies (ISO 8601), if Meta said."
                                    },
                                    "remediation": {
                                      "anyOf": [
                                        {
                                          "type": "string"
                                        },
                                        {
                                          "type": "null"
                                        }
                                      ],
                                      "description": "What to do to lift the restriction."
                                    }
                                  },
                                  "required": [
                                    "types",
                                    "until",
                                    "remediation"
                                  ]
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Active account restriction; `null` when there is none."
                            },
                            "register_status": {
                              "type": "string",
                              "description": "Cloud API registration: `not_needed`, `pending`, `registered` or `failed`."
                            },
                            "contacts_sync_status": {
                              "type": "string",
                              "description": "Coexistence contacts sync."
                            },
                            "history_sync_status": {
                              "type": "string",
                              "description": "Coexistence history sync."
                            },
                            "history_sync_progress": {
                              "anyOf": [
                                {
                                  "type": "integer",
                                  "minimum": -9007199254740991,
                                  "maximum": 9007199254740991
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "History progress, from 0 to 100."
                            },
                            "username": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "WhatsApp username."
                            }
                          },
                          "required": [
                            "phone_number_id",
                            "messaging_account_id",
                            "mode",
                            "display_phone_number",
                            "verified_name",
                            "quality_rating",
                            "messaging_limit",
                            "throughput_level",
                            "send_rate_mps",
                            "can_send_message",
                            "restriction",
                            "register_status",
                            "contacts_sync_status",
                            "history_sync_status",
                            "history_sync_progress",
                            "username"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "WhatsApp data; `null` on other channels."
                    },
                    "instagram": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "ig_user_id": {
                              "type": "string",
                              "description": "ID of the Instagram professional account (`ig_user_id`)."
                            },
                            "username": {
                              "type": "string",
                              "description": "Account username (@)."
                            },
                            "name": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Account display name."
                            },
                            "account_type": {
                              "type": "string",
                              "description": "Account type: `BUSINESS` or `MEDIA_CREATOR`. Unified-login connections report `BUSINESS` until item 2-20."
                            },
                            "scopes": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              },
                              "description": "Permissions granted by Meta."
                            },
                            "missing_scopes": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              },
                              "description": "Instagram permissions not granted; features that need them answer `403 instagram_scope_missing` until you reconnect."
                            },
                            "token_expires_at": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "When the token expires (ISO 8601, UTC). Always null for Instagram: the token does not expire."
                            },
                            "token_refreshed_at": {
                              "type": "string",
                              "description": "When the current token was issued, at connect or reconnect (ISO 8601, UTC)."
                            },
                            "followers_count": {
                              "anyOf": [
                                {
                                  "type": "integer",
                                  "minimum": -9007199254740991,
                                  "maximum": 9007199254740991
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Followers at the last read."
                            },
                            "publishing_quota": {
                              "anyOf": [
                                {
                                  "type": "object",
                                  "properties": {
                                    "quota_usage": {
                                      "type": "integer",
                                      "minimum": -9007199254740991,
                                      "maximum": 9007199254740991,
                                      "description": "Publications made in the quota window."
                                    },
                                    "quota_total": {
                                      "type": "integer",
                                      "minimum": -9007199254740991,
                                      "maximum": 9007199254740991,
                                      "description": "Publications allowed in the window."
                                    },
                                    "quota_duration_s": {
                                      "type": "integer",
                                      "minimum": -9007199254740991,
                                      "maximum": 9007199254740991,
                                      "description": "Window length, in seconds."
                                    },
                                    "checked_at": {
                                      "type": "string",
                                      "description": "When the quota was read (ISO 8601, UTC)."
                                    }
                                  },
                                  "required": [
                                    "quota_usage",
                                    "quota_total",
                                    "quota_duration_s",
                                    "checked_at"
                                  ]
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Publishing quota at the last health check; `null` without the publishing permission."
                            }
                          },
                          "required": [
                            "ig_user_id",
                            "username",
                            "name",
                            "account_type",
                            "scopes",
                            "missing_scopes",
                            "token_expires_at",
                            "token_refreshed_at",
                            "followers_count",
                            "publishing_quota"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Instagram data; `null` on other channels."
                    },
                    "messenger": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "page_id": {
                              "type": "string",
                              "description": "Facebook Page ID."
                            },
                            "page_name": {
                              "type": "string",
                              "description": "Page name."
                            },
                            "page_category": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Page category."
                            },
                            "tasks": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              },
                              "description": "Tasks the connecting user has on the Page (`MESSAGING`, `MANAGE`…)."
                            },
                            "scopes": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              },
                              "description": "Permissions granted by Meta."
                            }
                          },
                          "required": [
                            "page_id",
                            "page_name",
                            "page_category",
                            "tasks",
                            "scopes"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Facebook Page data (Messenger); `null` on other channels."
                    }
                  },
                  "required": [
                    "id",
                    "channel",
                    "status",
                    "status_reason",
                    "label",
                    "external_id",
                    "external_label",
                    "mode",
                    "send_rate_mps",
                    "connected_at",
                    "last_webhook_at",
                    "created_at",
                    "updated_at",
                    "whatsapp",
                    "instagram",
                    "messenger"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/connections/{id}/profile": {
      "get": {
        "operationId": "getConnectionProfile",
        "summary": "Get the business profile",
        "description": "Returns the number's business profile at Meta (about, address, description, email, websites, vertical and picture). Permission: `read`.",
        "tags": [
          "connections"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Connection ID (`con_…`)."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The business profile.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "about": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Profile \"about\" text."
                    },
                    "address": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Address."
                    },
                    "description": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Business description."
                    },
                    "email": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Contact email."
                    },
                    "websites": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      },
                      "description": "Up to 2 websites."
                    },
                    "vertical": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Business vertical, e.g. `RETAIL`."
                    },
                    "profile_picture_url": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Profile picture link at Meta."
                    }
                  },
                  "required": [
                    "about",
                    "address",
                    "description",
                    "email",
                    "websites",
                    "vertical",
                    "profile_picture_url"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "patch": {
        "operationId": "updateConnectionProfile",
        "summary": "Edit the business profile",
        "description": "Changes the business profile fields sent. The picture comes from a media uploaded earlier with `POST /media`. In coexistence Meta does not allow editing through the API: the response is `422 coex_not_supported` (edit it in the phone app). Permission: `admin`.",
        "tags": [
          "connections"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Connection ID (`con_…`)."
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "about": {
                    "type": "string",
                    "description": "Profile \"about\" text."
                  },
                  "address": {
                    "type": "string",
                    "description": "Address."
                  },
                  "description": {
                    "type": "string",
                    "description": "Business description."
                  },
                  "email": {
                    "type": "string",
                    "description": "Contact email."
                  },
                  "websites": {
                    "type": "array",
                    "maxItems": 2,
                    "items": {
                      "type": "string"
                    },
                    "description": "Up to 2 websites."
                  },
                  "vertical": {
                    "enum": [
                      "UNDEFINED",
                      "OTHER",
                      "AUTO",
                      "BEAUTY",
                      "APPAREL",
                      "EDU",
                      "ENTERTAIN",
                      "EVENT_PLAN",
                      "FINANCE",
                      "GROCERY",
                      "GOVT",
                      "HOTEL",
                      "HEALTH",
                      "NONPROFIT",
                      "PROF_SERVICES",
                      "RETAIL",
                      "TRAVEL",
                      "RESTAURANT",
                      "NOT_A_BIZ"
                    ],
                    "type": "string",
                    "description": "Business vertical, e.g. `RETAIL`."
                  },
                  "profile_picture_media_id": {
                    "type": "string",
                    "description": "Media (`med_…`) uploaded with `POST /media` to become the picture."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The updated business profile.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "about": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Profile \"about\" text."
                    },
                    "address": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Address."
                    },
                    "description": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Business description."
                    },
                    "email": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Contact email."
                    },
                    "websites": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      },
                      "description": "Up to 2 websites."
                    },
                    "vertical": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Business vertical, e.g. `RETAIL`."
                    },
                    "profile_picture_url": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Profile picture link at Meta."
                    }
                  },
                  "required": [
                    "about",
                    "address",
                    "description",
                    "email",
                    "websites",
                    "vertical",
                    "profile_picture_url"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/connections/{id}/display-name": {
      "post": {
        "operationId": "requestDisplayName",
        "summary": "Request a new display name",
        "description": "Asks Meta for a new display name; it goes through review and the status comes back in `new_name_status`. In coexistence: `422 coex_not_supported`. Permission: `admin`.",
        "tags": [
          "connections"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Connection ID (`con_…`)."
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "Requested display name."
                  }
                },
                "required": [
                  "name"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The request status.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "new_name_status": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Review status of the new name at Meta."
                    }
                  },
                  "required": [
                    "new_name_status"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/connections/{id}/username": {
      "get": {
        "operationId": "getUsername",
        "summary": "Get the username",
        "description": "Returns the number's WhatsApp username and its status at Meta. Permission: `read`.",
        "tags": [
          "connections"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Connection ID (`con_…`)."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The username and its status.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "username": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Username; `null` when there is none."
                    },
                    "status": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Username status at Meta."
                    }
                  },
                  "required": [
                    "username",
                    "status"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "put": {
        "operationId": "setUsername",
        "summary": "Set the username",
        "description": "Sets or changes the number's username (3 to 35 characters: letters, digits, `.` and `_`). In coexistence: `422 coex_not_supported`. Permission: `admin`.",
        "tags": [
          "connections"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Connection ID (`con_…`)."
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "username": {
                    "type": "string",
                    "description": "Username; `null` when there is none."
                  }
                },
                "required": [
                  "username"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The username and its status.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "username": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Username; `null` when there is none."
                    },
                    "status": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Username status at Meta."
                    }
                  },
                  "required": [
                    "username",
                    "status"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "operationId": "deleteUsername",
        "summary": "Remove the username",
        "description": "Removes the number's username. In coexistence: `422 coex_not_supported`. Permission: `admin`.",
        "tags": [
          "connections"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Connection ID (`con_…`)."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The (empty) username and its status.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "username": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Username; `null` when there is none."
                    },
                    "status": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Username status at Meta."
                    }
                  },
                  "required": [
                    "username",
                    "status"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/connections/{id}/username/suggestions": {
      "get": {
        "operationId": "listUsernameSuggestions",
        "summary": "Username suggestions",
        "description": "Available usernames Meta suggests for the number. Permission: `read`.",
        "tags": [
          "connections"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Connection ID (`con_…`)."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The suggestions.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "suggestions": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      },
                      "description": "Suggested usernames."
                    }
                  },
                  "required": [
                    "suggestions"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/messages": {
      "post": {
        "operationId": "sendMessage",
        "summary": "Send a message",
        "description": "Sends a message through a connection. The body depends on the channel (see the union below). WhatsApp: text, media, template, interactive, reaction, location, contacts and sticker. Instagram and Messenger: `text` (with `quick_replies`), `image`, `images` (2 to 10, Instagram only), `video`, `audio`, `document`, `like` (Instagram only), `reaction`, `share` (post, Instagram only), `buttons` and `cards`. A type the channel lacks: `422 type_not_supported_by_channel`. Outside the 24 h window: WhatsApp only takes templates; Instagram and Messenger accept `tag: \"human_agent\"` up to 7 days after the contact's last message, **only for replies written by a person** (Meta policy; never for automation), and after that `422 human_agent_window_closed`. Without the tag: `422 outside_service_window`. Each connection has a messages-per-second limit; above it the answer is `429 connection_rate_limited` with `retry_after_ms`. Use `Idempotency-Key` to retry without duplicates: if Meta did not say whether it accepted (`502 meta_unknown_outcome`), Messajo does not resend on its own. Permission: `send`.",
        "tags": [
          "messages"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "anyOf": [
                  {
                    "anyOf": [
                      {
                        "type": "object",
                        "properties": {
                          "connection_id": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 64
                          },
                          "to": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 135
                          },
                          "reply_to": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 256
                          },
                          "tag": {
                            "const": "human_agent"
                          },
                          "delay_ms": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 20000,
                            "default": 0
                          },
                          "typing": {
                            "type": "boolean",
                            "default": false
                          },
                          "biz_opaque_callback_data": {
                            "type": "string",
                            "maxLength": 512
                          },
                          "type": {
                            "const": "text"
                          },
                          "text": {
                            "type": "object",
                            "properties": {
                              "body": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 4096
                              },
                              "preview_url": {
                                "type": "boolean"
                              }
                            },
                            "required": [
                              "body"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "to",
                          "type",
                          "text"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "connection_id": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 64
                          },
                          "to": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 135
                          },
                          "reply_to": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 256
                          },
                          "tag": {
                            "const": "human_agent"
                          },
                          "delay_ms": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 20000,
                            "default": 0
                          },
                          "typing": {
                            "type": "boolean",
                            "default": false
                          },
                          "biz_opaque_callback_data": {
                            "type": "string",
                            "maxLength": 512
                          },
                          "type": {
                            "const": "image"
                          },
                          "image": {
                            "type": "object",
                            "properties": {
                              "media_id": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 256
                              },
                              "link": {
                                "type": "string",
                                "format": "uri"
                              },
                              "caption": {
                                "type": "string",
                                "maxLength": 1024
                              }
                            },
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "to",
                          "type",
                          "image"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "connection_id": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 64
                          },
                          "to": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 135
                          },
                          "reply_to": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 256
                          },
                          "tag": {
                            "const": "human_agent"
                          },
                          "delay_ms": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 20000,
                            "default": 0
                          },
                          "typing": {
                            "type": "boolean",
                            "default": false
                          },
                          "biz_opaque_callback_data": {
                            "type": "string",
                            "maxLength": 512
                          },
                          "type": {
                            "const": "video"
                          },
                          "video": {
                            "type": "object",
                            "properties": {
                              "media_id": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 256
                              },
                              "link": {
                                "type": "string",
                                "format": "uri"
                              },
                              "caption": {
                                "type": "string",
                                "maxLength": 1024
                              }
                            },
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "to",
                          "type",
                          "video"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "connection_id": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 64
                          },
                          "to": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 135
                          },
                          "reply_to": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 256
                          },
                          "tag": {
                            "const": "human_agent"
                          },
                          "delay_ms": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 20000,
                            "default": 0
                          },
                          "typing": {
                            "type": "boolean",
                            "default": false
                          },
                          "biz_opaque_callback_data": {
                            "type": "string",
                            "maxLength": 512
                          },
                          "type": {
                            "const": "document"
                          },
                          "document": {
                            "type": "object",
                            "properties": {
                              "media_id": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 256
                              },
                              "link": {
                                "type": "string",
                                "format": "uri"
                              },
                              "caption": {
                                "type": "string",
                                "maxLength": 1024
                              },
                              "filename": {
                                "type": "string",
                                "maxLength": 240
                              }
                            },
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "to",
                          "type",
                          "document"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "connection_id": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 64
                          },
                          "to": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 135
                          },
                          "reply_to": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 256
                          },
                          "tag": {
                            "const": "human_agent"
                          },
                          "delay_ms": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 20000,
                            "default": 0
                          },
                          "typing": {
                            "type": "boolean",
                            "default": false
                          },
                          "biz_opaque_callback_data": {
                            "type": "string",
                            "maxLength": 512
                          },
                          "type": {
                            "const": "audio"
                          },
                          "audio": {
                            "type": "object",
                            "properties": {
                              "media_id": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 256
                              },
                              "link": {
                                "type": "string",
                                "format": "uri"
                              },
                              "voice": {
                                "type": "boolean"
                              }
                            },
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "to",
                          "type",
                          "audio"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "connection_id": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 64
                          },
                          "to": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 135
                          },
                          "reply_to": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 256
                          },
                          "tag": {
                            "const": "human_agent"
                          },
                          "delay_ms": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 20000,
                            "default": 0
                          },
                          "typing": {
                            "type": "boolean",
                            "default": false
                          },
                          "biz_opaque_callback_data": {
                            "type": "string",
                            "maxLength": 512
                          },
                          "type": {
                            "const": "sticker"
                          },
                          "sticker": {
                            "type": "object",
                            "properties": {
                              "media_id": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 256
                              },
                              "link": {
                                "type": "string",
                                "format": "uri"
                              }
                            },
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "to",
                          "type",
                          "sticker"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "connection_id": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 64
                          },
                          "to": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 135
                          },
                          "reply_to": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 256
                          },
                          "tag": {
                            "const": "human_agent"
                          },
                          "delay_ms": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 20000,
                            "default": 0
                          },
                          "typing": {
                            "type": "boolean",
                            "default": false
                          },
                          "biz_opaque_callback_data": {
                            "type": "string",
                            "maxLength": 512
                          },
                          "type": {
                            "const": "template"
                          },
                          "template": {
                            "type": "object",
                            "properties": {
                              "name": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 512
                              },
                              "language": {
                                "type": "string",
                                "minLength": 2,
                                "maxLength": 16
                              },
                              "components": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "propertyNames": {
                                    "type": "string"
                                  },
                                  "additionalProperties": {}
                                }
                              }
                            },
                            "required": [
                              "name",
                              "language"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "to",
                          "type",
                          "template"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "connection_id": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 64
                          },
                          "to": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 135
                          },
                          "reply_to": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 256
                          },
                          "tag": {
                            "const": "human_agent"
                          },
                          "delay_ms": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 20000,
                            "default": 0
                          },
                          "typing": {
                            "type": "boolean",
                            "default": false
                          },
                          "biz_opaque_callback_data": {
                            "type": "string",
                            "maxLength": 512
                          },
                          "type": {
                            "const": "interactive"
                          },
                          "interactive": {
                            "anyOf": [
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "const": "button"
                                  },
                                  "header": {
                                    "type": "object",
                                    "properties": {
                                      "type": {
                                        "enum": [
                                          "text",
                                          "image",
                                          "video",
                                          "document"
                                        ],
                                        "type": "string"
                                      },
                                      "text": {
                                        "type": "string",
                                        "maxLength": 60
                                      }
                                    },
                                    "required": [
                                      "type"
                                    ],
                                    "additionalProperties": {}
                                  },
                                  "body": {
                                    "type": "object",
                                    "properties": {
                                      "text": {
                                        "type": "string",
                                        "minLength": 1,
                                        "maxLength": 1024
                                      }
                                    },
                                    "required": [
                                      "text"
                                    ]
                                  },
                                  "footer": {
                                    "type": "object",
                                    "properties": {
                                      "text": {
                                        "type": "string",
                                        "maxLength": 60
                                      }
                                    },
                                    "required": [
                                      "text"
                                    ]
                                  },
                                  "action": {
                                    "type": "object",
                                    "properties": {
                                      "buttons": {
                                        "type": "array",
                                        "minItems": 1,
                                        "maxItems": 3,
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "type": {
                                              "const": "reply"
                                            },
                                            "reply": {
                                              "type": "object",
                                              "properties": {
                                                "id": {
                                                  "type": "string",
                                                  "minLength": 1,
                                                  "maxLength": 256
                                                },
                                                "title": {
                                                  "type": "string",
                                                  "minLength": 1,
                                                  "maxLength": 20
                                                }
                                              },
                                              "required": [
                                                "id",
                                                "title"
                                              ]
                                            }
                                          },
                                          "required": [
                                            "type",
                                            "reply"
                                          ],
                                          "additionalProperties": {}
                                        }
                                      }
                                    },
                                    "required": [
                                      "buttons"
                                    ],
                                    "additionalProperties": {}
                                  }
                                },
                                "required": [
                                  "type",
                                  "body",
                                  "action"
                                ],
                                "additionalProperties": {}
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "const": "list"
                                  },
                                  "header": {
                                    "type": "object",
                                    "properties": {
                                      "type": {
                                        "enum": [
                                          "text",
                                          "image",
                                          "video",
                                          "document"
                                        ],
                                        "type": "string"
                                      },
                                      "text": {
                                        "type": "string",
                                        "maxLength": 60
                                      }
                                    },
                                    "required": [
                                      "type"
                                    ],
                                    "additionalProperties": {}
                                  },
                                  "body": {
                                    "type": "object",
                                    "properties": {
                                      "text": {
                                        "type": "string",
                                        "minLength": 1,
                                        "maxLength": 1024
                                      }
                                    },
                                    "required": [
                                      "text"
                                    ]
                                  },
                                  "footer": {
                                    "type": "object",
                                    "properties": {
                                      "text": {
                                        "type": "string",
                                        "maxLength": 60
                                      }
                                    },
                                    "required": [
                                      "text"
                                    ]
                                  },
                                  "action": {
                                    "type": "object",
                                    "properties": {
                                      "button": {
                                        "type": "string",
                                        "minLength": 1,
                                        "maxLength": 20
                                      },
                                      "sections": {
                                        "type": "array",
                                        "minItems": 1,
                                        "maxItems": 10,
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "title": {
                                              "type": "string",
                                              "maxLength": 24
                                            },
                                            "rows": {
                                              "type": "array",
                                              "minItems": 1,
                                              "items": {
                                                "type": "object",
                                                "properties": {
                                                  "id": {
                                                    "type": "string",
                                                    "minLength": 1,
                                                    "maxLength": 200
                                                  },
                                                  "title": {
                                                    "type": "string",
                                                    "minLength": 1,
                                                    "maxLength": 24
                                                  },
                                                  "description": {
                                                    "type": "string",
                                                    "maxLength": 72
                                                  }
                                                },
                                                "required": [
                                                  "id",
                                                  "title"
                                                ],
                                                "additionalProperties": {}
                                              }
                                            }
                                          },
                                          "required": [
                                            "rows"
                                          ],
                                          "additionalProperties": {}
                                        }
                                      }
                                    },
                                    "required": [
                                      "button",
                                      "sections"
                                    ],
                                    "additionalProperties": {}
                                  }
                                },
                                "required": [
                                  "type",
                                  "body",
                                  "action"
                                ],
                                "additionalProperties": {}
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "const": "cta_url"
                                  },
                                  "header": {
                                    "type": "object",
                                    "properties": {
                                      "type": {
                                        "enum": [
                                          "text",
                                          "image",
                                          "video",
                                          "document"
                                        ],
                                        "type": "string"
                                      },
                                      "text": {
                                        "type": "string",
                                        "maxLength": 60
                                      }
                                    },
                                    "required": [
                                      "type"
                                    ],
                                    "additionalProperties": {}
                                  },
                                  "body": {
                                    "type": "object",
                                    "properties": {
                                      "text": {
                                        "type": "string",
                                        "minLength": 1,
                                        "maxLength": 1024
                                      }
                                    },
                                    "required": [
                                      "text"
                                    ]
                                  },
                                  "footer": {
                                    "type": "object",
                                    "properties": {
                                      "text": {
                                        "type": "string",
                                        "maxLength": 60
                                      }
                                    },
                                    "required": [
                                      "text"
                                    ]
                                  },
                                  "action": {
                                    "type": "object",
                                    "properties": {
                                      "name": {
                                        "const": "cta_url"
                                      },
                                      "parameters": {
                                        "type": "object",
                                        "properties": {
                                          "display_text": {
                                            "type": "string",
                                            "minLength": 1,
                                            "maxLength": 20
                                          },
                                          "url": {
                                            "type": "string",
                                            "format": "uri"
                                          }
                                        },
                                        "required": [
                                          "display_text",
                                          "url"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "name",
                                      "parameters"
                                    ],
                                    "additionalProperties": {}
                                  }
                                },
                                "required": [
                                  "type",
                                  "body",
                                  "action"
                                ],
                                "additionalProperties": {}
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "const": "location_request_message"
                                  },
                                  "body": {
                                    "type": "object",
                                    "properties": {
                                      "text": {
                                        "type": "string",
                                        "minLength": 1,
                                        "maxLength": 1024
                                      }
                                    },
                                    "required": [
                                      "text"
                                    ]
                                  },
                                  "action": {
                                    "type": "object",
                                    "properties": {
                                      "name": {
                                        "const": "send_location"
                                      }
                                    },
                                    "required": [
                                      "name"
                                    ],
                                    "additionalProperties": {}
                                  }
                                },
                                "required": [
                                  "type",
                                  "body",
                                  "action"
                                ],
                                "additionalProperties": {}
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "const": "flow"
                                  },
                                  "header": {
                                    "type": "object",
                                    "properties": {
                                      "type": {
                                        "enum": [
                                          "text",
                                          "image",
                                          "video",
                                          "document"
                                        ],
                                        "type": "string"
                                      },
                                      "text": {
                                        "type": "string",
                                        "maxLength": 60
                                      }
                                    },
                                    "required": [
                                      "type"
                                    ],
                                    "additionalProperties": {}
                                  },
                                  "body": {
                                    "type": "object",
                                    "properties": {
                                      "text": {
                                        "type": "string",
                                        "minLength": 1,
                                        "maxLength": 1024
                                      }
                                    },
                                    "required": [
                                      "text"
                                    ]
                                  },
                                  "footer": {
                                    "type": "object",
                                    "properties": {
                                      "text": {
                                        "type": "string",
                                        "maxLength": 60
                                      }
                                    },
                                    "required": [
                                      "text"
                                    ]
                                  },
                                  "action": {
                                    "type": "object",
                                    "properties": {
                                      "name": {
                                        "const": "flow"
                                      },
                                      "parameters": {
                                        "type": "object",
                                        "properties": {
                                          "flow_token": {
                                            "type": "string",
                                            "minLength": 1,
                                            "maxLength": 512
                                          },
                                          "flow_id": {
                                            "type": "string",
                                            "minLength": 1,
                                            "maxLength": 64
                                          },
                                          "flow_cta": {
                                            "type": "string",
                                            "minLength": 1,
                                            "maxLength": 20
                                          },
                                          "flow_action": {
                                            "enum": [
                                              "navigate",
                                              "data_exchange"
                                            ],
                                            "type": "string"
                                          },
                                          "flow_message_version": {
                                            "type": "string",
                                            "maxLength": 16
                                          },
                                          "flow_action_payload": {
                                            "type": "object",
                                            "properties": {
                                              "screen": {
                                                "type": "string",
                                                "minLength": 1,
                                                "maxLength": 256
                                              },
                                              "data": {
                                                "type": "object",
                                                "propertyNames": {
                                                  "type": "string"
                                                },
                                                "additionalProperties": {}
                                              }
                                            },
                                            "required": [
                                              "screen"
                                            ],
                                            "additionalProperties": {}
                                          },
                                          "mode": {
                                            "enum": [
                                              "draft",
                                              "published"
                                            ],
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "flow_id",
                                          "flow_cta",
                                          "flow_action"
                                        ],
                                        "additionalProperties": {}
                                      }
                                    },
                                    "required": [
                                      "name",
                                      "parameters"
                                    ],
                                    "additionalProperties": {}
                                  }
                                },
                                "required": [
                                  "type",
                                  "body",
                                  "action"
                                ],
                                "additionalProperties": {}
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "const": "product"
                                  },
                                  "body": {
                                    "type": "object",
                                    "properties": {
                                      "text": {
                                        "type": "string",
                                        "maxLength": 1024
                                      }
                                    },
                                    "required": [
                                      "text"
                                    ]
                                  },
                                  "footer": {
                                    "type": "object",
                                    "properties": {
                                      "text": {
                                        "type": "string",
                                        "maxLength": 60
                                      }
                                    },
                                    "required": [
                                      "text"
                                    ]
                                  },
                                  "action": {
                                    "type": "object",
                                    "properties": {
                                      "catalog_id": {
                                        "type": "string",
                                        "minLength": 1,
                                        "maxLength": 128
                                      },
                                      "product_retailer_id": {
                                        "type": "string",
                                        "minLength": 1,
                                        "maxLength": 128
                                      }
                                    },
                                    "required": [
                                      "catalog_id",
                                      "product_retailer_id"
                                    ],
                                    "additionalProperties": {}
                                  }
                                },
                                "required": [
                                  "type",
                                  "action"
                                ],
                                "additionalProperties": {}
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "const": "product_list"
                                  },
                                  "header": {
                                    "type": "object",
                                    "properties": {
                                      "type": {
                                        "const": "text"
                                      },
                                      "text": {
                                        "type": "string",
                                        "minLength": 1,
                                        "maxLength": 60
                                      }
                                    },
                                    "required": [
                                      "type",
                                      "text"
                                    ]
                                  },
                                  "body": {
                                    "type": "object",
                                    "properties": {
                                      "text": {
                                        "type": "string",
                                        "minLength": 1,
                                        "maxLength": 1024
                                      }
                                    },
                                    "required": [
                                      "text"
                                    ]
                                  },
                                  "footer": {
                                    "type": "object",
                                    "properties": {
                                      "text": {
                                        "type": "string",
                                        "maxLength": 60
                                      }
                                    },
                                    "required": [
                                      "text"
                                    ]
                                  },
                                  "action": {
                                    "type": "object",
                                    "properties": {
                                      "catalog_id": {
                                        "type": "string",
                                        "minLength": 1,
                                        "maxLength": 128
                                      },
                                      "sections": {
                                        "type": "array",
                                        "minItems": 1,
                                        "maxItems": 10,
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "title": {
                                              "type": "string",
                                              "minLength": 1,
                                              "maxLength": 24
                                            },
                                            "product_items": {
                                              "type": "array",
                                              "minItems": 1,
                                              "items": {
                                                "type": "object",
                                                "properties": {
                                                  "product_retailer_id": {
                                                    "type": "string",
                                                    "minLength": 1,
                                                    "maxLength": 128
                                                  }
                                                },
                                                "required": [
                                                  "product_retailer_id"
                                                ]
                                              }
                                            }
                                          },
                                          "required": [
                                            "title",
                                            "product_items"
                                          ],
                                          "additionalProperties": {}
                                        }
                                      }
                                    },
                                    "required": [
                                      "catalog_id",
                                      "sections"
                                    ],
                                    "additionalProperties": {}
                                  }
                                },
                                "required": [
                                  "type",
                                  "header",
                                  "body",
                                  "action"
                                ],
                                "additionalProperties": {}
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "const": "catalog_message"
                                  },
                                  "body": {
                                    "type": "object",
                                    "properties": {
                                      "text": {
                                        "type": "string",
                                        "minLength": 1,
                                        "maxLength": 1024
                                      }
                                    },
                                    "required": [
                                      "text"
                                    ]
                                  },
                                  "footer": {
                                    "type": "object",
                                    "properties": {
                                      "text": {
                                        "type": "string",
                                        "maxLength": 60
                                      }
                                    },
                                    "required": [
                                      "text"
                                    ]
                                  },
                                  "action": {
                                    "type": "object",
                                    "properties": {
                                      "name": {
                                        "const": "catalog_message"
                                      },
                                      "parameters": {
                                        "type": "object",
                                        "properties": {
                                          "thumbnail_product_retailer_id": {
                                            "type": "string",
                                            "minLength": 1,
                                            "maxLength": 128
                                          }
                                        },
                                        "required": [
                                          "thumbnail_product_retailer_id"
                                        ],
                                        "additionalProperties": {}
                                      }
                                    },
                                    "required": [
                                      "name"
                                    ],
                                    "additionalProperties": {}
                                  }
                                },
                                "required": [
                                  "type",
                                  "body",
                                  "action"
                                ],
                                "additionalProperties": {}
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "const": "order_details"
                                  },
                                  "header": {
                                    "type": "object",
                                    "properties": {
                                      "type": {
                                        "enum": [
                                          "text",
                                          "image",
                                          "video",
                                          "document"
                                        ],
                                        "type": "string"
                                      },
                                      "text": {
                                        "type": "string",
                                        "maxLength": 60
                                      }
                                    },
                                    "required": [
                                      "type"
                                    ],
                                    "additionalProperties": {}
                                  },
                                  "body": {
                                    "type": "object",
                                    "properties": {
                                      "text": {
                                        "type": "string",
                                        "minLength": 1,
                                        "maxLength": 1024
                                      }
                                    },
                                    "required": [
                                      "text"
                                    ]
                                  },
                                  "footer": {
                                    "type": "object",
                                    "properties": {
                                      "text": {
                                        "type": "string",
                                        "maxLength": 60
                                      }
                                    },
                                    "required": [
                                      "text"
                                    ]
                                  },
                                  "action": {
                                    "type": "object",
                                    "properties": {
                                      "name": {
                                        "const": "review_and_pay"
                                      },
                                      "parameters": {
                                        "type": "object",
                                        "properties": {
                                          "reference_id": {
                                            "type": "string",
                                            "pattern": "^[A-Za-z0-9_.-]{1,35}$"
                                          },
                                          "type": {
                                            "enum": [
                                              "digital-goods",
                                              "physical-goods"
                                            ],
                                            "type": "string"
                                          },
                                          "payment_type": {
                                            "type": "string",
                                            "minLength": 1,
                                            "maxLength": 16
                                          },
                                          "payment_settings": {
                                            "type": "array",
                                            "minItems": 1,
                                            "maxItems": 3,
                                            "items": {
                                              "anyOf": [
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "const": "pix_dynamic_code"
                                                    },
                                                    "pix_dynamic_code": {
                                                      "type": "object",
                                                      "properties": {
                                                        "code": {},
                                                        "merchant_name": {},
                                                        "key": {},
                                                        "key_type": {}
                                                      }
                                                    }
                                                  },
                                                  "required": [
                                                    "type",
                                                    "pix_dynamic_code"
                                                  ]
                                                },
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "const": "payment_link"
                                                    },
                                                    "payment_link": {
                                                      "type": "object",
                                                      "properties": {
                                                        "uri": {}
                                                      }
                                                    }
                                                  },
                                                  "required": [
                                                    "type",
                                                    "payment_link"
                                                  ]
                                                },
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "const": "boleto"
                                                    },
                                                    "boleto": {
                                                      "type": "object",
                                                      "properties": {
                                                        "digitable_line": {}
                                                      }
                                                    }
                                                  },
                                                  "required": [
                                                    "type",
                                                    "boleto"
                                                  ]
                                                }
                                              ]
                                            }
                                          },
                                          "currency": {
                                            "type": "string",
                                            "minLength": 3,
                                            "maxLength": 3
                                          },
                                          "total_amount": {
                                            "type": "object",
                                            "properties": {
                                              "value": {
                                                "type": "integer",
                                                "minimum": 0,
                                                "maximum": 9007199254740991
                                              },
                                              "offset": {
                                                "const": 100
                                              }
                                            },
                                            "required": [
                                              "value",
                                              "offset"
                                            ]
                                          },
                                          "order": {
                                            "type": "object",
                                            "properties": {
                                              "status": {
                                                "const": "pending"
                                              },
                                              "catalog_id": {
                                                "type": "string",
                                                "minLength": 1,
                                                "maxLength": 128
                                              },
                                              "items": {
                                                "type": "array",
                                                "minItems": 1,
                                                "maxItems": 100,
                                                "items": {
                                                  "type": "object",
                                                  "properties": {
                                                    "retailer_id": {
                                                      "type": "string",
                                                      "minLength": 1,
                                                      "maxLength": 128
                                                    },
                                                    "name": {
                                                      "type": "string",
                                                      "minLength": 1,
                                                      "maxLength": 60
                                                    },
                                                    "amount": {
                                                      "type": "object",
                                                      "properties": {
                                                        "value": {},
                                                        "offset": {}
                                                      }
                                                    },
                                                    "sale_amount": {
                                                      "type": "object",
                                                      "properties": {
                                                        "value": {},
                                                        "offset": {}
                                                      }
                                                    },
                                                    "quantity": {
                                                      "type": "integer",
                                                      "minimum": 1,
                                                      "maximum": 9007199254740991
                                                    }
                                                  },
                                                  "required": [
                                                    "retailer_id",
                                                    "name",
                                                    "amount",
                                                    "quantity"
                                                  ],
                                                  "additionalProperties": {}
                                                }
                                              },
                                              "subtotal": {
                                                "type": "object",
                                                "properties": {
                                                  "value": {
                                                    "type": "integer",
                                                    "minimum": 0,
                                                    "maximum": 9007199254740991
                                                  },
                                                  "offset": {
                                                    "const": 100
                                                  }
                                                },
                                                "required": [
                                                  "value",
                                                  "offset"
                                                ]
                                              },
                                              "tax": {
                                                "type": "object",
                                                "properties": {
                                                  "value": {
                                                    "type": "integer",
                                                    "minimum": 0,
                                                    "maximum": 9007199254740991
                                                  },
                                                  "offset": {
                                                    "const": 100
                                                  },
                                                  "description": {
                                                    "type": "string",
                                                    "maxLength": 60
                                                  }
                                                },
                                                "required": [
                                                  "value",
                                                  "offset"
                                                ]
                                              },
                                              "shipping": {
                                                "type": "object",
                                                "properties": {
                                                  "value": {
                                                    "type": "integer",
                                                    "minimum": 0,
                                                    "maximum": 9007199254740991
                                                  },
                                                  "offset": {
                                                    "const": 100
                                                  },
                                                  "description": {
                                                    "type": "string",
                                                    "maxLength": 60
                                                  }
                                                },
                                                "required": [
                                                  "value",
                                                  "offset"
                                                ]
                                              },
                                              "discount": {
                                                "type": "object",
                                                "properties": {
                                                  "value": {
                                                    "type": "integer",
                                                    "minimum": 0,
                                                    "maximum": 9007199254740991
                                                  },
                                                  "offset": {
                                                    "const": 100
                                                  },
                                                  "description": {
                                                    "type": "string",
                                                    "maxLength": 60
                                                  }
                                                },
                                                "required": [
                                                  "value",
                                                  "offset"
                                                ]
                                              },
                                              "expiration": {
                                                "type": "object",
                                                "properties": {
                                                  "timestamp": {
                                                    "type": "string",
                                                    "minLength": 1,
                                                    "maxLength": 16
                                                  },
                                                  "description": {
                                                    "type": "string",
                                                    "maxLength": 60
                                                  }
                                                },
                                                "required": [
                                                  "timestamp",
                                                  "description"
                                                ]
                                              }
                                            },
                                            "required": [
                                              "status",
                                              "items",
                                              "subtotal",
                                              "tax"
                                            ],
                                            "additionalProperties": {}
                                          }
                                        },
                                        "required": [
                                          "reference_id",
                                          "type",
                                          "payment_type",
                                          "payment_settings",
                                          "currency",
                                          "total_amount",
                                          "order"
                                        ],
                                        "additionalProperties": {}
                                      }
                                    },
                                    "required": [
                                      "name",
                                      "parameters"
                                    ],
                                    "additionalProperties": {}
                                  }
                                },
                                "required": [
                                  "type",
                                  "body",
                                  "action"
                                ],
                                "additionalProperties": {}
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "const": "order_status"
                                  },
                                  "body": {
                                    "type": "object",
                                    "properties": {
                                      "text": {
                                        "type": "string",
                                        "minLength": 1,
                                        "maxLength": 1024
                                      }
                                    },
                                    "required": [
                                      "text"
                                    ]
                                  },
                                  "footer": {
                                    "type": "object",
                                    "properties": {
                                      "text": {
                                        "type": "string",
                                        "maxLength": 60
                                      }
                                    },
                                    "required": [
                                      "text"
                                    ]
                                  },
                                  "action": {
                                    "type": "object",
                                    "properties": {
                                      "name": {
                                        "const": "review_order"
                                      },
                                      "parameters": {
                                        "type": "object",
                                        "properties": {
                                          "reference_id": {
                                            "type": "string",
                                            "pattern": "^[A-Za-z0-9_.-]{1,35}$"
                                          },
                                          "order": {
                                            "type": "object",
                                            "properties": {
                                              "status": {
                                                "enum": [
                                                  "pending",
                                                  "processing",
                                                  "partially_shipped",
                                                  "shipped",
                                                  "completed",
                                                  "canceled"
                                                ],
                                                "type": "string"
                                              },
                                              "description": {
                                                "type": "string",
                                                "maxLength": 120
                                              }
                                            },
                                            "required": [
                                              "status"
                                            ],
                                            "additionalProperties": {}
                                          }
                                        },
                                        "required": [
                                          "reference_id",
                                          "order"
                                        ],
                                        "additionalProperties": {}
                                      }
                                    },
                                    "required": [
                                      "name",
                                      "parameters"
                                    ],
                                    "additionalProperties": {}
                                  }
                                },
                                "required": [
                                  "type",
                                  "body",
                                  "action"
                                ],
                                "additionalProperties": {}
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "const": "call_permission_request"
                                  },
                                  "body": {
                                    "type": "object",
                                    "properties": {
                                      "text": {
                                        "type": "string",
                                        "minLength": 1,
                                        "maxLength": 1024
                                      }
                                    },
                                    "required": [
                                      "text"
                                    ]
                                  },
                                  "action": {
                                    "type": "object",
                                    "properties": {
                                      "name": {
                                        "const": "call_permission_request"
                                      }
                                    },
                                    "required": [
                                      "name"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "type",
                                  "body",
                                  "action"
                                ],
                                "additionalProperties": false
                              }
                            ]
                          }
                        },
                        "required": [
                          "to",
                          "type",
                          "interactive"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "connection_id": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 64
                          },
                          "to": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 135
                          },
                          "reply_to": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 256
                          },
                          "tag": {
                            "const": "human_agent"
                          },
                          "delay_ms": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 20000,
                            "default": 0
                          },
                          "typing": {
                            "type": "boolean",
                            "default": false
                          },
                          "biz_opaque_callback_data": {
                            "type": "string",
                            "maxLength": 512
                          },
                          "type": {
                            "const": "otp"
                          },
                          "otp": {
                            "type": "object",
                            "properties": {
                              "template_id": {
                                "type": "string",
                                "maxLength": 64,
                                "pattern": "^tpl_.*"
                              },
                              "template": {
                                "type": "object",
                                "properties": {
                                  "name": {
                                    "type": "string",
                                    "minLength": 1,
                                    "maxLength": 512
                                  },
                                  "language": {
                                    "type": "string",
                                    "minLength": 2,
                                    "maxLength": 16
                                  }
                                },
                                "required": [
                                  "name",
                                  "language"
                                ],
                                "additionalProperties": false
                              },
                              "code": {
                                "type": "string",
                                "pattern": "^[A-Za-z0-9]{4,15}$"
                              }
                            },
                            "required": [
                              "code"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "to",
                          "type",
                          "otp"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "connection_id": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 64
                          },
                          "to": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 135
                          },
                          "reply_to": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 256
                          },
                          "tag": {
                            "const": "human_agent"
                          },
                          "delay_ms": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 20000,
                            "default": 0
                          },
                          "typing": {
                            "type": "boolean",
                            "default": false
                          },
                          "biz_opaque_callback_data": {
                            "type": "string",
                            "maxLength": 512
                          },
                          "type": {
                            "const": "reaction"
                          },
                          "reaction": {
                            "type": "object",
                            "properties": {
                              "message_id": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 256
                              },
                              "emoji": {
                                "type": "string",
                                "maxLength": 16
                              }
                            },
                            "required": [
                              "message_id",
                              "emoji"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "to",
                          "type",
                          "reaction"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "connection_id": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 64
                          },
                          "to": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 135
                          },
                          "reply_to": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 256
                          },
                          "tag": {
                            "const": "human_agent"
                          },
                          "delay_ms": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 20000,
                            "default": 0
                          },
                          "typing": {
                            "type": "boolean",
                            "default": false
                          },
                          "biz_opaque_callback_data": {
                            "type": "string",
                            "maxLength": 512
                          },
                          "type": {
                            "const": "location"
                          },
                          "location": {
                            "type": "object",
                            "properties": {
                              "latitude": {
                                "type": "number",
                                "minimum": -90,
                                "maximum": 90
                              },
                              "longitude": {
                                "type": "number",
                                "minimum": -180,
                                "maximum": 180
                              },
                              "name": {
                                "type": "string",
                                "maxLength": 256
                              },
                              "address": {
                                "type": "string",
                                "maxLength": 512
                              }
                            },
                            "required": [
                              "latitude",
                              "longitude"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "to",
                          "type",
                          "location"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "connection_id": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 64
                          },
                          "to": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 135
                          },
                          "reply_to": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 256
                          },
                          "tag": {
                            "const": "human_agent"
                          },
                          "delay_ms": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 20000,
                            "default": 0
                          },
                          "typing": {
                            "type": "boolean",
                            "default": false
                          },
                          "biz_opaque_callback_data": {
                            "type": "string",
                            "maxLength": 512
                          },
                          "type": {
                            "const": "contacts"
                          },
                          "contacts": {
                            "type": "array",
                            "minItems": 1,
                            "maxItems": 10,
                            "items": {
                              "type": "object",
                              "properties": {
                                "name": {
                                  "type": "object",
                                  "properties": {
                                    "formatted_name": {
                                      "type": "string",
                                      "minLength": 1,
                                      "maxLength": 256
                                    },
                                    "first_name": {
                                      "type": "string",
                                      "maxLength": 128
                                    },
                                    "last_name": {
                                      "type": "string",
                                      "maxLength": 128
                                    }
                                  },
                                  "required": [
                                    "formatted_name"
                                  ],
                                  "additionalProperties": false
                                },
                                "phones": {
                                  "type": "array",
                                  "maxItems": 10,
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "phone": {
                                        "type": "string",
                                        "minLength": 1,
                                        "maxLength": 64
                                      },
                                      "type": {
                                        "type": "string",
                                        "maxLength": 32
                                      },
                                      "wa_id": {
                                        "type": "string",
                                        "maxLength": 64
                                      }
                                    },
                                    "required": [
                                      "phone"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "emails": {
                                  "type": "array",
                                  "maxItems": 10,
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "email": {
                                        "type": "string",
                                        "minLength": 1,
                                        "maxLength": 128
                                      },
                                      "type": {
                                        "type": "string",
                                        "maxLength": 32
                                      }
                                    },
                                    "required": [
                                      "email"
                                    ],
                                    "additionalProperties": false
                                  }
                                }
                              },
                              "required": [
                                "name"
                              ],
                              "additionalProperties": false
                            }
                          }
                        },
                        "required": [
                          "to",
                          "type",
                          "contacts"
                        ],
                        "additionalProperties": false
                      }
                    ]
                  },
                  {
                    "anyOf": [
                      {
                        "type": "object",
                        "properties": {
                          "connection_id": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 64
                          },
                          "to": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 64
                          },
                          "reply_to": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 256
                          },
                          "tag": {
                            "const": "human_agent"
                          },
                          "delay_ms": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 20000,
                            "default": 0
                          },
                          "typing": {
                            "type": "boolean",
                            "default": false
                          },
                          "type": {
                            "const": "text"
                          },
                          "text": {
                            "type": "object",
                            "properties": {
                              "body": {
                                "type": "string",
                                "minLength": 1
                              },
                              "quick_replies": {
                                "type": "array",
                                "minItems": 1,
                                "maxItems": 13,
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "title": {
                                      "type": "string",
                                      "minLength": 1,
                                      "maxLength": 20
                                    },
                                    "payload": {
                                      "type": "string",
                                      "minLength": 1,
                                      "maxLength": 1000
                                    }
                                  },
                                  "required": [
                                    "title",
                                    "payload"
                                  ],
                                  "additionalProperties": false
                                }
                              }
                            },
                            "required": [
                              "body"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "to",
                          "type",
                          "text"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "connection_id": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 64
                          },
                          "to": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 64
                          },
                          "reply_to": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 256
                          },
                          "tag": {
                            "const": "human_agent"
                          },
                          "delay_ms": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 20000,
                            "default": 0
                          },
                          "typing": {
                            "type": "boolean",
                            "default": false
                          },
                          "type": {
                            "const": "image"
                          },
                          "image": {
                            "type": "object",
                            "properties": {
                              "media_id": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 256
                              },
                              "link": {
                                "type": "string",
                                "format": "uri"
                              }
                            },
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "to",
                          "type",
                          "image"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "connection_id": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 64
                          },
                          "to": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 64
                          },
                          "reply_to": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 256
                          },
                          "tag": {
                            "const": "human_agent"
                          },
                          "delay_ms": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 20000,
                            "default": 0
                          },
                          "typing": {
                            "type": "boolean",
                            "default": false
                          },
                          "type": {
                            "const": "video"
                          },
                          "video": {
                            "type": "object",
                            "properties": {
                              "media_id": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 256
                              },
                              "link": {
                                "type": "string",
                                "format": "uri"
                              }
                            },
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "to",
                          "type",
                          "video"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "connection_id": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 64
                          },
                          "to": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 64
                          },
                          "reply_to": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 256
                          },
                          "tag": {
                            "const": "human_agent"
                          },
                          "delay_ms": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 20000,
                            "default": 0
                          },
                          "typing": {
                            "type": "boolean",
                            "default": false
                          },
                          "type": {
                            "const": "audio"
                          },
                          "audio": {
                            "type": "object",
                            "properties": {
                              "media_id": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 256
                              },
                              "link": {
                                "type": "string",
                                "format": "uri"
                              }
                            },
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "to",
                          "type",
                          "audio"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "connection_id": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 64
                          },
                          "to": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 64
                          },
                          "reply_to": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 256
                          },
                          "tag": {
                            "const": "human_agent"
                          },
                          "delay_ms": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 20000,
                            "default": 0
                          },
                          "typing": {
                            "type": "boolean",
                            "default": false
                          },
                          "type": {
                            "const": "document"
                          },
                          "document": {
                            "type": "object",
                            "properties": {
                              "media_id": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 256
                              },
                              "link": {
                                "type": "string",
                                "format": "uri"
                              }
                            },
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "to",
                          "type",
                          "document"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "connection_id": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 64
                          },
                          "to": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 64
                          },
                          "reply_to": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 256
                          },
                          "tag": {
                            "const": "human_agent"
                          },
                          "delay_ms": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 20000,
                            "default": 0
                          },
                          "typing": {
                            "type": "boolean",
                            "default": false
                          },
                          "type": {
                            "const": "images"
                          },
                          "images": {
                            "type": "object",
                            "properties": {
                              "items": {
                                "type": "array",
                                "minItems": 2,
                                "maxItems": 10,
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "media_id": {
                                      "type": "string",
                                      "minLength": 1,
                                      "maxLength": 256
                                    },
                                    "link": {
                                      "type": "string",
                                      "format": "uri"
                                    }
                                  },
                                  "additionalProperties": false
                                }
                              }
                            },
                            "required": [
                              "items"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "to",
                          "type",
                          "images"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "connection_id": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 64
                          },
                          "to": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 64
                          },
                          "reply_to": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 256
                          },
                          "tag": {
                            "const": "human_agent"
                          },
                          "delay_ms": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 20000,
                            "default": 0
                          },
                          "typing": {
                            "type": "boolean",
                            "default": false
                          },
                          "type": {
                            "const": "like"
                          }
                        },
                        "required": [
                          "to",
                          "type"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "connection_id": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 64
                          },
                          "to": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 64
                          },
                          "reply_to": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 256
                          },
                          "tag": {
                            "const": "human_agent"
                          },
                          "delay_ms": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 20000,
                            "default": 0
                          },
                          "typing": {
                            "type": "boolean",
                            "default": false
                          },
                          "type": {
                            "const": "reaction"
                          },
                          "reaction": {
                            "type": "object",
                            "properties": {
                              "message_id": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 256
                              },
                              "emoji": {
                                "type": "string",
                                "maxLength": 16
                              }
                            },
                            "required": [
                              "message_id",
                              "emoji"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "to",
                          "type",
                          "reaction"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "connection_id": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 64
                          },
                          "to": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 64
                          },
                          "reply_to": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 256
                          },
                          "tag": {
                            "const": "human_agent"
                          },
                          "delay_ms": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 20000,
                            "default": 0
                          },
                          "typing": {
                            "type": "boolean",
                            "default": false
                          },
                          "type": {
                            "const": "share"
                          },
                          "share": {
                            "type": "object",
                            "properties": {
                              "post_id": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 64
                              }
                            },
                            "required": [
                              "post_id"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "to",
                          "type",
                          "share"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "connection_id": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 64
                          },
                          "to": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 64
                          },
                          "reply_to": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 256
                          },
                          "tag": {
                            "const": "human_agent"
                          },
                          "delay_ms": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 20000,
                            "default": 0
                          },
                          "typing": {
                            "type": "boolean",
                            "default": false
                          },
                          "type": {
                            "const": "buttons"
                          },
                          "buttons": {
                            "type": "object",
                            "properties": {
                              "text": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 640
                              },
                              "buttons": {
                                "type": "array",
                                "minItems": 1,
                                "maxItems": 3,
                                "items": {
                                  "anyOf": [
                                    {
                                      "type": "object",
                                      "properties": {
                                        "type": {
                                          "const": "postback"
                                        },
                                        "title": {
                                          "type": "string",
                                          "minLength": 1,
                                          "maxLength": 20
                                        },
                                        "payload": {
                                          "type": "string",
                                          "minLength": 1,
                                          "maxLength": 1000
                                        }
                                      },
                                      "required": [
                                        "type",
                                        "title",
                                        "payload"
                                      ],
                                      "additionalProperties": false
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "type": {
                                          "const": "web_url"
                                        },
                                        "title": {
                                          "type": "string",
                                          "minLength": 1,
                                          "maxLength": 20
                                        },
                                        "url": {
                                          "type": "string",
                                          "format": "uri"
                                        }
                                      },
                                      "required": [
                                        "type",
                                        "title",
                                        "url"
                                      ],
                                      "additionalProperties": false
                                    }
                                  ]
                                }
                              },
                              "quick_replies": {
                                "type": "array",
                                "minItems": 1,
                                "maxItems": 13,
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "title": {
                                      "type": "string",
                                      "minLength": 1,
                                      "maxLength": 20
                                    },
                                    "payload": {
                                      "type": "string",
                                      "minLength": 1,
                                      "maxLength": 1000
                                    }
                                  },
                                  "required": [
                                    "title",
                                    "payload"
                                  ],
                                  "additionalProperties": false
                                }
                              }
                            },
                            "required": [
                              "text",
                              "buttons"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "to",
                          "type",
                          "buttons"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "connection_id": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 64
                          },
                          "to": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 64
                          },
                          "reply_to": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 256
                          },
                          "tag": {
                            "const": "human_agent"
                          },
                          "delay_ms": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 20000,
                            "default": 0
                          },
                          "typing": {
                            "type": "boolean",
                            "default": false
                          },
                          "type": {
                            "const": "cards"
                          },
                          "cards": {
                            "type": "object",
                            "properties": {
                              "cards": {
                                "type": "array",
                                "minItems": 1,
                                "maxItems": 10,
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "title": {
                                      "type": "string",
                                      "minLength": 1,
                                      "maxLength": 80
                                    },
                                    "subtitle": {
                                      "type": "string",
                                      "minLength": 1,
                                      "maxLength": 80
                                    },
                                    "image_url": {
                                      "type": "string",
                                      "format": "uri"
                                    },
                                    "default_url": {
                                      "type": "string",
                                      "format": "uri"
                                    },
                                    "buttons": {
                                      "type": "array",
                                      "minItems": 1,
                                      "maxItems": 3,
                                      "items": {
                                        "anyOf": [
                                          {
                                            "type": "object",
                                            "properties": {
                                              "type": {
                                                "const": "postback"
                                              },
                                              "title": {
                                                "type": "string",
                                                "minLength": 1,
                                                "maxLength": 20
                                              },
                                              "payload": {
                                                "type": "string",
                                                "minLength": 1,
                                                "maxLength": 1000
                                              }
                                            },
                                            "required": [
                                              "type",
                                              "title",
                                              "payload"
                                            ],
                                            "additionalProperties": false
                                          },
                                          {
                                            "type": "object",
                                            "properties": {
                                              "type": {
                                                "const": "web_url"
                                              },
                                              "title": {
                                                "type": "string",
                                                "minLength": 1,
                                                "maxLength": 20
                                              },
                                              "url": {
                                                "type": "string",
                                                "format": "uri"
                                              }
                                            },
                                            "required": [
                                              "type",
                                              "title",
                                              "url"
                                            ],
                                            "additionalProperties": false
                                          }
                                        ]
                                      }
                                    }
                                  },
                                  "required": [
                                    "title"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "quick_replies": {
                                "type": "array",
                                "minItems": 1,
                                "maxItems": 13,
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "title": {
                                      "type": "string",
                                      "minLength": 1,
                                      "maxLength": 20
                                    },
                                    "payload": {
                                      "type": "string",
                                      "minLength": 1,
                                      "maxLength": 1000
                                    }
                                  },
                                  "required": [
                                    "title",
                                    "payload"
                                  ],
                                  "additionalProperties": false
                                }
                              }
                            },
                            "required": [
                              "cards"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "to",
                          "type",
                          "cards"
                        ],
                        "additionalProperties": false
                      }
                    ]
                  },
                  {
                    "anyOf": [
                      {
                        "type": "object",
                        "properties": {
                          "connection_id": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 64
                          },
                          "to": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 64
                          },
                          "reply_to": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 256
                          },
                          "tag": {
                            "const": "human_agent"
                          },
                          "delay_ms": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 20000,
                            "default": 0
                          },
                          "typing": {
                            "type": "boolean",
                            "default": false
                          },
                          "type": {
                            "const": "text"
                          },
                          "text": {
                            "type": "object",
                            "properties": {
                              "body": {
                                "type": "string",
                                "minLength": 1
                              },
                              "quick_replies": {
                                "type": "array",
                                "minItems": 1,
                                "maxItems": 13,
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "title": {
                                      "type": "string",
                                      "minLength": 1,
                                      "maxLength": 20
                                    },
                                    "payload": {
                                      "type": "string",
                                      "minLength": 1,
                                      "maxLength": 1000
                                    }
                                  },
                                  "required": [
                                    "title",
                                    "payload"
                                  ],
                                  "additionalProperties": false
                                }
                              }
                            },
                            "required": [
                              "body"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "to",
                          "type",
                          "text"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "connection_id": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 64
                          },
                          "to": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 64
                          },
                          "reply_to": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 256
                          },
                          "tag": {
                            "const": "human_agent"
                          },
                          "delay_ms": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 20000,
                            "default": 0
                          },
                          "typing": {
                            "type": "boolean",
                            "default": false
                          },
                          "type": {
                            "const": "image"
                          },
                          "image": {
                            "type": "object",
                            "properties": {
                              "media_id": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 256
                              },
                              "link": {
                                "type": "string",
                                "format": "uri"
                              }
                            },
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "to",
                          "type",
                          "image"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "connection_id": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 64
                          },
                          "to": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 64
                          },
                          "reply_to": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 256
                          },
                          "tag": {
                            "const": "human_agent"
                          },
                          "delay_ms": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 20000,
                            "default": 0
                          },
                          "typing": {
                            "type": "boolean",
                            "default": false
                          },
                          "type": {
                            "const": "video"
                          },
                          "video": {
                            "type": "object",
                            "properties": {
                              "media_id": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 256
                              },
                              "link": {
                                "type": "string",
                                "format": "uri"
                              }
                            },
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "to",
                          "type",
                          "video"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "connection_id": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 64
                          },
                          "to": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 64
                          },
                          "reply_to": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 256
                          },
                          "tag": {
                            "const": "human_agent"
                          },
                          "delay_ms": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 20000,
                            "default": 0
                          },
                          "typing": {
                            "type": "boolean",
                            "default": false
                          },
                          "type": {
                            "const": "audio"
                          },
                          "audio": {
                            "type": "object",
                            "properties": {
                              "media_id": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 256
                              },
                              "link": {
                                "type": "string",
                                "format": "uri"
                              }
                            },
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "to",
                          "type",
                          "audio"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "connection_id": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 64
                          },
                          "to": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 64
                          },
                          "reply_to": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 256
                          },
                          "tag": {
                            "const": "human_agent"
                          },
                          "delay_ms": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 20000,
                            "default": 0
                          },
                          "typing": {
                            "type": "boolean",
                            "default": false
                          },
                          "type": {
                            "const": "document"
                          },
                          "document": {
                            "type": "object",
                            "properties": {
                              "media_id": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 256
                              },
                              "link": {
                                "type": "string",
                                "format": "uri"
                              }
                            },
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "to",
                          "type",
                          "document"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "connection_id": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 64
                          },
                          "to": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 64
                          },
                          "reply_to": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 256
                          },
                          "tag": {
                            "const": "human_agent"
                          },
                          "delay_ms": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 20000,
                            "default": 0
                          },
                          "typing": {
                            "type": "boolean",
                            "default": false
                          },
                          "type": {
                            "const": "images"
                          },
                          "images": {
                            "type": "object",
                            "properties": {
                              "items": {
                                "type": "array",
                                "minItems": 2,
                                "maxItems": 1,
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "media_id": {
                                      "type": "string",
                                      "minLength": 1,
                                      "maxLength": 256
                                    },
                                    "link": {
                                      "type": "string",
                                      "format": "uri"
                                    }
                                  },
                                  "additionalProperties": false
                                }
                              }
                            },
                            "required": [
                              "items"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "to",
                          "type",
                          "images"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "connection_id": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 64
                          },
                          "to": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 64
                          },
                          "reply_to": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 256
                          },
                          "tag": {
                            "const": "human_agent"
                          },
                          "delay_ms": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 20000,
                            "default": 0
                          },
                          "typing": {
                            "type": "boolean",
                            "default": false
                          },
                          "type": {
                            "const": "like"
                          }
                        },
                        "required": [
                          "to",
                          "type"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "connection_id": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 64
                          },
                          "to": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 64
                          },
                          "reply_to": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 256
                          },
                          "tag": {
                            "const": "human_agent"
                          },
                          "delay_ms": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 20000,
                            "default": 0
                          },
                          "typing": {
                            "type": "boolean",
                            "default": false
                          },
                          "type": {
                            "const": "reaction"
                          },
                          "reaction": {
                            "type": "object",
                            "properties": {
                              "message_id": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 256
                              },
                              "emoji": {
                                "type": "string",
                                "maxLength": 16
                              }
                            },
                            "required": [
                              "message_id",
                              "emoji"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "to",
                          "type",
                          "reaction"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "connection_id": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 64
                          },
                          "to": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 64
                          },
                          "reply_to": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 256
                          },
                          "tag": {
                            "const": "human_agent"
                          },
                          "delay_ms": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 20000,
                            "default": 0
                          },
                          "typing": {
                            "type": "boolean",
                            "default": false
                          },
                          "type": {
                            "const": "share"
                          },
                          "share": {
                            "type": "object",
                            "properties": {
                              "post_id": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 64
                              }
                            },
                            "required": [
                              "post_id"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "to",
                          "type",
                          "share"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "connection_id": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 64
                          },
                          "to": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 64
                          },
                          "reply_to": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 256
                          },
                          "tag": {
                            "const": "human_agent"
                          },
                          "delay_ms": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 20000,
                            "default": 0
                          },
                          "typing": {
                            "type": "boolean",
                            "default": false
                          },
                          "type": {
                            "const": "buttons"
                          },
                          "buttons": {
                            "type": "object",
                            "properties": {
                              "text": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 640
                              },
                              "buttons": {
                                "type": "array",
                                "minItems": 1,
                                "maxItems": 3,
                                "items": {
                                  "anyOf": [
                                    {
                                      "type": "object",
                                      "properties": {
                                        "type": {
                                          "const": "postback"
                                        },
                                        "title": {
                                          "type": "string",
                                          "minLength": 1,
                                          "maxLength": 20
                                        },
                                        "payload": {
                                          "type": "string",
                                          "minLength": 1,
                                          "maxLength": 1000
                                        }
                                      },
                                      "required": [
                                        "type",
                                        "title",
                                        "payload"
                                      ],
                                      "additionalProperties": false
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "type": {
                                          "const": "web_url"
                                        },
                                        "title": {
                                          "type": "string",
                                          "minLength": 1,
                                          "maxLength": 20
                                        },
                                        "url": {
                                          "type": "string",
                                          "format": "uri"
                                        }
                                      },
                                      "required": [
                                        "type",
                                        "title",
                                        "url"
                                      ],
                                      "additionalProperties": false
                                    }
                                  ]
                                }
                              },
                              "quick_replies": {
                                "type": "array",
                                "minItems": 1,
                                "maxItems": 13,
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "title": {
                                      "type": "string",
                                      "minLength": 1,
                                      "maxLength": 20
                                    },
                                    "payload": {
                                      "type": "string",
                                      "minLength": 1,
                                      "maxLength": 1000
                                    }
                                  },
                                  "required": [
                                    "title",
                                    "payload"
                                  ],
                                  "additionalProperties": false
                                }
                              }
                            },
                            "required": [
                              "text",
                              "buttons"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "to",
                          "type",
                          "buttons"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "connection_id": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 64
                          },
                          "to": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 64
                          },
                          "reply_to": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 256
                          },
                          "tag": {
                            "const": "human_agent"
                          },
                          "delay_ms": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 20000,
                            "default": 0
                          },
                          "typing": {
                            "type": "boolean",
                            "default": false
                          },
                          "type": {
                            "const": "cards"
                          },
                          "cards": {
                            "type": "object",
                            "properties": {
                              "cards": {
                                "type": "array",
                                "minItems": 1,
                                "maxItems": 10,
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "title": {
                                      "type": "string",
                                      "minLength": 1,
                                      "maxLength": 80
                                    },
                                    "subtitle": {
                                      "type": "string",
                                      "minLength": 1,
                                      "maxLength": 80
                                    },
                                    "image_url": {
                                      "type": "string",
                                      "format": "uri"
                                    },
                                    "default_url": {
                                      "type": "string",
                                      "format": "uri"
                                    },
                                    "buttons": {
                                      "type": "array",
                                      "minItems": 1,
                                      "maxItems": 3,
                                      "items": {
                                        "anyOf": [
                                          {
                                            "type": "object",
                                            "properties": {
                                              "type": {
                                                "const": "postback"
                                              },
                                              "title": {
                                                "type": "string",
                                                "minLength": 1,
                                                "maxLength": 20
                                              },
                                              "payload": {
                                                "type": "string",
                                                "minLength": 1,
                                                "maxLength": 1000
                                              }
                                            },
                                            "required": [
                                              "type",
                                              "title",
                                              "payload"
                                            ],
                                            "additionalProperties": false
                                          },
                                          {
                                            "type": "object",
                                            "properties": {
                                              "type": {
                                                "const": "web_url"
                                              },
                                              "title": {
                                                "type": "string",
                                                "minLength": 1,
                                                "maxLength": 20
                                              },
                                              "url": {
                                                "type": "string",
                                                "format": "uri"
                                              }
                                            },
                                            "required": [
                                              "type",
                                              "title",
                                              "url"
                                            ],
                                            "additionalProperties": false
                                          }
                                        ]
                                      }
                                    }
                                  },
                                  "required": [
                                    "title"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "quick_replies": {
                                "type": "array",
                                "minItems": 1,
                                "maxItems": 13,
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "title": {
                                      "type": "string",
                                      "minLength": 1,
                                      "maxLength": 20
                                    },
                                    "payload": {
                                      "type": "string",
                                      "minLength": 1,
                                      "maxLength": 1000
                                    }
                                  },
                                  "required": [
                                    "title",
                                    "payload"
                                  ],
                                  "additionalProperties": false
                                }
                              }
                            },
                            "required": [
                              "cards"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "to",
                          "type",
                          "cards"
                        ],
                        "additionalProperties": false
                      }
                    ]
                  }
                ],
                "description": "Message to send, in the format of the chosen `type` and of the connection's channel."
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The message, stored and accepted by Meta.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Message ID at Messajo (`msg_…`).",
                      "examples": [
                        "msg_0193a1b2c3d47e8f9a0b1c2d3e4f5a6b"
                      ]
                    },
                    "external_id": {
                      "type": "string",
                      "description": "Message ID at Meta (`wamid`)."
                    },
                    "status": {
                      "const": "queued",
                      "description": "Message status; starts as `queued` and changes with webhooks."
                    },
                    "meta_status": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Meta's answer: `accepted`, `held_for_quality_assessment`, `paused` or `null`."
                    },
                    "conversation_id": {
                      "type": "string",
                      "description": "Conversation of the message."
                    },
                    "contact_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Recipient contact."
                    },
                    "created_at": {
                      "type": "string",
                      "description": "When the message was stored (ISO 8601, UTC)."
                    }
                  },
                  "required": [
                    "id",
                    "external_id",
                    "status",
                    "meta_status",
                    "conversation_id",
                    "contact_id",
                    "created_at"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ]
      },
      "get": {
        "operationId": "listMessages",
        "summary": "List messages",
        "description": "Lists the organization's messages with filters. The `since`…`until` range always stays within retention: a larger request is cut, without an error. Permission: `read`.",
        "tags": [
          "history"
        ],
        "parameters": [
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 512,
              "description": "Opaque cursor for the next page: the `next_cursor` of the previous response, with the same filters. Tampered or from another route → `400 invalid_cursor`."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50,
              "description": "Items per page, from 1 to 100 (default 50)."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "order",
            "in": "query",
            "schema": {
              "enum": [
                "desc",
                "asc"
              ],
              "type": "string",
              "default": "desc",
              "description": "Order: `desc` (default, newest first) or `asc`."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "direction",
            "in": "query",
            "schema": {
              "enum": [
                "inbound",
                "outbound"
              ],
              "type": "string",
              "description": "Direction: `inbound` (received) or `outbound` (sent)."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "type",
            "in": "query",
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "Content type, e.g. `text`, `image`, `template`."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "since",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time",
              "description": "Start of the range (ISO 8601). Default and floor: now minus the organization's retention."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "until",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time",
              "description": "End of the range (ISO 8601). Default: now."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "connection_id",
            "in": "query",
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "Connection ID."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "contact_id",
            "in": "query",
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "Contact ID."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "conversation_id",
            "in": "query",
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "Conversation ID."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "enum": [
                "received",
                "queued",
                "sent",
                "delivered",
                "read",
                "played",
                "failed",
                "deleted"
              ],
              "type": "string",
              "description": "Message status."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "source",
            "in": "query",
            "schema": {
              "enum": [
                "customer",
                "api",
                "business_app",
                "history",
                "campaign"
              ],
              "type": "string",
              "description": "Source: `customer`, `api`, `business_app`, `history` or `campaign`."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "campaign_id",
            "in": "query",
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "Only messages from this campaign."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          }
        ],
        "responses": {
          "200": {
            "description": "A page of messages.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "description": "Message ID at Messajo (`msg_…`).",
                            "examples": [
                              "msg_0193a1b2c3d47e8f9a0b1c2d3e4f5a6b"
                            ]
                          },
                          "external_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Message ID at Meta; `null` before acceptance."
                          },
                          "direction": {
                            "enum": [
                              "inbound",
                              "outbound"
                            ],
                            "type": "string",
                            "description": "Direction: `inbound` (received) or `outbound` (sent)."
                          },
                          "source": {
                            "enum": [
                              "customer",
                              "api",
                              "business_app",
                              "history",
                              "campaign"
                            ],
                            "type": "string",
                            "description": "Source: `customer`, `api`, `business_app`, `history` or `campaign`."
                          },
                          "timestamp": {
                            "type": "string",
                            "description": "When the message happened (ISO 8601, UTC)."
                          },
                          "content": {
                            "anyOf": [
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "const": "text"
                                  },
                                  "body": {
                                    "type": "string"
                                  },
                                  "quick_replies": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "title": {
                                          "type": "string"
                                        },
                                        "payload": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "title",
                                        "payload"
                                      ]
                                    }
                                  }
                                },
                                "required": [
                                  "type",
                                  "body"
                                ]
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "enum": [
                                      "image",
                                      "video",
                                      "document"
                                    ]
                                  },
                                  "media": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "mime_type": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "sha256": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "size_bytes": {
                                        "anyOf": [
                                          {
                                            "type": "integer",
                                            "minimum": 0,
                                            "maximum": 9007199254740991
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "filename": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "caption": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "status": {
                                        "enum": [
                                          "pending",
                                          "stored",
                                          "failed"
                                        ],
                                        "type": "string"
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "mime_type",
                                      "sha256",
                                      "size_bytes",
                                      "filename",
                                      "caption",
                                      "status"
                                    ]
                                  }
                                },
                                "required": [
                                  "type",
                                  "media"
                                ]
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "const": "audio"
                                  },
                                  "media": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "mime_type": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "sha256": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "size_bytes": {
                                        "anyOf": [
                                          {
                                            "type": "integer",
                                            "minimum": 0,
                                            "maximum": 9007199254740991
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "filename": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "caption": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "status": {
                                        "enum": [
                                          "pending",
                                          "stored",
                                          "failed"
                                        ],
                                        "type": "string"
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "mime_type",
                                      "sha256",
                                      "size_bytes",
                                      "filename",
                                      "caption",
                                      "status"
                                    ]
                                  },
                                  "voice": {
                                    "type": "boolean"
                                  }
                                },
                                "required": [
                                  "type",
                                  "media",
                                  "voice"
                                ]
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "const": "images"
                                  },
                                  "images": {
                                    "type": "array",
                                    "minItems": 1,
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "id": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "mime_type": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "sha256": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "size_bytes": {
                                          "anyOf": [
                                            {
                                              "type": "integer",
                                              "minimum": 0,
                                              "maximum": 9007199254740991
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "filename": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "caption": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "status": {
                                          "enum": [
                                            "pending",
                                            "stored",
                                            "failed"
                                          ],
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "id",
                                        "mime_type",
                                        "sha256",
                                        "size_bytes",
                                        "filename",
                                        "caption",
                                        "status"
                                      ]
                                    }
                                  }
                                },
                                "required": [
                                  "type",
                                  "images"
                                ]
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "const": "like"
                                  }
                                },
                                "required": [
                                  "type"
                                ]
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "const": "sticker"
                                  },
                                  "media": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "mime_type": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "sha256": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "size_bytes": {
                                        "anyOf": [
                                          {
                                            "type": "integer",
                                            "minimum": 0,
                                            "maximum": 9007199254740991
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "filename": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "caption": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "status": {
                                        "enum": [
                                          "pending",
                                          "stored",
                                          "failed"
                                        ],
                                        "type": "string"
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "mime_type",
                                      "sha256",
                                      "size_bytes",
                                      "filename",
                                      "caption",
                                      "status"
                                    ]
                                  },
                                  "animated": {
                                    "type": "boolean"
                                  }
                                },
                                "required": [
                                  "type",
                                  "media",
                                  "animated"
                                ]
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "const": "location"
                                  },
                                  "latitude": {
                                    "type": "number"
                                  },
                                  "longitude": {
                                    "type": "number"
                                  },
                                  "name": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "address": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "url": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  }
                                },
                                "required": [
                                  "type",
                                  "latitude",
                                  "longitude",
                                  "name",
                                  "address",
                                  "url"
                                ]
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "const": "contacts"
                                  },
                                  "contacts": {
                                    "type": "array",
                                    "minItems": 1,
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "name": {
                                          "type": "object",
                                          "properties": {
                                            "formatted_name": {
                                              "type": "string"
                                            },
                                            "first_name": {
                                              "anyOf": [
                                                {
                                                  "type": "string"
                                                },
                                                {
                                                  "type": "null"
                                                }
                                              ]
                                            },
                                            "last_name": {
                                              "anyOf": [
                                                {
                                                  "type": "string"
                                                },
                                                {
                                                  "type": "null"
                                                }
                                              ]
                                            }
                                          },
                                          "required": [
                                            "formatted_name",
                                            "first_name",
                                            "last_name"
                                          ]
                                        },
                                        "phones": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "properties": {
                                              "phone": {
                                                "type": "string"
                                              },
                                              "wa_id": {
                                                "anyOf": [
                                                  {
                                                    "type": "string"
                                                  },
                                                  {
                                                    "type": "null"
                                                  }
                                                ]
                                              },
                                              "type": {
                                                "anyOf": [
                                                  {
                                                    "type": "string"
                                                  },
                                                  {
                                                    "type": "null"
                                                  }
                                                ]
                                              }
                                            },
                                            "required": [
                                              "phone",
                                              "wa_id",
                                              "type"
                                            ]
                                          }
                                        },
                                        "emails": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "properties": {
                                              "email": {
                                                "type": "string"
                                              },
                                              "type": {
                                                "anyOf": [
                                                  {
                                                    "type": "string"
                                                  },
                                                  {
                                                    "type": "null"
                                                  }
                                                ]
                                              }
                                            },
                                            "required": [
                                              "email",
                                              "type"
                                            ]
                                          }
                                        }
                                      },
                                      "required": [
                                        "name",
                                        "phones",
                                        "emails"
                                      ]
                                    }
                                  }
                                },
                                "required": [
                                  "type",
                                  "contacts"
                                ]
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "const": "reaction"
                                  },
                                  "message_id": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "external_message_id": {
                                    "type": "string"
                                  },
                                  "emoji": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  }
                                },
                                "required": [
                                  "type",
                                  "message_id",
                                  "external_message_id",
                                  "emoji"
                                ]
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "const": "reply"
                                  },
                                  "kind": {
                                    "enum": [
                                      "button",
                                      "list",
                                      "quick_reply",
                                      "postback",
                                      "flow"
                                    ],
                                    "type": "string"
                                  },
                                  "id": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "title": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "description": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "payload": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  }
                                },
                                "required": [
                                  "type",
                                  "kind",
                                  "id",
                                  "title",
                                  "description",
                                  "payload"
                                ]
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "const": "order"
                                  },
                                  "catalog_id": {
                                    "type": "string"
                                  },
                                  "items": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "product_retailer_id": {
                                          "type": "string"
                                        },
                                        "quantity": {
                                          "type": "integer",
                                          "minimum": -9007199254740991,
                                          "maximum": 9007199254740991,
                                          "exclusiveMinimum": 0
                                        },
                                        "item_price": {
                                          "type": "number",
                                          "minimum": 0
                                        },
                                        "currency": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "product_retailer_id",
                                        "quantity",
                                        "item_price",
                                        "currency"
                                      ]
                                    }
                                  },
                                  "note": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  }
                                },
                                "required": [
                                  "type",
                                  "catalog_id",
                                  "items",
                                  "note"
                                ]
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "const": "call_permission_reply"
                                  },
                                  "response": {
                                    "enum": [
                                      "accept",
                                      "reject"
                                    ],
                                    "type": "string"
                                  },
                                  "permanent": {
                                    "type": "boolean"
                                  },
                                  "expires_at": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "date-time"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "source": {
                                    "enum": [
                                      "user_action",
                                      "automatic"
                                    ],
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "type",
                                  "response",
                                  "permanent",
                                  "expires_at",
                                  "source"
                                ]
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "const": "share"
                                  },
                                  "kind": {
                                    "enum": [
                                      "post",
                                      "reel",
                                      "story",
                                      "story_mention",
                                      "link"
                                    ],
                                    "type": "string"
                                  },
                                  "url": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "external_id": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  }
                                },
                                "required": [
                                  "type",
                                  "kind",
                                  "url",
                                  "external_id"
                                ]
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "const": "system"
                                  },
                                  "kind": {
                                    "type": "string"
                                  },
                                  "body": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  }
                                },
                                "required": [
                                  "type",
                                  "kind",
                                  "body"
                                ]
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "const": "unsupported"
                                  },
                                  "meta_type": {
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "type",
                                  "meta_type"
                                ]
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "const": "template"
                                  },
                                  "name": {
                                    "type": "string"
                                  },
                                  "language": {
                                    "type": "string"
                                  },
                                  "components": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    }
                                  },
                                  "otp": {
                                    "type": "boolean"
                                  }
                                },
                                "required": [
                                  "type",
                                  "name",
                                  "language",
                                  "components"
                                ]
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "const": "interactive"
                                  },
                                  "kind": {
                                    "enum": [
                                      "button",
                                      "list",
                                      "cta_url",
                                      "location_request",
                                      "flow",
                                      "product",
                                      "product_list",
                                      "catalog_message",
                                      "order_details",
                                      "order_status",
                                      "call_permission_request"
                                    ],
                                    "type": "string"
                                  },
                                  "body": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "interactive": {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {}
                                  }
                                },
                                "required": [
                                  "type",
                                  "kind",
                                  "body",
                                  "interactive"
                                ]
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "const": "buttons"
                                  },
                                  "body": {
                                    "type": "string"
                                  },
                                  "buttons": {
                                    "type": "array",
                                    "minItems": 1,
                                    "items": {
                                      "anyOf": [
                                        {
                                          "type": "object",
                                          "properties": {
                                            "type": {
                                              "const": "postback"
                                            },
                                            "title": {
                                              "type": "string"
                                            },
                                            "payload": {
                                              "type": "string"
                                            }
                                          },
                                          "required": [
                                            "type",
                                            "title",
                                            "payload"
                                          ]
                                        },
                                        {
                                          "type": "object",
                                          "properties": {
                                            "type": {
                                              "const": "web_url"
                                            },
                                            "title": {
                                              "type": "string"
                                            },
                                            "url": {
                                              "type": "string"
                                            }
                                          },
                                          "required": [
                                            "type",
                                            "title",
                                            "url"
                                          ]
                                        }
                                      ]
                                    }
                                  },
                                  "quick_replies": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "title": {
                                          "type": "string"
                                        },
                                        "payload": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "title",
                                        "payload"
                                      ]
                                    }
                                  }
                                },
                                "required": [
                                  "type",
                                  "body",
                                  "buttons"
                                ]
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "const": "cards"
                                  },
                                  "cards": {
                                    "type": "array",
                                    "minItems": 1,
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "title": {
                                          "type": "string"
                                        },
                                        "subtitle": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "image_url": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "default_url": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "buttons": {
                                          "type": "array",
                                          "items": {
                                            "anyOf": [
                                              {
                                                "type": "object",
                                                "properties": {
                                                  "type": {
                                                    "const": "postback"
                                                  },
                                                  "title": {
                                                    "type": "string"
                                                  },
                                                  "payload": {
                                                    "type": "string"
                                                  }
                                                },
                                                "required": [
                                                  "type",
                                                  "title",
                                                  "payload"
                                                ]
                                              },
                                              {
                                                "type": "object",
                                                "properties": {
                                                  "type": {
                                                    "const": "web_url"
                                                  },
                                                  "title": {
                                                    "type": "string"
                                                  },
                                                  "url": {
                                                    "type": "string"
                                                  }
                                                },
                                                "required": [
                                                  "type",
                                                  "title",
                                                  "url"
                                                ]
                                              }
                                            ]
                                          }
                                        }
                                      },
                                      "required": [
                                        "title",
                                        "subtitle",
                                        "image_url",
                                        "default_url",
                                        "buttons"
                                      ]
                                    }
                                  },
                                  "quick_replies": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "title": {
                                          "type": "string"
                                        },
                                        "payload": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "title",
                                        "payload"
                                      ]
                                    }
                                  }
                                },
                                "required": [
                                  "type",
                                  "cards"
                                ]
                              }
                            ],
                            "description": "Normalized content (the same as in `message.*` events)."
                          },
                          "context": {
                            "anyOf": [
                              {
                                "type": "object",
                                "properties": {
                                  "reply_to": {
                                    "anyOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "message_id": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "external_id": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "message_id",
                                          "external_id"
                                        ]
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "forwarded": {
                                    "type": "boolean"
                                  },
                                  "frequently_forwarded": {
                                    "type": "boolean"
                                  },
                                  "referral": {
                                    "anyOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "source_type": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "source_id": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "source_url": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "headline": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "ctwa_clid": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          }
                                        },
                                        "required": [
                                          "source_type",
                                          "source_id",
                                          "source_url",
                                          "headline",
                                          "ctwa_clid"
                                        ]
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "reply_to_story": {
                                    "anyOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "external_id": {
                                            "type": "string"
                                          },
                                          "url": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          }
                                        },
                                        "required": [
                                          "external_id",
                                          "url"
                                        ]
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "standby": {
                                    "type": "boolean"
                                  }
                                },
                                "required": [
                                  "reply_to",
                                  "forwarded",
                                  "frequently_forwarded",
                                  "referral"
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Context: reply, forward, source ad; `null` = no context."
                          },
                          "conversation_id": {
                            "type": "string",
                            "description": "Conversation ID."
                          },
                          "contact_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Contact ID."
                          },
                          "status": {
                            "enum": [
                              "received",
                              "queued",
                              "sent",
                              "delivered",
                              "read",
                              "played",
                              "failed",
                              "deleted"
                            ],
                            "type": "string",
                            "description": "Message status."
                          },
                          "sent_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Sent (ISO 8601, UTC)."
                          },
                          "delivered_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Delivered (ISO 8601, UTC)."
                          },
                          "read_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Read (ISO 8601, UTC)."
                          },
                          "failed_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Failed (ISO 8601, UTC)."
                          },
                          "edited_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Edited (ISO 8601, UTC)."
                          },
                          "revoked_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Deleted by the sender (ISO 8601, UTC)."
                          },
                          "error": {
                            "anyOf": [
                              {
                                "type": "object",
                                "propertyNames": {
                                  "type": "string"
                                },
                                "additionalProperties": {}
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Send error, in Meta's format; `null` = no error."
                          },
                          "campaign": {
                            "anyOf": [
                              {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "description": "Only messages from this campaign."
                                  },
                                  "recipient_id": {
                                    "type": "string",
                                    "description": "Campaign recipient ID."
                                  }
                                },
                                "required": [
                                  "id",
                                  "recipient_id"
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Campaign that sent the message; `null` outside campaigns."
                          }
                        },
                        "required": [
                          "id",
                          "external_id",
                          "direction",
                          "source",
                          "timestamp",
                          "content",
                          "context",
                          "conversation_id",
                          "contact_id",
                          "status",
                          "sent_at",
                          "delivered_at",
                          "read_at",
                          "failed_at",
                          "edited_at",
                          "revoked_at",
                          "error",
                          "campaign"
                        ]
                      },
                      "description": "Page items, newest first."
                    },
                    "next_cursor": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Cursor for the next page; `null` when there are no more items."
                    }
                  },
                  "required": [
                    "data",
                    "next_cursor"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/messages/{id}/read": {
      "post": {
        "operationId": "markMessageRead",
        "summary": "Mark as read",
        "description": "Marks a received message as read. With `typing: true` it also shows \"typing…\" to the contact; on WhatsApp \"typing\" always marks as read. Permission: `send`.",
        "tags": [
          "messages"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Received message (`msg_…`)."
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "typing": {
                    "type": "boolean",
                    "default": false,
                    "description": "Also show \"typing…\"."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Confirmation.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Received message (`msg_…`)."
                    },
                    "read": {
                      "const": true,
                      "description": "Always `true`."
                    }
                  },
                  "required": [
                    "id",
                    "read"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/templates": {
      "get": {
        "operationId": "listTemplates",
        "summary": "List templates",
        "description": "Lists the templates of the organization's WhatsApp accounts, with filters. A key bound to connections must send `connection_id`. Permission: `read`.",
        "tags": [
          "templates"
        ],
        "parameters": [
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "Next page cursor: the `next_cursor` of the previous response."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50,
              "description": "Items per page, from 1 to 100 (default 50)."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "connection_id",
            "in": "query",
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "Connection whose WhatsApp account is used. Optional with a connection key (uses the key's connection)."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "enum": [
                "APPROVED",
                "PENDING",
                "REJECTED",
                "PAUSED",
                "DISABLED",
                "IN_APPEAL",
                "PENDING_DELETION",
                "DELETED",
                "ARCHIVED",
                "LIMIT_EXCEEDED",
                "LOCKED",
                "FLAGGED",
                "REINSTATED"
              ],
              "type": "string",
              "description": "Status at Meta, e.g. `APPROVED`, `PENDING`, `REJECTED`."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "category",
            "in": "query",
            "schema": {
              "enum": [
                "MARKETING",
                "UTILITY",
                "AUTHENTICATION"
              ],
              "type": "string",
              "description": "Category: `MARKETING`, `UTILITY` or `AUTHENTICATION`."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "language",
            "in": "query",
            "schema": {
              "type": "string",
              "description": "Language, e.g. `en_US`."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "name",
            "in": "query",
            "schema": {
              "type": "string",
              "description": "Name (lowercase letters, digits and `_`)."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          }
        ],
        "responses": {
          "200": {
            "description": "A page of templates.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "description": "Template ID at Messajo (`tpl_…`).",
                            "examples": [
                              "tpl_0193a1b2c3d47e8f9a0b1c2d3e4f5a6b"
                            ]
                          },
                          "messaging_account_id": {
                            "type": "string",
                            "description": "WhatsApp Business account (WABA) of the template."
                          },
                          "external_id": {
                            "type": "string",
                            "description": "Template ID at Meta."
                          },
                          "name": {
                            "type": "string",
                            "description": "Name (lowercase letters, digits and `_`)."
                          },
                          "language": {
                            "type": "string",
                            "description": "Language, e.g. `en_US`."
                          },
                          "category": {
                            "enum": [
                              "MARKETING",
                              "UTILITY",
                              "AUTHENTICATION"
                            ],
                            "type": "string",
                            "description": "Category: `MARKETING`, `UTILITY` or `AUTHENTICATION`."
                          },
                          "previous_category": {
                            "anyOf": [
                              {
                                "enum": [
                                  "MARKETING",
                                  "UTILITY",
                                  "AUTHENTICATION"
                                ],
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Previous category, when Meta reclassified it."
                          },
                          "status": {
                            "enum": [
                              "APPROVED",
                              "PENDING",
                              "REJECTED",
                              "PAUSED",
                              "DISABLED",
                              "IN_APPEAL",
                              "PENDING_DELETION",
                              "DELETED",
                              "ARCHIVED",
                              "LIMIT_EXCEEDED",
                              "LOCKED",
                              "FLAGGED",
                              "REINSTATED"
                            ],
                            "type": "string",
                            "description": "Status at Meta, e.g. `APPROVED`, `PENDING`, `REJECTED`."
                          },
                          "rejected_reason": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Rejection reason, when there is one."
                          },
                          "quality_score": {
                            "enum": [
                              "GREEN",
                              "YELLOW",
                              "RED",
                              "UNKNOWN"
                            ],
                            "type": "string",
                            "description": "Quality: `GREEN`, `YELLOW`, `RED` or `UNKNOWN`."
                          },
                          "parameter_format": {
                            "enum": [
                              "POSITIONAL",
                              "NAMED"
                            ],
                            "type": "string",
                            "description": "Variable format: `POSITIONAL` or `NAMED`."
                          },
                          "components": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "propertyNames": {
                                "type": "string"
                              },
                              "additionalProperties": {}
                            },
                            "description": "Components in Meta's format (`HEADER`, `BODY`, `FOOTER`, `BUTTONS`)."
                          },
                          "last_synced_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Last read from Meta (ISO 8601, UTC)."
                          },
                          "status_updated_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Last status change (ISO 8601, UTC)."
                          },
                          "created_at": {
                            "type": "string",
                            "description": "When it was created at Messajo (ISO 8601, UTC)."
                          },
                          "updated_at": {
                            "type": "string",
                            "description": "Last change (ISO 8601, UTC)."
                          }
                        },
                        "required": [
                          "id",
                          "messaging_account_id",
                          "external_id",
                          "name",
                          "language",
                          "category",
                          "previous_category",
                          "status",
                          "rejected_reason",
                          "quality_score",
                          "parameter_format",
                          "components",
                          "last_synced_at",
                          "status_updated_at",
                          "created_at",
                          "updated_at"
                        ]
                      },
                      "description": "Page items, newest first."
                    },
                    "next_cursor": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Cursor for the next page; `null` when there are no more items."
                    }
                  },
                  "required": [
                    "data",
                    "next_cursor"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "createTemplate",
        "summary": "Create a template",
        "description": "Creates the template in the connection's WhatsApp account and sends it to Meta's review; the status changes with the `template.status` event. Permission: `templates`.",
        "tags": [
          "templates"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "connection_id": {
                    "type": "string",
                    "minLength": 1,
                    "description": "Connection whose WhatsApp account is used. Optional with a connection key (uses the key's connection)."
                  },
                  "name": {
                    "type": "string",
                    "pattern": "^[a-z0-9_]{1,512}$",
                    "description": "Name (lowercase letters, digits and `_`)."
                  },
                  "language": {
                    "type": "string",
                    "pattern": "^[a-z]{2,3}(_[A-Z]{2})?$",
                    "description": "Language, e.g. `en_US`."
                  },
                  "category": {
                    "enum": [
                      "MARKETING",
                      "UTILITY",
                      "AUTHENTICATION"
                    ],
                    "type": "string",
                    "description": "Category: `MARKETING`, `UTILITY` or `AUTHENTICATION`."
                  },
                  "components": {
                    "type": "array",
                    "minItems": 1,
                    "items": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "enum": [
                            "HEADER",
                            "BODY",
                            "FOOTER",
                            "BUTTONS"
                          ],
                          "type": "string"
                        },
                        "format": {
                          "enum": [
                            "TEXT",
                            "IMAGE",
                            "VIDEO",
                            "DOCUMENT",
                            "LOCATION"
                          ],
                          "type": "string"
                        },
                        "text": {
                          "type": "string",
                          "minLength": 1
                        },
                        "buttons": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "type": {
                                "enum": [
                                  "QUICK_REPLY",
                                  "URL",
                                  "PHONE_NUMBER",
                                  "COPY_CODE",
                                  "OTP",
                                  "FLOW",
                                  "CATALOG",
                                  "MPM",
                                  "VOICE_CALL"
                                ],
                                "type": "string"
                              }
                            },
                            "required": [
                              "type"
                            ],
                            "additionalProperties": {}
                          }
                        },
                        "example": {
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {}
                        }
                      },
                      "required": [
                        "type"
                      ],
                      "additionalProperties": {}
                    },
                    "description": "Components in Meta's format (`HEADER`, `BODY`, `FOOTER`, `BUTTONS`)."
                  },
                  "parameter_format": {
                    "enum": [
                      "POSITIONAL",
                      "NAMED"
                    ],
                    "type": "string",
                    "description": "Variable format: `POSITIONAL` or `NAMED`."
                  }
                },
                "required": [
                  "name",
                  "language",
                  "category",
                  "components"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The created template.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Template ID at Messajo (`tpl_…`).",
                      "examples": [
                        "tpl_0193a1b2c3d47e8f9a0b1c2d3e4f5a6b"
                      ]
                    },
                    "messaging_account_id": {
                      "type": "string",
                      "description": "WhatsApp Business account (WABA) of the template."
                    },
                    "external_id": {
                      "type": "string",
                      "description": "Template ID at Meta."
                    },
                    "name": {
                      "type": "string",
                      "description": "Name (lowercase letters, digits and `_`)."
                    },
                    "language": {
                      "type": "string",
                      "description": "Language, e.g. `en_US`."
                    },
                    "category": {
                      "enum": [
                        "MARKETING",
                        "UTILITY",
                        "AUTHENTICATION"
                      ],
                      "type": "string",
                      "description": "Category: `MARKETING`, `UTILITY` or `AUTHENTICATION`."
                    },
                    "previous_category": {
                      "anyOf": [
                        {
                          "enum": [
                            "MARKETING",
                            "UTILITY",
                            "AUTHENTICATION"
                          ],
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Previous category, when Meta reclassified it."
                    },
                    "status": {
                      "enum": [
                        "APPROVED",
                        "PENDING",
                        "REJECTED",
                        "PAUSED",
                        "DISABLED",
                        "IN_APPEAL",
                        "PENDING_DELETION",
                        "DELETED",
                        "ARCHIVED",
                        "LIMIT_EXCEEDED",
                        "LOCKED",
                        "FLAGGED",
                        "REINSTATED"
                      ],
                      "type": "string",
                      "description": "Status at Meta, e.g. `APPROVED`, `PENDING`, `REJECTED`."
                    },
                    "rejected_reason": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Rejection reason, when there is one."
                    },
                    "quality_score": {
                      "enum": [
                        "GREEN",
                        "YELLOW",
                        "RED",
                        "UNKNOWN"
                      ],
                      "type": "string",
                      "description": "Quality: `GREEN`, `YELLOW`, `RED` or `UNKNOWN`."
                    },
                    "parameter_format": {
                      "enum": [
                        "POSITIONAL",
                        "NAMED"
                      ],
                      "type": "string",
                      "description": "Variable format: `POSITIONAL` or `NAMED`."
                    },
                    "components": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "propertyNames": {
                          "type": "string"
                        },
                        "additionalProperties": {}
                      },
                      "description": "Components in Meta's format (`HEADER`, `BODY`, `FOOTER`, `BUTTONS`)."
                    },
                    "last_synced_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Last read from Meta (ISO 8601, UTC)."
                    },
                    "status_updated_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Last status change (ISO 8601, UTC)."
                    },
                    "created_at": {
                      "type": "string",
                      "description": "When it was created at Messajo (ISO 8601, UTC)."
                    },
                    "updated_at": {
                      "type": "string",
                      "description": "Last change (ISO 8601, UTC)."
                    }
                  },
                  "required": [
                    "id",
                    "messaging_account_id",
                    "external_id",
                    "name",
                    "language",
                    "category",
                    "previous_category",
                    "status",
                    "rejected_reason",
                    "quality_score",
                    "parameter_format",
                    "components",
                    "last_synced_at",
                    "status_updated_at",
                    "created_at",
                    "updated_at"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ]
      }
    },
    "/templates/{id}": {
      "get": {
        "operationId": "getTemplate",
        "summary": "Get a template",
        "description": "Returns the template with status, category and components. Permission: `read`.",
        "tags": [
          "templates"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Template ID at Messajo (`tpl_…`)."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The template.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Template ID at Messajo (`tpl_…`).",
                      "examples": [
                        "tpl_0193a1b2c3d47e8f9a0b1c2d3e4f5a6b"
                      ]
                    },
                    "messaging_account_id": {
                      "type": "string",
                      "description": "WhatsApp Business account (WABA) of the template."
                    },
                    "external_id": {
                      "type": "string",
                      "description": "Template ID at Meta."
                    },
                    "name": {
                      "type": "string",
                      "description": "Name (lowercase letters, digits and `_`)."
                    },
                    "language": {
                      "type": "string",
                      "description": "Language, e.g. `en_US`."
                    },
                    "category": {
                      "enum": [
                        "MARKETING",
                        "UTILITY",
                        "AUTHENTICATION"
                      ],
                      "type": "string",
                      "description": "Category: `MARKETING`, `UTILITY` or `AUTHENTICATION`."
                    },
                    "previous_category": {
                      "anyOf": [
                        {
                          "enum": [
                            "MARKETING",
                            "UTILITY",
                            "AUTHENTICATION"
                          ],
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Previous category, when Meta reclassified it."
                    },
                    "status": {
                      "enum": [
                        "APPROVED",
                        "PENDING",
                        "REJECTED",
                        "PAUSED",
                        "DISABLED",
                        "IN_APPEAL",
                        "PENDING_DELETION",
                        "DELETED",
                        "ARCHIVED",
                        "LIMIT_EXCEEDED",
                        "LOCKED",
                        "FLAGGED",
                        "REINSTATED"
                      ],
                      "type": "string",
                      "description": "Status at Meta, e.g. `APPROVED`, `PENDING`, `REJECTED`."
                    },
                    "rejected_reason": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Rejection reason, when there is one."
                    },
                    "quality_score": {
                      "enum": [
                        "GREEN",
                        "YELLOW",
                        "RED",
                        "UNKNOWN"
                      ],
                      "type": "string",
                      "description": "Quality: `GREEN`, `YELLOW`, `RED` or `UNKNOWN`."
                    },
                    "parameter_format": {
                      "enum": [
                        "POSITIONAL",
                        "NAMED"
                      ],
                      "type": "string",
                      "description": "Variable format: `POSITIONAL` or `NAMED`."
                    },
                    "components": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "propertyNames": {
                          "type": "string"
                        },
                        "additionalProperties": {}
                      },
                      "description": "Components in Meta's format (`HEADER`, `BODY`, `FOOTER`, `BUTTONS`)."
                    },
                    "last_synced_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Last read from Meta (ISO 8601, UTC)."
                    },
                    "status_updated_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Last status change (ISO 8601, UTC)."
                    },
                    "created_at": {
                      "type": "string",
                      "description": "When it was created at Messajo (ISO 8601, UTC)."
                    },
                    "updated_at": {
                      "type": "string",
                      "description": "Last change (ISO 8601, UTC)."
                    }
                  },
                  "required": [
                    "id",
                    "messaging_account_id",
                    "external_id",
                    "name",
                    "language",
                    "category",
                    "previous_category",
                    "status",
                    "rejected_reason",
                    "quality_score",
                    "parameter_format",
                    "components",
                    "last_synced_at",
                    "status_updated_at",
                    "created_at",
                    "updated_at"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "patch": {
        "operationId": "updateTemplate",
        "summary": "Edit a template",
        "description": "Edits the components or the category. Meta only allows editing `APPROVED`, `REJECTED` or `PAUSED` templates, and an approved one cannot change category. Permission: `templates`.",
        "tags": [
          "templates"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Template ID at Messajo (`tpl_…`)."
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "category": {
                    "enum": [
                      "MARKETING",
                      "UTILITY",
                      "AUTHENTICATION"
                    ],
                    "type": "string",
                    "description": "Category: `MARKETING`, `UTILITY` or `AUTHENTICATION`."
                  },
                  "components": {
                    "type": "array",
                    "minItems": 1,
                    "items": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "enum": [
                            "HEADER",
                            "BODY",
                            "FOOTER",
                            "BUTTONS"
                          ],
                          "type": "string"
                        },
                        "format": {
                          "enum": [
                            "TEXT",
                            "IMAGE",
                            "VIDEO",
                            "DOCUMENT",
                            "LOCATION"
                          ],
                          "type": "string"
                        },
                        "text": {
                          "type": "string",
                          "minLength": 1
                        },
                        "buttons": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "type": {
                                "enum": [
                                  "QUICK_REPLY",
                                  "URL",
                                  "PHONE_NUMBER",
                                  "COPY_CODE",
                                  "OTP",
                                  "FLOW",
                                  "CATALOG",
                                  "MPM",
                                  "VOICE_CALL"
                                ],
                                "type": "string"
                              }
                            },
                            "required": [
                              "type"
                            ],
                            "additionalProperties": {}
                          }
                        },
                        "example": {
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {}
                        }
                      },
                      "required": [
                        "type"
                      ],
                      "additionalProperties": {}
                    },
                    "description": "Components in Meta's format (`HEADER`, `BODY`, `FOOTER`, `BUTTONS`)."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The updated template.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Template ID at Messajo (`tpl_…`).",
                      "examples": [
                        "tpl_0193a1b2c3d47e8f9a0b1c2d3e4f5a6b"
                      ]
                    },
                    "messaging_account_id": {
                      "type": "string",
                      "description": "WhatsApp Business account (WABA) of the template."
                    },
                    "external_id": {
                      "type": "string",
                      "description": "Template ID at Meta."
                    },
                    "name": {
                      "type": "string",
                      "description": "Name (lowercase letters, digits and `_`)."
                    },
                    "language": {
                      "type": "string",
                      "description": "Language, e.g. `en_US`."
                    },
                    "category": {
                      "enum": [
                        "MARKETING",
                        "UTILITY",
                        "AUTHENTICATION"
                      ],
                      "type": "string",
                      "description": "Category: `MARKETING`, `UTILITY` or `AUTHENTICATION`."
                    },
                    "previous_category": {
                      "anyOf": [
                        {
                          "enum": [
                            "MARKETING",
                            "UTILITY",
                            "AUTHENTICATION"
                          ],
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Previous category, when Meta reclassified it."
                    },
                    "status": {
                      "enum": [
                        "APPROVED",
                        "PENDING",
                        "REJECTED",
                        "PAUSED",
                        "DISABLED",
                        "IN_APPEAL",
                        "PENDING_DELETION",
                        "DELETED",
                        "ARCHIVED",
                        "LIMIT_EXCEEDED",
                        "LOCKED",
                        "FLAGGED",
                        "REINSTATED"
                      ],
                      "type": "string",
                      "description": "Status at Meta, e.g. `APPROVED`, `PENDING`, `REJECTED`."
                    },
                    "rejected_reason": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Rejection reason, when there is one."
                    },
                    "quality_score": {
                      "enum": [
                        "GREEN",
                        "YELLOW",
                        "RED",
                        "UNKNOWN"
                      ],
                      "type": "string",
                      "description": "Quality: `GREEN`, `YELLOW`, `RED` or `UNKNOWN`."
                    },
                    "parameter_format": {
                      "enum": [
                        "POSITIONAL",
                        "NAMED"
                      ],
                      "type": "string",
                      "description": "Variable format: `POSITIONAL` or `NAMED`."
                    },
                    "components": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "propertyNames": {
                          "type": "string"
                        },
                        "additionalProperties": {}
                      },
                      "description": "Components in Meta's format (`HEADER`, `BODY`, `FOOTER`, `BUTTONS`)."
                    },
                    "last_synced_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Last read from Meta (ISO 8601, UTC)."
                    },
                    "status_updated_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Last status change (ISO 8601, UTC)."
                    },
                    "created_at": {
                      "type": "string",
                      "description": "When it was created at Messajo (ISO 8601, UTC)."
                    },
                    "updated_at": {
                      "type": "string",
                      "description": "Last change (ISO 8601, UTC)."
                    }
                  },
                  "required": [
                    "id",
                    "messaging_account_id",
                    "external_id",
                    "name",
                    "language",
                    "category",
                    "previous_category",
                    "status",
                    "rejected_reason",
                    "quality_score",
                    "parameter_format",
                    "components",
                    "last_synced_at",
                    "status_updated_at",
                    "created_at",
                    "updated_at"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "operationId": "deleteTemplate",
        "summary": "Delete a template",
        "description": "Deletes the template at Meta and at Messajo. Permission: `templates`.",
        "tags": [
          "templates"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Template ID at Messajo (`tpl_…`)."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Deletion confirmation.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Template ID at Messajo (`tpl_…`)."
                    },
                    "deleted": {
                      "const": true,
                      "description": "Always `true`."
                    }
                  },
                  "required": [
                    "id",
                    "deleted"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/templates/sync": {
      "post": {
        "operationId": "syncTemplates",
        "summary": "Sync templates",
        "description": "Reads all templates of the connection's account from Meta now (Messajo already does this daily). A template gone from Meta is marked as deleted. Permission: `templates`.",
        "tags": [
          "templates"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "connection_id": {
                    "type": "string",
                    "minLength": 1,
                    "description": "Connection whose WhatsApp account is used. Optional with a connection key (uses the key's connection)."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "How many templates came and how many left.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "synced": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "Templates read from Meta."
                    },
                    "deleted": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "Templates marked as deleted."
                    }
                  },
                  "required": [
                    "synced",
                    "deleted"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ]
      }
    },
    "/media": {
      "post": {
        "operationId": "uploadMedia",
        "summary": "Upload media",
        "description": "Stores a file (`multipart/form-data`) to use later in `POST /messages` (`media_id`) or as the profile picture. The type is read from the bytes and must fit Meta's limit. `convert=voice` converts audio to OGG/Opus (voice message) and returns the converted media. Permission: `send`.",
        "tags": [
          "media"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "file": {
                    "type": "string",
                    "contentMediaType": "*/*",
                    "description": "The file."
                  },
                  "connection_id": {
                    "type": "string",
                    "minLength": 1,
                    "description": "Connection of the media. Optional with a connection key (uses the key's connection)."
                  },
                  "convert": {
                    "enum": [
                      "voice"
                    ],
                    "type": "string",
                    "description": "`voice`: converts to a voice message (OGG/Opus)."
                  },
                  "purpose": {
                    "enum": [
                      "message",
                      "publication"
                    ],
                    "type": "string",
                    "description": "`message` (default) or `publication`: applies the channel's limits for that purpose (Instagram publication: JPEG up to 8 MiB, video up to 300 MiB)."
                  }
                },
                "required": [
                  "file"
                ]
              }
            },
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "file": {
                    "type": "string",
                    "contentMediaType": "*/*",
                    "description": "The file."
                  },
                  "connection_id": {
                    "type": "string",
                    "minLength": 1,
                    "description": "Connection of the media. Optional with a connection key (uses the key's connection)."
                  },
                  "convert": {
                    "enum": [
                      "voice"
                    ],
                    "type": "string",
                    "description": "`voice`: converts to a voice message (OGG/Opus)."
                  },
                  "purpose": {
                    "enum": [
                      "message",
                      "publication"
                    ],
                    "type": "string",
                    "description": "`message` (default) or `publication`: applies the channel's limits for that purpose (Instagram publication: JPEG up to 8 MiB, video up to 300 MiB)."
                  }
                },
                "required": [
                  "file"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The stored media.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Media ID (`med_…`).",
                      "examples": [
                        "med_0193a1b2c3d47e8f9a0b1c2d3e4f5a6b"
                      ]
                    },
                    "connection_id": {
                      "type": "string",
                      "description": "Connection of the media. Optional with a connection key (uses the key's connection)."
                    },
                    "mime_type": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "File type, e.g. `image/jpeg`."
                    },
                    "filename": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "File name, when there is one."
                    },
                    "size_bytes": {
                      "anyOf": [
                        {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Size in bytes."
                    },
                    "sha256": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "SHA-256 hash of the content."
                    },
                    "status": {
                      "enum": [
                        "pending",
                        "stored",
                        "failed",
                        "purging"
                      ],
                      "type": "string",
                      "description": "Status: `pending`, `stored` or `failed`."
                    },
                    "origin": {
                      "enum": [
                        "inbound",
                        "upload",
                        "converted"
                      ],
                      "type": "string",
                      "description": "Origin: `inbound` (received), `upload` or `converted`."
                    },
                    "converted_from_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Original media, when this one is a conversion."
                    },
                    "created_at": {
                      "type": "string",
                      "description": "When the media was stored (ISO 8601, UTC)."
                    }
                  },
                  "required": [
                    "id",
                    "connection_id",
                    "mime_type",
                    "filename",
                    "size_bytes",
                    "sha256",
                    "status",
                    "origin",
                    "converted_from_id",
                    "created_at"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ]
      }
    },
    "/media/{id}": {
      "get": {
        "operationId": "getMedia",
        "summary": "Get a media",
        "description": "Returns the media data (type, size, status). Permission: `read`.",
        "tags": [
          "media"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Media ID (`med_…`)."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The media.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Media ID (`med_…`).",
                      "examples": [
                        "med_0193a1b2c3d47e8f9a0b1c2d3e4f5a6b"
                      ]
                    },
                    "connection_id": {
                      "type": "string",
                      "description": "Connection of the media. Optional with a connection key (uses the key's connection)."
                    },
                    "mime_type": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "File type, e.g. `image/jpeg`."
                    },
                    "filename": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "File name, when there is one."
                    },
                    "size_bytes": {
                      "anyOf": [
                        {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Size in bytes."
                    },
                    "sha256": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "SHA-256 hash of the content."
                    },
                    "status": {
                      "enum": [
                        "pending",
                        "stored",
                        "failed",
                        "purging"
                      ],
                      "type": "string",
                      "description": "Status: `pending`, `stored` or `failed`."
                    },
                    "origin": {
                      "enum": [
                        "inbound",
                        "upload",
                        "converted"
                      ],
                      "type": "string",
                      "description": "Origin: `inbound` (received), `upload` or `converted`."
                    },
                    "converted_from_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Original media, when this one is a conversion."
                    },
                    "created_at": {
                      "type": "string",
                      "description": "When the media was stored (ISO 8601, UTC)."
                    }
                  },
                  "required": [
                    "id",
                    "connection_id",
                    "mime_type",
                    "filename",
                    "size_bytes",
                    "sha256",
                    "status",
                    "origin",
                    "converted_from_id",
                    "created_at"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "operationId": "deleteMedia",
        "summary": "Delete a media",
        "description": "Deletes the file from Messajo and, if it had already been uploaded, also tries to delete it at Meta (there it expires on its own in 30 days). Permission: `send`.",
        "tags": [
          "media"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Media ID (`med_…`)."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Deletion confirmation.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Media ID (`med_…`)."
                    },
                    "deleted": {
                      "const": true,
                      "description": "Always `true`."
                    },
                    "meta_deleted": {
                      "type": "boolean",
                      "description": "Whether it was also removed from Meta."
                    }
                  },
                  "required": [
                    "id",
                    "deleted",
                    "meta_deleted"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/media/{id}/content": {
      "get": {
        "operationId": "getMediaContent",
        "summary": "Download a media",
        "description": "Returns the media bytes. Received media not yet downloaded from Meta is downloaded on the spot. Permission: `read`.",
        "tags": [
          "media"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Media ID (`med_…`)."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The file.",
            "content": {
              "*/*": {
                "schema": {
                  "type": "string",
                  "contentMediaType": "*/*",
                  "description": "The file."
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/media/{id}/link": {
      "post": {
        "operationId": "createMediaLink",
        "summary": "Create a temporary link",
        "description": "Creates a signed link to download the media without a key, valid from 60 seconds to 7 days (default 1 hour). Permission: `read`.",
        "tags": [
          "media"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Media ID (`med_…`)."
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "expires_in_seconds": {
                    "type": "integer",
                    "minimum": 60,
                    "maximum": 604800,
                    "default": 3600,
                    "description": "Link validity, from 60 to 604,800 seconds."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The link and when it expires.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "url": {
                      "type": "string",
                      "description": "Signed link."
                    },
                    "expires_at": {
                      "type": "string",
                      "description": "When the link expires (ISO 8601, UTC)."
                    }
                  },
                  "required": [
                    "url",
                    "expires_at"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/connection-links": {
      "get": {
        "operationId": "listConnectionLinks",
        "summary": "List connection links",
        "description": "Lists the links that let an outside person (without a Messajo account) connect a number to the organization. Permission: `admin`. Requires an organization key.",
        "tags": [
          "connection-links"
        ],
        "responses": {
          "200": {
            "description": "The connection links.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "description": "Link ID (`clk_…`).",
                            "examples": [
                              "clk_0193a1b2c3d47e8f9a0b1c2d3e4f5a6b"
                            ]
                          },
                          "channel": {
                            "enum": [
                              "whatsapp",
                              "instagram",
                              "messenger"
                            ],
                            "type": "string",
                            "description": "Channel to connect (for now, `whatsapp`)."
                          },
                          "mode": {
                            "anyOf": [
                              {
                                "enum": [
                                  "coex",
                                  "api_only",
                                  "any"
                                ],
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Mode: `coex`, `api_only` or `any` (the person chooses)."
                          },
                          "label": {
                            "type": "string",
                            "description": "Link name, for the organization."
                          },
                          "token_last4": {
                            "type": "string",
                            "description": "Last 4 characters of the token."
                          },
                          "expires_at": {
                            "type": "string",
                            "description": "When the link expires (ISO 8601, UTC)."
                          },
                          "reusable": {
                            "type": "boolean",
                            "description": "`true` = works for several numbers; `false` = single use."
                          },
                          "uses_count": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991,
                            "description": "Connections already made with the link."
                          },
                          "has_password": {
                            "type": "boolean",
                            "description": "Whether the link asks for a password."
                          },
                          "locale": {
                            "type": "string",
                            "description": "Language of the page and the email: `pt-BR`, `en-US` or `es`."
                          },
                          "reconnect_connection_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Connection to reconnect, when it is a reconnection link."
                          },
                          "recipient_email": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Email the link goes to."
                          },
                          "status": {
                            "enum": [
                              "active",
                              "used",
                              "expired",
                              "revoked"
                            ],
                            "type": "string",
                            "description": "Status: `active`, `used`, `expired` or `revoked`."
                          },
                          "last_sent_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Last email sent (ISO 8601, UTC)."
                          },
                          "last_used_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Last use (ISO 8601, UTC)."
                          },
                          "created_at": {
                            "type": "string",
                            "description": "When the link was created (ISO 8601, UTC)."
                          },
                          "updated_at": {
                            "type": "string",
                            "description": "Last change (ISO 8601, UTC)."
                          }
                        },
                        "required": [
                          "id",
                          "channel",
                          "mode",
                          "label",
                          "token_last4",
                          "expires_at",
                          "reusable",
                          "uses_count",
                          "has_password",
                          "locale",
                          "reconnect_connection_id",
                          "recipient_email",
                          "status",
                          "last_sent_at",
                          "last_used_at",
                          "created_at",
                          "updated_at"
                        ]
                      },
                      "description": "Page items, newest first."
                    },
                    "next_cursor": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Cursor for the next page; `null` when there are no more items."
                    }
                  },
                  "required": [
                    "data",
                    "next_cursor"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "createConnectionLink",
        "summary": "Create a connection link",
        "description": "Creates a public connection link, valid from 1 hour to 30 days, with an optional password and single or reusable use. The `url` appears only in this response (and in the email, if `recipient_email` is sent): Messajo stores only the token hash. To reconnect a number, send `reconnect_connection_id`. Permission: `admin`. Requires an organization key.",
        "tags": [
          "connection-links"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "channel": {
                    "enum": [
                      "whatsapp",
                      "instagram",
                      "messenger"
                    ],
                    "type": "string",
                    "default": "whatsapp",
                    "description": "Channel to connect (for now, `whatsapp`)."
                  },
                  "mode": {
                    "enum": [
                      "coex",
                      "api_only",
                      "any"
                    ],
                    "type": "string",
                    "description": "Mode: `coex`, `api_only` or `any` (the person chooses)."
                  },
                  "label": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100,
                    "description": "Link name, for the organization."
                  },
                  "expires_in_hours": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 720,
                    "default": 168,
                    "description": "Validity in hours, from 1 to 720 (default 168)."
                  },
                  "reusable": {
                    "type": "boolean",
                    "default": false,
                    "description": "`true` = works for several numbers; `false` = single use."
                  },
                  "password": {
                    "type": "string",
                    "minLength": 8,
                    "maxLength": 128,
                    "description": "Optional password, 8 to 128 characters."
                  },
                  "locale": {
                    "enum": [
                      "pt-BR",
                      "en-US",
                      "es"
                    ],
                    "type": "string",
                    "description": "Language of the page and the email: `pt-BR`, `en-US` or `es`."
                  },
                  "reconnect_connection_id": {
                    "type": "string",
                    "description": "Connection to reconnect, when it is a reconnection link."
                  },
                  "recipient_email": {
                    "type": "string",
                    "maxLength": 254,
                    "format": "email",
                    "description": "Email the link goes to."
                  }
                },
                "required": [
                  "label",
                  "locale"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The created link, with the `url`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Link ID (`clk_…`).",
                      "examples": [
                        "clk_0193a1b2c3d47e8f9a0b1c2d3e4f5a6b"
                      ]
                    },
                    "channel": {
                      "enum": [
                        "whatsapp",
                        "instagram",
                        "messenger"
                      ],
                      "type": "string",
                      "description": "Channel to connect (for now, `whatsapp`)."
                    },
                    "mode": {
                      "anyOf": [
                        {
                          "enum": [
                            "coex",
                            "api_only",
                            "any"
                          ],
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Mode: `coex`, `api_only` or `any` (the person chooses)."
                    },
                    "label": {
                      "type": "string",
                      "description": "Link name, for the organization."
                    },
                    "token_last4": {
                      "type": "string",
                      "description": "Last 4 characters of the token."
                    },
                    "expires_at": {
                      "type": "string",
                      "description": "When the link expires (ISO 8601, UTC)."
                    },
                    "reusable": {
                      "type": "boolean",
                      "description": "`true` = works for several numbers; `false` = single use."
                    },
                    "uses_count": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "Connections already made with the link."
                    },
                    "has_password": {
                      "type": "boolean",
                      "description": "Whether the link asks for a password."
                    },
                    "locale": {
                      "type": "string",
                      "description": "Language of the page and the email: `pt-BR`, `en-US` or `es`."
                    },
                    "reconnect_connection_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Connection to reconnect, when it is a reconnection link."
                    },
                    "recipient_email": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Email the link goes to."
                    },
                    "status": {
                      "enum": [
                        "active",
                        "used",
                        "expired",
                        "revoked"
                      ],
                      "type": "string",
                      "description": "Status: `active`, `used`, `expired` or `revoked`."
                    },
                    "last_sent_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Last email sent (ISO 8601, UTC)."
                    },
                    "last_used_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Last use (ISO 8601, UTC)."
                    },
                    "created_at": {
                      "type": "string",
                      "description": "When the link was created (ISO 8601, UTC)."
                    },
                    "updated_at": {
                      "type": "string",
                      "description": "Last change (ISO 8601, UTC)."
                    },
                    "url": {
                      "type": "string",
                      "description": "Public address of the link. Only appears when creating or resending."
                    }
                  },
                  "required": [
                    "id",
                    "channel",
                    "mode",
                    "label",
                    "token_last4",
                    "expires_at",
                    "reusable",
                    "uses_count",
                    "has_password",
                    "locale",
                    "reconnect_connection_id",
                    "recipient_email",
                    "status",
                    "last_sent_at",
                    "last_used_at",
                    "created_at",
                    "updated_at",
                    "url"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ]
      }
    },
    "/connection-links/{id}": {
      "get": {
        "operationId": "getConnectionLink",
        "summary": "Get a connection link",
        "description": "Returns the link, without the token. Permission: `admin`. Requires an organization key.",
        "tags": [
          "connection-links"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Link ID (`clk_…`)."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The connection link.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Link ID (`clk_…`).",
                      "examples": [
                        "clk_0193a1b2c3d47e8f9a0b1c2d3e4f5a6b"
                      ]
                    },
                    "channel": {
                      "enum": [
                        "whatsapp",
                        "instagram",
                        "messenger"
                      ],
                      "type": "string",
                      "description": "Channel to connect (for now, `whatsapp`)."
                    },
                    "mode": {
                      "anyOf": [
                        {
                          "enum": [
                            "coex",
                            "api_only",
                            "any"
                          ],
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Mode: `coex`, `api_only` or `any` (the person chooses)."
                    },
                    "label": {
                      "type": "string",
                      "description": "Link name, for the organization."
                    },
                    "token_last4": {
                      "type": "string",
                      "description": "Last 4 characters of the token."
                    },
                    "expires_at": {
                      "type": "string",
                      "description": "When the link expires (ISO 8601, UTC)."
                    },
                    "reusable": {
                      "type": "boolean",
                      "description": "`true` = works for several numbers; `false` = single use."
                    },
                    "uses_count": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "Connections already made with the link."
                    },
                    "has_password": {
                      "type": "boolean",
                      "description": "Whether the link asks for a password."
                    },
                    "locale": {
                      "type": "string",
                      "description": "Language of the page and the email: `pt-BR`, `en-US` or `es`."
                    },
                    "reconnect_connection_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Connection to reconnect, when it is a reconnection link."
                    },
                    "recipient_email": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Email the link goes to."
                    },
                    "status": {
                      "enum": [
                        "active",
                        "used",
                        "expired",
                        "revoked"
                      ],
                      "type": "string",
                      "description": "Status: `active`, `used`, `expired` or `revoked`."
                    },
                    "last_sent_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Last email sent (ISO 8601, UTC)."
                    },
                    "last_used_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Last use (ISO 8601, UTC)."
                    },
                    "created_at": {
                      "type": "string",
                      "description": "When the link was created (ISO 8601, UTC)."
                    },
                    "updated_at": {
                      "type": "string",
                      "description": "Last change (ISO 8601, UTC)."
                    }
                  },
                  "required": [
                    "id",
                    "channel",
                    "mode",
                    "label",
                    "token_last4",
                    "expires_at",
                    "reusable",
                    "uses_count",
                    "has_password",
                    "locale",
                    "reconnect_connection_id",
                    "recipient_email",
                    "status",
                    "last_sent_at",
                    "last_used_at",
                    "created_at",
                    "updated_at"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "operationId": "revokeConnectionLink",
        "summary": "Revoke a connection link",
        "description": "Revokes the link: it no longer opens. Permission: `admin`. Requires an organization key.",
        "tags": [
          "connection-links"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Link ID (`clk_…`)."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The revoked link.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Link ID (`clk_…`).",
                      "examples": [
                        "clk_0193a1b2c3d47e8f9a0b1c2d3e4f5a6b"
                      ]
                    },
                    "channel": {
                      "enum": [
                        "whatsapp",
                        "instagram",
                        "messenger"
                      ],
                      "type": "string",
                      "description": "Channel to connect (for now, `whatsapp`)."
                    },
                    "mode": {
                      "anyOf": [
                        {
                          "enum": [
                            "coex",
                            "api_only",
                            "any"
                          ],
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Mode: `coex`, `api_only` or `any` (the person chooses)."
                    },
                    "label": {
                      "type": "string",
                      "description": "Link name, for the organization."
                    },
                    "token_last4": {
                      "type": "string",
                      "description": "Last 4 characters of the token."
                    },
                    "expires_at": {
                      "type": "string",
                      "description": "When the link expires (ISO 8601, UTC)."
                    },
                    "reusable": {
                      "type": "boolean",
                      "description": "`true` = works for several numbers; `false` = single use."
                    },
                    "uses_count": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "Connections already made with the link."
                    },
                    "has_password": {
                      "type": "boolean",
                      "description": "Whether the link asks for a password."
                    },
                    "locale": {
                      "type": "string",
                      "description": "Language of the page and the email: `pt-BR`, `en-US` or `es`."
                    },
                    "reconnect_connection_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Connection to reconnect, when it is a reconnection link."
                    },
                    "recipient_email": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Email the link goes to."
                    },
                    "status": {
                      "enum": [
                        "active",
                        "used",
                        "expired",
                        "revoked"
                      ],
                      "type": "string",
                      "description": "Status: `active`, `used`, `expired` or `revoked`."
                    },
                    "last_sent_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Last email sent (ISO 8601, UTC)."
                    },
                    "last_used_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Last use (ISO 8601, UTC)."
                    },
                    "created_at": {
                      "type": "string",
                      "description": "When the link was created (ISO 8601, UTC)."
                    },
                    "updated_at": {
                      "type": "string",
                      "description": "Last change (ISO 8601, UTC)."
                    }
                  },
                  "required": [
                    "id",
                    "channel",
                    "mode",
                    "label",
                    "token_last4",
                    "expires_at",
                    "reusable",
                    "uses_count",
                    "has_password",
                    "locale",
                    "reconnect_connection_id",
                    "recipient_email",
                    "status",
                    "last_sent_at",
                    "last_used_at",
                    "created_at",
                    "updated_at"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/connection-links/{id}/send": {
      "post": {
        "operationId": "sendConnectionLink",
        "summary": "Email the link",
        "description": "Emails the link, in the link's language. Creates a new token: the previous URL stops working. The password never goes in the email. Permission: `admin`. Requires an organization key.",
        "tags": [
          "connection-links"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Link ID (`clk_…`)."
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "recipient_email": {
                    "type": "string",
                    "maxLength": 254,
                    "format": "email",
                    "description": "Email the link goes to."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The link, with the new `url`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Link ID (`clk_…`).",
                      "examples": [
                        "clk_0193a1b2c3d47e8f9a0b1c2d3e4f5a6b"
                      ]
                    },
                    "channel": {
                      "enum": [
                        "whatsapp",
                        "instagram",
                        "messenger"
                      ],
                      "type": "string",
                      "description": "Channel to connect (for now, `whatsapp`)."
                    },
                    "mode": {
                      "anyOf": [
                        {
                          "enum": [
                            "coex",
                            "api_only",
                            "any"
                          ],
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Mode: `coex`, `api_only` or `any` (the person chooses)."
                    },
                    "label": {
                      "type": "string",
                      "description": "Link name, for the organization."
                    },
                    "token_last4": {
                      "type": "string",
                      "description": "Last 4 characters of the token."
                    },
                    "expires_at": {
                      "type": "string",
                      "description": "When the link expires (ISO 8601, UTC)."
                    },
                    "reusable": {
                      "type": "boolean",
                      "description": "`true` = works for several numbers; `false` = single use."
                    },
                    "uses_count": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "Connections already made with the link."
                    },
                    "has_password": {
                      "type": "boolean",
                      "description": "Whether the link asks for a password."
                    },
                    "locale": {
                      "type": "string",
                      "description": "Language of the page and the email: `pt-BR`, `en-US` or `es`."
                    },
                    "reconnect_connection_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Connection to reconnect, when it is a reconnection link."
                    },
                    "recipient_email": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Email the link goes to."
                    },
                    "status": {
                      "enum": [
                        "active",
                        "used",
                        "expired",
                        "revoked"
                      ],
                      "type": "string",
                      "description": "Status: `active`, `used`, `expired` or `revoked`."
                    },
                    "last_sent_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Last email sent (ISO 8601, UTC)."
                    },
                    "last_used_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Last use (ISO 8601, UTC)."
                    },
                    "created_at": {
                      "type": "string",
                      "description": "When the link was created (ISO 8601, UTC)."
                    },
                    "updated_at": {
                      "type": "string",
                      "description": "Last change (ISO 8601, UTC)."
                    },
                    "url": {
                      "type": "string",
                      "description": "Public address of the link. Only appears when creating or resending."
                    }
                  },
                  "required": [
                    "id",
                    "channel",
                    "mode",
                    "label",
                    "token_last4",
                    "expires_at",
                    "reusable",
                    "uses_count",
                    "has_password",
                    "locale",
                    "reconnect_connection_id",
                    "recipient_email",
                    "status",
                    "last_sent_at",
                    "last_used_at",
                    "created_at",
                    "updated_at",
                    "url"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/connections/{id}/messaging-profile": {
      "get": {
        "operationId": "getMessagingProfile",
        "summary": "Get the messaging profile",
        "description": "Reads from Meta the messaging profile of the Instagram account or the Page: ice breakers, persistent menu and, on Messenger, greeting and Get Started button. Unset fields come as `null`. Permission: `read`.",
        "tags": [
          "messaging-profile"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Instagram or Messenger connection (`con_…`)."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The profile.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "connection_id": {
                      "type": "string",
                      "description": "Instagram or Messenger connection (`con_…`)."
                    },
                    "channel": {
                      "enum": [
                        "instagram",
                        "messenger"
                      ],
                      "type": "string",
                      "description": "`instagram` or `messenger`."
                    },
                    "ice_breakers": {
                      "anyOf": [
                        {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "locale": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "locale"
                            ],
                            "additionalProperties": {}
                          }
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Ready-made first-conversation questions, per locale (`locale`, `questions[{ question, payload }]`)."
                    },
                    "persistent_menu": {
                      "anyOf": [
                        {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "locale": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "locale"
                            ],
                            "additionalProperties": {}
                          }
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Persistent menu, per locale (`locale`, `items[]`, `composer_input_disabled` Messenger only)."
                    },
                    "greeting": {
                      "anyOf": [
                        {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "locale": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "locale"
                            ],
                            "additionalProperties": {}
                          }
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Greeting shown before the first message, per locale (`locale`, `text` up to 160, accepts `{{user_first_name}}`). Messenger only."
                    },
                    "get_started": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "payload": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "payload"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Get Started button (`payload`). Messenger only."
                    },
                    "synced_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "When the profile was read from Meta (ISO 8601, UTC)."
                    }
                  },
                  "required": [
                    "connection_id",
                    "channel",
                    "synced_at"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "put": {
        "operationId": "updateMessagingProfile",
        "summary": "Change the messaging profile",
        "description": "Saves the messaging profile partially: a missing field stays as it is, `null` removes it. Ice breakers: up to 4 questions per locale; persistent menu: up to 20 items (`postback` or `web_url`); each list needs the `default` locale. `greeting` and `get_started` are Messenger only (on Instagram: `422 type_not_supported_by_channel`); removing `get_started` while the menu is active is refused. Permission: `admin`.",
        "tags": [
          "messaging-profile"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Instagram or Messenger connection (`con_…`)."
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "ice_breakers": {
                    "anyOf": [
                      {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "locale": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "locale"
                          ],
                          "additionalProperties": {}
                        }
                      },
                      {
                        "type": "null"
                      }
                    ],
                    "description": "Ready-made first-conversation questions, per locale (`locale`, `questions[{ question, payload }]`)."
                  },
                  "persistent_menu": {
                    "anyOf": [
                      {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "locale": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "locale"
                          ],
                          "additionalProperties": {}
                        }
                      },
                      {
                        "type": "null"
                      }
                    ],
                    "description": "Persistent menu, per locale (`locale`, `items[]`, `composer_input_disabled` Messenger only)."
                  },
                  "greeting": {
                    "anyOf": [
                      {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "locale": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "locale"
                          ],
                          "additionalProperties": {}
                        }
                      },
                      {
                        "type": "null"
                      }
                    ],
                    "description": "Greeting shown before the first message, per locale (`locale`, `text` up to 160, accepts `{{user_first_name}}`). Messenger only."
                  },
                  "get_started": {
                    "anyOf": [
                      {
                        "type": "object",
                        "properties": {
                          "payload": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "payload"
                        ]
                      },
                      {
                        "type": "null"
                      }
                    ],
                    "description": "Get Started button (`payload`). Messenger only."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The profile read back from Meta.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "connection_id": {
                      "type": "string",
                      "description": "Instagram or Messenger connection (`con_…`)."
                    },
                    "channel": {
                      "enum": [
                        "instagram",
                        "messenger"
                      ],
                      "type": "string",
                      "description": "`instagram` or `messenger`."
                    },
                    "ice_breakers": {
                      "anyOf": [
                        {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "locale": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "locale"
                            ],
                            "additionalProperties": {}
                          }
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Ready-made first-conversation questions, per locale (`locale`, `questions[{ question, payload }]`)."
                    },
                    "persistent_menu": {
                      "anyOf": [
                        {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "locale": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "locale"
                            ],
                            "additionalProperties": {}
                          }
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Persistent menu, per locale (`locale`, `items[]`, `composer_input_disabled` Messenger only)."
                    },
                    "greeting": {
                      "anyOf": [
                        {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "locale": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "locale"
                            ],
                            "additionalProperties": {}
                          }
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Greeting shown before the first message, per locale (`locale`, `text` up to 160, accepts `{{user_first_name}}`). Messenger only."
                    },
                    "get_started": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "payload": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "payload"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Get Started button (`payload`). Messenger only."
                    },
                    "synced_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "When the profile was read from Meta (ISO 8601, UTC)."
                    }
                  },
                  "required": [
                    "connection_id",
                    "channel",
                    "synced_at"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/connections/{id}/welcome-flows": {
      "get": {
        "operationId": "listWelcomeFlows",
        "summary": "List welcome flows",
        "description": "Lists the Instagram account's welcome flows (ads that lead to Direct). Permission: `read`.",
        "tags": [
          "messaging-profile"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Instagram or Messenger connection (`con_…`)."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The flows.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "description": "Flow ID at Meta."
                          },
                          "name": {
                            "type": "string",
                            "description": "Flow name."
                          },
                          "messages": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "text": {
                                  "type": "string"
                                },
                                "quick_replies": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "title": {
                                        "type": "string"
                                      },
                                      "payload": {
                                        "type": "string"
                                      }
                                    },
                                    "required": [
                                      "title",
                                      "payload"
                                    ]
                                  }
                                }
                              },
                              "required": [
                                "text",
                                "quick_replies"
                              ]
                            },
                            "description": "The flow's messages, in order."
                          },
                          "is_used_in_ad": {
                            "type": "boolean",
                            "description": "Flow used in an ad (cannot change or be deleted)."
                          }
                        },
                        "required": [
                          "id",
                          "name",
                          "messages",
                          "is_used_in_ad"
                        ]
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "createWelcomeFlow",
        "summary": "Create a welcome flow",
        "description": "Creates an Instagram welcome flow: name and messages with quick replies. Permission: `admin`.",
        "tags": [
          "messaging-profile"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Instagram or Messenger connection (`con_…`)."
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "Flow name."
                  },
                  "messages": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "text": {
                          "type": "string",
                          "description": "Message text."
                        },
                        "quick_replies": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "title": {
                                "type": "string",
                                "description": "Button text (up to 20 characters)."
                              },
                              "payload": {
                                "type": "string",
                                "description": "Value sent back in the webhook when the contact taps."
                              }
                            },
                            "required": [
                              "title",
                              "payload"
                            ]
                          },
                          "description": "The message's quick replies (up to 13)."
                        }
                      },
                      "required": [
                        "text"
                      ]
                    },
                    "description": "The flow's messages, in order."
                  }
                },
                "required": [
                  "name",
                  "messages"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The flow created.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Flow ID at Meta."
                    }
                  },
                  "required": [
                    "id"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/connections/{id}/welcome-flows/{flow_id}": {
      "patch": {
        "operationId": "updateWelcomeFlow",
        "summary": "Change a welcome flow",
        "description": "Replaces a flow's name and messages. A flow used in an ad does not change (`409 welcome_flow_in_use`). Permission: `admin`.",
        "tags": [
          "messaging-profile"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Instagram or Messenger connection (`con_…`)."
            }
          },
          {
            "name": "flow_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Flow ID at Meta."
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "Flow name."
                  },
                  "messages": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "text": {
                          "type": "string",
                          "description": "Message text."
                        },
                        "quick_replies": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "title": {
                                "type": "string",
                                "description": "Button text (up to 20 characters)."
                              },
                              "payload": {
                                "type": "string",
                                "description": "Value sent back in the webhook when the contact taps."
                              }
                            },
                            "required": [
                              "title",
                              "payload"
                            ]
                          },
                          "description": "The message's quick replies (up to 13)."
                        }
                      },
                      "required": [
                        "text"
                      ]
                    },
                    "description": "The flow's messages, in order."
                  }
                },
                "required": [
                  "name",
                  "messages"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The changed flow.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Flow ID at Meta."
                    }
                  },
                  "required": [
                    "id"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "operationId": "deleteWelcomeFlow",
        "summary": "Delete a welcome flow",
        "description": "Deletes a flow. A flow used in an ad is not deleted (`409 welcome_flow_in_use`). Permission: `admin`.",
        "tags": [
          "messaging-profile"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Instagram or Messenger connection (`con_…`)."
            }
          },
          {
            "name": "flow_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Flow ID at Meta."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Confirmation.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Flow ID at Meta."
                    },
                    "deleted": {
                      "const": true,
                      "description": "Always `true`."
                    }
                  },
                  "required": [
                    "id",
                    "deleted"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/connections/{id}/posts": {
      "get": {
        "operationId": "listPosts",
        "summary": "List posts",
        "description": "Lists the Instagram account's posts, live from Meta, newest first, with type, caption, link, likes and comments. Permission: `read`.",
        "tags": [
          "posts"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Instagram connection (`con_…`)."
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "Next page cursor: the `next_cursor` of the previous response."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50,
              "description": "Items per page, from 1 to 100 (default 50)."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          }
        ],
        "responses": {
          "200": {
            "description": "A page of posts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "description": "Post (media) ID at Meta."
                          }
                        },
                        "required": [
                          "id"
                        ],
                        "additionalProperties": {},
                        "description": "Post as Meta returns it: `id`, `caption`, `media_type`, `media_product_type`, `permalink`, `timestamp`, `like_count`, `comments_count`, `thumbnail_url`, `media_url`."
                      },
                      "description": "Page items, newest first."
                    },
                    "next_cursor": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Cursor for the next page; `null` when there are no more items."
                    }
                  },
                  "required": [
                    "data",
                    "next_cursor"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/connections/{id}/posts/{post_id}": {
      "get": {
        "operationId": "getPost",
        "summary": "Get a post",
        "description": "Returns a post of the account, live from Meta. Another account's post: `404`. Permission: `read`.",
        "tags": [
          "posts"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Instagram connection (`con_…`)."
            }
          },
          {
            "name": "post_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Post (media) ID at Meta."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The post.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Post (media) ID at Meta."
                    }
                  },
                  "required": [
                    "id"
                  ],
                  "additionalProperties": {},
                  "description": "Post as Meta returns it: `id`, `caption`, `media_type`, `media_product_type`, `permalink`, `timestamp`, `like_count`, `comments_count`, `thumbnail_url`, `media_url`."
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/connections/{id}/publishing-limit": {
      "get": {
        "operationId": "getPublishingLimit",
        "summary": "Publishing quota",
        "description": "Reads from Meta how many publications the account made in the quota window (Meta limits per 24 h). Permission: `read`.",
        "tags": [
          "posts"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Instagram connection (`con_…`)."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The quota.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "quota_usage": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "Publications made in the quota window."
                    },
                    "quota_total": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "Publications allowed in the window."
                    },
                    "quota_duration_s": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "Window length, in seconds."
                    }
                  },
                  "required": [
                    "quota_usage",
                    "quota_total",
                    "quota_duration_s"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/connections/{id}/posts/{post_id}/comments": {
      "get": {
        "operationId": "listPostComments",
        "summary": "List a post's comments",
        "description": "Lists the comments of an Instagram post, live from Meta, with replies and the local state (`private_replied_at`, `deleted_at`). Needs the account's `instagram_manage_comments` permission (`403 instagram_scope_missing`). Permission: `read`.",
        "tags": [
          "comments"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Instagram connection (`con_…`)."
            }
          },
          {
            "name": "post_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Post (media) ID at Meta."
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "Next page cursor: the `next_cursor` of the previous response."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50,
              "description": "Items per page, from 1 to 100 (default 50)."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          }
        ],
        "responses": {
          "200": {
            "description": "A page of comments.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "id"
                        ],
                        "additionalProperties": {},
                        "description": "Comment as Meta returns it, with Messajo's `comment_id`, `private_replied_at` and `deleted_at`."
                      },
                      "description": "Page items, newest first."
                    },
                    "next_cursor": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Cursor for the next page; `null` when there are no more items."
                    }
                  },
                  "required": [
                    "data",
                    "next_cursor"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/connections/{id}/comments/{comment_id}": {
      "get": {
        "operationId": "getComment",
        "summary": "Get a comment",
        "description": "Returns a comment or mention stored by Messajo (`cmt_…`). Permission: `read`.",
        "tags": [
          "comments"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Instagram connection (`con_…`)."
            }
          },
          {
            "name": "comment_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Comment ID in Messajo (`cmt_…`)."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The comment.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Comment ID in Messajo (`cmt_…`).",
                      "examples": [
                        "cmt_0193a1b2c3d47e8f9a0b1c2d3e4f5a6b"
                      ]
                    },
                    "external_id": {
                      "type": "string",
                      "description": "Comment ID at Meta."
                    },
                    "kind": {
                      "enum": [
                        "comment",
                        "live_comment",
                        "mention"
                      ],
                      "type": "string",
                      "description": "`comment`, `live_comment` (from a live) or `mention`."
                    },
                    "text": {
                      "type": "string",
                      "description": "Text."
                    },
                    "parent_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Parent comment (at Meta), when this is a reply."
                    },
                    "from": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "username": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      },
                      "required": [
                        "id",
                        "username"
                      ],
                      "description": "Who wrote it."
                    },
                    "from_self": {
                      "type": "boolean",
                      "description": "`true` when the account itself wrote it."
                    },
                    "post": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "product_type": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      },
                      "required": [
                        "id",
                        "product_type"
                      ],
                      "description": "The comment's post: ID and type (`FEED`, `REELS`, `STORY`)."
                    },
                    "hidden": {
                      "type": "boolean",
                      "description": "Hidden comment."
                    },
                    "reply_count": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "Replies sent by Messajo."
                    },
                    "private_replied_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "When the Direct reply was sent (ISO 8601, UTC)."
                    },
                    "deleted_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "When it was deleted (ISO 8601, UTC)."
                    },
                    "occurred_at": {
                      "type": "string",
                      "description": "When it happened (ISO 8601, UTC)."
                    }
                  },
                  "required": [
                    "id",
                    "external_id",
                    "kind",
                    "text",
                    "parent_id",
                    "from",
                    "from_self",
                    "post",
                    "hidden",
                    "reply_count",
                    "private_replied_at",
                    "deleted_at",
                    "occurred_at"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "operationId": "deleteComment",
        "summary": "Delete a comment",
        "description": "Deletes a comment on the account's own media; on another account's media (mention): `409 comment_not_owned`. Emits `comment.deleted`. Permission: `send`.",
        "tags": [
          "comments"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Instagram connection (`con_…`)."
            }
          },
          {
            "name": "comment_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Comment ID in Messajo (`cmt_…`)."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Confirmation.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Comment ID in Messajo (`cmt_…`)."
                    },
                    "deleted": {
                      "const": true,
                      "description": "Always `true`."
                    }
                  },
                  "required": [
                    "id",
                    "deleted"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/connections/{id}/comments/{comment_id}/replies": {
      "post": {
        "operationId": "replyComment",
        "summary": "Reply to a comment",
        "description": "Replies publicly to a comment (up to 2200 characters). Not idempotent at Meta: use `Idempotency-Key` to retry without duplicates. Emits `comment.replied`. Permission: `send`.",
        "tags": [
          "comments"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Instagram connection (`con_…`)."
            }
          },
          {
            "name": "comment_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Comment ID in Messajo (`cmt_…`)."
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "message": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 2200,
                    "description": "Reply text (up to 2200 characters)."
                  }
                },
                "required": [
                  "message"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The reply created.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Reply ID at Meta."
                    }
                  },
                  "required": [
                    "id"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/connections/{id}/comments/{comment_id}/private-reply": {
      "post": {
        "operationId": "privateReplyComment",
        "summary": "Reply in Direct",
        "description": "Sends a Direct message to the commenter: `text`, `buttons` or `cards`, in the same format as `POST /messages`. Once per comment (`409 private_reply_already_sent`), up to 7 days after the comment (`422 private_reply_window_closed`), regardless of the 24 h window. Opens the conversation with the contact and emits `comment.private_replied` and `message.sent`. Permission: `send`.",
        "tags": [
          "comments"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Instagram connection (`con_…`)."
            }
          },
          {
            "name": "comment_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Comment ID in Messajo (`cmt_…`)."
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "minLength": 1,
                    "description": "`text`, `buttons` or `cards`, with the field of the same name as in `POST /messages`."
                  }
                },
                "required": [
                  "type"
                ],
                "additionalProperties": {}
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The message sent.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Message ID at Messajo (`msg_…`)."
                    },
                    "external_id": {
                      "type": "string",
                      "description": "Message ID at Meta (`wamid`)."
                    },
                    "conversation_id": {
                      "type": "string",
                      "description": "Conversation of the message."
                    },
                    "contact_id": {
                      "type": "string",
                      "description": "Recipient contact."
                    },
                    "created_at": {
                      "type": "string",
                      "description": "When the message was stored (ISO 8601, UTC)."
                    }
                  },
                  "required": [
                    "id",
                    "external_id",
                    "conversation_id",
                    "contact_id",
                    "created_at"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/connections/{id}/comments/{comment_id}/hide": {
      "post": {
        "operationId": "hideComment",
        "summary": "Hide or show a comment",
        "description": "Hides (`hidden: true`) or shows a comment again. Emits `comment.hidden` or `comment.unhidden`. Permission: `send`.",
        "tags": [
          "comments"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Instagram connection (`con_…`)."
            }
          },
          {
            "name": "comment_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Comment ID in Messajo (`cmt_…`)."
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "hidden": {
                    "type": "boolean",
                    "description": "Hidden comment."
                  }
                },
                "required": [
                  "hidden"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The updated comment.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Comment ID in Messajo (`cmt_…`).",
                      "examples": [
                        "cmt_0193a1b2c3d47e8f9a0b1c2d3e4f5a6b"
                      ]
                    },
                    "external_id": {
                      "type": "string",
                      "description": "Comment ID at Meta."
                    },
                    "kind": {
                      "enum": [
                        "comment",
                        "live_comment",
                        "mention"
                      ],
                      "type": "string",
                      "description": "`comment`, `live_comment` (from a live) or `mention`."
                    },
                    "text": {
                      "type": "string",
                      "description": "Text."
                    },
                    "parent_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Parent comment (at Meta), when this is a reply."
                    },
                    "from": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "username": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      },
                      "required": [
                        "id",
                        "username"
                      ],
                      "description": "Who wrote it."
                    },
                    "from_self": {
                      "type": "boolean",
                      "description": "`true` when the account itself wrote it."
                    },
                    "post": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "product_type": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      },
                      "required": [
                        "id",
                        "product_type"
                      ],
                      "description": "The comment's post: ID and type (`FEED`, `REELS`, `STORY`)."
                    },
                    "hidden": {
                      "type": "boolean",
                      "description": "Hidden comment."
                    },
                    "reply_count": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "Replies sent by Messajo."
                    },
                    "private_replied_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "When the Direct reply was sent (ISO 8601, UTC)."
                    },
                    "deleted_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "When it was deleted (ISO 8601, UTC)."
                    },
                    "occurred_at": {
                      "type": "string",
                      "description": "When it happened (ISO 8601, UTC)."
                    }
                  },
                  "required": [
                    "id",
                    "external_id",
                    "kind",
                    "text",
                    "parent_id",
                    "from",
                    "from_self",
                    "post",
                    "hidden",
                    "reply_count",
                    "private_replied_at",
                    "deleted_at",
                    "occurred_at"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/connections/{id}/mentions": {
      "get": {
        "operationId": "listMentions",
        "summary": "List mentions",
        "description": "Lists the account's mentions (in comments, captions and stories) stored by Messajo, newest first. Permission: `read`.",
        "tags": [
          "comments"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Instagram connection (`con_…`)."
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "Next page cursor: the `next_cursor` of the previous response."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50,
              "description": "Items per page, from 1 to 100 (default 50)."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          }
        ],
        "responses": {
          "200": {
            "description": "A page of mentions.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "description": "Mention ID in Messajo (`cmt_…`)."
                          },
                          "source": {
                            "enum": [
                              "comment",
                              "caption",
                              "story"
                            ],
                            "type": "string",
                            "description": "Where the account was mentioned: `comment`, `caption` or `story`."
                          },
                          "post_id": {
                            "type": "string",
                            "description": "Post (media) ID at Meta."
                          },
                          "comment_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Comment ID at Meta."
                          },
                          "from": {
                            "type": "object",
                            "properties": {
                              "username": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              }
                            },
                            "required": [
                              "username"
                            ],
                            "description": "Who wrote it."
                          },
                          "text": {
                            "type": "string",
                            "description": "Text."
                          },
                          "occurred_at": {
                            "type": "string",
                            "description": "When it happened (ISO 8601, UTC)."
                          }
                        },
                        "required": [
                          "id",
                          "source",
                          "post_id",
                          "comment_id",
                          "from",
                          "text",
                          "occurred_at"
                        ],
                        "description": "Mention of the account."
                      },
                      "description": "Page items, newest first."
                    },
                    "next_cursor": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Cursor for the next page; `null` when there are no more items."
                    }
                  },
                  "required": [
                    "data",
                    "next_cursor"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/connections/{id}/insights": {
      "get": {
        "operationId": "getAccountInsights",
        "summary": "Account insights",
        "description": "Metrics of the Instagram account. `period=day`: `reach`, `views`, `accounts_engaged`, `total_interactions`, `likes`, `comments`, `shares`, `saves`, `replies`, `reposts`, `follows_and_unfollows`, `profile_links_taps`. `period=lifetime` with `timeframe` (`this_week`, `this_month`): `follower_demographics`, `engaged_audience_demographics`. `impressions` was retired by Meta (`422 validation_failed`). Results are cached for 15 min. Needs `instagram_manage_insights`. Permission: `read`.",
        "tags": [
          "insights"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Instagram connection (`con_…`)."
            }
          },
          {
            "name": "metric",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "Comma-separated metrics."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "period",
            "in": "query",
            "required": true,
            "schema": {
              "enum": [
                "day",
                "lifetime"
              ],
              "type": "string",
              "description": "`day` or `lifetime`."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "metric_type",
            "in": "query",
            "required": false,
            "schema": {
              "enum": [
                "time_series",
                "total_value"
              ],
              "type": "string",
              "description": "`time_series` or `total_value`."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "breakdown",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "description": "Metric breakdown (for example `city`, `age`, `gender`)."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "timeframe",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "description": "Demographics window: `this_week` or `this_month`."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "since",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time",
              "description": "Start (ISO 8601)."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "until",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time",
              "description": "End (ISO 8601)."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          }
        ],
        "responses": {
          "200": {
            "description": "The metrics.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "metric": {
                            "type": "string",
                            "description": "Metric name."
                          },
                          "period": {
                            "type": "string",
                            "description": "`day` or `lifetime`."
                          },
                          "total_value": {
                            "description": "Total value, when Meta returns one."
                          },
                          "values": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "value": {},
                                "end_time": {
                                  "type": "string"
                                }
                              }
                            },
                            "description": "Values per period (`value`, `end_time`)."
                          },
                          "breakdowns": {
                            "type": "array",
                            "items": {
                              "anyOf": [
                                {},
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "description": "Breakdowns, as Meta returns them."
                          }
                        },
                        "required": [
                          "metric",
                          "period",
                          "values",
                          "breakdowns"
                        ],
                        "description": "One metric."
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/connections/{id}/posts/{post_id}/insights": {
      "get": {
        "operationId": "getPostInsights",
        "summary": "Post insights",
        "description": "Metrics of a post, by its type (feed, Reels or story). An expired story comes from the last stored snapshot (`source: snapshot`). Carousel child or small audience: `422 insights_not_available`. Permission: `read`.",
        "tags": [
          "insights"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Instagram connection (`con_…`)."
            }
          },
          {
            "name": "post_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Post (media) ID at Meta."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The post's metrics.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "media_id": {
                      "type": "string",
                      "description": "Post (media) ID at Meta."
                    },
                    "product_type": {
                      "enum": [
                        "FEED",
                        "REELS",
                        "STORY"
                      ],
                      "type": "string",
                      "description": "Post type: `FEED`, `REELS` or `STORY`."
                    },
                    "source": {
                      "enum": [
                        "live",
                        "snapshot"
                      ],
                      "type": "string",
                      "description": "`live` (read now) or `snapshot` (snapshot of an expired story)."
                    },
                    "captured_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "When the snapshot was taken (ISO 8601, UTC)."
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "metric": {
                            "type": "string",
                            "description": "Metric name."
                          },
                          "period": {
                            "type": "string",
                            "description": "`day` or `lifetime`."
                          },
                          "total_value": {
                            "description": "Total value, when Meta returns one."
                          },
                          "values": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "value": {},
                                "end_time": {
                                  "type": "string"
                                }
                              }
                            },
                            "description": "Values per period (`value`, `end_time`)."
                          },
                          "breakdowns": {
                            "type": "array",
                            "items": {
                              "anyOf": [
                                {},
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "description": "Breakdowns, as Meta returns them."
                          }
                        },
                        "required": [
                          "metric",
                          "period",
                          "values",
                          "breakdowns"
                        ],
                        "description": "One metric."
                      }
                    }
                  },
                  "required": [
                    "media_id",
                    "product_type",
                    "source",
                    "captured_at",
                    "data"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/publications": {
      "post": {
        "operationId": "createPublication",
        "summary": "Create a publication",
        "description": "Publishes to Instagram now or schedules it (`scheduled_at` between 1 min and 75 days ahead). `photo`: 1 image; `video` and `reel`: 1 video (becomes Reels); `carousel`: 2 to 20 items; `story`: 1 image or video. Caption up to 2200 characters, 30 hashtags and 20 mentions. Each item is a `media_id` (from `POST /media` with `purpose=publication`) or a public https `url`. PNG/WebP images are converted to JPEG. A publication is never retried blindly. Use `Idempotency-Key` to avoid creating two. Emits `publication.published` or `publication.failed`. Needs `instagram_content_publish`. Permission: `send`.",
        "tags": [
          "publications"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "connection_id": {
                    "type": "string",
                    "minLength": 1,
                    "description": "Instagram connection (`con_…`)."
                  },
                  "type": {
                    "enum": [
                      "photo",
                      "video",
                      "carousel",
                      "reel",
                      "story"
                    ],
                    "type": "string",
                    "description": "`photo`, `video`, `carousel`, `reel` or `story`."
                  },
                  "caption": {
                    "type": "string",
                    "minLength": 1,
                    "description": "Caption."
                  },
                  "items": {
                    "type": "array",
                    "minItems": 1,
                    "items": {
                      "type": "object",
                      "properties": {
                        "media_id": {
                          "type": "string",
                          "minLength": 1,
                          "description": "Media stored in Messajo (`med_…`)."
                        },
                        "url": {
                          "type": "string",
                          "minLength": 1,
                          "description": "Public https URL that Meta downloads."
                        },
                        "alt_text": {
                          "type": "string",
                          "minLength": 1,
                          "description": "Image alt text."
                        },
                        "user_tags": {
                          "type": "array",
                          "items": {},
                          "description": "People tags, in Meta's format."
                        }
                      },
                      "description": "One media item: `media_id` or `url`."
                    },
                    "description": "The publication's media, in order."
                  },
                  "scheduled_at": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "date-time",
                        "description": "Scheduled time (ISO 8601); empty or `null` = publish now."
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "share_to_feed": {
                    "type": "boolean",
                    "description": "Reels also shows in the feed."
                  },
                  "cover": {
                    "type": "string",
                    "minLength": 1,
                    "description": "Reels cover URL."
                  },
                  "thumb_offset_ms": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 9007199254740991,
                    "description": "Video cover frame, in ms."
                  },
                  "collaborators": {
                    "type": "array",
                    "maxItems": 3,
                    "items": {
                      "type": "string",
                      "minLength": 1
                    },
                    "description": "Up to 3 collaborator accounts (@)."
                  },
                  "location_id": {
                    "type": "string",
                    "minLength": 1,
                    "description": "Location ID at Meta."
                  },
                  "audio_name": {
                    "type": "string",
                    "minLength": 1,
                    "description": "Reels audio name."
                  }
                },
                "required": [
                  "type",
                  "items"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The publication created.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Publication ID (`pub_…`).",
                      "examples": [
                        "pub_0193a1b2c3d47e8f9a0b1c2d3e4f5a6b"
                      ]
                    },
                    "connection_id": {
                      "type": "string",
                      "description": "Instagram connection (`con_…`)."
                    },
                    "type": {
                      "enum": [
                        "photo",
                        "video",
                        "carousel",
                        "reel",
                        "story"
                      ],
                      "type": "string",
                      "description": "`photo`, `video`, `carousel`, `reel` or `story`."
                    },
                    "caption": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Caption."
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "media_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "url": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "kind": {
                            "enum": [
                              "image",
                              "video"
                            ],
                            "type": "string"
                          },
                          "alt_text": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "user_tags": {
                            "type": "array",
                            "items": {
                              "anyOf": [
                                {},
                                {
                                  "type": "null"
                                }
                              ]
                            }
                          }
                        },
                        "required": [
                          "media_id",
                          "url",
                          "kind",
                          "alt_text",
                          "user_tags"
                        ]
                      },
                      "description": "The publication's media, in order."
                    },
                    "options": {
                      "type": "object",
                      "properties": {
                        "share_to_feed": {
                          "type": "boolean",
                          "description": "Reels also shows in the feed."
                        },
                        "cover": {
                          "type": "string",
                          "minLength": 1,
                          "description": "Reels cover URL."
                        },
                        "thumb_offset_ms": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 9007199254740991,
                          "description": "Video cover frame, in ms."
                        },
                        "collaborators": {
                          "type": "array",
                          "maxItems": 3,
                          "items": {
                            "type": "string",
                            "minLength": 1
                          },
                          "description": "Up to 3 collaborator accounts (@)."
                        },
                        "location_id": {
                          "type": "string",
                          "minLength": 1,
                          "description": "Location ID at Meta."
                        },
                        "audio_name": {
                          "type": "string",
                          "minLength": 1,
                          "description": "Reels audio name."
                        }
                      },
                      "description": "Publication options (`share_to_feed`, `cover`, `thumb_offset_ms`, `collaborators`, `location_id`, `audio_name`)."
                    },
                    "status": {
                      "enum": [
                        "scheduled",
                        "queued",
                        "creating",
                        "processing",
                        "publishing",
                        "published",
                        "failed",
                        "canceled"
                      ],
                      "type": "string",
                      "description": "`scheduled`, `queued`, `creating`, `processing`, `publishing`, `published`, `failed` or `canceled`."
                    },
                    "scheduled_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Scheduled time (ISO 8601); empty or `null` = publish now."
                    },
                    "external_media_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "ID of the published post at Meta."
                    },
                    "permalink": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Link to the published post."
                    },
                    "published_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "When it was published (ISO 8601, UTC)."
                    },
                    "error": {
                      "anyOf": [
                        {
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {}
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Last error, when it failed."
                    },
                    "attempts": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "Attempts made."
                    },
                    "created_at": {
                      "type": "string",
                      "description": "Creation (ISO 8601, UTC)."
                    },
                    "updated_at": {
                      "type": "string",
                      "description": "Last change (ISO 8601, UTC)."
                    }
                  },
                  "required": [
                    "id",
                    "connection_id",
                    "type",
                    "caption",
                    "items",
                    "options",
                    "status",
                    "scheduled_at",
                    "external_media_id",
                    "permalink",
                    "published_at",
                    "error",
                    "attempts",
                    "created_at",
                    "updated_at"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ]
      },
      "get": {
        "operationId": "listPublications",
        "summary": "List publications",
        "description": "Lists the organization's publications, newest first, filtered by connection, status and time (`since`/`until`). Permission: `read`.",
        "tags": [
          "publications"
        ],
        "parameters": [
          {
            "name": "connection_id",
            "in": "query",
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "Instagram connection (`con_…`)."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "enum": [
                "scheduled",
                "queued",
                "creating",
                "processing",
                "publishing",
                "published",
                "failed",
                "canceled"
              ],
              "type": "string",
              "description": "`scheduled`, `queued`, `creating`, `processing`, `publishing`, `published`, `failed` or `canceled`."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "since",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time",
              "description": "Scheduled or created from (ISO 8601)."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "until",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time",
              "description": "Scheduled or created until (ISO 8601)."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50,
              "description": "Items per page, from 1 to 100 (default 50)."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          }
        ],
        "responses": {
          "200": {
            "description": "The publications.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "description": "Publication ID (`pub_…`).",
                            "examples": [
                              "pub_0193a1b2c3d47e8f9a0b1c2d3e4f5a6b"
                            ]
                          },
                          "connection_id": {
                            "type": "string",
                            "description": "Instagram connection (`con_…`)."
                          },
                          "type": {
                            "enum": [
                              "photo",
                              "video",
                              "carousel",
                              "reel",
                              "story"
                            ],
                            "type": "string",
                            "description": "`photo`, `video`, `carousel`, `reel` or `story`."
                          },
                          "caption": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Caption."
                          },
                          "items": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "media_id": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "url": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "kind": {
                                  "enum": [
                                    "image",
                                    "video"
                                  ],
                                  "type": "string"
                                },
                                "alt_text": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "user_tags": {
                                  "type": "array",
                                  "items": {
                                    "anyOf": [
                                      {},
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  }
                                }
                              },
                              "required": [
                                "media_id",
                                "url",
                                "kind",
                                "alt_text",
                                "user_tags"
                              ]
                            },
                            "description": "The publication's media, in order."
                          },
                          "options": {
                            "type": "object",
                            "properties": {
                              "share_to_feed": {
                                "type": "boolean",
                                "description": "Reels also shows in the feed."
                              },
                              "cover": {
                                "type": "string",
                                "minLength": 1,
                                "description": "Reels cover URL."
                              },
                              "thumb_offset_ms": {
                                "type": "integer",
                                "minimum": 0,
                                "maximum": 9007199254740991,
                                "description": "Video cover frame, in ms."
                              },
                              "collaborators": {
                                "type": "array",
                                "maxItems": 3,
                                "items": {
                                  "type": "string",
                                  "minLength": 1
                                },
                                "description": "Up to 3 collaborator accounts (@)."
                              },
                              "location_id": {
                                "type": "string",
                                "minLength": 1,
                                "description": "Location ID at Meta."
                              },
                              "audio_name": {
                                "type": "string",
                                "minLength": 1,
                                "description": "Reels audio name."
                              }
                            },
                            "description": "Publication options (`share_to_feed`, `cover`, `thumb_offset_ms`, `collaborators`, `location_id`, `audio_name`)."
                          },
                          "status": {
                            "enum": [
                              "scheduled",
                              "queued",
                              "creating",
                              "processing",
                              "publishing",
                              "published",
                              "failed",
                              "canceled"
                            ],
                            "type": "string",
                            "description": "`scheduled`, `queued`, `creating`, `processing`, `publishing`, `published`, `failed` or `canceled`."
                          },
                          "scheduled_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Scheduled time (ISO 8601); empty or `null` = publish now."
                          },
                          "external_media_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "ID of the published post at Meta."
                          },
                          "permalink": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Link to the published post."
                          },
                          "published_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "When it was published (ISO 8601, UTC)."
                          },
                          "error": {
                            "anyOf": [
                              {
                                "type": "object",
                                "propertyNames": {
                                  "type": "string"
                                },
                                "additionalProperties": {}
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Last error, when it failed."
                          },
                          "attempts": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991,
                            "description": "Attempts made."
                          },
                          "created_at": {
                            "type": "string",
                            "description": "Creation (ISO 8601, UTC)."
                          },
                          "updated_at": {
                            "type": "string",
                            "description": "Last change (ISO 8601, UTC)."
                          }
                        },
                        "required": [
                          "id",
                          "connection_id",
                          "type",
                          "caption",
                          "items",
                          "options",
                          "status",
                          "scheduled_at",
                          "external_media_id",
                          "permalink",
                          "published_at",
                          "error",
                          "attempts",
                          "created_at",
                          "updated_at"
                        ]
                      },
                      "description": "Page items, newest first."
                    },
                    "next_cursor": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Cursor for the next page; `null` when there are no more items."
                    }
                  },
                  "required": [
                    "data",
                    "next_cursor"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/publications/{id}": {
      "get": {
        "operationId": "getPublication",
        "summary": "Get a publication",
        "description": "Returns the publication with status, attempts, error and, once published, the post ID and link. Permission: `read`.",
        "tags": [
          "publications"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Publication ID (`pub_…`)."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The publication.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Publication ID (`pub_…`).",
                      "examples": [
                        "pub_0193a1b2c3d47e8f9a0b1c2d3e4f5a6b"
                      ]
                    },
                    "connection_id": {
                      "type": "string",
                      "description": "Instagram connection (`con_…`)."
                    },
                    "type": {
                      "enum": [
                        "photo",
                        "video",
                        "carousel",
                        "reel",
                        "story"
                      ],
                      "type": "string",
                      "description": "`photo`, `video`, `carousel`, `reel` or `story`."
                    },
                    "caption": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Caption."
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "media_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "url": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "kind": {
                            "enum": [
                              "image",
                              "video"
                            ],
                            "type": "string"
                          },
                          "alt_text": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "user_tags": {
                            "type": "array",
                            "items": {
                              "anyOf": [
                                {},
                                {
                                  "type": "null"
                                }
                              ]
                            }
                          }
                        },
                        "required": [
                          "media_id",
                          "url",
                          "kind",
                          "alt_text",
                          "user_tags"
                        ]
                      },
                      "description": "The publication's media, in order."
                    },
                    "options": {
                      "type": "object",
                      "properties": {
                        "share_to_feed": {
                          "type": "boolean",
                          "description": "Reels also shows in the feed."
                        },
                        "cover": {
                          "type": "string",
                          "minLength": 1,
                          "description": "Reels cover URL."
                        },
                        "thumb_offset_ms": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 9007199254740991,
                          "description": "Video cover frame, in ms."
                        },
                        "collaborators": {
                          "type": "array",
                          "maxItems": 3,
                          "items": {
                            "type": "string",
                            "minLength": 1
                          },
                          "description": "Up to 3 collaborator accounts (@)."
                        },
                        "location_id": {
                          "type": "string",
                          "minLength": 1,
                          "description": "Location ID at Meta."
                        },
                        "audio_name": {
                          "type": "string",
                          "minLength": 1,
                          "description": "Reels audio name."
                        }
                      },
                      "description": "Publication options (`share_to_feed`, `cover`, `thumb_offset_ms`, `collaborators`, `location_id`, `audio_name`)."
                    },
                    "status": {
                      "enum": [
                        "scheduled",
                        "queued",
                        "creating",
                        "processing",
                        "publishing",
                        "published",
                        "failed",
                        "canceled"
                      ],
                      "type": "string",
                      "description": "`scheduled`, `queued`, `creating`, `processing`, `publishing`, `published`, `failed` or `canceled`."
                    },
                    "scheduled_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Scheduled time (ISO 8601); empty or `null` = publish now."
                    },
                    "external_media_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "ID of the published post at Meta."
                    },
                    "permalink": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Link to the published post."
                    },
                    "published_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "When it was published (ISO 8601, UTC)."
                    },
                    "error": {
                      "anyOf": [
                        {
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {}
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Last error, when it failed."
                    },
                    "attempts": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "Attempts made."
                    },
                    "created_at": {
                      "type": "string",
                      "description": "Creation (ISO 8601, UTC)."
                    },
                    "updated_at": {
                      "type": "string",
                      "description": "Last change (ISO 8601, UTC)."
                    }
                  },
                  "required": [
                    "id",
                    "connection_id",
                    "type",
                    "caption",
                    "items",
                    "options",
                    "status",
                    "scheduled_at",
                    "external_media_id",
                    "permalink",
                    "published_at",
                    "error",
                    "attempts",
                    "created_at",
                    "updated_at"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "patch": {
        "operationId": "updatePublication",
        "summary": "Change a scheduled publication",
        "description": "Changes caption, items, time or options of a `scheduled` or `queued` publication; missing fields stay as they are. `scheduled_at: null` publishes now. Other statuses: `409 publication_not_editable`. Permission: `send`.",
        "tags": [
          "publications"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Publication ID (`pub_…`)."
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "caption": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ],
                    "description": "Caption."
                  },
                  "items": {
                    "type": "array",
                    "minItems": 1,
                    "items": {
                      "type": "object",
                      "properties": {
                        "media_id": {
                          "type": "string",
                          "minLength": 1,
                          "description": "Media stored in Messajo (`med_…`)."
                        },
                        "url": {
                          "type": "string",
                          "minLength": 1,
                          "description": "Public https URL that Meta downloads."
                        },
                        "alt_text": {
                          "type": "string",
                          "minLength": 1,
                          "description": "Image alt text."
                        },
                        "user_tags": {
                          "type": "array",
                          "items": {},
                          "description": "People tags, in Meta's format."
                        }
                      },
                      "description": "One media item: `media_id` or `url`."
                    },
                    "description": "The publication's media, in order."
                  },
                  "scheduled_at": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "date-time",
                        "description": "Scheduled time (ISO 8601); empty or `null` = publish now."
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "share_to_feed": {
                    "type": "boolean",
                    "description": "Reels also shows in the feed."
                  },
                  "cover": {
                    "type": "string",
                    "minLength": 1,
                    "description": "Reels cover URL."
                  },
                  "thumb_offset_ms": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 9007199254740991,
                    "description": "Video cover frame, in ms."
                  },
                  "collaborators": {
                    "type": "array",
                    "maxItems": 3,
                    "items": {
                      "type": "string",
                      "minLength": 1
                    },
                    "description": "Up to 3 collaborator accounts (@)."
                  },
                  "location_id": {
                    "type": "string",
                    "minLength": 1,
                    "description": "Location ID at Meta."
                  },
                  "audio_name": {
                    "type": "string",
                    "minLength": 1,
                    "description": "Reels audio name."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The changed publication.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Publication ID (`pub_…`).",
                      "examples": [
                        "pub_0193a1b2c3d47e8f9a0b1c2d3e4f5a6b"
                      ]
                    },
                    "connection_id": {
                      "type": "string",
                      "description": "Instagram connection (`con_…`)."
                    },
                    "type": {
                      "enum": [
                        "photo",
                        "video",
                        "carousel",
                        "reel",
                        "story"
                      ],
                      "type": "string",
                      "description": "`photo`, `video`, `carousel`, `reel` or `story`."
                    },
                    "caption": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Caption."
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "media_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "url": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "kind": {
                            "enum": [
                              "image",
                              "video"
                            ],
                            "type": "string"
                          },
                          "alt_text": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "user_tags": {
                            "type": "array",
                            "items": {
                              "anyOf": [
                                {},
                                {
                                  "type": "null"
                                }
                              ]
                            }
                          }
                        },
                        "required": [
                          "media_id",
                          "url",
                          "kind",
                          "alt_text",
                          "user_tags"
                        ]
                      },
                      "description": "The publication's media, in order."
                    },
                    "options": {
                      "type": "object",
                      "properties": {
                        "share_to_feed": {
                          "type": "boolean",
                          "description": "Reels also shows in the feed."
                        },
                        "cover": {
                          "type": "string",
                          "minLength": 1,
                          "description": "Reels cover URL."
                        },
                        "thumb_offset_ms": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 9007199254740991,
                          "description": "Video cover frame, in ms."
                        },
                        "collaborators": {
                          "type": "array",
                          "maxItems": 3,
                          "items": {
                            "type": "string",
                            "minLength": 1
                          },
                          "description": "Up to 3 collaborator accounts (@)."
                        },
                        "location_id": {
                          "type": "string",
                          "minLength": 1,
                          "description": "Location ID at Meta."
                        },
                        "audio_name": {
                          "type": "string",
                          "minLength": 1,
                          "description": "Reels audio name."
                        }
                      },
                      "description": "Publication options (`share_to_feed`, `cover`, `thumb_offset_ms`, `collaborators`, `location_id`, `audio_name`)."
                    },
                    "status": {
                      "enum": [
                        "scheduled",
                        "queued",
                        "creating",
                        "processing",
                        "publishing",
                        "published",
                        "failed",
                        "canceled"
                      ],
                      "type": "string",
                      "description": "`scheduled`, `queued`, `creating`, `processing`, `publishing`, `published`, `failed` or `canceled`."
                    },
                    "scheduled_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Scheduled time (ISO 8601); empty or `null` = publish now."
                    },
                    "external_media_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "ID of the published post at Meta."
                    },
                    "permalink": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Link to the published post."
                    },
                    "published_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "When it was published (ISO 8601, UTC)."
                    },
                    "error": {
                      "anyOf": [
                        {
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {}
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Last error, when it failed."
                    },
                    "attempts": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "Attempts made."
                    },
                    "created_at": {
                      "type": "string",
                      "description": "Creation (ISO 8601, UTC)."
                    },
                    "updated_at": {
                      "type": "string",
                      "description": "Last change (ISO 8601, UTC)."
                    }
                  },
                  "required": [
                    "id",
                    "connection_id",
                    "type",
                    "caption",
                    "items",
                    "options",
                    "status",
                    "scheduled_at",
                    "external_media_id",
                    "permalink",
                    "published_at",
                    "error",
                    "attempts",
                    "created_at",
                    "updated_at"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/publications/{id}/cancel": {
      "post": {
        "operationId": "cancelPublication",
        "summary": "Cancel a publication",
        "description": "Cancels a `scheduled` or `queued` publication. Other statuses: `409 publication_not_editable`. Permission: `send`.",
        "tags": [
          "publications"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Publication ID (`pub_…`)."
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "description": "The canceled publication.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Publication ID (`pub_…`).",
                      "examples": [
                        "pub_0193a1b2c3d47e8f9a0b1c2d3e4f5a6b"
                      ]
                    },
                    "connection_id": {
                      "type": "string",
                      "description": "Instagram connection (`con_…`)."
                    },
                    "type": {
                      "enum": [
                        "photo",
                        "video",
                        "carousel",
                        "reel",
                        "story"
                      ],
                      "type": "string",
                      "description": "`photo`, `video`, `carousel`, `reel` or `story`."
                    },
                    "caption": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Caption."
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "media_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "url": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "kind": {
                            "enum": [
                              "image",
                              "video"
                            ],
                            "type": "string"
                          },
                          "alt_text": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "user_tags": {
                            "type": "array",
                            "items": {
                              "anyOf": [
                                {},
                                {
                                  "type": "null"
                                }
                              ]
                            }
                          }
                        },
                        "required": [
                          "media_id",
                          "url",
                          "kind",
                          "alt_text",
                          "user_tags"
                        ]
                      },
                      "description": "The publication's media, in order."
                    },
                    "options": {
                      "type": "object",
                      "properties": {
                        "share_to_feed": {
                          "type": "boolean",
                          "description": "Reels also shows in the feed."
                        },
                        "cover": {
                          "type": "string",
                          "minLength": 1,
                          "description": "Reels cover URL."
                        },
                        "thumb_offset_ms": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 9007199254740991,
                          "description": "Video cover frame, in ms."
                        },
                        "collaborators": {
                          "type": "array",
                          "maxItems": 3,
                          "items": {
                            "type": "string",
                            "minLength": 1
                          },
                          "description": "Up to 3 collaborator accounts (@)."
                        },
                        "location_id": {
                          "type": "string",
                          "minLength": 1,
                          "description": "Location ID at Meta."
                        },
                        "audio_name": {
                          "type": "string",
                          "minLength": 1,
                          "description": "Reels audio name."
                        }
                      },
                      "description": "Publication options (`share_to_feed`, `cover`, `thumb_offset_ms`, `collaborators`, `location_id`, `audio_name`)."
                    },
                    "status": {
                      "enum": [
                        "scheduled",
                        "queued",
                        "creating",
                        "processing",
                        "publishing",
                        "published",
                        "failed",
                        "canceled"
                      ],
                      "type": "string",
                      "description": "`scheduled`, `queued`, `creating`, `processing`, `publishing`, `published`, `failed` or `canceled`."
                    },
                    "scheduled_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Scheduled time (ISO 8601); empty or `null` = publish now."
                    },
                    "external_media_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "ID of the published post at Meta."
                    },
                    "permalink": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Link to the published post."
                    },
                    "published_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "When it was published (ISO 8601, UTC)."
                    },
                    "error": {
                      "anyOf": [
                        {
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {}
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Last error, when it failed."
                    },
                    "attempts": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "Attempts made."
                    },
                    "created_at": {
                      "type": "string",
                      "description": "Creation (ISO 8601, UTC)."
                    },
                    "updated_at": {
                      "type": "string",
                      "description": "Last change (ISO 8601, UTC)."
                    }
                  },
                  "required": [
                    "id",
                    "connection_id",
                    "type",
                    "caption",
                    "items",
                    "options",
                    "status",
                    "scheduled_at",
                    "external_media_id",
                    "permalink",
                    "published_at",
                    "error",
                    "attempts",
                    "created_at",
                    "updated_at"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/publications/{id}/retry": {
      "post": {
        "operationId": "retryPublication",
        "summary": "Retry",
        "description": "Queues a `failed` publication again, with new containers. Not allowed when the outcome was uncertain. Permission: `send`.",
        "tags": [
          "publications"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Publication ID (`pub_…`)."
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "description": "The queued publication.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Publication ID (`pub_…`).",
                      "examples": [
                        "pub_0193a1b2c3d47e8f9a0b1c2d3e4f5a6b"
                      ]
                    },
                    "connection_id": {
                      "type": "string",
                      "description": "Instagram connection (`con_…`)."
                    },
                    "type": {
                      "enum": [
                        "photo",
                        "video",
                        "carousel",
                        "reel",
                        "story"
                      ],
                      "type": "string",
                      "description": "`photo`, `video`, `carousel`, `reel` or `story`."
                    },
                    "caption": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Caption."
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "media_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "url": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "kind": {
                            "enum": [
                              "image",
                              "video"
                            ],
                            "type": "string"
                          },
                          "alt_text": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "user_tags": {
                            "type": "array",
                            "items": {
                              "anyOf": [
                                {},
                                {
                                  "type": "null"
                                }
                              ]
                            }
                          }
                        },
                        "required": [
                          "media_id",
                          "url",
                          "kind",
                          "alt_text",
                          "user_tags"
                        ]
                      },
                      "description": "The publication's media, in order."
                    },
                    "options": {
                      "type": "object",
                      "properties": {
                        "share_to_feed": {
                          "type": "boolean",
                          "description": "Reels also shows in the feed."
                        },
                        "cover": {
                          "type": "string",
                          "minLength": 1,
                          "description": "Reels cover URL."
                        },
                        "thumb_offset_ms": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 9007199254740991,
                          "description": "Video cover frame, in ms."
                        },
                        "collaborators": {
                          "type": "array",
                          "maxItems": 3,
                          "items": {
                            "type": "string",
                            "minLength": 1
                          },
                          "description": "Up to 3 collaborator accounts (@)."
                        },
                        "location_id": {
                          "type": "string",
                          "minLength": 1,
                          "description": "Location ID at Meta."
                        },
                        "audio_name": {
                          "type": "string",
                          "minLength": 1,
                          "description": "Reels audio name."
                        }
                      },
                      "description": "Publication options (`share_to_feed`, `cover`, `thumb_offset_ms`, `collaborators`, `location_id`, `audio_name`)."
                    },
                    "status": {
                      "enum": [
                        "scheduled",
                        "queued",
                        "creating",
                        "processing",
                        "publishing",
                        "published",
                        "failed",
                        "canceled"
                      ],
                      "type": "string",
                      "description": "`scheduled`, `queued`, `creating`, `processing`, `publishing`, `published`, `failed` or `canceled`."
                    },
                    "scheduled_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Scheduled time (ISO 8601); empty or `null` = publish now."
                    },
                    "external_media_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "ID of the published post at Meta."
                    },
                    "permalink": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Link to the published post."
                    },
                    "published_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "When it was published (ISO 8601, UTC)."
                    },
                    "error": {
                      "anyOf": [
                        {
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {}
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Last error, when it failed."
                    },
                    "attempts": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "Attempts made."
                    },
                    "created_at": {
                      "type": "string",
                      "description": "Creation (ISO 8601, UTC)."
                    },
                    "updated_at": {
                      "type": "string",
                      "description": "Last change (ISO 8601, UTC)."
                    }
                  },
                  "required": [
                    "id",
                    "connection_id",
                    "type",
                    "caption",
                    "items",
                    "options",
                    "status",
                    "scheduled_at",
                    "external_media_id",
                    "permalink",
                    "published_at",
                    "error",
                    "attempts",
                    "created_at",
                    "updated_at"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/conversations": {
      "get": {
        "operationId": "listConversations",
        "summary": "List conversations",
        "description": "Lists the organization's conversations, from the most recent last message to the oldest. A key restricted to connections only sees their conversations. Permission: `read`.",
        "tags": [
          "history"
        ],
        "parameters": [
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 512,
              "description": "Opaque cursor for the next page: the `next_cursor` of the previous response, with the same filters. Tampered or from another route → `400 invalid_cursor`."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50,
              "description": "Items per page, from 1 to 100 (default 50)."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "connection_id",
            "in": "query",
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "Connection ID."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "contact_id",
            "in": "query",
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "Contact ID."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "window",
            "in": "query",
            "schema": {
              "enum": [
                "open",
                "closed"
              ],
              "type": "string",
              "description": "`open` = service window open; `closed` = closed."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "since",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time",
              "description": "Last message from this date on (ISO 8601)."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "until",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time",
              "description": "Last message up to this date (ISO 8601)."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          }
        ],
        "responses": {
          "200": {
            "description": "A page of conversations.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "description": "Conversation ID."
                          },
                          "connection_id": {
                            "type": "string",
                            "description": "Connection ID."
                          },
                          "channel": {
                            "enum": [
                              "whatsapp",
                              "instagram",
                              "messenger"
                            ],
                            "type": "string",
                            "description": "Channel: `whatsapp`, `instagram` or `messenger`."
                          },
                          "contact": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "description": "Contact ID."
                              },
                              "display_name": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ],
                                "description": "Contact name, when known."
                              }
                            },
                            "required": [
                              "id",
                              "display_name"
                            ],
                            "description": "The conversation's contact."
                          },
                          "last_message_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Last message of the conversation (ISO 8601, UTC)."
                          },
                          "last_inbound_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Last message received from the contact (ISO 8601, UTC)."
                          },
                          "last_outbound_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Last message sent to the contact (ISO 8601, UTC)."
                          },
                          "window_ends_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "End of the 24 h service window (ISO 8601, UTC)."
                          },
                          "extended_window_ends_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "End of the extended window (ISO 8601, UTC); `null` = no extended window."
                          },
                          "extended_window_kind": {
                            "anyOf": [
                              {
                                "enum": [
                                  "human_agent",
                                  "ad_referral"
                                ],
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Kind of extended window: `human_agent` or `ad_referral`."
                          },
                          "window_open": {
                            "type": "boolean",
                            "description": "`true` while the service window is open."
                          },
                          "last_sequence": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991,
                            "description": "Sequence number of the conversation's last event."
                          },
                          "created_at": {
                            "type": "string",
                            "description": "Creation date (ISO 8601, UTC)."
                          }
                        },
                        "required": [
                          "id",
                          "connection_id",
                          "channel",
                          "contact",
                          "last_message_at",
                          "last_inbound_at",
                          "last_outbound_at",
                          "window_ends_at",
                          "extended_window_ends_at",
                          "extended_window_kind",
                          "window_open",
                          "last_sequence",
                          "created_at"
                        ]
                      },
                      "description": "Page items, newest first."
                    },
                    "next_cursor": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Cursor for the next page; `null` when there are no more items."
                    }
                  },
                  "required": [
                    "data",
                    "next_cursor"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/conversations/{id}": {
      "get": {
        "operationId": "getConversation",
        "summary": "Get conversation",
        "description": "Returns a conversation, with its service window. Permission: `read`.",
        "tags": [
          "history"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Conversation ID."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The conversation.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Conversation ID."
                    },
                    "connection_id": {
                      "type": "string",
                      "description": "Connection ID."
                    },
                    "channel": {
                      "enum": [
                        "whatsapp",
                        "instagram",
                        "messenger"
                      ],
                      "type": "string",
                      "description": "Channel: `whatsapp`, `instagram` or `messenger`."
                    },
                    "contact": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "description": "Contact ID."
                        },
                        "display_name": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ],
                          "description": "Contact name, when known."
                        }
                      },
                      "required": [
                        "id",
                        "display_name"
                      ],
                      "description": "The conversation's contact."
                    },
                    "last_message_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Last message of the conversation (ISO 8601, UTC)."
                    },
                    "last_inbound_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Last message received from the contact (ISO 8601, UTC)."
                    },
                    "last_outbound_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Last message sent to the contact (ISO 8601, UTC)."
                    },
                    "window_ends_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "End of the 24 h service window (ISO 8601, UTC)."
                    },
                    "extended_window_ends_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "End of the extended window (ISO 8601, UTC); `null` = no extended window."
                    },
                    "extended_window_kind": {
                      "anyOf": [
                        {
                          "enum": [
                            "human_agent",
                            "ad_referral"
                          ],
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Kind of extended window: `human_agent` or `ad_referral`."
                    },
                    "window_open": {
                      "type": "boolean",
                      "description": "`true` while the service window is open."
                    },
                    "last_sequence": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "Sequence number of the conversation's last event."
                    },
                    "created_at": {
                      "type": "string",
                      "description": "Creation date (ISO 8601, UTC)."
                    }
                  },
                  "required": [
                    "id",
                    "connection_id",
                    "channel",
                    "contact",
                    "last_message_at",
                    "last_inbound_at",
                    "last_outbound_at",
                    "window_ends_at",
                    "extended_window_ends_at",
                    "extended_window_kind",
                    "window_open",
                    "last_sequence",
                    "created_at"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/conversations/{id}/messages": {
      "get": {
        "operationId": "listConversationMessages",
        "summary": "List conversation messages",
        "description": "Lists a conversation's messages within the organization's retention (default: newest first). Permission: `read`.",
        "tags": [
          "history"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Conversation ID."
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 512,
              "description": "Opaque cursor for the next page: the `next_cursor` of the previous response, with the same filters. Tampered or from another route → `400 invalid_cursor`."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50,
              "description": "Items per page, from 1 to 100 (default 50)."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "order",
            "in": "query",
            "schema": {
              "enum": [
                "desc",
                "asc"
              ],
              "type": "string",
              "default": "desc",
              "description": "Order: `desc` (default, newest first) or `asc`."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "direction",
            "in": "query",
            "schema": {
              "enum": [
                "inbound",
                "outbound"
              ],
              "type": "string",
              "description": "Direction: `inbound` (received) or `outbound` (sent)."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "type",
            "in": "query",
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "Content type, e.g. `text`, `image`, `template`."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "since",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time",
              "description": "Start of the range (ISO 8601). Default and floor: now minus the organization's retention."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "until",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time",
              "description": "End of the range (ISO 8601). Default: now."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          }
        ],
        "responses": {
          "200": {
            "description": "A page of messages.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "description": "Message ID at Messajo (`msg_…`).",
                            "examples": [
                              "msg_0193a1b2c3d47e8f9a0b1c2d3e4f5a6b"
                            ]
                          },
                          "external_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Message ID at Meta; `null` before acceptance."
                          },
                          "direction": {
                            "enum": [
                              "inbound",
                              "outbound"
                            ],
                            "type": "string",
                            "description": "Direction: `inbound` (received) or `outbound` (sent)."
                          },
                          "source": {
                            "enum": [
                              "customer",
                              "api",
                              "business_app",
                              "history",
                              "campaign"
                            ],
                            "type": "string",
                            "description": "Source: `customer`, `api`, `business_app`, `history` or `campaign`."
                          },
                          "timestamp": {
                            "type": "string",
                            "description": "When the message happened (ISO 8601, UTC)."
                          },
                          "content": {
                            "anyOf": [
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "const": "text"
                                  },
                                  "body": {
                                    "type": "string"
                                  },
                                  "quick_replies": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "title": {
                                          "type": "string"
                                        },
                                        "payload": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "title",
                                        "payload"
                                      ]
                                    }
                                  }
                                },
                                "required": [
                                  "type",
                                  "body"
                                ]
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "enum": [
                                      "image",
                                      "video",
                                      "document"
                                    ]
                                  },
                                  "media": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "mime_type": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "sha256": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "size_bytes": {
                                        "anyOf": [
                                          {
                                            "type": "integer",
                                            "minimum": 0,
                                            "maximum": 9007199254740991
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "filename": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "caption": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "status": {
                                        "enum": [
                                          "pending",
                                          "stored",
                                          "failed"
                                        ],
                                        "type": "string"
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "mime_type",
                                      "sha256",
                                      "size_bytes",
                                      "filename",
                                      "caption",
                                      "status"
                                    ]
                                  }
                                },
                                "required": [
                                  "type",
                                  "media"
                                ]
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "const": "audio"
                                  },
                                  "media": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "mime_type": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "sha256": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "size_bytes": {
                                        "anyOf": [
                                          {
                                            "type": "integer",
                                            "minimum": 0,
                                            "maximum": 9007199254740991
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "filename": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "caption": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "status": {
                                        "enum": [
                                          "pending",
                                          "stored",
                                          "failed"
                                        ],
                                        "type": "string"
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "mime_type",
                                      "sha256",
                                      "size_bytes",
                                      "filename",
                                      "caption",
                                      "status"
                                    ]
                                  },
                                  "voice": {
                                    "type": "boolean"
                                  }
                                },
                                "required": [
                                  "type",
                                  "media",
                                  "voice"
                                ]
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "const": "images"
                                  },
                                  "images": {
                                    "type": "array",
                                    "minItems": 1,
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "id": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "mime_type": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "sha256": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "size_bytes": {
                                          "anyOf": [
                                            {
                                              "type": "integer",
                                              "minimum": 0,
                                              "maximum": 9007199254740991
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "filename": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "caption": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "status": {
                                          "enum": [
                                            "pending",
                                            "stored",
                                            "failed"
                                          ],
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "id",
                                        "mime_type",
                                        "sha256",
                                        "size_bytes",
                                        "filename",
                                        "caption",
                                        "status"
                                      ]
                                    }
                                  }
                                },
                                "required": [
                                  "type",
                                  "images"
                                ]
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "const": "like"
                                  }
                                },
                                "required": [
                                  "type"
                                ]
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "const": "sticker"
                                  },
                                  "media": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "mime_type": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "sha256": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "size_bytes": {
                                        "anyOf": [
                                          {
                                            "type": "integer",
                                            "minimum": 0,
                                            "maximum": 9007199254740991
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "filename": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "caption": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "status": {
                                        "enum": [
                                          "pending",
                                          "stored",
                                          "failed"
                                        ],
                                        "type": "string"
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "mime_type",
                                      "sha256",
                                      "size_bytes",
                                      "filename",
                                      "caption",
                                      "status"
                                    ]
                                  },
                                  "animated": {
                                    "type": "boolean"
                                  }
                                },
                                "required": [
                                  "type",
                                  "media",
                                  "animated"
                                ]
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "const": "location"
                                  },
                                  "latitude": {
                                    "type": "number"
                                  },
                                  "longitude": {
                                    "type": "number"
                                  },
                                  "name": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "address": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "url": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  }
                                },
                                "required": [
                                  "type",
                                  "latitude",
                                  "longitude",
                                  "name",
                                  "address",
                                  "url"
                                ]
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "const": "contacts"
                                  },
                                  "contacts": {
                                    "type": "array",
                                    "minItems": 1,
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "name": {
                                          "type": "object",
                                          "properties": {
                                            "formatted_name": {
                                              "type": "string"
                                            },
                                            "first_name": {
                                              "anyOf": [
                                                {
                                                  "type": "string"
                                                },
                                                {
                                                  "type": "null"
                                                }
                                              ]
                                            },
                                            "last_name": {
                                              "anyOf": [
                                                {
                                                  "type": "string"
                                                },
                                                {
                                                  "type": "null"
                                                }
                                              ]
                                            }
                                          },
                                          "required": [
                                            "formatted_name",
                                            "first_name",
                                            "last_name"
                                          ]
                                        },
                                        "phones": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "properties": {
                                              "phone": {
                                                "type": "string"
                                              },
                                              "wa_id": {
                                                "anyOf": [
                                                  {
                                                    "type": "string"
                                                  },
                                                  {
                                                    "type": "null"
                                                  }
                                                ]
                                              },
                                              "type": {
                                                "anyOf": [
                                                  {
                                                    "type": "string"
                                                  },
                                                  {
                                                    "type": "null"
                                                  }
                                                ]
                                              }
                                            },
                                            "required": [
                                              "phone",
                                              "wa_id",
                                              "type"
                                            ]
                                          }
                                        },
                                        "emails": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "properties": {
                                              "email": {
                                                "type": "string"
                                              },
                                              "type": {
                                                "anyOf": [
                                                  {
                                                    "type": "string"
                                                  },
                                                  {
                                                    "type": "null"
                                                  }
                                                ]
                                              }
                                            },
                                            "required": [
                                              "email",
                                              "type"
                                            ]
                                          }
                                        }
                                      },
                                      "required": [
                                        "name",
                                        "phones",
                                        "emails"
                                      ]
                                    }
                                  }
                                },
                                "required": [
                                  "type",
                                  "contacts"
                                ]
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "const": "reaction"
                                  },
                                  "message_id": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "external_message_id": {
                                    "type": "string"
                                  },
                                  "emoji": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  }
                                },
                                "required": [
                                  "type",
                                  "message_id",
                                  "external_message_id",
                                  "emoji"
                                ]
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "const": "reply"
                                  },
                                  "kind": {
                                    "enum": [
                                      "button",
                                      "list",
                                      "quick_reply",
                                      "postback",
                                      "flow"
                                    ],
                                    "type": "string"
                                  },
                                  "id": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "title": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "description": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "payload": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  }
                                },
                                "required": [
                                  "type",
                                  "kind",
                                  "id",
                                  "title",
                                  "description",
                                  "payload"
                                ]
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "const": "order"
                                  },
                                  "catalog_id": {
                                    "type": "string"
                                  },
                                  "items": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "product_retailer_id": {
                                          "type": "string"
                                        },
                                        "quantity": {
                                          "type": "integer",
                                          "minimum": -9007199254740991,
                                          "maximum": 9007199254740991,
                                          "exclusiveMinimum": 0
                                        },
                                        "item_price": {
                                          "type": "number",
                                          "minimum": 0
                                        },
                                        "currency": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "product_retailer_id",
                                        "quantity",
                                        "item_price",
                                        "currency"
                                      ]
                                    }
                                  },
                                  "note": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  }
                                },
                                "required": [
                                  "type",
                                  "catalog_id",
                                  "items",
                                  "note"
                                ]
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "const": "call_permission_reply"
                                  },
                                  "response": {
                                    "enum": [
                                      "accept",
                                      "reject"
                                    ],
                                    "type": "string"
                                  },
                                  "permanent": {
                                    "type": "boolean"
                                  },
                                  "expires_at": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "date-time"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "source": {
                                    "enum": [
                                      "user_action",
                                      "automatic"
                                    ],
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "type",
                                  "response",
                                  "permanent",
                                  "expires_at",
                                  "source"
                                ]
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "const": "share"
                                  },
                                  "kind": {
                                    "enum": [
                                      "post",
                                      "reel",
                                      "story",
                                      "story_mention",
                                      "link"
                                    ],
                                    "type": "string"
                                  },
                                  "url": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "external_id": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  }
                                },
                                "required": [
                                  "type",
                                  "kind",
                                  "url",
                                  "external_id"
                                ]
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "const": "system"
                                  },
                                  "kind": {
                                    "type": "string"
                                  },
                                  "body": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  }
                                },
                                "required": [
                                  "type",
                                  "kind",
                                  "body"
                                ]
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "const": "unsupported"
                                  },
                                  "meta_type": {
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "type",
                                  "meta_type"
                                ]
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "const": "template"
                                  },
                                  "name": {
                                    "type": "string"
                                  },
                                  "language": {
                                    "type": "string"
                                  },
                                  "components": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    }
                                  },
                                  "otp": {
                                    "type": "boolean"
                                  }
                                },
                                "required": [
                                  "type",
                                  "name",
                                  "language",
                                  "components"
                                ]
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "const": "interactive"
                                  },
                                  "kind": {
                                    "enum": [
                                      "button",
                                      "list",
                                      "cta_url",
                                      "location_request",
                                      "flow",
                                      "product",
                                      "product_list",
                                      "catalog_message",
                                      "order_details",
                                      "order_status",
                                      "call_permission_request"
                                    ],
                                    "type": "string"
                                  },
                                  "body": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "interactive": {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {}
                                  }
                                },
                                "required": [
                                  "type",
                                  "kind",
                                  "body",
                                  "interactive"
                                ]
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "const": "buttons"
                                  },
                                  "body": {
                                    "type": "string"
                                  },
                                  "buttons": {
                                    "type": "array",
                                    "minItems": 1,
                                    "items": {
                                      "anyOf": [
                                        {
                                          "type": "object",
                                          "properties": {
                                            "type": {
                                              "const": "postback"
                                            },
                                            "title": {
                                              "type": "string"
                                            },
                                            "payload": {
                                              "type": "string"
                                            }
                                          },
                                          "required": [
                                            "type",
                                            "title",
                                            "payload"
                                          ]
                                        },
                                        {
                                          "type": "object",
                                          "properties": {
                                            "type": {
                                              "const": "web_url"
                                            },
                                            "title": {
                                              "type": "string"
                                            },
                                            "url": {
                                              "type": "string"
                                            }
                                          },
                                          "required": [
                                            "type",
                                            "title",
                                            "url"
                                          ]
                                        }
                                      ]
                                    }
                                  },
                                  "quick_replies": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "title": {
                                          "type": "string"
                                        },
                                        "payload": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "title",
                                        "payload"
                                      ]
                                    }
                                  }
                                },
                                "required": [
                                  "type",
                                  "body",
                                  "buttons"
                                ]
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "const": "cards"
                                  },
                                  "cards": {
                                    "type": "array",
                                    "minItems": 1,
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "title": {
                                          "type": "string"
                                        },
                                        "subtitle": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "image_url": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "default_url": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "buttons": {
                                          "type": "array",
                                          "items": {
                                            "anyOf": [
                                              {
                                                "type": "object",
                                                "properties": {
                                                  "type": {
                                                    "const": "postback"
                                                  },
                                                  "title": {
                                                    "type": "string"
                                                  },
                                                  "payload": {
                                                    "type": "string"
                                                  }
                                                },
                                                "required": [
                                                  "type",
                                                  "title",
                                                  "payload"
                                                ]
                                              },
                                              {
                                                "type": "object",
                                                "properties": {
                                                  "type": {
                                                    "const": "web_url"
                                                  },
                                                  "title": {
                                                    "type": "string"
                                                  },
                                                  "url": {
                                                    "type": "string"
                                                  }
                                                },
                                                "required": [
                                                  "type",
                                                  "title",
                                                  "url"
                                                ]
                                              }
                                            ]
                                          }
                                        }
                                      },
                                      "required": [
                                        "title",
                                        "subtitle",
                                        "image_url",
                                        "default_url",
                                        "buttons"
                                      ]
                                    }
                                  },
                                  "quick_replies": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "title": {
                                          "type": "string"
                                        },
                                        "payload": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "title",
                                        "payload"
                                      ]
                                    }
                                  }
                                },
                                "required": [
                                  "type",
                                  "cards"
                                ]
                              }
                            ],
                            "description": "Normalized content (the same as in `message.*` events)."
                          },
                          "context": {
                            "anyOf": [
                              {
                                "type": "object",
                                "properties": {
                                  "reply_to": {
                                    "anyOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "message_id": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "external_id": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "message_id",
                                          "external_id"
                                        ]
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "forwarded": {
                                    "type": "boolean"
                                  },
                                  "frequently_forwarded": {
                                    "type": "boolean"
                                  },
                                  "referral": {
                                    "anyOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "source_type": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "source_id": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "source_url": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "headline": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "ctwa_clid": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          }
                                        },
                                        "required": [
                                          "source_type",
                                          "source_id",
                                          "source_url",
                                          "headline",
                                          "ctwa_clid"
                                        ]
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "reply_to_story": {
                                    "anyOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "external_id": {
                                            "type": "string"
                                          },
                                          "url": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          }
                                        },
                                        "required": [
                                          "external_id",
                                          "url"
                                        ]
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "standby": {
                                    "type": "boolean"
                                  }
                                },
                                "required": [
                                  "reply_to",
                                  "forwarded",
                                  "frequently_forwarded",
                                  "referral"
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Context: reply, forward, source ad; `null` = no context."
                          },
                          "conversation_id": {
                            "type": "string",
                            "description": "Conversation ID."
                          },
                          "contact_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Contact ID."
                          },
                          "status": {
                            "enum": [
                              "received",
                              "queued",
                              "sent",
                              "delivered",
                              "read",
                              "played",
                              "failed",
                              "deleted"
                            ],
                            "type": "string",
                            "description": "Message status."
                          },
                          "sent_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Sent (ISO 8601, UTC)."
                          },
                          "delivered_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Delivered (ISO 8601, UTC)."
                          },
                          "read_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Read (ISO 8601, UTC)."
                          },
                          "failed_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Failed (ISO 8601, UTC)."
                          },
                          "edited_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Edited (ISO 8601, UTC)."
                          },
                          "revoked_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Deleted by the sender (ISO 8601, UTC)."
                          },
                          "error": {
                            "anyOf": [
                              {
                                "type": "object",
                                "propertyNames": {
                                  "type": "string"
                                },
                                "additionalProperties": {}
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Send error, in Meta's format; `null` = no error."
                          },
                          "campaign": {
                            "anyOf": [
                              {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "description": "Only messages from this campaign."
                                  },
                                  "recipient_id": {
                                    "type": "string",
                                    "description": "Campaign recipient ID."
                                  }
                                },
                                "required": [
                                  "id",
                                  "recipient_id"
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Campaign that sent the message; `null` outside campaigns."
                          }
                        },
                        "required": [
                          "id",
                          "external_id",
                          "direction",
                          "source",
                          "timestamp",
                          "content",
                          "context",
                          "conversation_id",
                          "contact_id",
                          "status",
                          "sent_at",
                          "delivered_at",
                          "read_at",
                          "failed_at",
                          "edited_at",
                          "revoked_at",
                          "error",
                          "campaign"
                        ]
                      },
                      "description": "Page items, newest first."
                    },
                    "next_cursor": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Cursor for the next page; `null` when there are no more items."
                    }
                  },
                  "required": [
                    "data",
                    "next_cursor"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/messages/{id}": {
      "get": {
        "operationId": "getMessage",
        "summary": "Get message",
        "description": "Returns a message within the organization's retention. Media shows up with an `id`; the content comes from `GET /v1/media/{id}/content`. Permission: `read`.",
        "tags": [
          "history"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Message ID at Messajo (`msg_…`)."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The message.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Message ID at Messajo (`msg_…`).",
                      "examples": [
                        "msg_0193a1b2c3d47e8f9a0b1c2d3e4f5a6b"
                      ]
                    },
                    "external_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Message ID at Meta; `null` before acceptance."
                    },
                    "direction": {
                      "enum": [
                        "inbound",
                        "outbound"
                      ],
                      "type": "string",
                      "description": "Direction: `inbound` (received) or `outbound` (sent)."
                    },
                    "source": {
                      "enum": [
                        "customer",
                        "api",
                        "business_app",
                        "history",
                        "campaign"
                      ],
                      "type": "string",
                      "description": "Source: `customer`, `api`, `business_app`, `history` or `campaign`."
                    },
                    "timestamp": {
                      "type": "string",
                      "description": "When the message happened (ISO 8601, UTC)."
                    },
                    "content": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "const": "text"
                            },
                            "body": {
                              "type": "string"
                            },
                            "quick_replies": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "title": {
                                    "type": "string"
                                  },
                                  "payload": {
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "title",
                                  "payload"
                                ]
                              }
                            }
                          },
                          "required": [
                            "type",
                            "body"
                          ]
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "enum": [
                                "image",
                                "video",
                                "document"
                              ]
                            },
                            "media": {
                              "type": "object",
                              "properties": {
                                "id": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "mime_type": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "sha256": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "size_bytes": {
                                  "anyOf": [
                                    {
                                      "type": "integer",
                                      "minimum": 0,
                                      "maximum": 9007199254740991
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "filename": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "caption": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "status": {
                                  "enum": [
                                    "pending",
                                    "stored",
                                    "failed"
                                  ],
                                  "type": "string"
                                }
                              },
                              "required": [
                                "id",
                                "mime_type",
                                "sha256",
                                "size_bytes",
                                "filename",
                                "caption",
                                "status"
                              ]
                            }
                          },
                          "required": [
                            "type",
                            "media"
                          ]
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "const": "audio"
                            },
                            "media": {
                              "type": "object",
                              "properties": {
                                "id": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "mime_type": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "sha256": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "size_bytes": {
                                  "anyOf": [
                                    {
                                      "type": "integer",
                                      "minimum": 0,
                                      "maximum": 9007199254740991
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "filename": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "caption": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "status": {
                                  "enum": [
                                    "pending",
                                    "stored",
                                    "failed"
                                  ],
                                  "type": "string"
                                }
                              },
                              "required": [
                                "id",
                                "mime_type",
                                "sha256",
                                "size_bytes",
                                "filename",
                                "caption",
                                "status"
                              ]
                            },
                            "voice": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "type",
                            "media",
                            "voice"
                          ]
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "const": "images"
                            },
                            "images": {
                              "type": "array",
                              "minItems": 1,
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "mime_type": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "sha256": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "size_bytes": {
                                    "anyOf": [
                                      {
                                        "type": "integer",
                                        "minimum": 0,
                                        "maximum": 9007199254740991
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "filename": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "caption": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "status": {
                                    "enum": [
                                      "pending",
                                      "stored",
                                      "failed"
                                    ],
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "id",
                                  "mime_type",
                                  "sha256",
                                  "size_bytes",
                                  "filename",
                                  "caption",
                                  "status"
                                ]
                              }
                            }
                          },
                          "required": [
                            "type",
                            "images"
                          ]
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "const": "like"
                            }
                          },
                          "required": [
                            "type"
                          ]
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "const": "sticker"
                            },
                            "media": {
                              "type": "object",
                              "properties": {
                                "id": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "mime_type": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "sha256": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "size_bytes": {
                                  "anyOf": [
                                    {
                                      "type": "integer",
                                      "minimum": 0,
                                      "maximum": 9007199254740991
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "filename": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "caption": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "status": {
                                  "enum": [
                                    "pending",
                                    "stored",
                                    "failed"
                                  ],
                                  "type": "string"
                                }
                              },
                              "required": [
                                "id",
                                "mime_type",
                                "sha256",
                                "size_bytes",
                                "filename",
                                "caption",
                                "status"
                              ]
                            },
                            "animated": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "type",
                            "media",
                            "animated"
                          ]
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "const": "location"
                            },
                            "latitude": {
                              "type": "number"
                            },
                            "longitude": {
                              "type": "number"
                            },
                            "name": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "address": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "url": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            }
                          },
                          "required": [
                            "type",
                            "latitude",
                            "longitude",
                            "name",
                            "address",
                            "url"
                          ]
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "const": "contacts"
                            },
                            "contacts": {
                              "type": "array",
                              "minItems": 1,
                              "items": {
                                "type": "object",
                                "properties": {
                                  "name": {
                                    "type": "object",
                                    "properties": {
                                      "formatted_name": {
                                        "type": "string"
                                      },
                                      "first_name": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "last_name": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      }
                                    },
                                    "required": [
                                      "formatted_name",
                                      "first_name",
                                      "last_name"
                                    ]
                                  },
                                  "phones": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "phone": {
                                          "type": "string"
                                        },
                                        "wa_id": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "type": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        }
                                      },
                                      "required": [
                                        "phone",
                                        "wa_id",
                                        "type"
                                      ]
                                    }
                                  },
                                  "emails": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "email": {
                                          "type": "string"
                                        },
                                        "type": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        }
                                      },
                                      "required": [
                                        "email",
                                        "type"
                                      ]
                                    }
                                  }
                                },
                                "required": [
                                  "name",
                                  "phones",
                                  "emails"
                                ]
                              }
                            }
                          },
                          "required": [
                            "type",
                            "contacts"
                          ]
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "const": "reaction"
                            },
                            "message_id": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "external_message_id": {
                              "type": "string"
                            },
                            "emoji": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            }
                          },
                          "required": [
                            "type",
                            "message_id",
                            "external_message_id",
                            "emoji"
                          ]
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "const": "reply"
                            },
                            "kind": {
                              "enum": [
                                "button",
                                "list",
                                "quick_reply",
                                "postback",
                                "flow"
                              ],
                              "type": "string"
                            },
                            "id": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "title": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "description": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "payload": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            }
                          },
                          "required": [
                            "type",
                            "kind",
                            "id",
                            "title",
                            "description",
                            "payload"
                          ]
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "const": "order"
                            },
                            "catalog_id": {
                              "type": "string"
                            },
                            "items": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "product_retailer_id": {
                                    "type": "string"
                                  },
                                  "quantity": {
                                    "type": "integer",
                                    "minimum": -9007199254740991,
                                    "maximum": 9007199254740991,
                                    "exclusiveMinimum": 0
                                  },
                                  "item_price": {
                                    "type": "number",
                                    "minimum": 0
                                  },
                                  "currency": {
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "product_retailer_id",
                                  "quantity",
                                  "item_price",
                                  "currency"
                                ]
                              }
                            },
                            "note": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            }
                          },
                          "required": [
                            "type",
                            "catalog_id",
                            "items",
                            "note"
                          ]
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "const": "call_permission_reply"
                            },
                            "response": {
                              "enum": [
                                "accept",
                                "reject"
                              ],
                              "type": "string"
                            },
                            "permanent": {
                              "type": "boolean"
                            },
                            "expires_at": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "source": {
                              "enum": [
                                "user_action",
                                "automatic"
                              ],
                              "type": "string"
                            }
                          },
                          "required": [
                            "type",
                            "response",
                            "permanent",
                            "expires_at",
                            "source"
                          ]
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "const": "share"
                            },
                            "kind": {
                              "enum": [
                                "post",
                                "reel",
                                "story",
                                "story_mention",
                                "link"
                              ],
                              "type": "string"
                            },
                            "url": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "external_id": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            }
                          },
                          "required": [
                            "type",
                            "kind",
                            "url",
                            "external_id"
                          ]
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "const": "system"
                            },
                            "kind": {
                              "type": "string"
                            },
                            "body": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            }
                          },
                          "required": [
                            "type",
                            "kind",
                            "body"
                          ]
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "const": "unsupported"
                            },
                            "meta_type": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "type",
                            "meta_type"
                          ]
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "const": "template"
                            },
                            "name": {
                              "type": "string"
                            },
                            "language": {
                              "type": "string"
                            },
                            "components": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "propertyNames": {
                                  "type": "string"
                                },
                                "additionalProperties": {}
                              }
                            },
                            "otp": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "type",
                            "name",
                            "language",
                            "components"
                          ]
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "const": "interactive"
                            },
                            "kind": {
                              "enum": [
                                "button",
                                "list",
                                "cta_url",
                                "location_request",
                                "flow",
                                "product",
                                "product_list",
                                "catalog_message",
                                "order_details",
                                "order_status",
                                "call_permission_request"
                              ],
                              "type": "string"
                            },
                            "body": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "interactive": {
                              "type": "object",
                              "propertyNames": {
                                "type": "string"
                              },
                              "additionalProperties": {}
                            }
                          },
                          "required": [
                            "type",
                            "kind",
                            "body",
                            "interactive"
                          ]
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "const": "buttons"
                            },
                            "body": {
                              "type": "string"
                            },
                            "buttons": {
                              "type": "array",
                              "minItems": 1,
                              "items": {
                                "anyOf": [
                                  {
                                    "type": "object",
                                    "properties": {
                                      "type": {
                                        "const": "postback"
                                      },
                                      "title": {
                                        "type": "string"
                                      },
                                      "payload": {
                                        "type": "string"
                                      }
                                    },
                                    "required": [
                                      "type",
                                      "title",
                                      "payload"
                                    ]
                                  },
                                  {
                                    "type": "object",
                                    "properties": {
                                      "type": {
                                        "const": "web_url"
                                      },
                                      "title": {
                                        "type": "string"
                                      },
                                      "url": {
                                        "type": "string"
                                      }
                                    },
                                    "required": [
                                      "type",
                                      "title",
                                      "url"
                                    ]
                                  }
                                ]
                              }
                            },
                            "quick_replies": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "title": {
                                    "type": "string"
                                  },
                                  "payload": {
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "title",
                                  "payload"
                                ]
                              }
                            }
                          },
                          "required": [
                            "type",
                            "body",
                            "buttons"
                          ]
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "const": "cards"
                            },
                            "cards": {
                              "type": "array",
                              "minItems": 1,
                              "items": {
                                "type": "object",
                                "properties": {
                                  "title": {
                                    "type": "string"
                                  },
                                  "subtitle": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "image_url": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "default_url": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "buttons": {
                                    "type": "array",
                                    "items": {
                                      "anyOf": [
                                        {
                                          "type": "object",
                                          "properties": {
                                            "type": {
                                              "const": "postback"
                                            },
                                            "title": {
                                              "type": "string"
                                            },
                                            "payload": {
                                              "type": "string"
                                            }
                                          },
                                          "required": [
                                            "type",
                                            "title",
                                            "payload"
                                          ]
                                        },
                                        {
                                          "type": "object",
                                          "properties": {
                                            "type": {
                                              "const": "web_url"
                                            },
                                            "title": {
                                              "type": "string"
                                            },
                                            "url": {
                                              "type": "string"
                                            }
                                          },
                                          "required": [
                                            "type",
                                            "title",
                                            "url"
                                          ]
                                        }
                                      ]
                                    }
                                  }
                                },
                                "required": [
                                  "title",
                                  "subtitle",
                                  "image_url",
                                  "default_url",
                                  "buttons"
                                ]
                              }
                            },
                            "quick_replies": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "title": {
                                    "type": "string"
                                  },
                                  "payload": {
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "title",
                                  "payload"
                                ]
                              }
                            }
                          },
                          "required": [
                            "type",
                            "cards"
                          ]
                        }
                      ],
                      "description": "Normalized content (the same as in `message.*` events)."
                    },
                    "context": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "reply_to": {
                              "anyOf": [
                                {
                                  "type": "object",
                                  "properties": {
                                    "message_id": {
                                      "anyOf": [
                                        {
                                          "type": "string"
                                        },
                                        {
                                          "type": "null"
                                        }
                                      ]
                                    },
                                    "external_id": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "message_id",
                                    "external_id"
                                  ]
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "forwarded": {
                              "type": "boolean"
                            },
                            "frequently_forwarded": {
                              "type": "boolean"
                            },
                            "referral": {
                              "anyOf": [
                                {
                                  "type": "object",
                                  "properties": {
                                    "source_type": {
                                      "anyOf": [
                                        {
                                          "type": "string"
                                        },
                                        {
                                          "type": "null"
                                        }
                                      ]
                                    },
                                    "source_id": {
                                      "anyOf": [
                                        {
                                          "type": "string"
                                        },
                                        {
                                          "type": "null"
                                        }
                                      ]
                                    },
                                    "source_url": {
                                      "anyOf": [
                                        {
                                          "type": "string"
                                        },
                                        {
                                          "type": "null"
                                        }
                                      ]
                                    },
                                    "headline": {
                                      "anyOf": [
                                        {
                                          "type": "string"
                                        },
                                        {
                                          "type": "null"
                                        }
                                      ]
                                    },
                                    "ctwa_clid": {
                                      "anyOf": [
                                        {
                                          "type": "string"
                                        },
                                        {
                                          "type": "null"
                                        }
                                      ]
                                    }
                                  },
                                  "required": [
                                    "source_type",
                                    "source_id",
                                    "source_url",
                                    "headline",
                                    "ctwa_clid"
                                  ]
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "reply_to_story": {
                              "anyOf": [
                                {
                                  "type": "object",
                                  "properties": {
                                    "external_id": {
                                      "type": "string"
                                    },
                                    "url": {
                                      "anyOf": [
                                        {
                                          "type": "string"
                                        },
                                        {
                                          "type": "null"
                                        }
                                      ]
                                    }
                                  },
                                  "required": [
                                    "external_id",
                                    "url"
                                  ]
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "standby": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "reply_to",
                            "forwarded",
                            "frequently_forwarded",
                            "referral"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Context: reply, forward, source ad; `null` = no context."
                    },
                    "conversation_id": {
                      "type": "string",
                      "description": "Conversation ID."
                    },
                    "contact_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Contact ID."
                    },
                    "status": {
                      "enum": [
                        "received",
                        "queued",
                        "sent",
                        "delivered",
                        "read",
                        "played",
                        "failed",
                        "deleted"
                      ],
                      "type": "string",
                      "description": "Message status."
                    },
                    "sent_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Sent (ISO 8601, UTC)."
                    },
                    "delivered_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Delivered (ISO 8601, UTC)."
                    },
                    "read_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Read (ISO 8601, UTC)."
                    },
                    "failed_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Failed (ISO 8601, UTC)."
                    },
                    "edited_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Edited (ISO 8601, UTC)."
                    },
                    "revoked_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Deleted by the sender (ISO 8601, UTC)."
                    },
                    "error": {
                      "anyOf": [
                        {
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {}
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Send error, in Meta's format; `null` = no error."
                    },
                    "campaign": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "description": "Only messages from this campaign."
                            },
                            "recipient_id": {
                              "type": "string",
                              "description": "Campaign recipient ID."
                            }
                          },
                          "required": [
                            "id",
                            "recipient_id"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Campaign that sent the message; `null` outside campaigns."
                    }
                  },
                  "required": [
                    "id",
                    "external_id",
                    "direction",
                    "source",
                    "timestamp",
                    "content",
                    "context",
                    "conversation_id",
                    "contact_id",
                    "status",
                    "sent_at",
                    "delivered_at",
                    "read_at",
                    "failed_at",
                    "edited_at",
                    "revoked_at",
                    "error",
                    "campaign"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/contacts": {
      "get": {
        "operationId": "listContacts",
        "summary": "List contacts",
        "description": "Lists contacts, from the most recently seen to the oldest. `identity` is an exact search (phone, BSUID, @username, IGSID/PSID); `q` searches the start of the name. A key restricted to connections only sees contacts with a conversation on them. Permission: `read`.",
        "tags": [
          "history"
        ],
        "parameters": [
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 512,
              "description": "Opaque cursor for the next page: the `next_cursor` of the previous response, with the same filters. Tampered or from another route → `400 invalid_cursor`."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50,
              "description": "Items per page, from 1 to 100 (default 50)."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "connection_id",
            "in": "query",
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "Connection ID."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "channel",
            "in": "query",
            "schema": {
              "enum": [
                "whatsapp",
                "instagram",
                "messenger"
              ],
              "type": "string",
              "description": "Channel: `whatsapp`, `instagram` or `messenger`."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "identity",
            "in": "query",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256,
              "description": "Exact identity: phone (digits only), BSUID, @username, IGSID or PSID."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "q",
            "in": "query",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64,
              "description": "Start of the contact name (up to 64 characters)."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "since",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time",
              "description": "Contacts seen from this date on (ISO 8601)."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          }
        ],
        "responses": {
          "200": {
            "description": "A page of contacts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "description": "Contact ID."
                          },
                          "channel": {
                            "enum": [
                              "whatsapp",
                              "instagram",
                              "messenger"
                            ],
                            "type": "string",
                            "description": "Channel: `whatsapp`, `instagram` or `messenger`."
                          },
                          "display_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Contact name, when known."
                          },
                          "identities": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "kind": {
                                  "type": "string",
                                  "description": "Kind: `wa_id`, `bsuid`, `username`, `igsid` or `psid`."
                                },
                                "value": {
                                  "type": "string",
                                  "description": "Identity value."
                                },
                                "scope": {
                                  "type": "string",
                                  "description": "Identity scope (e.g. the BSUID portfolio); empty = global."
                                }
                              },
                              "required": [
                                "kind",
                                "value",
                                "scope"
                              ]
                            },
                            "description": "The contact's identities on the channel."
                          },
                          "first_seen_at": {
                            "type": "string",
                            "description": "First time the contact showed up (ISO 8601, UTC)."
                          },
                          "last_seen_at": {
                            "type": "string",
                            "description": "Last time the contact showed up (ISO 8601, UTC)."
                          },
                          "created_at": {
                            "type": "string",
                            "description": "Creation date (ISO 8601, UTC)."
                          }
                        },
                        "required": [
                          "id",
                          "channel",
                          "display_name",
                          "identities",
                          "first_seen_at",
                          "last_seen_at",
                          "created_at"
                        ]
                      },
                      "description": "Page items, newest first."
                    },
                    "next_cursor": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Cursor for the next page; `null` when there are no more items."
                    }
                  },
                  "required": [
                    "data",
                    "next_cursor"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/contacts/{id}": {
      "get": {
        "operationId": "getContact",
        "summary": "Get contact",
        "description": "Returns a contact with its identities. Permission: `read`.",
        "tags": [
          "history"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Contact ID."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The contact.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Contact ID."
                    },
                    "channel": {
                      "enum": [
                        "whatsapp",
                        "instagram",
                        "messenger"
                      ],
                      "type": "string",
                      "description": "Channel: `whatsapp`, `instagram` or `messenger`."
                    },
                    "display_name": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Contact name, when known."
                    },
                    "identities": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "kind": {
                            "type": "string",
                            "description": "Kind: `wa_id`, `bsuid`, `username`, `igsid` or `psid`."
                          },
                          "value": {
                            "type": "string",
                            "description": "Identity value."
                          },
                          "scope": {
                            "type": "string",
                            "description": "Identity scope (e.g. the BSUID portfolio); empty = global."
                          }
                        },
                        "required": [
                          "kind",
                          "value",
                          "scope"
                        ]
                      },
                      "description": "The contact's identities on the channel."
                    },
                    "first_seen_at": {
                      "type": "string",
                      "description": "First time the contact showed up (ISO 8601, UTC)."
                    },
                    "last_seen_at": {
                      "type": "string",
                      "description": "Last time the contact showed up (ISO 8601, UTC)."
                    },
                    "created_at": {
                      "type": "string",
                      "description": "Creation date (ISO 8601, UTC)."
                    }
                  },
                  "required": [
                    "id",
                    "channel",
                    "display_name",
                    "identities",
                    "first_seen_at",
                    "last_seen_at",
                    "created_at"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/campaigns": {
      "get": {
        "operationId": "listCampaigns",
        "summary": "List campaigns",
        "description": "Lists the organization's campaigns, newest first. A key restricted to connections only sees their campaigns. Permission: `read`.",
        "tags": [
          "campaigns"
        ],
        "parameters": [
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "Next page cursor: the `next_cursor` of the previous response."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50,
              "description": "Items per page, from 1 to 100 (default 50)."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "connection_id",
            "in": "query",
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "ID of the sending WhatsApp connection. Optional with a connection key (uses the key's connection)."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          }
        ],
        "responses": {
          "200": {
            "description": "A page of campaigns.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "description": "Campaign ID (`cmp_…`).",
                            "examples": [
                              "cmp_0193a1b2c3d47e8f9a0b1c2d3e4f5a6b"
                            ]
                          },
                          "name": {
                            "type": "string",
                            "description": "Campaign name."
                          },
                          "status": {
                            "enum": [
                              "draft",
                              "scheduled",
                              "running",
                              "waiting_limit",
                              "paused",
                              "auto_paused",
                              "completed",
                              "canceled"
                            ],
                            "type": "string",
                            "description": "Status: `draft`, `scheduled`, `running`, `waiting_limit`, `paused`, `auto_paused`, `completed` or `canceled`."
                          },
                          "connection_id": {
                            "type": "string",
                            "description": "ID of the sending WhatsApp connection. Optional with a connection key (uses the key's connection)."
                          },
                          "template": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ],
                                "description": "Template ID in Messajo."
                              },
                              "name": {
                                "type": "string",
                                "description": "Template name."
                              },
                              "language": {
                                "type": "string",
                                "description": "Template language, e.g. `en_US`."
                              },
                              "category": {
                                "type": "string",
                                "description": "Template category: `MARKETING` or `UTILITY`."
                              }
                            },
                            "required": [
                              "id",
                              "name",
                              "language",
                              "category"
                            ],
                            "description": "Campaign template."
                          },
                          "variables": {
                            "type": "object",
                            "propertyNames": {
                              "type": "string"
                            },
                            "additionalProperties": {},
                            "description": "Template variable mapping: `header`, `body` and `buttons`, each parameter with `column` (list column), `value` (fixed) or `contact: \"display_name\"`."
                          },
                          "rate_limit_mps": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Messages per second; `null` = automatic (80% of the number's throughput)."
                          },
                          "effective_rate_mps": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991,
                            "description": "Messages per second actually used."
                          },
                          "scheduled_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Scheduled start (ISO 8601)."
                          },
                          "started_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Start (ISO 8601, UTC)."
                          },
                          "paused_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Pause (ISO 8601, UTC)."
                          },
                          "pause_reason": {
                            "anyOf": [
                              {
                                "enum": [
                                  "manual",
                                  "quality_low",
                                  "template_paused",
                                  "template_quality_low",
                                  "error_rate",
                                  "marketing_limit",
                                  "policy",
                                  "spam_limit",
                                  "connection_not_active",
                                  "org_suspended",
                                  "spend_cap"
                                ],
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Pause reason: `manual` or the automatic pause reason."
                          },
                          "completed_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Completion (ISO 8601, UTC)."
                          },
                          "canceled_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Cancellation (ISO 8601, UTC)."
                          },
                          "stats": {
                            "type": "object",
                            "properties": {
                              "total": {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991
                              },
                              "pending": {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991
                              },
                              "invalid": {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991
                              },
                              "sending": {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991
                              },
                              "sent": {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991
                              },
                              "delivered": {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991
                              },
                              "read": {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991
                              },
                              "failed": {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991
                              },
                              "unknown": {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991
                              },
                              "skipped": {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991
                              },
                              "by_error": {
                                "type": "object",
                                "propertyNames": {
                                  "type": "string"
                                },
                                "additionalProperties": {
                                  "type": "integer",
                                  "minimum": -9007199254740991,
                                  "maximum": 9007199254740991
                                },
                                "description": "Failures per error code."
                              }
                            },
                            "required": [
                              "total",
                              "pending",
                              "invalid",
                              "sending",
                              "sent",
                              "delivered",
                              "read",
                              "failed",
                              "unknown",
                              "skipped",
                              "by_error"
                            ],
                            "description": "Recipients per status."
                          },
                          "estimate": {
                            "type": "object",
                            "properties": {
                              "recipients_valid": {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991,
                                "description": "Recipients still to be sent."
                              },
                              "effective_rate_mps": {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991,
                                "description": "Messages per second actually used."
                              },
                              "duration_s": {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991,
                                "description": "Estimated duration in seconds."
                              },
                              "limit": {
                                "type": "object",
                                "properties": {
                                  "tier": {
                                    "anyOf": [
                                      {
                                        "type": "integer",
                                        "minimum": -9007199254740991,
                                        "maximum": 9007199254740991
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ],
                                    "description": "Limit ceiling; `null` = unlimited."
                                  },
                                  "used_24h": {
                                    "type": "integer",
                                    "minimum": -9007199254740991,
                                    "maximum": 9007199254740991,
                                    "description": "Recipients counted in the last 24 hours."
                                  },
                                  "remaining": {
                                    "anyOf": [
                                      {
                                        "type": "integer",
                                        "minimum": -9007199254740991,
                                        "maximum": 9007199254740991
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ],
                                    "description": "Remaining slots; `null` = unlimited."
                                  }
                                },
                                "required": [
                                  "tier",
                                  "used_24h",
                                  "remaining"
                                ],
                                "description": "Portfolio 24-hour messaging limit."
                              }
                            },
                            "required": [
                              "recipients_valid",
                              "effective_rate_mps",
                              "duration_s",
                              "limit"
                            ],
                            "description": "Send estimate."
                          },
                          "created_at": {
                            "type": "string",
                            "description": "Creation date (ISO 8601, UTC)."
                          },
                          "updated_at": {
                            "type": "string",
                            "description": "Last change (ISO 8601, UTC)."
                          }
                        },
                        "required": [
                          "id",
                          "name",
                          "status",
                          "connection_id",
                          "template",
                          "variables",
                          "rate_limit_mps",
                          "effective_rate_mps",
                          "scheduled_at",
                          "started_at",
                          "paused_at",
                          "pause_reason",
                          "completed_at",
                          "canceled_at",
                          "stats",
                          "estimate",
                          "created_at",
                          "updated_at"
                        ]
                      },
                      "description": "Page items, newest first."
                    },
                    "next_cursor": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Cursor for the next page; `null` when there are no more items."
                    }
                  },
                  "required": [
                    "data",
                    "next_cursor"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "createCampaign",
        "summary": "Create campaign",
        "description": "Creates a `draft` campaign for a WhatsApp connection with an approved template (`MARKETING` or `UTILITY`). The `variables` mapping must cover every template parameter. Permission: `send`.",
        "tags": [
          "campaigns"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 120,
                    "description": "Campaign name."
                  },
                  "connection_id": {
                    "type": "string",
                    "minLength": 1,
                    "description": "ID of the sending WhatsApp connection. Optional with a connection key (uses the key's connection)."
                  },
                  "template_id": {
                    "type": "string",
                    "minLength": 1,
                    "description": "Template ID in Messajo."
                  },
                  "template": {
                    "type": "object",
                    "properties": {
                      "name": {
                        "type": "string",
                        "minLength": 1,
                        "description": "Template name."
                      },
                      "language": {
                        "type": "string",
                        "minLength": 1,
                        "description": "Template language, e.g. `en_US`."
                      }
                    },
                    "required": [
                      "name",
                      "language"
                    ],
                    "description": "Template by name and language (instead of `template_id`)."
                  },
                  "variables": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {},
                    "description": "Template variable mapping: `header`, `body` and `buttons`, each parameter with `column` (list column), `value` (fixed) or `contact: \"display_name\"`."
                  },
                  "rate_limit_mps": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "minimum": 1,
                        "maximum": 9007199254740991
                      },
                      {
                        "type": "null"
                      }
                    ],
                    "description": "Messages per second; `null` = automatic (80% of the number's throughput)."
                  }
                },
                "required": [
                  "name",
                  "variables"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The created campaign.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Campaign ID (`cmp_…`).",
                      "examples": [
                        "cmp_0193a1b2c3d47e8f9a0b1c2d3e4f5a6b"
                      ]
                    },
                    "name": {
                      "type": "string",
                      "description": "Campaign name."
                    },
                    "status": {
                      "enum": [
                        "draft",
                        "scheduled",
                        "running",
                        "waiting_limit",
                        "paused",
                        "auto_paused",
                        "completed",
                        "canceled"
                      ],
                      "type": "string",
                      "description": "Status: `draft`, `scheduled`, `running`, `waiting_limit`, `paused`, `auto_paused`, `completed` or `canceled`."
                    },
                    "connection_id": {
                      "type": "string",
                      "description": "ID of the sending WhatsApp connection. Optional with a connection key (uses the key's connection)."
                    },
                    "template": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ],
                          "description": "Template ID in Messajo."
                        },
                        "name": {
                          "type": "string",
                          "description": "Template name."
                        },
                        "language": {
                          "type": "string",
                          "description": "Template language, e.g. `en_US`."
                        },
                        "category": {
                          "type": "string",
                          "description": "Template category: `MARKETING` or `UTILITY`."
                        }
                      },
                      "required": [
                        "id",
                        "name",
                        "language",
                        "category"
                      ],
                      "description": "Campaign template."
                    },
                    "variables": {
                      "type": "object",
                      "propertyNames": {
                        "type": "string"
                      },
                      "additionalProperties": {},
                      "description": "Template variable mapping: `header`, `body` and `buttons`, each parameter with `column` (list column), `value` (fixed) or `contact: \"display_name\"`."
                    },
                    "rate_limit_mps": {
                      "anyOf": [
                        {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Messages per second; `null` = automatic (80% of the number's throughput)."
                    },
                    "effective_rate_mps": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "Messages per second actually used."
                    },
                    "scheduled_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Scheduled start (ISO 8601)."
                    },
                    "started_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Start (ISO 8601, UTC)."
                    },
                    "paused_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Pause (ISO 8601, UTC)."
                    },
                    "pause_reason": {
                      "anyOf": [
                        {
                          "enum": [
                            "manual",
                            "quality_low",
                            "template_paused",
                            "template_quality_low",
                            "error_rate",
                            "marketing_limit",
                            "policy",
                            "spam_limit",
                            "connection_not_active",
                            "org_suspended",
                            "spend_cap"
                          ],
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Pause reason: `manual` or the automatic pause reason."
                    },
                    "completed_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Completion (ISO 8601, UTC)."
                    },
                    "canceled_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Cancellation (ISO 8601, UTC)."
                    },
                    "stats": {
                      "type": "object",
                      "properties": {
                        "total": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "pending": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "invalid": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "sending": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "sent": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "delivered": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "read": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "failed": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "unknown": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "skipped": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "by_error": {
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991
                          },
                          "description": "Failures per error code."
                        }
                      },
                      "required": [
                        "total",
                        "pending",
                        "invalid",
                        "sending",
                        "sent",
                        "delivered",
                        "read",
                        "failed",
                        "unknown",
                        "skipped",
                        "by_error"
                      ],
                      "description": "Recipients per status."
                    },
                    "estimate": {
                      "type": "object",
                      "properties": {
                        "recipients_valid": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "Recipients still to be sent."
                        },
                        "effective_rate_mps": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "Messages per second actually used."
                        },
                        "duration_s": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "Estimated duration in seconds."
                        },
                        "limit": {
                          "type": "object",
                          "properties": {
                            "tier": {
                              "anyOf": [
                                {
                                  "type": "integer",
                                  "minimum": -9007199254740991,
                                  "maximum": 9007199254740991
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Limit ceiling; `null` = unlimited."
                            },
                            "used_24h": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991,
                              "description": "Recipients counted in the last 24 hours."
                            },
                            "remaining": {
                              "anyOf": [
                                {
                                  "type": "integer",
                                  "minimum": -9007199254740991,
                                  "maximum": 9007199254740991
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Remaining slots; `null` = unlimited."
                            }
                          },
                          "required": [
                            "tier",
                            "used_24h",
                            "remaining"
                          ],
                          "description": "Portfolio 24-hour messaging limit."
                        }
                      },
                      "required": [
                        "recipients_valid",
                        "effective_rate_mps",
                        "duration_s",
                        "limit"
                      ],
                      "description": "Send estimate."
                    },
                    "created_at": {
                      "type": "string",
                      "description": "Creation date (ISO 8601, UTC)."
                    },
                    "updated_at": {
                      "type": "string",
                      "description": "Last change (ISO 8601, UTC)."
                    }
                  },
                  "required": [
                    "id",
                    "name",
                    "status",
                    "connection_id",
                    "template",
                    "variables",
                    "rate_limit_mps",
                    "effective_rate_mps",
                    "scheduled_at",
                    "started_at",
                    "paused_at",
                    "pause_reason",
                    "completed_at",
                    "canceled_at",
                    "stats",
                    "estimate",
                    "created_at",
                    "updated_at"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ]
      }
    },
    "/campaigns/{id}": {
      "get": {
        "operationId": "getCampaign",
        "summary": "Get campaign",
        "description": "Returns the campaign with per-status counts (`stats`) and the send estimate (`estimate`). Permission: `read`.",
        "tags": [
          "campaigns"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "Campaign ID (`cmp_…`)."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The campaign.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Campaign ID (`cmp_…`).",
                      "examples": [
                        "cmp_0193a1b2c3d47e8f9a0b1c2d3e4f5a6b"
                      ]
                    },
                    "name": {
                      "type": "string",
                      "description": "Campaign name."
                    },
                    "status": {
                      "enum": [
                        "draft",
                        "scheduled",
                        "running",
                        "waiting_limit",
                        "paused",
                        "auto_paused",
                        "completed",
                        "canceled"
                      ],
                      "type": "string",
                      "description": "Status: `draft`, `scheduled`, `running`, `waiting_limit`, `paused`, `auto_paused`, `completed` or `canceled`."
                    },
                    "connection_id": {
                      "type": "string",
                      "description": "ID of the sending WhatsApp connection. Optional with a connection key (uses the key's connection)."
                    },
                    "template": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ],
                          "description": "Template ID in Messajo."
                        },
                        "name": {
                          "type": "string",
                          "description": "Template name."
                        },
                        "language": {
                          "type": "string",
                          "description": "Template language, e.g. `en_US`."
                        },
                        "category": {
                          "type": "string",
                          "description": "Template category: `MARKETING` or `UTILITY`."
                        }
                      },
                      "required": [
                        "id",
                        "name",
                        "language",
                        "category"
                      ],
                      "description": "Campaign template."
                    },
                    "variables": {
                      "type": "object",
                      "propertyNames": {
                        "type": "string"
                      },
                      "additionalProperties": {},
                      "description": "Template variable mapping: `header`, `body` and `buttons`, each parameter with `column` (list column), `value` (fixed) or `contact: \"display_name\"`."
                    },
                    "rate_limit_mps": {
                      "anyOf": [
                        {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Messages per second; `null` = automatic (80% of the number's throughput)."
                    },
                    "effective_rate_mps": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "Messages per second actually used."
                    },
                    "scheduled_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Scheduled start (ISO 8601)."
                    },
                    "started_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Start (ISO 8601, UTC)."
                    },
                    "paused_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Pause (ISO 8601, UTC)."
                    },
                    "pause_reason": {
                      "anyOf": [
                        {
                          "enum": [
                            "manual",
                            "quality_low",
                            "template_paused",
                            "template_quality_low",
                            "error_rate",
                            "marketing_limit",
                            "policy",
                            "spam_limit",
                            "connection_not_active",
                            "org_suspended",
                            "spend_cap"
                          ],
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Pause reason: `manual` or the automatic pause reason."
                    },
                    "completed_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Completion (ISO 8601, UTC)."
                    },
                    "canceled_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Cancellation (ISO 8601, UTC)."
                    },
                    "stats": {
                      "type": "object",
                      "properties": {
                        "total": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "pending": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "invalid": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "sending": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "sent": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "delivered": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "read": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "failed": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "unknown": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "skipped": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "by_error": {
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991
                          },
                          "description": "Failures per error code."
                        }
                      },
                      "required": [
                        "total",
                        "pending",
                        "invalid",
                        "sending",
                        "sent",
                        "delivered",
                        "read",
                        "failed",
                        "unknown",
                        "skipped",
                        "by_error"
                      ],
                      "description": "Recipients per status."
                    },
                    "estimate": {
                      "type": "object",
                      "properties": {
                        "recipients_valid": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "Recipients still to be sent."
                        },
                        "effective_rate_mps": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "Messages per second actually used."
                        },
                        "duration_s": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "Estimated duration in seconds."
                        },
                        "limit": {
                          "type": "object",
                          "properties": {
                            "tier": {
                              "anyOf": [
                                {
                                  "type": "integer",
                                  "minimum": -9007199254740991,
                                  "maximum": 9007199254740991
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Limit ceiling; `null` = unlimited."
                            },
                            "used_24h": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991,
                              "description": "Recipients counted in the last 24 hours."
                            },
                            "remaining": {
                              "anyOf": [
                                {
                                  "type": "integer",
                                  "minimum": -9007199254740991,
                                  "maximum": 9007199254740991
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Remaining slots; `null` = unlimited."
                            }
                          },
                          "required": [
                            "tier",
                            "used_24h",
                            "remaining"
                          ],
                          "description": "Portfolio 24-hour messaging limit."
                        }
                      },
                      "required": [
                        "recipients_valid",
                        "effective_rate_mps",
                        "duration_s",
                        "limit"
                      ],
                      "description": "Send estimate."
                    },
                    "created_at": {
                      "type": "string",
                      "description": "Creation date (ISO 8601, UTC)."
                    },
                    "updated_at": {
                      "type": "string",
                      "description": "Last change (ISO 8601, UTC)."
                    }
                  },
                  "required": [
                    "id",
                    "name",
                    "status",
                    "connection_id",
                    "template",
                    "variables",
                    "rate_limit_mps",
                    "effective_rate_mps",
                    "scheduled_at",
                    "started_at",
                    "paused_at",
                    "pause_reason",
                    "completed_at",
                    "canceled_at",
                    "stats",
                    "estimate",
                    "created_at",
                    "updated_at"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "patch": {
        "operationId": "updateCampaign",
        "summary": "Update campaign",
        "description": "Template, `variables` and recipients change only in `draft`; `name` and `rate_limit_mps` also in `scheduled`, `paused` and `auto_paused`. Otherwise: `409 campaign_not_editable`. Permission: `send`.",
        "tags": [
          "campaigns"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "Campaign ID (`cmp_…`)."
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 120,
                    "description": "Campaign name."
                  },
                  "template_id": {
                    "type": "string",
                    "minLength": 1,
                    "description": "Template ID in Messajo."
                  },
                  "template": {
                    "type": "object",
                    "properties": {
                      "name": {
                        "type": "string",
                        "minLength": 1,
                        "description": "Template name."
                      },
                      "language": {
                        "type": "string",
                        "minLength": 1,
                        "description": "Template language, e.g. `en_US`."
                      }
                    },
                    "required": [
                      "name",
                      "language"
                    ],
                    "description": "Template by name and language (instead of `template_id`)."
                  },
                  "variables": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {},
                    "description": "Template variable mapping: `header`, `body` and `buttons`, each parameter with `column` (list column), `value` (fixed) or `contact: \"display_name\"`."
                  },
                  "rate_limit_mps": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "minimum": 1,
                        "maximum": 9007199254740991
                      },
                      {
                        "type": "null"
                      }
                    ],
                    "description": "Messages per second; `null` = automatic (80% of the number's throughput)."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The updated campaign.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Campaign ID (`cmp_…`).",
                      "examples": [
                        "cmp_0193a1b2c3d47e8f9a0b1c2d3e4f5a6b"
                      ]
                    },
                    "name": {
                      "type": "string",
                      "description": "Campaign name."
                    },
                    "status": {
                      "enum": [
                        "draft",
                        "scheduled",
                        "running",
                        "waiting_limit",
                        "paused",
                        "auto_paused",
                        "completed",
                        "canceled"
                      ],
                      "type": "string",
                      "description": "Status: `draft`, `scheduled`, `running`, `waiting_limit`, `paused`, `auto_paused`, `completed` or `canceled`."
                    },
                    "connection_id": {
                      "type": "string",
                      "description": "ID of the sending WhatsApp connection. Optional with a connection key (uses the key's connection)."
                    },
                    "template": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ],
                          "description": "Template ID in Messajo."
                        },
                        "name": {
                          "type": "string",
                          "description": "Template name."
                        },
                        "language": {
                          "type": "string",
                          "description": "Template language, e.g. `en_US`."
                        },
                        "category": {
                          "type": "string",
                          "description": "Template category: `MARKETING` or `UTILITY`."
                        }
                      },
                      "required": [
                        "id",
                        "name",
                        "language",
                        "category"
                      ],
                      "description": "Campaign template."
                    },
                    "variables": {
                      "type": "object",
                      "propertyNames": {
                        "type": "string"
                      },
                      "additionalProperties": {},
                      "description": "Template variable mapping: `header`, `body` and `buttons`, each parameter with `column` (list column), `value` (fixed) or `contact: \"display_name\"`."
                    },
                    "rate_limit_mps": {
                      "anyOf": [
                        {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Messages per second; `null` = automatic (80% of the number's throughput)."
                    },
                    "effective_rate_mps": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "Messages per second actually used."
                    },
                    "scheduled_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Scheduled start (ISO 8601)."
                    },
                    "started_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Start (ISO 8601, UTC)."
                    },
                    "paused_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Pause (ISO 8601, UTC)."
                    },
                    "pause_reason": {
                      "anyOf": [
                        {
                          "enum": [
                            "manual",
                            "quality_low",
                            "template_paused",
                            "template_quality_low",
                            "error_rate",
                            "marketing_limit",
                            "policy",
                            "spam_limit",
                            "connection_not_active",
                            "org_suspended",
                            "spend_cap"
                          ],
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Pause reason: `manual` or the automatic pause reason."
                    },
                    "completed_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Completion (ISO 8601, UTC)."
                    },
                    "canceled_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Cancellation (ISO 8601, UTC)."
                    },
                    "stats": {
                      "type": "object",
                      "properties": {
                        "total": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "pending": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "invalid": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "sending": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "sent": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "delivered": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "read": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "failed": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "unknown": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "skipped": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "by_error": {
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991
                          },
                          "description": "Failures per error code."
                        }
                      },
                      "required": [
                        "total",
                        "pending",
                        "invalid",
                        "sending",
                        "sent",
                        "delivered",
                        "read",
                        "failed",
                        "unknown",
                        "skipped",
                        "by_error"
                      ],
                      "description": "Recipients per status."
                    },
                    "estimate": {
                      "type": "object",
                      "properties": {
                        "recipients_valid": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "Recipients still to be sent."
                        },
                        "effective_rate_mps": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "Messages per second actually used."
                        },
                        "duration_s": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "Estimated duration in seconds."
                        },
                        "limit": {
                          "type": "object",
                          "properties": {
                            "tier": {
                              "anyOf": [
                                {
                                  "type": "integer",
                                  "minimum": -9007199254740991,
                                  "maximum": 9007199254740991
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Limit ceiling; `null` = unlimited."
                            },
                            "used_24h": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991,
                              "description": "Recipients counted in the last 24 hours."
                            },
                            "remaining": {
                              "anyOf": [
                                {
                                  "type": "integer",
                                  "minimum": -9007199254740991,
                                  "maximum": 9007199254740991
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Remaining slots; `null` = unlimited."
                            }
                          },
                          "required": [
                            "tier",
                            "used_24h",
                            "remaining"
                          ],
                          "description": "Portfolio 24-hour messaging limit."
                        }
                      },
                      "required": [
                        "recipients_valid",
                        "effective_rate_mps",
                        "duration_s",
                        "limit"
                      ],
                      "description": "Send estimate."
                    },
                    "created_at": {
                      "type": "string",
                      "description": "Creation date (ISO 8601, UTC)."
                    },
                    "updated_at": {
                      "type": "string",
                      "description": "Last change (ISO 8601, UTC)."
                    }
                  },
                  "required": [
                    "id",
                    "name",
                    "status",
                    "connection_id",
                    "template",
                    "variables",
                    "rate_limit_mps",
                    "effective_rate_mps",
                    "scheduled_at",
                    "started_at",
                    "paused_at",
                    "pause_reason",
                    "completed_at",
                    "canceled_at",
                    "stats",
                    "estimate",
                    "created_at",
                    "updated_at"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "operationId": "deleteCampaign",
        "summary": "Delete campaign",
        "description": "Deletes the campaign and its recipients. Only in `draft`, `completed` or `canceled`. Permission: `send`.",
        "tags": [
          "campaigns"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "Campaign ID (`cmp_…`)."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Deletion confirmation.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Campaign ID (`cmp_…`)."
                    },
                    "deleted": {
                      "const": true,
                      "description": "Always `true`."
                    }
                  },
                  "required": [
                    "id",
                    "deleted"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/campaigns/{id}/recipients": {
      "post": {
        "operationId": "addCampaignRecipients",
        "summary": "Add recipients",
        "description": "JSON `{ recipients }` (up to 10,000 per call) is stored right away and returns the completed import (`201`). Multipart with `file` (CSV, JSON or NDJSON, up to 20 MiB) returns `202` and is processed in the background: follow it at `GET /v1/campaigns/{id}/imports/{import_id}`. Only in `draft`. Permission: `send`.",
        "tags": [
          "campaigns"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "Campaign ID (`cmp_…`)."
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "recipients": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 10000,
                    "items": {
                      "type": "object",
                      "properties": {
                        "to": {
                          "type": "string",
                          "minLength": 1,
                          "description": "Destination: phone (with country code), BSUID or a contact's `ctc_…`."
                        },
                        "variables": {
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {
                            "type": "string",
                            "maxLength": 1024
                          },
                          "description": "Recipient variables (column → value)."
                        }
                      },
                      "required": [
                        "to"
                      ]
                    },
                    "description": "Inline recipients (up to 10,000)."
                  },
                  "file": {
                    "type": "string",
                    "contentMediaType": "*/*",
                    "description": "CSV, JSON or NDJSON file (up to 20 MiB)."
                  },
                  "to_column": {
                    "type": "string",
                    "minLength": 1,
                    "description": "CSV column with the destination (default `to`)."
                  }
                }
              }
            },
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "recipients": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 10000,
                    "items": {
                      "type": "object",
                      "properties": {
                        "to": {
                          "type": "string",
                          "minLength": 1,
                          "description": "Destination: phone (with country code), BSUID or a contact's `ctc_…`."
                        },
                        "variables": {
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {
                            "type": "string",
                            "maxLength": 1024
                          },
                          "description": "Recipient variables (column → value)."
                        }
                      },
                      "required": [
                        "to"
                      ]
                    },
                    "description": "Inline recipients (up to 10,000)."
                  },
                  "file": {
                    "type": "string",
                    "contentMediaType": "*/*",
                    "description": "CSV, JSON or NDJSON file (up to 20 MiB)."
                  },
                  "to_column": {
                    "type": "string",
                    "minLength": 1,
                    "description": "CSV column with the destination (default `to`)."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Inline list stored.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Import ID (`cim_…`)."
                    },
                    "campaign_id": {
                      "type": "string",
                      "description": "Campaign ID (`cmp_…`)."
                    },
                    "source": {
                      "enum": [
                        "inline",
                        "csv",
                        "json",
                        "ndjson"
                      ],
                      "type": "string",
                      "description": "Source: `inline`, `csv`, `json` or `ndjson`."
                    },
                    "filename": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Uploaded file name."
                    },
                    "status": {
                      "enum": [
                        "queued",
                        "processing",
                        "completed",
                        "failed"
                      ],
                      "type": "string",
                      "description": "Status: `queued`, `processing`, `completed` or `failed`."
                    },
                    "rows_total": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "Rows read."
                    },
                    "rows_valid": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "Valid recipients stored."
                    },
                    "rows_invalid": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "Invalid rows."
                    },
                    "rows_duplicate": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "Duplicate rows (ignored)."
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "row": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991
                          },
                          "column": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "code": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "row",
                          "column",
                          "code"
                        ]
                      },
                      "description": "Up to 100 row errors (`row`, `column`, `code`)."
                    },
                    "created_at": {
                      "type": "string",
                      "description": "Creation date (ISO 8601, UTC)."
                    },
                    "started_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Start (ISO 8601, UTC)."
                    },
                    "completed_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Completion (ISO 8601, UTC)."
                    }
                  },
                  "required": [
                    "id",
                    "campaign_id",
                    "source",
                    "filename",
                    "status",
                    "rows_total",
                    "rows_valid",
                    "rows_invalid",
                    "rows_duplicate",
                    "errors",
                    "created_at",
                    "started_at",
                    "completed_at"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "202": {
            "description": "File received; the import runs in the background.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Import ID (`cim_…`)."
                    },
                    "campaign_id": {
                      "type": "string",
                      "description": "Campaign ID (`cmp_…`)."
                    },
                    "source": {
                      "enum": [
                        "inline",
                        "csv",
                        "json",
                        "ndjson"
                      ],
                      "type": "string",
                      "description": "Source: `inline`, `csv`, `json` or `ndjson`."
                    },
                    "filename": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Uploaded file name."
                    },
                    "status": {
                      "enum": [
                        "queued",
                        "processing",
                        "completed",
                        "failed"
                      ],
                      "type": "string",
                      "description": "Status: `queued`, `processing`, `completed` or `failed`."
                    },
                    "rows_total": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "Rows read."
                    },
                    "rows_valid": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "Valid recipients stored."
                    },
                    "rows_invalid": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "Invalid rows."
                    },
                    "rows_duplicate": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "Duplicate rows (ignored)."
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "row": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991
                          },
                          "column": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "code": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "row",
                          "column",
                          "code"
                        ]
                      },
                      "description": "Up to 100 row errors (`row`, `column`, `code`)."
                    },
                    "created_at": {
                      "type": "string",
                      "description": "Creation date (ISO 8601, UTC)."
                    },
                    "started_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Start (ISO 8601, UTC)."
                    },
                    "completed_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Completion (ISO 8601, UTC)."
                    }
                  },
                  "required": [
                    "id",
                    "campaign_id",
                    "source",
                    "filename",
                    "status",
                    "rows_total",
                    "rows_valid",
                    "rows_invalid",
                    "rows_duplicate",
                    "errors",
                    "created_at",
                    "started_at",
                    "completed_at"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "get": {
        "operationId": "listCampaignRecipients",
        "summary": "List recipients",
        "description": "Lists the campaign's recipients in send order, filterable by status. Permission: `read`.",
        "tags": [
          "campaigns"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "Campaign ID (`cmp_…`)."
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "Next page cursor: the `next_cursor` of the previous response."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50,
              "description": "Items per page, from 1 to 100 (default 50)."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "enum": [
                "pending",
                "invalid",
                "sending",
                "sent",
                "delivered",
                "read",
                "failed",
                "unknown",
                "skipped"
              ],
              "type": "string",
              "description": "Recipient status: `pending`, `invalid`, `sending`, `sent`, `delivered`, `read`, `failed`, `unknown` or `skipped`."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          }
        ],
        "responses": {
          "200": {
            "description": "A page of recipients.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "description": "Recipient ID (`crc_…`)."
                          },
                          "seq": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991,
                            "description": "Position in send order."
                          },
                          "to_kind": {
                            "enum": [
                              "phone",
                              "bsuid"
                            ],
                            "type": "string",
                            "description": "Destination type: `phone` or `bsuid`."
                          },
                          "to": {
                            "type": "string",
                            "description": "Destination: phone (with country code), BSUID or a contact's `ctc_…`."
                          },
                          "contact_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Recipient's contact, when known."
                          },
                          "variables": {
                            "type": "object",
                            "propertyNames": {
                              "type": "string"
                            },
                            "additionalProperties": {
                              "type": "string"
                            },
                            "description": "Recipient variables (column → value)."
                          },
                          "status": {
                            "enum": [
                              "pending",
                              "invalid",
                              "sending",
                              "sent",
                              "delivered",
                              "read",
                              "failed",
                              "unknown",
                              "skipped"
                            ],
                            "type": "string",
                            "description": "Recipient status: `pending`, `invalid`, `sending`, `sent`, `delivered`, `read`, `failed`, `unknown` or `skipped`."
                          },
                          "invalid_reason": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Why the recipient is invalid."
                          },
                          "message_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Sent message ID (`msg_…`)."
                          },
                          "external_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Message ID at Meta."
                          },
                          "error": {
                            "anyOf": [
                              {
                                "type": "object",
                                "properties": {
                                  "code": {
                                    "type": "string"
                                  },
                                  "meta_code": {
                                    "anyOf": [
                                      {
                                        "type": "integer",
                                        "minimum": -9007199254740991,
                                        "maximum": 9007199254740991
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "message": {
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "code",
                                  "meta_code",
                                  "message"
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Send error (`code`, `meta_code`, `message`)."
                          },
                          "sent_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Sent (ISO 8601, UTC)."
                          },
                          "delivered_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Delivered (ISO 8601, UTC)."
                          },
                          "read_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Read (ISO 8601, UTC)."
                          },
                          "failed_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Failed (ISO 8601, UTC)."
                          }
                        },
                        "required": [
                          "id",
                          "seq",
                          "to_kind",
                          "to",
                          "contact_id",
                          "variables",
                          "status",
                          "invalid_reason",
                          "message_id",
                          "external_id",
                          "error",
                          "sent_at",
                          "delivered_at",
                          "read_at",
                          "failed_at"
                        ]
                      },
                      "description": "Page items, newest first."
                    },
                    "next_cursor": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Cursor for the next page; `null` when there are no more items."
                    }
                  },
                  "required": [
                    "data",
                    "next_cursor"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/campaigns/{id}/imports": {
      "get": {
        "operationId": "listCampaignImports",
        "summary": "List imports",
        "description": "Lists the campaign's recipient imports, newest first. Permission: `read`.",
        "tags": [
          "campaigns"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "Campaign ID (`cmp_…`)."
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "Next page cursor: the `next_cursor` of the previous response."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50,
              "description": "Items per page, from 1 to 100 (default 50)."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          }
        ],
        "responses": {
          "200": {
            "description": "A page of imports.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "description": "Import ID (`cim_…`)."
                          },
                          "campaign_id": {
                            "type": "string",
                            "description": "Campaign ID (`cmp_…`)."
                          },
                          "source": {
                            "enum": [
                              "inline",
                              "csv",
                              "json",
                              "ndjson"
                            ],
                            "type": "string",
                            "description": "Source: `inline`, `csv`, `json` or `ndjson`."
                          },
                          "filename": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Uploaded file name."
                          },
                          "status": {
                            "enum": [
                              "queued",
                              "processing",
                              "completed",
                              "failed"
                            ],
                            "type": "string",
                            "description": "Status: `queued`, `processing`, `completed` or `failed`."
                          },
                          "rows_total": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991,
                            "description": "Rows read."
                          },
                          "rows_valid": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991,
                            "description": "Valid recipients stored."
                          },
                          "rows_invalid": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991,
                            "description": "Invalid rows."
                          },
                          "rows_duplicate": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991,
                            "description": "Duplicate rows (ignored)."
                          },
                          "errors": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "row": {
                                  "type": "integer",
                                  "minimum": -9007199254740991,
                                  "maximum": 9007199254740991
                                },
                                "column": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "code": {
                                  "type": "string"
                                }
                              },
                              "required": [
                                "row",
                                "column",
                                "code"
                              ]
                            },
                            "description": "Up to 100 row errors (`row`, `column`, `code`)."
                          },
                          "created_at": {
                            "type": "string",
                            "description": "Creation date (ISO 8601, UTC)."
                          },
                          "started_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Start (ISO 8601, UTC)."
                          },
                          "completed_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Completion (ISO 8601, UTC)."
                          }
                        },
                        "required": [
                          "id",
                          "campaign_id",
                          "source",
                          "filename",
                          "status",
                          "rows_total",
                          "rows_valid",
                          "rows_invalid",
                          "rows_duplicate",
                          "errors",
                          "created_at",
                          "started_at",
                          "completed_at"
                        ]
                      },
                      "description": "Page items, newest first."
                    },
                    "next_cursor": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Cursor for the next page; `null` when there are no more items."
                    }
                  },
                  "required": [
                    "data",
                    "next_cursor"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/campaigns/{id}/imports/{import_id}": {
      "get": {
        "operationId": "getCampaignImport",
        "summary": "Get import",
        "description": "Returns an import with its counts and up to 100 row errors. Permission: `read`.",
        "tags": [
          "campaigns"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "Campaign ID (`cmp_…`)."
            }
          },
          {
            "name": "import_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "Import ID (`cim_…`)."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The import.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Import ID (`cim_…`)."
                    },
                    "campaign_id": {
                      "type": "string",
                      "description": "Campaign ID (`cmp_…`)."
                    },
                    "source": {
                      "enum": [
                        "inline",
                        "csv",
                        "json",
                        "ndjson"
                      ],
                      "type": "string",
                      "description": "Source: `inline`, `csv`, `json` or `ndjson`."
                    },
                    "filename": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Uploaded file name."
                    },
                    "status": {
                      "enum": [
                        "queued",
                        "processing",
                        "completed",
                        "failed"
                      ],
                      "type": "string",
                      "description": "Status: `queued`, `processing`, `completed` or `failed`."
                    },
                    "rows_total": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "Rows read."
                    },
                    "rows_valid": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "Valid recipients stored."
                    },
                    "rows_invalid": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "Invalid rows."
                    },
                    "rows_duplicate": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "Duplicate rows (ignored)."
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "row": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991
                          },
                          "column": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "code": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "row",
                          "column",
                          "code"
                        ]
                      },
                      "description": "Up to 100 row errors (`row`, `column`, `code`)."
                    },
                    "created_at": {
                      "type": "string",
                      "description": "Creation date (ISO 8601, UTC)."
                    },
                    "started_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Start (ISO 8601, UTC)."
                    },
                    "completed_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Completion (ISO 8601, UTC)."
                    }
                  },
                  "required": [
                    "id",
                    "campaign_id",
                    "source",
                    "filename",
                    "status",
                    "rows_total",
                    "rows_valid",
                    "rows_invalid",
                    "rows_duplicate",
                    "errors",
                    "created_at",
                    "started_at",
                    "completed_at"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/campaigns/{id}/preview": {
      "post": {
        "operationId": "previewCampaign",
        "summary": "Preview campaign",
        "description": "Builds the message for the first valid recipients with variables filled in, without sending anything. Permission: `read`.",
        "tags": [
          "campaigns"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "Campaign ID (`cmp_…`)."
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "limit": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 10,
                    "default": 5,
                    "description": "How many recipients to preview (1 to 10, default 5)."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The built messages.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "recipient_id": {
                            "type": "string",
                            "description": "Recipient ID (`crc_…`)."
                          },
                          "to": {
                            "type": "string",
                            "description": "Destination: phone (with country code), BSUID or a contact's `ctc_…`."
                          },
                          "components": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "propertyNames": {
                                "type": "string"
                              },
                              "additionalProperties": {}
                            },
                            "description": "Template `components`, as sent to Meta."
                          },
                          "rendered_body": {
                            "type": "string",
                            "description": "Body with parameters filled in."
                          }
                        },
                        "required": [
                          "recipient_id",
                          "to",
                          "components",
                          "rendered_body"
                        ]
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/campaigns/{id}/schedule": {
      "post": {
        "operationId": "scheduleCampaign",
        "summary": "Schedule campaign",
        "description": "Schedules the start between now + 1 min and now + 90 days. Requires at least one valid recipient and no import in progress. Permission: `send`.",
        "tags": [
          "campaigns"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "Campaign ID (`cmp_…`)."
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "scheduled_at": {
                    "type": "string",
                    "format": "date-time",
                    "description": "Scheduled start (ISO 8601)."
                  }
                },
                "required": [
                  "scheduled_at"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The scheduled campaign.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Campaign ID (`cmp_…`).",
                      "examples": [
                        "cmp_0193a1b2c3d47e8f9a0b1c2d3e4f5a6b"
                      ]
                    },
                    "name": {
                      "type": "string",
                      "description": "Campaign name."
                    },
                    "status": {
                      "enum": [
                        "draft",
                        "scheduled",
                        "running",
                        "waiting_limit",
                        "paused",
                        "auto_paused",
                        "completed",
                        "canceled"
                      ],
                      "type": "string",
                      "description": "Status: `draft`, `scheduled`, `running`, `waiting_limit`, `paused`, `auto_paused`, `completed` or `canceled`."
                    },
                    "connection_id": {
                      "type": "string",
                      "description": "ID of the sending WhatsApp connection. Optional with a connection key (uses the key's connection)."
                    },
                    "template": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ],
                          "description": "Template ID in Messajo."
                        },
                        "name": {
                          "type": "string",
                          "description": "Template name."
                        },
                        "language": {
                          "type": "string",
                          "description": "Template language, e.g. `en_US`."
                        },
                        "category": {
                          "type": "string",
                          "description": "Template category: `MARKETING` or `UTILITY`."
                        }
                      },
                      "required": [
                        "id",
                        "name",
                        "language",
                        "category"
                      ],
                      "description": "Campaign template."
                    },
                    "variables": {
                      "type": "object",
                      "propertyNames": {
                        "type": "string"
                      },
                      "additionalProperties": {},
                      "description": "Template variable mapping: `header`, `body` and `buttons`, each parameter with `column` (list column), `value` (fixed) or `contact: \"display_name\"`."
                    },
                    "rate_limit_mps": {
                      "anyOf": [
                        {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Messages per second; `null` = automatic (80% of the number's throughput)."
                    },
                    "effective_rate_mps": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "Messages per second actually used."
                    },
                    "scheduled_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Scheduled start (ISO 8601)."
                    },
                    "started_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Start (ISO 8601, UTC)."
                    },
                    "paused_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Pause (ISO 8601, UTC)."
                    },
                    "pause_reason": {
                      "anyOf": [
                        {
                          "enum": [
                            "manual",
                            "quality_low",
                            "template_paused",
                            "template_quality_low",
                            "error_rate",
                            "marketing_limit",
                            "policy",
                            "spam_limit",
                            "connection_not_active",
                            "org_suspended",
                            "spend_cap"
                          ],
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Pause reason: `manual` or the automatic pause reason."
                    },
                    "completed_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Completion (ISO 8601, UTC)."
                    },
                    "canceled_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Cancellation (ISO 8601, UTC)."
                    },
                    "stats": {
                      "type": "object",
                      "properties": {
                        "total": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "pending": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "invalid": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "sending": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "sent": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "delivered": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "read": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "failed": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "unknown": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "skipped": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "by_error": {
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991
                          },
                          "description": "Failures per error code."
                        }
                      },
                      "required": [
                        "total",
                        "pending",
                        "invalid",
                        "sending",
                        "sent",
                        "delivered",
                        "read",
                        "failed",
                        "unknown",
                        "skipped",
                        "by_error"
                      ],
                      "description": "Recipients per status."
                    },
                    "estimate": {
                      "type": "object",
                      "properties": {
                        "recipients_valid": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "Recipients still to be sent."
                        },
                        "effective_rate_mps": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "Messages per second actually used."
                        },
                        "duration_s": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "Estimated duration in seconds."
                        },
                        "limit": {
                          "type": "object",
                          "properties": {
                            "tier": {
                              "anyOf": [
                                {
                                  "type": "integer",
                                  "minimum": -9007199254740991,
                                  "maximum": 9007199254740991
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Limit ceiling; `null` = unlimited."
                            },
                            "used_24h": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991,
                              "description": "Recipients counted in the last 24 hours."
                            },
                            "remaining": {
                              "anyOf": [
                                {
                                  "type": "integer",
                                  "minimum": -9007199254740991,
                                  "maximum": 9007199254740991
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Remaining slots; `null` = unlimited."
                            }
                          },
                          "required": [
                            "tier",
                            "used_24h",
                            "remaining"
                          ],
                          "description": "Portfolio 24-hour messaging limit."
                        }
                      },
                      "required": [
                        "recipients_valid",
                        "effective_rate_mps",
                        "duration_s",
                        "limit"
                      ],
                      "description": "Send estimate."
                    },
                    "created_at": {
                      "type": "string",
                      "description": "Creation date (ISO 8601, UTC)."
                    },
                    "updated_at": {
                      "type": "string",
                      "description": "Last change (ISO 8601, UTC)."
                    }
                  },
                  "required": [
                    "id",
                    "name",
                    "status",
                    "connection_id",
                    "template",
                    "variables",
                    "rate_limit_mps",
                    "effective_rate_mps",
                    "scheduled_at",
                    "started_at",
                    "paused_at",
                    "pause_reason",
                    "completed_at",
                    "canceled_at",
                    "stats",
                    "estimate",
                    "created_at",
                    "updated_at"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/campaigns/{id}/unschedule": {
      "post": {
        "operationId": "unscheduleCampaign",
        "summary": "Unschedule campaign",
        "description": "Moves a scheduled campaign back to `draft`. Permission: `send`.",
        "tags": [
          "campaigns"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "Campaign ID (`cmp_…`)."
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "description": "The draft campaign.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Campaign ID (`cmp_…`).",
                      "examples": [
                        "cmp_0193a1b2c3d47e8f9a0b1c2d3e4f5a6b"
                      ]
                    },
                    "name": {
                      "type": "string",
                      "description": "Campaign name."
                    },
                    "status": {
                      "enum": [
                        "draft",
                        "scheduled",
                        "running",
                        "waiting_limit",
                        "paused",
                        "auto_paused",
                        "completed",
                        "canceled"
                      ],
                      "type": "string",
                      "description": "Status: `draft`, `scheduled`, `running`, `waiting_limit`, `paused`, `auto_paused`, `completed` or `canceled`."
                    },
                    "connection_id": {
                      "type": "string",
                      "description": "ID of the sending WhatsApp connection. Optional with a connection key (uses the key's connection)."
                    },
                    "template": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ],
                          "description": "Template ID in Messajo."
                        },
                        "name": {
                          "type": "string",
                          "description": "Template name."
                        },
                        "language": {
                          "type": "string",
                          "description": "Template language, e.g. `en_US`."
                        },
                        "category": {
                          "type": "string",
                          "description": "Template category: `MARKETING` or `UTILITY`."
                        }
                      },
                      "required": [
                        "id",
                        "name",
                        "language",
                        "category"
                      ],
                      "description": "Campaign template."
                    },
                    "variables": {
                      "type": "object",
                      "propertyNames": {
                        "type": "string"
                      },
                      "additionalProperties": {},
                      "description": "Template variable mapping: `header`, `body` and `buttons`, each parameter with `column` (list column), `value` (fixed) or `contact: \"display_name\"`."
                    },
                    "rate_limit_mps": {
                      "anyOf": [
                        {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Messages per second; `null` = automatic (80% of the number's throughput)."
                    },
                    "effective_rate_mps": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "Messages per second actually used."
                    },
                    "scheduled_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Scheduled start (ISO 8601)."
                    },
                    "started_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Start (ISO 8601, UTC)."
                    },
                    "paused_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Pause (ISO 8601, UTC)."
                    },
                    "pause_reason": {
                      "anyOf": [
                        {
                          "enum": [
                            "manual",
                            "quality_low",
                            "template_paused",
                            "template_quality_low",
                            "error_rate",
                            "marketing_limit",
                            "policy",
                            "spam_limit",
                            "connection_not_active",
                            "org_suspended",
                            "spend_cap"
                          ],
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Pause reason: `manual` or the automatic pause reason."
                    },
                    "completed_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Completion (ISO 8601, UTC)."
                    },
                    "canceled_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Cancellation (ISO 8601, UTC)."
                    },
                    "stats": {
                      "type": "object",
                      "properties": {
                        "total": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "pending": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "invalid": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "sending": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "sent": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "delivered": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "read": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "failed": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "unknown": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "skipped": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "by_error": {
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991
                          },
                          "description": "Failures per error code."
                        }
                      },
                      "required": [
                        "total",
                        "pending",
                        "invalid",
                        "sending",
                        "sent",
                        "delivered",
                        "read",
                        "failed",
                        "unknown",
                        "skipped",
                        "by_error"
                      ],
                      "description": "Recipients per status."
                    },
                    "estimate": {
                      "type": "object",
                      "properties": {
                        "recipients_valid": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "Recipients still to be sent."
                        },
                        "effective_rate_mps": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "Messages per second actually used."
                        },
                        "duration_s": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "Estimated duration in seconds."
                        },
                        "limit": {
                          "type": "object",
                          "properties": {
                            "tier": {
                              "anyOf": [
                                {
                                  "type": "integer",
                                  "minimum": -9007199254740991,
                                  "maximum": 9007199254740991
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Limit ceiling; `null` = unlimited."
                            },
                            "used_24h": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991,
                              "description": "Recipients counted in the last 24 hours."
                            },
                            "remaining": {
                              "anyOf": [
                                {
                                  "type": "integer",
                                  "minimum": -9007199254740991,
                                  "maximum": 9007199254740991
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Remaining slots; `null` = unlimited."
                            }
                          },
                          "required": [
                            "tier",
                            "used_24h",
                            "remaining"
                          ],
                          "description": "Portfolio 24-hour messaging limit."
                        }
                      },
                      "required": [
                        "recipients_valid",
                        "effective_rate_mps",
                        "duration_s",
                        "limit"
                      ],
                      "description": "Send estimate."
                    },
                    "created_at": {
                      "type": "string",
                      "description": "Creation date (ISO 8601, UTC)."
                    },
                    "updated_at": {
                      "type": "string",
                      "description": "Last change (ISO 8601, UTC)."
                    }
                  },
                  "required": [
                    "id",
                    "name",
                    "status",
                    "connection_id",
                    "template",
                    "variables",
                    "rate_limit_mps",
                    "effective_rate_mps",
                    "scheduled_at",
                    "started_at",
                    "paused_at",
                    "pause_reason",
                    "completed_at",
                    "canceled_at",
                    "stats",
                    "estimate",
                    "created_at",
                    "updated_at"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/campaigns/{id}/start": {
      "post": {
        "operationId": "startCampaign",
        "summary": "Start campaign",
        "description": "Starts sending now from `draft`. Permission: `send`.",
        "tags": [
          "campaigns"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "Campaign ID (`cmp_…`)."
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "description": "The sending campaign.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Campaign ID (`cmp_…`).",
                      "examples": [
                        "cmp_0193a1b2c3d47e8f9a0b1c2d3e4f5a6b"
                      ]
                    },
                    "name": {
                      "type": "string",
                      "description": "Campaign name."
                    },
                    "status": {
                      "enum": [
                        "draft",
                        "scheduled",
                        "running",
                        "waiting_limit",
                        "paused",
                        "auto_paused",
                        "completed",
                        "canceled"
                      ],
                      "type": "string",
                      "description": "Status: `draft`, `scheduled`, `running`, `waiting_limit`, `paused`, `auto_paused`, `completed` or `canceled`."
                    },
                    "connection_id": {
                      "type": "string",
                      "description": "ID of the sending WhatsApp connection. Optional with a connection key (uses the key's connection)."
                    },
                    "template": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ],
                          "description": "Template ID in Messajo."
                        },
                        "name": {
                          "type": "string",
                          "description": "Template name."
                        },
                        "language": {
                          "type": "string",
                          "description": "Template language, e.g. `en_US`."
                        },
                        "category": {
                          "type": "string",
                          "description": "Template category: `MARKETING` or `UTILITY`."
                        }
                      },
                      "required": [
                        "id",
                        "name",
                        "language",
                        "category"
                      ],
                      "description": "Campaign template."
                    },
                    "variables": {
                      "type": "object",
                      "propertyNames": {
                        "type": "string"
                      },
                      "additionalProperties": {},
                      "description": "Template variable mapping: `header`, `body` and `buttons`, each parameter with `column` (list column), `value` (fixed) or `contact: \"display_name\"`."
                    },
                    "rate_limit_mps": {
                      "anyOf": [
                        {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Messages per second; `null` = automatic (80% of the number's throughput)."
                    },
                    "effective_rate_mps": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "Messages per second actually used."
                    },
                    "scheduled_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Scheduled start (ISO 8601)."
                    },
                    "started_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Start (ISO 8601, UTC)."
                    },
                    "paused_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Pause (ISO 8601, UTC)."
                    },
                    "pause_reason": {
                      "anyOf": [
                        {
                          "enum": [
                            "manual",
                            "quality_low",
                            "template_paused",
                            "template_quality_low",
                            "error_rate",
                            "marketing_limit",
                            "policy",
                            "spam_limit",
                            "connection_not_active",
                            "org_suspended",
                            "spend_cap"
                          ],
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Pause reason: `manual` or the automatic pause reason."
                    },
                    "completed_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Completion (ISO 8601, UTC)."
                    },
                    "canceled_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Cancellation (ISO 8601, UTC)."
                    },
                    "stats": {
                      "type": "object",
                      "properties": {
                        "total": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "pending": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "invalid": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "sending": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "sent": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "delivered": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "read": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "failed": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "unknown": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "skipped": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "by_error": {
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991
                          },
                          "description": "Failures per error code."
                        }
                      },
                      "required": [
                        "total",
                        "pending",
                        "invalid",
                        "sending",
                        "sent",
                        "delivered",
                        "read",
                        "failed",
                        "unknown",
                        "skipped",
                        "by_error"
                      ],
                      "description": "Recipients per status."
                    },
                    "estimate": {
                      "type": "object",
                      "properties": {
                        "recipients_valid": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "Recipients still to be sent."
                        },
                        "effective_rate_mps": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "Messages per second actually used."
                        },
                        "duration_s": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "Estimated duration in seconds."
                        },
                        "limit": {
                          "type": "object",
                          "properties": {
                            "tier": {
                              "anyOf": [
                                {
                                  "type": "integer",
                                  "minimum": -9007199254740991,
                                  "maximum": 9007199254740991
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Limit ceiling; `null` = unlimited."
                            },
                            "used_24h": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991,
                              "description": "Recipients counted in the last 24 hours."
                            },
                            "remaining": {
                              "anyOf": [
                                {
                                  "type": "integer",
                                  "minimum": -9007199254740991,
                                  "maximum": 9007199254740991
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Remaining slots; `null` = unlimited."
                            }
                          },
                          "required": [
                            "tier",
                            "used_24h",
                            "remaining"
                          ],
                          "description": "Portfolio 24-hour messaging limit."
                        }
                      },
                      "required": [
                        "recipients_valid",
                        "effective_rate_mps",
                        "duration_s",
                        "limit"
                      ],
                      "description": "Send estimate."
                    },
                    "created_at": {
                      "type": "string",
                      "description": "Creation date (ISO 8601, UTC)."
                    },
                    "updated_at": {
                      "type": "string",
                      "description": "Last change (ISO 8601, UTC)."
                    }
                  },
                  "required": [
                    "id",
                    "name",
                    "status",
                    "connection_id",
                    "template",
                    "variables",
                    "rate_limit_mps",
                    "effective_rate_mps",
                    "scheduled_at",
                    "started_at",
                    "paused_at",
                    "pause_reason",
                    "completed_at",
                    "canceled_at",
                    "stats",
                    "estimate",
                    "created_at",
                    "updated_at"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/campaigns/{id}/pause": {
      "post": {
        "operationId": "pauseCampaign",
        "summary": "Pause campaign",
        "description": "Pauses sending; messages already going out finish. Permission: `send`.",
        "tags": [
          "campaigns"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "Campaign ID (`cmp_…`)."
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "description": "The paused campaign.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Campaign ID (`cmp_…`).",
                      "examples": [
                        "cmp_0193a1b2c3d47e8f9a0b1c2d3e4f5a6b"
                      ]
                    },
                    "name": {
                      "type": "string",
                      "description": "Campaign name."
                    },
                    "status": {
                      "enum": [
                        "draft",
                        "scheduled",
                        "running",
                        "waiting_limit",
                        "paused",
                        "auto_paused",
                        "completed",
                        "canceled"
                      ],
                      "type": "string",
                      "description": "Status: `draft`, `scheduled`, `running`, `waiting_limit`, `paused`, `auto_paused`, `completed` or `canceled`."
                    },
                    "connection_id": {
                      "type": "string",
                      "description": "ID of the sending WhatsApp connection. Optional with a connection key (uses the key's connection)."
                    },
                    "template": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ],
                          "description": "Template ID in Messajo."
                        },
                        "name": {
                          "type": "string",
                          "description": "Template name."
                        },
                        "language": {
                          "type": "string",
                          "description": "Template language, e.g. `en_US`."
                        },
                        "category": {
                          "type": "string",
                          "description": "Template category: `MARKETING` or `UTILITY`."
                        }
                      },
                      "required": [
                        "id",
                        "name",
                        "language",
                        "category"
                      ],
                      "description": "Campaign template."
                    },
                    "variables": {
                      "type": "object",
                      "propertyNames": {
                        "type": "string"
                      },
                      "additionalProperties": {},
                      "description": "Template variable mapping: `header`, `body` and `buttons`, each parameter with `column` (list column), `value` (fixed) or `contact: \"display_name\"`."
                    },
                    "rate_limit_mps": {
                      "anyOf": [
                        {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Messages per second; `null` = automatic (80% of the number's throughput)."
                    },
                    "effective_rate_mps": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "Messages per second actually used."
                    },
                    "scheduled_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Scheduled start (ISO 8601)."
                    },
                    "started_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Start (ISO 8601, UTC)."
                    },
                    "paused_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Pause (ISO 8601, UTC)."
                    },
                    "pause_reason": {
                      "anyOf": [
                        {
                          "enum": [
                            "manual",
                            "quality_low",
                            "template_paused",
                            "template_quality_low",
                            "error_rate",
                            "marketing_limit",
                            "policy",
                            "spam_limit",
                            "connection_not_active",
                            "org_suspended",
                            "spend_cap"
                          ],
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Pause reason: `manual` or the automatic pause reason."
                    },
                    "completed_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Completion (ISO 8601, UTC)."
                    },
                    "canceled_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Cancellation (ISO 8601, UTC)."
                    },
                    "stats": {
                      "type": "object",
                      "properties": {
                        "total": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "pending": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "invalid": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "sending": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "sent": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "delivered": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "read": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "failed": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "unknown": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "skipped": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "by_error": {
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991
                          },
                          "description": "Failures per error code."
                        }
                      },
                      "required": [
                        "total",
                        "pending",
                        "invalid",
                        "sending",
                        "sent",
                        "delivered",
                        "read",
                        "failed",
                        "unknown",
                        "skipped",
                        "by_error"
                      ],
                      "description": "Recipients per status."
                    },
                    "estimate": {
                      "type": "object",
                      "properties": {
                        "recipients_valid": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "Recipients still to be sent."
                        },
                        "effective_rate_mps": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "Messages per second actually used."
                        },
                        "duration_s": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "Estimated duration in seconds."
                        },
                        "limit": {
                          "type": "object",
                          "properties": {
                            "tier": {
                              "anyOf": [
                                {
                                  "type": "integer",
                                  "minimum": -9007199254740991,
                                  "maximum": 9007199254740991
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Limit ceiling; `null` = unlimited."
                            },
                            "used_24h": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991,
                              "description": "Recipients counted in the last 24 hours."
                            },
                            "remaining": {
                              "anyOf": [
                                {
                                  "type": "integer",
                                  "minimum": -9007199254740991,
                                  "maximum": 9007199254740991
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Remaining slots; `null` = unlimited."
                            }
                          },
                          "required": [
                            "tier",
                            "used_24h",
                            "remaining"
                          ],
                          "description": "Portfolio 24-hour messaging limit."
                        }
                      },
                      "required": [
                        "recipients_valid",
                        "effective_rate_mps",
                        "duration_s",
                        "limit"
                      ],
                      "description": "Send estimate."
                    },
                    "created_at": {
                      "type": "string",
                      "description": "Creation date (ISO 8601, UTC)."
                    },
                    "updated_at": {
                      "type": "string",
                      "description": "Last change (ISO 8601, UTC)."
                    }
                  },
                  "required": [
                    "id",
                    "name",
                    "status",
                    "connection_id",
                    "template",
                    "variables",
                    "rate_limit_mps",
                    "effective_rate_mps",
                    "scheduled_at",
                    "started_at",
                    "paused_at",
                    "pause_reason",
                    "completed_at",
                    "canceled_at",
                    "stats",
                    "estimate",
                    "created_at",
                    "updated_at"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/campaigns/{id}/resume": {
      "post": {
        "operationId": "resumeCampaign",
        "summary": "Resume campaign",
        "description": "Resumes a campaign paused manually or automatically, taking the current quality as the new baseline. Permission: `send`.",
        "tags": [
          "campaigns"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "Campaign ID (`cmp_…`)."
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "description": "The sending campaign.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Campaign ID (`cmp_…`).",
                      "examples": [
                        "cmp_0193a1b2c3d47e8f9a0b1c2d3e4f5a6b"
                      ]
                    },
                    "name": {
                      "type": "string",
                      "description": "Campaign name."
                    },
                    "status": {
                      "enum": [
                        "draft",
                        "scheduled",
                        "running",
                        "waiting_limit",
                        "paused",
                        "auto_paused",
                        "completed",
                        "canceled"
                      ],
                      "type": "string",
                      "description": "Status: `draft`, `scheduled`, `running`, `waiting_limit`, `paused`, `auto_paused`, `completed` or `canceled`."
                    },
                    "connection_id": {
                      "type": "string",
                      "description": "ID of the sending WhatsApp connection. Optional with a connection key (uses the key's connection)."
                    },
                    "template": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ],
                          "description": "Template ID in Messajo."
                        },
                        "name": {
                          "type": "string",
                          "description": "Template name."
                        },
                        "language": {
                          "type": "string",
                          "description": "Template language, e.g. `en_US`."
                        },
                        "category": {
                          "type": "string",
                          "description": "Template category: `MARKETING` or `UTILITY`."
                        }
                      },
                      "required": [
                        "id",
                        "name",
                        "language",
                        "category"
                      ],
                      "description": "Campaign template."
                    },
                    "variables": {
                      "type": "object",
                      "propertyNames": {
                        "type": "string"
                      },
                      "additionalProperties": {},
                      "description": "Template variable mapping: `header`, `body` and `buttons`, each parameter with `column` (list column), `value` (fixed) or `contact: \"display_name\"`."
                    },
                    "rate_limit_mps": {
                      "anyOf": [
                        {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Messages per second; `null` = automatic (80% of the number's throughput)."
                    },
                    "effective_rate_mps": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "Messages per second actually used."
                    },
                    "scheduled_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Scheduled start (ISO 8601)."
                    },
                    "started_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Start (ISO 8601, UTC)."
                    },
                    "paused_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Pause (ISO 8601, UTC)."
                    },
                    "pause_reason": {
                      "anyOf": [
                        {
                          "enum": [
                            "manual",
                            "quality_low",
                            "template_paused",
                            "template_quality_low",
                            "error_rate",
                            "marketing_limit",
                            "policy",
                            "spam_limit",
                            "connection_not_active",
                            "org_suspended",
                            "spend_cap"
                          ],
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Pause reason: `manual` or the automatic pause reason."
                    },
                    "completed_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Completion (ISO 8601, UTC)."
                    },
                    "canceled_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Cancellation (ISO 8601, UTC)."
                    },
                    "stats": {
                      "type": "object",
                      "properties": {
                        "total": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "pending": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "invalid": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "sending": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "sent": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "delivered": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "read": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "failed": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "unknown": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "skipped": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "by_error": {
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991
                          },
                          "description": "Failures per error code."
                        }
                      },
                      "required": [
                        "total",
                        "pending",
                        "invalid",
                        "sending",
                        "sent",
                        "delivered",
                        "read",
                        "failed",
                        "unknown",
                        "skipped",
                        "by_error"
                      ],
                      "description": "Recipients per status."
                    },
                    "estimate": {
                      "type": "object",
                      "properties": {
                        "recipients_valid": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "Recipients still to be sent."
                        },
                        "effective_rate_mps": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "Messages per second actually used."
                        },
                        "duration_s": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "Estimated duration in seconds."
                        },
                        "limit": {
                          "type": "object",
                          "properties": {
                            "tier": {
                              "anyOf": [
                                {
                                  "type": "integer",
                                  "minimum": -9007199254740991,
                                  "maximum": 9007199254740991
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Limit ceiling; `null` = unlimited."
                            },
                            "used_24h": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991,
                              "description": "Recipients counted in the last 24 hours."
                            },
                            "remaining": {
                              "anyOf": [
                                {
                                  "type": "integer",
                                  "minimum": -9007199254740991,
                                  "maximum": 9007199254740991
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Remaining slots; `null` = unlimited."
                            }
                          },
                          "required": [
                            "tier",
                            "used_24h",
                            "remaining"
                          ],
                          "description": "Portfolio 24-hour messaging limit."
                        }
                      },
                      "required": [
                        "recipients_valid",
                        "effective_rate_mps",
                        "duration_s",
                        "limit"
                      ],
                      "description": "Send estimate."
                    },
                    "created_at": {
                      "type": "string",
                      "description": "Creation date (ISO 8601, UTC)."
                    },
                    "updated_at": {
                      "type": "string",
                      "description": "Last change (ISO 8601, UTC)."
                    }
                  },
                  "required": [
                    "id",
                    "name",
                    "status",
                    "connection_id",
                    "template",
                    "variables",
                    "rate_limit_mps",
                    "effective_rate_mps",
                    "scheduled_at",
                    "started_at",
                    "paused_at",
                    "pause_reason",
                    "completed_at",
                    "canceled_at",
                    "stats",
                    "estimate",
                    "created_at",
                    "updated_at"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/campaigns/{id}/cancel": {
      "post": {
        "operationId": "cancelCampaign",
        "summary": "Cancel campaign",
        "description": "Cancels the campaign; recipients not yet sent become `skipped`. Permission: `send`.",
        "tags": [
          "campaigns"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "Campaign ID (`cmp_…`)."
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "description": "The canceled campaign.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Campaign ID (`cmp_…`).",
                      "examples": [
                        "cmp_0193a1b2c3d47e8f9a0b1c2d3e4f5a6b"
                      ]
                    },
                    "name": {
                      "type": "string",
                      "description": "Campaign name."
                    },
                    "status": {
                      "enum": [
                        "draft",
                        "scheduled",
                        "running",
                        "waiting_limit",
                        "paused",
                        "auto_paused",
                        "completed",
                        "canceled"
                      ],
                      "type": "string",
                      "description": "Status: `draft`, `scheduled`, `running`, `waiting_limit`, `paused`, `auto_paused`, `completed` or `canceled`."
                    },
                    "connection_id": {
                      "type": "string",
                      "description": "ID of the sending WhatsApp connection. Optional with a connection key (uses the key's connection)."
                    },
                    "template": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ],
                          "description": "Template ID in Messajo."
                        },
                        "name": {
                          "type": "string",
                          "description": "Template name."
                        },
                        "language": {
                          "type": "string",
                          "description": "Template language, e.g. `en_US`."
                        },
                        "category": {
                          "type": "string",
                          "description": "Template category: `MARKETING` or `UTILITY`."
                        }
                      },
                      "required": [
                        "id",
                        "name",
                        "language",
                        "category"
                      ],
                      "description": "Campaign template."
                    },
                    "variables": {
                      "type": "object",
                      "propertyNames": {
                        "type": "string"
                      },
                      "additionalProperties": {},
                      "description": "Template variable mapping: `header`, `body` and `buttons`, each parameter with `column` (list column), `value` (fixed) or `contact: \"display_name\"`."
                    },
                    "rate_limit_mps": {
                      "anyOf": [
                        {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Messages per second; `null` = automatic (80% of the number's throughput)."
                    },
                    "effective_rate_mps": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "Messages per second actually used."
                    },
                    "scheduled_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Scheduled start (ISO 8601)."
                    },
                    "started_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Start (ISO 8601, UTC)."
                    },
                    "paused_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Pause (ISO 8601, UTC)."
                    },
                    "pause_reason": {
                      "anyOf": [
                        {
                          "enum": [
                            "manual",
                            "quality_low",
                            "template_paused",
                            "template_quality_low",
                            "error_rate",
                            "marketing_limit",
                            "policy",
                            "spam_limit",
                            "connection_not_active",
                            "org_suspended",
                            "spend_cap"
                          ],
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Pause reason: `manual` or the automatic pause reason."
                    },
                    "completed_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Completion (ISO 8601, UTC)."
                    },
                    "canceled_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Cancellation (ISO 8601, UTC)."
                    },
                    "stats": {
                      "type": "object",
                      "properties": {
                        "total": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "pending": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "invalid": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "sending": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "sent": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "delivered": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "read": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "failed": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "unknown": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "skipped": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "by_error": {
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991
                          },
                          "description": "Failures per error code."
                        }
                      },
                      "required": [
                        "total",
                        "pending",
                        "invalid",
                        "sending",
                        "sent",
                        "delivered",
                        "read",
                        "failed",
                        "unknown",
                        "skipped",
                        "by_error"
                      ],
                      "description": "Recipients per status."
                    },
                    "estimate": {
                      "type": "object",
                      "properties": {
                        "recipients_valid": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "Recipients still to be sent."
                        },
                        "effective_rate_mps": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "Messages per second actually used."
                        },
                        "duration_s": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "Estimated duration in seconds."
                        },
                        "limit": {
                          "type": "object",
                          "properties": {
                            "tier": {
                              "anyOf": [
                                {
                                  "type": "integer",
                                  "minimum": -9007199254740991,
                                  "maximum": 9007199254740991
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Limit ceiling; `null` = unlimited."
                            },
                            "used_24h": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991,
                              "description": "Recipients counted in the last 24 hours."
                            },
                            "remaining": {
                              "anyOf": [
                                {
                                  "type": "integer",
                                  "minimum": -9007199254740991,
                                  "maximum": 9007199254740991
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Remaining slots; `null` = unlimited."
                            }
                          },
                          "required": [
                            "tier",
                            "used_24h",
                            "remaining"
                          ],
                          "description": "Portfolio 24-hour messaging limit."
                        }
                      },
                      "required": [
                        "recipients_valid",
                        "effective_rate_mps",
                        "duration_s",
                        "limit"
                      ],
                      "description": "Send estimate."
                    },
                    "created_at": {
                      "type": "string",
                      "description": "Creation date (ISO 8601, UTC)."
                    },
                    "updated_at": {
                      "type": "string",
                      "description": "Last change (ISO 8601, UTC)."
                    }
                  },
                  "required": [
                    "id",
                    "name",
                    "status",
                    "connection_id",
                    "template",
                    "variables",
                    "rate_limit_mps",
                    "effective_rate_mps",
                    "scheduled_at",
                    "started_at",
                    "paused_at",
                    "pause_reason",
                    "completed_at",
                    "canceled_at",
                    "stats",
                    "estimate",
                    "created_at",
                    "updated_at"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/campaigns/{id}/duplicate": {
      "post": {
        "operationId": "duplicateCampaign",
        "summary": "Duplicate campaign",
        "description": "Creates a `draft` with the same template, mapping and rate; `recipients` picks which recipients to copy. Permission: `send`.",
        "tags": [
          "campaigns"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "Campaign ID (`cmp_…`)."
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 120,
                    "description": "Campaign name."
                  },
                  "recipients": {
                    "enum": [
                      "none",
                      "all",
                      "failed",
                      "unknown_or_failed"
                    ],
                    "type": "string",
                    "default": "none",
                    "description": "Recipients to copy: `none`, `all`, `failed` or `unknown_or_failed`."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The new campaign.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Campaign ID (`cmp_…`).",
                      "examples": [
                        "cmp_0193a1b2c3d47e8f9a0b1c2d3e4f5a6b"
                      ]
                    },
                    "name": {
                      "type": "string",
                      "description": "Campaign name."
                    },
                    "status": {
                      "enum": [
                        "draft",
                        "scheduled",
                        "running",
                        "waiting_limit",
                        "paused",
                        "auto_paused",
                        "completed",
                        "canceled"
                      ],
                      "type": "string",
                      "description": "Status: `draft`, `scheduled`, `running`, `waiting_limit`, `paused`, `auto_paused`, `completed` or `canceled`."
                    },
                    "connection_id": {
                      "type": "string",
                      "description": "ID of the sending WhatsApp connection. Optional with a connection key (uses the key's connection)."
                    },
                    "template": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ],
                          "description": "Template ID in Messajo."
                        },
                        "name": {
                          "type": "string",
                          "description": "Template name."
                        },
                        "language": {
                          "type": "string",
                          "description": "Template language, e.g. `en_US`."
                        },
                        "category": {
                          "type": "string",
                          "description": "Template category: `MARKETING` or `UTILITY`."
                        }
                      },
                      "required": [
                        "id",
                        "name",
                        "language",
                        "category"
                      ],
                      "description": "Campaign template."
                    },
                    "variables": {
                      "type": "object",
                      "propertyNames": {
                        "type": "string"
                      },
                      "additionalProperties": {},
                      "description": "Template variable mapping: `header`, `body` and `buttons`, each parameter with `column` (list column), `value` (fixed) or `contact: \"display_name\"`."
                    },
                    "rate_limit_mps": {
                      "anyOf": [
                        {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Messages per second; `null` = automatic (80% of the number's throughput)."
                    },
                    "effective_rate_mps": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "Messages per second actually used."
                    },
                    "scheduled_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Scheduled start (ISO 8601)."
                    },
                    "started_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Start (ISO 8601, UTC)."
                    },
                    "paused_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Pause (ISO 8601, UTC)."
                    },
                    "pause_reason": {
                      "anyOf": [
                        {
                          "enum": [
                            "manual",
                            "quality_low",
                            "template_paused",
                            "template_quality_low",
                            "error_rate",
                            "marketing_limit",
                            "policy",
                            "spam_limit",
                            "connection_not_active",
                            "org_suspended",
                            "spend_cap"
                          ],
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Pause reason: `manual` or the automatic pause reason."
                    },
                    "completed_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Completion (ISO 8601, UTC)."
                    },
                    "canceled_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Cancellation (ISO 8601, UTC)."
                    },
                    "stats": {
                      "type": "object",
                      "properties": {
                        "total": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "pending": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "invalid": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "sending": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "sent": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "delivered": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "read": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "failed": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "unknown": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "skipped": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "by_error": {
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991
                          },
                          "description": "Failures per error code."
                        }
                      },
                      "required": [
                        "total",
                        "pending",
                        "invalid",
                        "sending",
                        "sent",
                        "delivered",
                        "read",
                        "failed",
                        "unknown",
                        "skipped",
                        "by_error"
                      ],
                      "description": "Recipients per status."
                    },
                    "estimate": {
                      "type": "object",
                      "properties": {
                        "recipients_valid": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "Recipients still to be sent."
                        },
                        "effective_rate_mps": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "Messages per second actually used."
                        },
                        "duration_s": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "Estimated duration in seconds."
                        },
                        "limit": {
                          "type": "object",
                          "properties": {
                            "tier": {
                              "anyOf": [
                                {
                                  "type": "integer",
                                  "minimum": -9007199254740991,
                                  "maximum": 9007199254740991
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Limit ceiling; `null` = unlimited."
                            },
                            "used_24h": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991,
                              "description": "Recipients counted in the last 24 hours."
                            },
                            "remaining": {
                              "anyOf": [
                                {
                                  "type": "integer",
                                  "minimum": -9007199254740991,
                                  "maximum": 9007199254740991
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Remaining slots; `null` = unlimited."
                            }
                          },
                          "required": [
                            "tier",
                            "used_24h",
                            "remaining"
                          ],
                          "description": "Portfolio 24-hour messaging limit."
                        }
                      },
                      "required": [
                        "recipients_valid",
                        "effective_rate_mps",
                        "duration_s",
                        "limit"
                      ],
                      "description": "Send estimate."
                    },
                    "created_at": {
                      "type": "string",
                      "description": "Creation date (ISO 8601, UTC)."
                    },
                    "updated_at": {
                      "type": "string",
                      "description": "Last change (ISO 8601, UTC)."
                    }
                  },
                  "required": [
                    "id",
                    "name",
                    "status",
                    "connection_id",
                    "template",
                    "variables",
                    "rate_limit_mps",
                    "effective_rate_mps",
                    "scheduled_at",
                    "started_at",
                    "paused_at",
                    "pause_reason",
                    "completed_at",
                    "canceled_at",
                    "stats",
                    "estimate",
                    "created_at",
                    "updated_at"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/campaigns/{id}/report": {
      "get": {
        "operationId": "getCampaignReport",
        "summary": "Download report",
        "description": "CSV with one line per recipient: status, error, message ids, timestamps and variables. Permission: `read`.",
        "tags": [
          "campaigns"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "Campaign ID (`cmp_…`)."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The CSV report.",
            "content": {
              "*/*": {
                "schema": {
                  "type": "string",
                  "contentMediaType": "*/*",
                  "description": "CSV report."
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/calls": {
      "get": {
        "operationId": "listCalls",
        "summary": "List calls",
        "description": "The organization's call log, newest first, filtered by connection, direction, status, end reason, contact and period. Reads never include the SDP (only `has_sdp`): it arrives in the `call.*` events. Permission: `read`.",
        "tags": [
          "calls"
        ],
        "parameters": [
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "Next page cursor: the `next_cursor` of the previous response."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50,
              "description": "Items per page, from 1 to 100 (default 50)."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "connection_id",
            "in": "query",
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "ID of the call's connection (number). Optional with a connection key (uses the key's connection)."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "direction",
            "in": "query",
            "schema": {
              "enum": [
                "user_initiated",
                "business_initiated"
              ],
              "type": "string",
              "description": "`user_initiated` (the user called) or `business_initiated` (the number called)."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "enum": [
                "offered",
                "pre_accepted",
                "dialing",
                "ringing",
                "accepted",
                "terminating",
                "ended",
                "rejected"
              ],
              "type": "string",
              "description": "Call state."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "end_reason",
            "in": "query",
            "schema": {
              "enum": [
                "completed",
                "failed",
                "rejected",
                "missed",
                "canceled",
                "unknown"
              ],
              "type": "string",
              "description": "Why it ended, once ended."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "contact_id",
            "in": "query",
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "The call's contact, when known."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "since",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time",
              "description": "Only calls created from this date (ISO 8601)."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "until",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time",
              "description": "Only calls created up to this date (ISO 8601)."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          }
        ],
        "responses": {
          "200": {
            "description": "A page of calls.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "description": "Call ID (`cal_…`).",
                            "examples": [
                              "cal_0193a1b2c3d47e8f"
                            ]
                          },
                          "connection_id": {
                            "type": "string",
                            "description": "ID of the call's connection (number). Optional with a connection key (uses the key's connection)."
                          },
                          "contact_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "The call's contact, when known."
                          },
                          "conversation_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "The call's conversation, if any."
                          },
                          "external_id": {
                            "type": "string",
                            "description": "Call ID at Meta (`wacid.…`)."
                          },
                          "direction": {
                            "enum": [
                              "user_initiated",
                              "business_initiated"
                            ],
                            "type": "string",
                            "description": "`user_initiated` (the user called) or `business_initiated` (the number called)."
                          },
                          "status": {
                            "enum": [
                              "offered",
                              "pre_accepted",
                              "dialing",
                              "ringing",
                              "accepted",
                              "terminating",
                              "ended",
                              "rejected"
                            ],
                            "type": "string",
                            "description": "Call state."
                          },
                          "end_reason": {
                            "anyOf": [
                              {
                                "enum": [
                                  "completed",
                                  "failed",
                                  "rejected",
                                  "missed",
                                  "canceled",
                                  "unknown"
                                ],
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Why it ended, once ended."
                          },
                          "has_sdp": {
                            "type": "boolean",
                            "description": "`true` while the SDP is stored (deleted 1 h after the end)."
                          },
                          "biz_opaque_callback_data": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Your own text that Meta returns in this call's webhooks."
                          },
                          "errors": {
                            "anyOf": [
                              {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "propertyNames": {
                                    "type": "string"
                                  },
                                  "additionalProperties": {}
                                }
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Errors Meta reported for the call."
                          },
                          "offered_at": {
                            "type": "string",
                            "description": "When the call started ringing."
                          },
                          "answered_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "When it was answered."
                          },
                          "start_time": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Conversation start, per Meta."
                          },
                          "end_time": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Call end."
                          },
                          "duration_s": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Duration in seconds."
                          },
                          "created_at": {
                            "type": "string",
                            "description": "When the row was created."
                          },
                          "updated_at": {
                            "type": "string",
                            "description": "Last change."
                          }
                        },
                        "required": [
                          "id",
                          "connection_id",
                          "contact_id",
                          "conversation_id",
                          "external_id",
                          "direction",
                          "status",
                          "end_reason",
                          "has_sdp",
                          "biz_opaque_callback_data",
                          "errors",
                          "offered_at",
                          "answered_at",
                          "start_time",
                          "end_time",
                          "duration_s",
                          "created_at",
                          "updated_at"
                        ]
                      },
                      "description": "Page items, newest first."
                    },
                    "next_cursor": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Cursor for the next page; `null` when there are no more items."
                    }
                  },
                  "required": [
                    "data",
                    "next_cursor"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "connectCall",
        "summary": "Call the user",
        "description": "Starts a call to the user with the SDP offer. Requires the user's call permission (`call_permission_required` without it) and the Calling API enabled on the number. Coexistence numbers → `422 calling_not_supported_in_coex`. Permission: `send`.",
        "tags": [
          "calls"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "connection_id": {
                    "type": "string",
                    "minLength": 1,
                    "description": "ID of the call's connection (number). Optional with a connection key (uses the key's connection)."
                  },
                  "to": {
                    "type": "string",
                    "minLength": 1,
                    "description": "The user's phone (digits only, with country code) or BSUID."
                  },
                  "sdp": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 65536,
                    "description": "SDP as text (up to 64 KiB, starts with `v=0`). Required for `pre-accept` and `accept`."
                  },
                  "biz_opaque_callback_data": {
                    "type": "string",
                    "maxLength": 512,
                    "description": "Your own text that Meta returns in this call's webhooks."
                  }
                },
                "required": [
                  "to",
                  "sdp"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The new call, in `dialing`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Call ID (`cal_…`).",
                      "examples": [
                        "cal_0193a1b2c3d47e8f"
                      ]
                    },
                    "connection_id": {
                      "type": "string",
                      "description": "ID of the call's connection (number). Optional with a connection key (uses the key's connection)."
                    },
                    "contact_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "The call's contact, when known."
                    },
                    "conversation_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "The call's conversation, if any."
                    },
                    "external_id": {
                      "type": "string",
                      "description": "Call ID at Meta (`wacid.…`)."
                    },
                    "direction": {
                      "enum": [
                        "user_initiated",
                        "business_initiated"
                      ],
                      "type": "string",
                      "description": "`user_initiated` (the user called) or `business_initiated` (the number called)."
                    },
                    "status": {
                      "enum": [
                        "offered",
                        "pre_accepted",
                        "dialing",
                        "ringing",
                        "accepted",
                        "terminating",
                        "ended",
                        "rejected"
                      ],
                      "type": "string",
                      "description": "Call state."
                    },
                    "end_reason": {
                      "anyOf": [
                        {
                          "enum": [
                            "completed",
                            "failed",
                            "rejected",
                            "missed",
                            "canceled",
                            "unknown"
                          ],
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Why it ended, once ended."
                    },
                    "has_sdp": {
                      "type": "boolean",
                      "description": "`true` while the SDP is stored (deleted 1 h after the end)."
                    },
                    "biz_opaque_callback_data": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Your own text that Meta returns in this call's webhooks."
                    },
                    "errors": {
                      "anyOf": [
                        {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "propertyNames": {
                              "type": "string"
                            },
                            "additionalProperties": {}
                          }
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Errors Meta reported for the call."
                    },
                    "offered_at": {
                      "type": "string",
                      "description": "When the call started ringing."
                    },
                    "answered_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "When it was answered."
                    },
                    "start_time": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Conversation start, per Meta."
                    },
                    "end_time": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Call end."
                    },
                    "duration_s": {
                      "anyOf": [
                        {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Duration in seconds."
                    },
                    "created_at": {
                      "type": "string",
                      "description": "When the row was created."
                    },
                    "updated_at": {
                      "type": "string",
                      "description": "Last change."
                    }
                  },
                  "required": [
                    "id",
                    "connection_id",
                    "contact_id",
                    "conversation_id",
                    "external_id",
                    "direction",
                    "status",
                    "end_reason",
                    "has_sdp",
                    "biz_opaque_callback_data",
                    "errors",
                    "offered_at",
                    "answered_at",
                    "start_time",
                    "end_time",
                    "duration_s",
                    "created_at",
                    "updated_at"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ]
      }
    },
    "/calls/{id}": {
      "get": {
        "operationId": "getCall",
        "summary": "Get call",
        "description": "One call from the log, without the SDP. Permission: `read`.",
        "tags": [
          "calls"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Call ID (`cal_…`)."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The call.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Call ID (`cal_…`).",
                      "examples": [
                        "cal_0193a1b2c3d47e8f"
                      ]
                    },
                    "connection_id": {
                      "type": "string",
                      "description": "ID of the call's connection (number). Optional with a connection key (uses the key's connection)."
                    },
                    "contact_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "The call's contact, when known."
                    },
                    "conversation_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "The call's conversation, if any."
                    },
                    "external_id": {
                      "type": "string",
                      "description": "Call ID at Meta (`wacid.…`)."
                    },
                    "direction": {
                      "enum": [
                        "user_initiated",
                        "business_initiated"
                      ],
                      "type": "string",
                      "description": "`user_initiated` (the user called) or `business_initiated` (the number called)."
                    },
                    "status": {
                      "enum": [
                        "offered",
                        "pre_accepted",
                        "dialing",
                        "ringing",
                        "accepted",
                        "terminating",
                        "ended",
                        "rejected"
                      ],
                      "type": "string",
                      "description": "Call state."
                    },
                    "end_reason": {
                      "anyOf": [
                        {
                          "enum": [
                            "completed",
                            "failed",
                            "rejected",
                            "missed",
                            "canceled",
                            "unknown"
                          ],
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Why it ended, once ended."
                    },
                    "has_sdp": {
                      "type": "boolean",
                      "description": "`true` while the SDP is stored (deleted 1 h after the end)."
                    },
                    "biz_opaque_callback_data": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Your own text that Meta returns in this call's webhooks."
                    },
                    "errors": {
                      "anyOf": [
                        {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "propertyNames": {
                              "type": "string"
                            },
                            "additionalProperties": {}
                          }
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Errors Meta reported for the call."
                    },
                    "offered_at": {
                      "type": "string",
                      "description": "When the call started ringing."
                    },
                    "answered_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "When it was answered."
                    },
                    "start_time": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Conversation start, per Meta."
                    },
                    "end_time": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Call end."
                    },
                    "duration_s": {
                      "anyOf": [
                        {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Duration in seconds."
                    },
                    "created_at": {
                      "type": "string",
                      "description": "When the row was created."
                    },
                    "updated_at": {
                      "type": "string",
                      "description": "Last change."
                    }
                  },
                  "required": [
                    "id",
                    "connection_id",
                    "contact_id",
                    "conversation_id",
                    "external_id",
                    "direction",
                    "status",
                    "end_reason",
                    "has_sdp",
                    "biz_opaque_callback_data",
                    "errors",
                    "offered_at",
                    "answered_at",
                    "start_time",
                    "end_time",
                    "duration_s",
                    "created_at",
                    "updated_at"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/calls/{id}/pre-accept": {
      "post": {
        "operationId": "preAcceptCall",
        "summary": "Pre-accept call",
        "description": "Sends the answer SDP before picking up, so media connects faster. The following `accept` must use the same SDP. Only while the call is `offered`. Permission: `send`.",
        "tags": [
          "calls"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Call ID (`cal_…`)."
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "sdp": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 65536,
                    "description": "SDP as text (up to 64 KiB, starts with `v=0`). Required for `pre-accept` and `accept`."
                  },
                  "biz_opaque_callback_data": {
                    "type": "string",
                    "maxLength": 512,
                    "description": "Your own text that Meta returns in this call's webhooks."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The call in `pre_accepted`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Call ID (`cal_…`).",
                      "examples": [
                        "cal_0193a1b2c3d47e8f"
                      ]
                    },
                    "connection_id": {
                      "type": "string",
                      "description": "ID of the call's connection (number). Optional with a connection key (uses the key's connection)."
                    },
                    "contact_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "The call's contact, when known."
                    },
                    "conversation_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "The call's conversation, if any."
                    },
                    "external_id": {
                      "type": "string",
                      "description": "Call ID at Meta (`wacid.…`)."
                    },
                    "direction": {
                      "enum": [
                        "user_initiated",
                        "business_initiated"
                      ],
                      "type": "string",
                      "description": "`user_initiated` (the user called) or `business_initiated` (the number called)."
                    },
                    "status": {
                      "enum": [
                        "offered",
                        "pre_accepted",
                        "dialing",
                        "ringing",
                        "accepted",
                        "terminating",
                        "ended",
                        "rejected"
                      ],
                      "type": "string",
                      "description": "Call state."
                    },
                    "end_reason": {
                      "anyOf": [
                        {
                          "enum": [
                            "completed",
                            "failed",
                            "rejected",
                            "missed",
                            "canceled",
                            "unknown"
                          ],
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Why it ended, once ended."
                    },
                    "has_sdp": {
                      "type": "boolean",
                      "description": "`true` while the SDP is stored (deleted 1 h after the end)."
                    },
                    "biz_opaque_callback_data": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Your own text that Meta returns in this call's webhooks."
                    },
                    "errors": {
                      "anyOf": [
                        {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "propertyNames": {
                              "type": "string"
                            },
                            "additionalProperties": {}
                          }
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Errors Meta reported for the call."
                    },
                    "offered_at": {
                      "type": "string",
                      "description": "When the call started ringing."
                    },
                    "answered_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "When it was answered."
                    },
                    "start_time": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Conversation start, per Meta."
                    },
                    "end_time": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Call end."
                    },
                    "duration_s": {
                      "anyOf": [
                        {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Duration in seconds."
                    },
                    "created_at": {
                      "type": "string",
                      "description": "When the row was created."
                    },
                    "updated_at": {
                      "type": "string",
                      "description": "Last change."
                    }
                  },
                  "required": [
                    "id",
                    "connection_id",
                    "contact_id",
                    "conversation_id",
                    "external_id",
                    "direction",
                    "status",
                    "end_reason",
                    "has_sdp",
                    "biz_opaque_callback_data",
                    "errors",
                    "offered_at",
                    "answered_at",
                    "start_time",
                    "end_time",
                    "duration_s",
                    "created_at",
                    "updated_at"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/calls/{id}/accept": {
      "post": {
        "operationId": "acceptCall",
        "summary": "Accept call",
        "description": "Answers the call with the answer SDP (the same one from `pre-accept`, if any; otherwise `409 call_sdp_mismatch`). Audio flows between Meta and your WebRTC/SIP client, never through Messajo. Permission: `send`.",
        "tags": [
          "calls"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Call ID (`cal_…`)."
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "sdp": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 65536,
                    "description": "SDP as text (up to 64 KiB, starts with `v=0`). Required for `pre-accept` and `accept`."
                  },
                  "biz_opaque_callback_data": {
                    "type": "string",
                    "maxLength": 512,
                    "description": "Your own text that Meta returns in this call's webhooks."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The call in `accepted`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Call ID (`cal_…`).",
                      "examples": [
                        "cal_0193a1b2c3d47e8f"
                      ]
                    },
                    "connection_id": {
                      "type": "string",
                      "description": "ID of the call's connection (number). Optional with a connection key (uses the key's connection)."
                    },
                    "contact_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "The call's contact, when known."
                    },
                    "conversation_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "The call's conversation, if any."
                    },
                    "external_id": {
                      "type": "string",
                      "description": "Call ID at Meta (`wacid.…`)."
                    },
                    "direction": {
                      "enum": [
                        "user_initiated",
                        "business_initiated"
                      ],
                      "type": "string",
                      "description": "`user_initiated` (the user called) or `business_initiated` (the number called)."
                    },
                    "status": {
                      "enum": [
                        "offered",
                        "pre_accepted",
                        "dialing",
                        "ringing",
                        "accepted",
                        "terminating",
                        "ended",
                        "rejected"
                      ],
                      "type": "string",
                      "description": "Call state."
                    },
                    "end_reason": {
                      "anyOf": [
                        {
                          "enum": [
                            "completed",
                            "failed",
                            "rejected",
                            "missed",
                            "canceled",
                            "unknown"
                          ],
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Why it ended, once ended."
                    },
                    "has_sdp": {
                      "type": "boolean",
                      "description": "`true` while the SDP is stored (deleted 1 h after the end)."
                    },
                    "biz_opaque_callback_data": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Your own text that Meta returns in this call's webhooks."
                    },
                    "errors": {
                      "anyOf": [
                        {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "propertyNames": {
                              "type": "string"
                            },
                            "additionalProperties": {}
                          }
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Errors Meta reported for the call."
                    },
                    "offered_at": {
                      "type": "string",
                      "description": "When the call started ringing."
                    },
                    "answered_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "When it was answered."
                    },
                    "start_time": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Conversation start, per Meta."
                    },
                    "end_time": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Call end."
                    },
                    "duration_s": {
                      "anyOf": [
                        {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Duration in seconds."
                    },
                    "created_at": {
                      "type": "string",
                      "description": "When the row was created."
                    },
                    "updated_at": {
                      "type": "string",
                      "description": "Last change."
                    }
                  },
                  "required": [
                    "id",
                    "connection_id",
                    "contact_id",
                    "conversation_id",
                    "external_id",
                    "direction",
                    "status",
                    "end_reason",
                    "has_sdp",
                    "biz_opaque_callback_data",
                    "errors",
                    "offered_at",
                    "answered_at",
                    "start_time",
                    "end_time",
                    "duration_s",
                    "created_at",
                    "updated_at"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/calls/{id}/reject": {
      "post": {
        "operationId": "rejectCall",
        "summary": "Reject call",
        "description": "Rejects an incoming call that has not been answered. Permission: `send`.",
        "tags": [
          "calls"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Call ID (`cal_…`)."
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "sdp": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 65536,
                    "description": "SDP as text (up to 64 KiB, starts with `v=0`). Required for `pre-accept` and `accept`."
                  },
                  "biz_opaque_callback_data": {
                    "type": "string",
                    "maxLength": 512,
                    "description": "Your own text that Meta returns in this call's webhooks."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The call in `rejected`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Call ID (`cal_…`).",
                      "examples": [
                        "cal_0193a1b2c3d47e8f"
                      ]
                    },
                    "connection_id": {
                      "type": "string",
                      "description": "ID of the call's connection (number). Optional with a connection key (uses the key's connection)."
                    },
                    "contact_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "The call's contact, when known."
                    },
                    "conversation_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "The call's conversation, if any."
                    },
                    "external_id": {
                      "type": "string",
                      "description": "Call ID at Meta (`wacid.…`)."
                    },
                    "direction": {
                      "enum": [
                        "user_initiated",
                        "business_initiated"
                      ],
                      "type": "string",
                      "description": "`user_initiated` (the user called) or `business_initiated` (the number called)."
                    },
                    "status": {
                      "enum": [
                        "offered",
                        "pre_accepted",
                        "dialing",
                        "ringing",
                        "accepted",
                        "terminating",
                        "ended",
                        "rejected"
                      ],
                      "type": "string",
                      "description": "Call state."
                    },
                    "end_reason": {
                      "anyOf": [
                        {
                          "enum": [
                            "completed",
                            "failed",
                            "rejected",
                            "missed",
                            "canceled",
                            "unknown"
                          ],
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Why it ended, once ended."
                    },
                    "has_sdp": {
                      "type": "boolean",
                      "description": "`true` while the SDP is stored (deleted 1 h after the end)."
                    },
                    "biz_opaque_callback_data": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Your own text that Meta returns in this call's webhooks."
                    },
                    "errors": {
                      "anyOf": [
                        {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "propertyNames": {
                              "type": "string"
                            },
                            "additionalProperties": {}
                          }
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Errors Meta reported for the call."
                    },
                    "offered_at": {
                      "type": "string",
                      "description": "When the call started ringing."
                    },
                    "answered_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "When it was answered."
                    },
                    "start_time": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Conversation start, per Meta."
                    },
                    "end_time": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Call end."
                    },
                    "duration_s": {
                      "anyOf": [
                        {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Duration in seconds."
                    },
                    "created_at": {
                      "type": "string",
                      "description": "When the row was created."
                    },
                    "updated_at": {
                      "type": "string",
                      "description": "Last change."
                    }
                  },
                  "required": [
                    "id",
                    "connection_id",
                    "contact_id",
                    "conversation_id",
                    "external_id",
                    "direction",
                    "status",
                    "end_reason",
                    "has_sdp",
                    "biz_opaque_callback_data",
                    "errors",
                    "offered_at",
                    "answered_at",
                    "start_time",
                    "end_time",
                    "duration_s",
                    "created_at",
                    "updated_at"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/calls/{id}/terminate": {
      "post": {
        "operationId": "terminateCall",
        "summary": "Terminate call",
        "description": "Hangs up an answered or ongoing call. `call.ended` arrives from Meta's webhook, with the duration. Permission: `send`.",
        "tags": [
          "calls"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Call ID (`cal_…`)."
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "sdp": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 65536,
                    "description": "SDP as text (up to 64 KiB, starts with `v=0`). Required for `pre-accept` and `accept`."
                  },
                  "biz_opaque_callback_data": {
                    "type": "string",
                    "maxLength": 512,
                    "description": "Your own text that Meta returns in this call's webhooks."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The call in `terminating`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Call ID (`cal_…`).",
                      "examples": [
                        "cal_0193a1b2c3d47e8f"
                      ]
                    },
                    "connection_id": {
                      "type": "string",
                      "description": "ID of the call's connection (number). Optional with a connection key (uses the key's connection)."
                    },
                    "contact_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "The call's contact, when known."
                    },
                    "conversation_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "The call's conversation, if any."
                    },
                    "external_id": {
                      "type": "string",
                      "description": "Call ID at Meta (`wacid.…`)."
                    },
                    "direction": {
                      "enum": [
                        "user_initiated",
                        "business_initiated"
                      ],
                      "type": "string",
                      "description": "`user_initiated` (the user called) or `business_initiated` (the number called)."
                    },
                    "status": {
                      "enum": [
                        "offered",
                        "pre_accepted",
                        "dialing",
                        "ringing",
                        "accepted",
                        "terminating",
                        "ended",
                        "rejected"
                      ],
                      "type": "string",
                      "description": "Call state."
                    },
                    "end_reason": {
                      "anyOf": [
                        {
                          "enum": [
                            "completed",
                            "failed",
                            "rejected",
                            "missed",
                            "canceled",
                            "unknown"
                          ],
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Why it ended, once ended."
                    },
                    "has_sdp": {
                      "type": "boolean",
                      "description": "`true` while the SDP is stored (deleted 1 h after the end)."
                    },
                    "biz_opaque_callback_data": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Your own text that Meta returns in this call's webhooks."
                    },
                    "errors": {
                      "anyOf": [
                        {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "propertyNames": {
                              "type": "string"
                            },
                            "additionalProperties": {}
                          }
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Errors Meta reported for the call."
                    },
                    "offered_at": {
                      "type": "string",
                      "description": "When the call started ringing."
                    },
                    "answered_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "When it was answered."
                    },
                    "start_time": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Conversation start, per Meta."
                    },
                    "end_time": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Call end."
                    },
                    "duration_s": {
                      "anyOf": [
                        {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Duration in seconds."
                    },
                    "created_at": {
                      "type": "string",
                      "description": "When the row was created."
                    },
                    "updated_at": {
                      "type": "string",
                      "description": "Last change."
                    }
                  },
                  "required": [
                    "id",
                    "connection_id",
                    "contact_id",
                    "conversation_id",
                    "external_id",
                    "direction",
                    "status",
                    "end_reason",
                    "has_sdp",
                    "biz_opaque_callback_data",
                    "errors",
                    "offered_at",
                    "answered_at",
                    "start_time",
                    "end_time",
                    "duration_s",
                    "created_at",
                    "updated_at"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/connections/{id}/call-permissions": {
      "get": {
        "operationId": "getCallPermission",
        "summary": "Get call permission",
        "description": "Asks Meta whether the number can call the user now and which actions are allowed, with their limits. Updates the local cache. Permission: `read`.",
        "tags": [
          "calls"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "ID of the call's connection (number). Optional with a connection key (uses the key's connection)."
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "The user's phone (digits only, with country code) or BSUID."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          }
        ],
        "responses": {
          "200": {
            "description": "Permission status and available actions.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "enum": [
                        "no_permission",
                        "temporary",
                        "permanent",
                        "rejected"
                      ],
                      "type": "string",
                      "description": "User permission: `no_permission`, `temporary`, `permanent` or `rejected`."
                    },
                    "expires_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "When the temporary permission expires."
                    },
                    "actions": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "action_name": {
                            "type": "string",
                            "description": "Action name at Meta (e.g. `start_call`, `send_call_permission_request`)."
                          },
                          "can_perform_action": {
                            "type": "boolean",
                            "description": "Whether the action can be done now."
                          },
                          "limits": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "propertyNames": {
                                "type": "string"
                              },
                              "additionalProperties": {}
                            },
                            "description": "Meta's limits for the action, as received."
                          }
                        },
                        "required": [
                          "action_name",
                          "can_perform_action",
                          "limits"
                        ]
                      },
                      "description": "Permission actions and whether they can be done now."
                    }
                  },
                  "required": [
                    "status",
                    "expires_at",
                    "actions"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/connections/{id}/calling-settings": {
      "get": {
        "operationId": "getCallingSettings",
        "summary": "Get calling settings",
        "description": "The `calling` block of the number settings: status, icon, callback, business hours and SIP. `include_sip_credentials=true` returns the SIP password once and requires `admin`; it is never stored. Permission: `read`.",
        "tags": [
          "calls"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "ID of the call's connection (number). Optional with a connection key (uses the key's connection)."
            }
          },
          {
            "name": "include_sip_credentials",
            "in": "query",
            "schema": {
              "enum": [
                "true",
                "false"
              ],
              "type": "string",
              "description": "`true` returns the SIP password (requires `admin`)."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          }
        ],
        "responses": {
          "200": {
            "description": "The calling settings.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "enum": [
                        "ENABLED",
                        "DISABLED"
                      ],
                      "type": "string",
                      "description": "Calling API enabled (`ENABLED`) or disabled (`DISABLED`) on the number."
                    },
                    "call_icon_visibility": {
                      "enum": [
                        "DEFAULT",
                        "DISABLE_ALL"
                      ],
                      "type": "string",
                      "description": "Show (`DEFAULT`) or hide (`DISABLE_ALL`) the call icon in the user's WhatsApp."
                    },
                    "callback_permission_status": {
                      "enum": [
                        "ENABLED",
                        "DISABLED"
                      ],
                      "type": "string",
                      "description": "Automatically ask for callback permission when the user calls."
                    },
                    "call_hours": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "status": {
                              "enum": [
                                "ENABLED",
                                "DISABLED"
                              ],
                              "type": "string"
                            },
                            "timezone_id": {
                              "type": "string",
                              "minLength": 1
                            },
                            "weekly_operating_hours": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "day_of_week": {
                                    "enum": [
                                      "MONDAY",
                                      "TUESDAY",
                                      "WEDNESDAY",
                                      "THURSDAY",
                                      "FRIDAY",
                                      "SATURDAY",
                                      "SUNDAY"
                                    ],
                                    "type": "string"
                                  },
                                  "open_time": {
                                    "type": "string",
                                    "pattern": "^([01]\\d|2[0-3])[0-5]\\d$"
                                  },
                                  "close_time": {
                                    "type": "string",
                                    "pattern": "^([01]\\d|2[0-3])[0-5]\\d$"
                                  }
                                },
                                "required": [
                                  "day_of_week",
                                  "open_time",
                                  "close_time"
                                ]
                              }
                            },
                            "holiday_schedule": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "date": {
                                    "type": "string",
                                    "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
                                  },
                                  "start_time": {
                                    "type": "string",
                                    "pattern": "^([01]\\d|2[0-3])[0-5]\\d$"
                                  },
                                  "end_time": {
                                    "type": "string",
                                    "pattern": "^([01]\\d|2[0-3])[0-5]\\d$"
                                  }
                                },
                                "required": [
                                  "date",
                                  "start_time",
                                  "end_time"
                                ]
                              }
                            }
                          },
                          "required": [
                            "status",
                            "timezone_id",
                            "weekly_operating_hours",
                            "holiday_schedule"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Business hours (week and holidays); `null` = none."
                    },
                    "sip": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "status": {
                              "enum": [
                                "ENABLED",
                                "DISABLED"
                              ],
                              "type": "string"
                            },
                            "servers": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "hostname": {
                                    "type": "string",
                                    "minLength": 1,
                                    "maxLength": 253
                                  },
                                  "port": {
                                    "type": "integer",
                                    "minimum": 1,
                                    "maximum": 65535
                                  },
                                  "request_uri_user_params": {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {
                                      "type": "string"
                                    }
                                  },
                                  "sip_user_password": {
                                    "type": "string",
                                    "description": "The server's SIP password; only with `include_sip_credentials=true`, once."
                                  }
                                },
                                "required": [
                                  "hostname",
                                  "port"
                                ]
                              }
                            }
                          },
                          "required": [
                            "status",
                            "servers"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "SIP configuration; `null` = no SIP."
                    }
                  },
                  "required": [
                    "status",
                    "call_icon_visibility",
                    "callback_permission_status",
                    "call_hours",
                    "sip"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "put": {
        "operationId": "updateCallingSettings",
        "summary": "Update calling settings",
        "description": "Partial update of the `calling` block (enable the Calling API, hours, icon, callback and SIP servers). The SIP hostname cannot be a private IP. Audited. Permission: `admin`.",
        "tags": [
          "calls"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "ID of the call's connection (number). Optional with a connection key (uses the key's connection)."
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "status": {
                    "enum": [
                      "ENABLED",
                      "DISABLED"
                    ],
                    "type": "string",
                    "description": "Calling API enabled (`ENABLED`) or disabled (`DISABLED`) on the number."
                  },
                  "call_icon_visibility": {
                    "enum": [
                      "DEFAULT",
                      "DISABLE_ALL"
                    ],
                    "type": "string",
                    "description": "Show (`DEFAULT`) or hide (`DISABLE_ALL`) the call icon in the user's WhatsApp."
                  },
                  "callback_permission_status": {
                    "enum": [
                      "ENABLED",
                      "DISABLED"
                    ],
                    "type": "string",
                    "description": "Automatically ask for callback permission when the user calls."
                  },
                  "call_hours": {
                    "anyOf": [
                      {
                        "type": "object",
                        "properties": {
                          "status": {
                            "enum": [
                              "ENABLED",
                              "DISABLED"
                            ],
                            "type": "string"
                          },
                          "timezone_id": {
                            "type": "string",
                            "minLength": 1
                          },
                          "weekly_operating_hours": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "day_of_week": {
                                  "enum": [
                                    "MONDAY",
                                    "TUESDAY",
                                    "WEDNESDAY",
                                    "THURSDAY",
                                    "FRIDAY",
                                    "SATURDAY",
                                    "SUNDAY"
                                  ],
                                  "type": "string"
                                },
                                "open_time": {
                                  "type": "string",
                                  "pattern": "^([01]\\d|2[0-3])[0-5]\\d$"
                                },
                                "close_time": {
                                  "type": "string",
                                  "pattern": "^([01]\\d|2[0-3])[0-5]\\d$"
                                }
                              },
                              "required": [
                                "day_of_week",
                                "open_time",
                                "close_time"
                              ]
                            }
                          },
                          "holiday_schedule": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "date": {
                                  "type": "string",
                                  "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
                                },
                                "start_time": {
                                  "type": "string",
                                  "pattern": "^([01]\\d|2[0-3])[0-5]\\d$"
                                },
                                "end_time": {
                                  "type": "string",
                                  "pattern": "^([01]\\d|2[0-3])[0-5]\\d$"
                                }
                              },
                              "required": [
                                "date",
                                "start_time",
                                "end_time"
                              ]
                            }
                          }
                        },
                        "required": [
                          "status",
                          "timezone_id",
                          "weekly_operating_hours",
                          "holiday_schedule"
                        ]
                      },
                      {
                        "type": "null"
                      }
                    ],
                    "description": "Business hours (week and holidays); `null` = none."
                  },
                  "sip": {
                    "anyOf": [
                      {
                        "type": "object",
                        "properties": {
                          "status": {
                            "enum": [
                              "ENABLED",
                              "DISABLED"
                            ],
                            "type": "string"
                          },
                          "servers": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "hostname": {
                                  "type": "string",
                                  "minLength": 1,
                                  "maxLength": 253
                                },
                                "port": {
                                  "type": "integer",
                                  "minimum": 1,
                                  "maximum": 65535
                                },
                                "request_uri_user_params": {
                                  "type": "object",
                                  "propertyNames": {
                                    "type": "string"
                                  },
                                  "additionalProperties": {
                                    "type": "string"
                                  }
                                }
                              },
                              "required": [
                                "hostname",
                                "port"
                              ]
                            }
                          }
                        },
                        "required": [
                          "status",
                          "servers"
                        ]
                      },
                      {
                        "type": "null"
                      }
                    ],
                    "description": "SIP configuration; `null` = no SIP."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The settings after the change.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "enum": [
                        "ENABLED",
                        "DISABLED"
                      ],
                      "type": "string",
                      "description": "Calling API enabled (`ENABLED`) or disabled (`DISABLED`) on the number."
                    },
                    "call_icon_visibility": {
                      "enum": [
                        "DEFAULT",
                        "DISABLE_ALL"
                      ],
                      "type": "string",
                      "description": "Show (`DEFAULT`) or hide (`DISABLE_ALL`) the call icon in the user's WhatsApp."
                    },
                    "callback_permission_status": {
                      "enum": [
                        "ENABLED",
                        "DISABLED"
                      ],
                      "type": "string",
                      "description": "Automatically ask for callback permission when the user calls."
                    },
                    "call_hours": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "status": {
                              "enum": [
                                "ENABLED",
                                "DISABLED"
                              ],
                              "type": "string"
                            },
                            "timezone_id": {
                              "type": "string",
                              "minLength": 1
                            },
                            "weekly_operating_hours": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "day_of_week": {
                                    "enum": [
                                      "MONDAY",
                                      "TUESDAY",
                                      "WEDNESDAY",
                                      "THURSDAY",
                                      "FRIDAY",
                                      "SATURDAY",
                                      "SUNDAY"
                                    ],
                                    "type": "string"
                                  },
                                  "open_time": {
                                    "type": "string",
                                    "pattern": "^([01]\\d|2[0-3])[0-5]\\d$"
                                  },
                                  "close_time": {
                                    "type": "string",
                                    "pattern": "^([01]\\d|2[0-3])[0-5]\\d$"
                                  }
                                },
                                "required": [
                                  "day_of_week",
                                  "open_time",
                                  "close_time"
                                ]
                              }
                            },
                            "holiday_schedule": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "date": {
                                    "type": "string",
                                    "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
                                  },
                                  "start_time": {
                                    "type": "string",
                                    "pattern": "^([01]\\d|2[0-3])[0-5]\\d$"
                                  },
                                  "end_time": {
                                    "type": "string",
                                    "pattern": "^([01]\\d|2[0-3])[0-5]\\d$"
                                  }
                                },
                                "required": [
                                  "date",
                                  "start_time",
                                  "end_time"
                                ]
                              }
                            }
                          },
                          "required": [
                            "status",
                            "timezone_id",
                            "weekly_operating_hours",
                            "holiday_schedule"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Business hours (week and holidays); `null` = none."
                    },
                    "sip": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "status": {
                              "enum": [
                                "ENABLED",
                                "DISABLED"
                              ],
                              "type": "string"
                            },
                            "servers": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "hostname": {
                                    "type": "string",
                                    "minLength": 1,
                                    "maxLength": 253
                                  },
                                  "port": {
                                    "type": "integer",
                                    "minimum": 1,
                                    "maximum": 65535
                                  },
                                  "request_uri_user_params": {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {
                                      "type": "string"
                                    }
                                  },
                                  "sip_user_password": {
                                    "type": "string",
                                    "description": "The server's SIP password; only with `include_sip_credentials=true`, once."
                                  }
                                },
                                "required": [
                                  "hostname",
                                  "port"
                                ]
                              }
                            }
                          },
                          "required": [
                            "status",
                            "servers"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "SIP configuration; `null` = no SIP."
                    }
                  },
                  "required": [
                    "status",
                    "call_icon_visibility",
                    "callback_permission_status",
                    "call_hours",
                    "sip"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/groups": {
      "post": {
        "operationId": "createGroup",
        "summary": "Create group",
        "description": "Creates a group on the number. Meta confirms by webhook: the group starts as `creating` and becomes `active` (`group.created` event) or `failed` (`group.create_failed`). Coexistence numbers → `422 group_not_supported`. Permission: `send`.",
        "tags": [
          "groups"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "connection_id": {
                    "type": "string",
                    "minLength": 1,
                    "description": "ID of the connection (number) that owns the group. Optional with a connection key (uses the key's connection)."
                  },
                  "subject": {
                    "type": "string",
                    "minLength": 1,
                    "description": "Group subject (up to 128 characters)."
                  },
                  "description": {
                    "type": "string",
                    "description": "Group description (up to 2048 characters)."
                  },
                  "join_approval_mode": {
                    "enum": [
                      "auto_approve",
                      "approval_required"
                    ],
                    "type": "string",
                    "description": "`auto_approve` (join straight from the link) or `approval_required` (join request)."
                  }
                },
                "required": [
                  "subject"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The group, in `creating`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Group ID (`grp_…`); use it as `to` in `POST /messages` to message the group.",
                      "examples": [
                        "grp_0193a1b2c3d47e8f"
                      ]
                    },
                    "connection_id": {
                      "type": "string",
                      "description": "ID of the connection (number) that owns the group. Optional with a connection key (uses the key's connection)."
                    },
                    "external_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Group ID at Meta; `null` until confirmed."
                    },
                    "subject": {
                      "type": "string",
                      "description": "Group subject (up to 128 characters)."
                    },
                    "description": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Group description (up to 2048 characters)."
                    },
                    "join_approval_mode": {
                      "enum": [
                        "auto_approve",
                        "approval_required"
                      ],
                      "type": "string",
                      "description": "`auto_approve` (join straight from the link) or `approval_required` (join request)."
                    },
                    "status": {
                      "enum": [
                        "creating",
                        "active",
                        "suspended",
                        "deleting",
                        "deleted",
                        "failed"
                      ],
                      "type": "string",
                      "description": "Group state."
                    },
                    "participant_count": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "Total participants."
                    },
                    "participants": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "wa_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "The participant's WhatsApp phone."
                          },
                          "user_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "The participant's BSUID."
                          },
                          "username": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "The participant's username, if any."
                          },
                          "joined_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "When they joined (or asked to join)."
                          }
                        },
                        "required": [
                          "wa_id",
                          "user_id",
                          "username",
                          "joined_at"
                        ]
                      },
                      "description": "Participants (up to 8)."
                    },
                    "pending_join_requests": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "Pending join requests."
                    },
                    "failure": {
                      "anyOf": [
                        {
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {}
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Meta's error when creation failed."
                    },
                    "created_at": {
                      "type": "string",
                      "description": "When the group was created."
                    },
                    "updated_at": {
                      "type": "string",
                      "description": "Last change."
                    }
                  },
                  "required": [
                    "id",
                    "connection_id",
                    "external_id",
                    "subject",
                    "description",
                    "join_approval_mode",
                    "status",
                    "participant_count",
                    "participants",
                    "pending_join_requests",
                    "failure",
                    "created_at",
                    "updated_at"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ]
      },
      "get": {
        "operationId": "listGroups",
        "summary": "List groups",
        "description": "The organization's groups, newest first. Permission: `read`.",
        "tags": [
          "groups"
        ],
        "parameters": [
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "Next page cursor: the `next_cursor` of the previous response."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50,
              "description": "Items per page, from 1 to 100 (default 50)."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "connection_id",
            "in": "query",
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "ID of the connection (number) that owns the group. Optional with a connection key (uses the key's connection)."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "enum": [
                "creating",
                "active",
                "suspended",
                "deleting",
                "deleted",
                "failed"
              ],
              "type": "string",
              "description": "Group state."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          }
        ],
        "responses": {
          "200": {
            "description": "A page of groups.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "description": "Group ID (`grp_…`); use it as `to` in `POST /messages` to message the group.",
                            "examples": [
                              "grp_0193a1b2c3d47e8f"
                            ]
                          },
                          "connection_id": {
                            "type": "string",
                            "description": "ID of the connection (number) that owns the group. Optional with a connection key (uses the key's connection)."
                          },
                          "external_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Group ID at Meta; `null` until confirmed."
                          },
                          "subject": {
                            "type": "string",
                            "description": "Group subject (up to 128 characters)."
                          },
                          "description": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Group description (up to 2048 characters)."
                          },
                          "join_approval_mode": {
                            "enum": [
                              "auto_approve",
                              "approval_required"
                            ],
                            "type": "string",
                            "description": "`auto_approve` (join straight from the link) or `approval_required` (join request)."
                          },
                          "status": {
                            "enum": [
                              "creating",
                              "active",
                              "suspended",
                              "deleting",
                              "deleted",
                              "failed"
                            ],
                            "type": "string",
                            "description": "Group state."
                          },
                          "participant_count": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991,
                            "description": "Total participants."
                          },
                          "participants": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "wa_id": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ],
                                  "description": "The participant's WhatsApp phone."
                                },
                                "user_id": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ],
                                  "description": "The participant's BSUID."
                                },
                                "username": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ],
                                  "description": "The participant's username, if any."
                                },
                                "joined_at": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ],
                                  "description": "When they joined (or asked to join)."
                                }
                              },
                              "required": [
                                "wa_id",
                                "user_id",
                                "username",
                                "joined_at"
                              ]
                            },
                            "description": "Participants (up to 8)."
                          },
                          "pending_join_requests": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991,
                            "description": "Pending join requests."
                          },
                          "failure": {
                            "anyOf": [
                              {
                                "type": "object",
                                "propertyNames": {
                                  "type": "string"
                                },
                                "additionalProperties": {}
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Meta's error when creation failed."
                          },
                          "created_at": {
                            "type": "string",
                            "description": "When the group was created."
                          },
                          "updated_at": {
                            "type": "string",
                            "description": "Last change."
                          }
                        },
                        "required": [
                          "id",
                          "connection_id",
                          "external_id",
                          "subject",
                          "description",
                          "join_approval_mode",
                          "status",
                          "participant_count",
                          "participants",
                          "pending_join_requests",
                          "failure",
                          "created_at",
                          "updated_at"
                        ]
                      },
                      "description": "Page items, newest first."
                    },
                    "next_cursor": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Cursor for the next page; `null` when there are no more items."
                    }
                  },
                  "required": [
                    "data",
                    "next_cursor"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/groups/{id}": {
      "get": {
        "operationId": "getGroup",
        "summary": "Get group",
        "description": "One group with subject, description, participants and pending requests. Permission: `read`.",
        "tags": [
          "groups"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Group ID (`grp_…`); use it as `to` in `POST /messages` to message the group."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The group.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Group ID (`grp_…`); use it as `to` in `POST /messages` to message the group.",
                      "examples": [
                        "grp_0193a1b2c3d47e8f"
                      ]
                    },
                    "connection_id": {
                      "type": "string",
                      "description": "ID of the connection (number) that owns the group. Optional with a connection key (uses the key's connection)."
                    },
                    "external_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Group ID at Meta; `null` until confirmed."
                    },
                    "subject": {
                      "type": "string",
                      "description": "Group subject (up to 128 characters)."
                    },
                    "description": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Group description (up to 2048 characters)."
                    },
                    "join_approval_mode": {
                      "enum": [
                        "auto_approve",
                        "approval_required"
                      ],
                      "type": "string",
                      "description": "`auto_approve` (join straight from the link) or `approval_required` (join request)."
                    },
                    "status": {
                      "enum": [
                        "creating",
                        "active",
                        "suspended",
                        "deleting",
                        "deleted",
                        "failed"
                      ],
                      "type": "string",
                      "description": "Group state."
                    },
                    "participant_count": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "Total participants."
                    },
                    "participants": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "wa_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "The participant's WhatsApp phone."
                          },
                          "user_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "The participant's BSUID."
                          },
                          "username": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "The participant's username, if any."
                          },
                          "joined_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "When they joined (or asked to join)."
                          }
                        },
                        "required": [
                          "wa_id",
                          "user_id",
                          "username",
                          "joined_at"
                        ]
                      },
                      "description": "Participants (up to 8)."
                    },
                    "pending_join_requests": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "Pending join requests."
                    },
                    "failure": {
                      "anyOf": [
                        {
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {}
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Meta's error when creation failed."
                    },
                    "created_at": {
                      "type": "string",
                      "description": "When the group was created."
                    },
                    "updated_at": {
                      "type": "string",
                      "description": "Last change."
                    }
                  },
                  "required": [
                    "id",
                    "connection_id",
                    "external_id",
                    "subject",
                    "description",
                    "join_approval_mode",
                    "status",
                    "participant_count",
                    "participants",
                    "pending_join_requests",
                    "failure",
                    "created_at",
                    "updated_at"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "patch": {
        "operationId": "updateGroup",
        "summary": "Update group",
        "description": "Changes subject, description or picture (multipart, `picture` field: square JPEG of at least 192 px, up to 5 MiB). Only while the group is `active`. Permission: `send`.",
        "tags": [
          "groups"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Group ID (`grp_…`); use it as `to` in `POST /messages` to message the group."
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "subject": {
                    "type": "string",
                    "minLength": 1,
                    "description": "Group subject (up to 128 characters)."
                  },
                  "description": {
                    "type": "string",
                    "description": "Group description (up to 2048 characters)."
                  },
                  "picture": {
                    "type": "string",
                    "contentMediaType": "*/*",
                    "description": "Group picture (square JPEG, ≥ 192 px, ≤ 5 MiB)."
                  }
                }
              }
            },
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "subject": {
                    "type": "string",
                    "minLength": 1,
                    "description": "Group subject (up to 128 characters)."
                  },
                  "description": {
                    "type": "string",
                    "description": "Group description (up to 2048 characters)."
                  },
                  "picture": {
                    "type": "string",
                    "contentMediaType": "*/*",
                    "description": "Group picture (square JPEG, ≥ 192 px, ≤ 5 MiB)."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The group.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Group ID (`grp_…`); use it as `to` in `POST /messages` to message the group.",
                      "examples": [
                        "grp_0193a1b2c3d47e8f"
                      ]
                    },
                    "connection_id": {
                      "type": "string",
                      "description": "ID of the connection (number) that owns the group. Optional with a connection key (uses the key's connection)."
                    },
                    "external_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Group ID at Meta; `null` until confirmed."
                    },
                    "subject": {
                      "type": "string",
                      "description": "Group subject (up to 128 characters)."
                    },
                    "description": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Group description (up to 2048 characters)."
                    },
                    "join_approval_mode": {
                      "enum": [
                        "auto_approve",
                        "approval_required"
                      ],
                      "type": "string",
                      "description": "`auto_approve` (join straight from the link) or `approval_required` (join request)."
                    },
                    "status": {
                      "enum": [
                        "creating",
                        "active",
                        "suspended",
                        "deleting",
                        "deleted",
                        "failed"
                      ],
                      "type": "string",
                      "description": "Group state."
                    },
                    "participant_count": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "Total participants."
                    },
                    "participants": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "wa_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "The participant's WhatsApp phone."
                          },
                          "user_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "The participant's BSUID."
                          },
                          "username": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "The participant's username, if any."
                          },
                          "joined_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "When they joined (or asked to join)."
                          }
                        },
                        "required": [
                          "wa_id",
                          "user_id",
                          "username",
                          "joined_at"
                        ]
                      },
                      "description": "Participants (up to 8)."
                    },
                    "pending_join_requests": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "Pending join requests."
                    },
                    "failure": {
                      "anyOf": [
                        {
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {}
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Meta's error when creation failed."
                    },
                    "created_at": {
                      "type": "string",
                      "description": "When the group was created."
                    },
                    "updated_at": {
                      "type": "string",
                      "description": "Last change."
                    }
                  },
                  "required": [
                    "id",
                    "connection_id",
                    "external_id",
                    "subject",
                    "description",
                    "join_approval_mode",
                    "status",
                    "participant_count",
                    "participants",
                    "pending_join_requests",
                    "failure",
                    "created_at",
                    "updated_at"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "operationId": "deleteGroup",
        "summary": "Delete group",
        "description": "Deletes the group at Meta and removes every participant. Audited. Permission: `admin`.",
        "tags": [
          "groups"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Group ID (`grp_…`); use it as `to` in `POST /messages` to message the group."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The group, in `deleted`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Group ID (`grp_…`); use it as `to` in `POST /messages` to message the group.",
                      "examples": [
                        "grp_0193a1b2c3d47e8f"
                      ]
                    },
                    "connection_id": {
                      "type": "string",
                      "description": "ID of the connection (number) that owns the group. Optional with a connection key (uses the key's connection)."
                    },
                    "external_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Group ID at Meta; `null` until confirmed."
                    },
                    "subject": {
                      "type": "string",
                      "description": "Group subject (up to 128 characters)."
                    },
                    "description": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Group description (up to 2048 characters)."
                    },
                    "join_approval_mode": {
                      "enum": [
                        "auto_approve",
                        "approval_required"
                      ],
                      "type": "string",
                      "description": "`auto_approve` (join straight from the link) or `approval_required` (join request)."
                    },
                    "status": {
                      "enum": [
                        "creating",
                        "active",
                        "suspended",
                        "deleting",
                        "deleted",
                        "failed"
                      ],
                      "type": "string",
                      "description": "Group state."
                    },
                    "participant_count": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "Total participants."
                    },
                    "participants": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "wa_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "The participant's WhatsApp phone."
                          },
                          "user_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "The participant's BSUID."
                          },
                          "username": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "The participant's username, if any."
                          },
                          "joined_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "When they joined (or asked to join)."
                          }
                        },
                        "required": [
                          "wa_id",
                          "user_id",
                          "username",
                          "joined_at"
                        ]
                      },
                      "description": "Participants (up to 8)."
                    },
                    "pending_join_requests": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "Pending join requests."
                    },
                    "failure": {
                      "anyOf": [
                        {
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {}
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Meta's error when creation failed."
                    },
                    "created_at": {
                      "type": "string",
                      "description": "When the group was created."
                    },
                    "updated_at": {
                      "type": "string",
                      "description": "Last change."
                    }
                  },
                  "required": [
                    "id",
                    "connection_id",
                    "external_id",
                    "subject",
                    "description",
                    "join_approval_mode",
                    "status",
                    "participant_count",
                    "participants",
                    "pending_join_requests",
                    "failure",
                    "created_at",
                    "updated_at"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/groups/{id}/invite-link": {
      "get": {
        "operationId": "getGroupInviteLink",
        "summary": "Get invite link",
        "description": "The group's current invite link. Permission: `read`.",
        "tags": [
          "groups"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Group ID (`grp_…`); use it as `to` in `POST /messages` to message the group."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The invite link.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "invite_link": {
                      "type": "string",
                      "description": "The group's invite link."
                    }
                  },
                  "required": [
                    "invite_link"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/groups/{id}/invite-link/reset": {
      "post": {
        "operationId": "resetGroupInviteLink",
        "summary": "Reset invite link",
        "description": "Creates a new link; the previous one stops working. Permission: `send`.",
        "tags": [
          "groups"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Group ID (`grp_…`); use it as `to` in `POST /messages` to message the group."
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "description": "The new link.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "invite_link": {
                      "type": "string",
                      "description": "The group's invite link."
                    }
                  },
                  "required": [
                    "invite_link"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/groups/{id}/participants/remove": {
      "post": {
        "operationId": "removeGroupParticipants",
        "summary": "Remove participants",
        "description": "Removes up to 8 participants per call, by `wa_id` or `user_id`. Audited. Permission: `send`.",
        "tags": [
          "groups"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Group ID (`grp_…`); use it as `to` in `POST /messages` to message the group."
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "participants": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 8,
                    "items": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "wa_id": {
                              "type": "string",
                              "minLength": 1,
                              "description": "The participant's WhatsApp phone."
                            }
                          },
                          "required": [
                            "wa_id"
                          ]
                        },
                        {
                          "type": "object",
                          "properties": {
                            "user_id": {
                              "type": "string",
                              "minLength": 1,
                              "description": "The participant's BSUID."
                            }
                          },
                          "required": [
                            "user_id"
                          ]
                        }
                      ]
                    },
                    "description": "Participants to remove: `{ wa_id }` or `{ user_id }` (up to 8)."
                  }
                },
                "required": [
                  "participants"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "How many were removed.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Group ID (`grp_…`); use it as `to` in `POST /messages` to message the group."
                    },
                    "removed": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "How many participants were removed."
                    }
                  },
                  "required": [
                    "id",
                    "removed"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/groups/{id}/join-requests": {
      "get": {
        "operationId": "listGroupJoinRequests",
        "summary": "List join requests",
        "description": "Pending requests from people who want to join (groups with approval). Permission: `read`.",
        "tags": [
          "groups"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Group ID (`grp_…`); use it as `to` in `POST /messages` to message the group."
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "Next page cursor: the `next_cursor` of the previous response."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          }
        ],
        "responses": {
          "200": {
            "description": "A page of requests.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "wa_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "The participant's WhatsApp phone."
                          },
                          "user_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "The participant's BSUID."
                          },
                          "username": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "The participant's username, if any."
                          },
                          "joined_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "When they joined (or asked to join)."
                          },
                          "id": {
                            "type": "string",
                            "description": "Join request ID."
                          }
                        },
                        "required": [
                          "wa_id",
                          "user_id",
                          "username",
                          "joined_at",
                          "id"
                        ]
                      },
                      "description": "Page items, newest first."
                    },
                    "next_cursor": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Cursor for the next page; `null` when there are no more items."
                    }
                  },
                  "required": [
                    "data",
                    "next_cursor"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/groups/{id}/join-requests/approve": {
      "post": {
        "operationId": "approveGroupJoinRequests",
        "summary": "Approve join requests",
        "description": "Approves join requests; Meta decides each one and those that did not work come back in `failed`. Permission: `send`.",
        "tags": [
          "groups"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Group ID (`grp_…`); use it as `to` in `POST /messages` to message the group."
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "join_request_ids": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 100,
                    "items": {
                      "type": "string",
                      "minLength": 1
                    },
                    "description": "Join request IDs."
                  }
                },
                "required": [
                  "join_request_ids"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Approved requests and the failed ones.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "approved": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      },
                      "description": "Approved requests."
                    },
                    "failed": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "description": "Join request ID."
                          },
                          "reason": {
                            "type": "string",
                            "description": "Why it failed."
                          }
                        },
                        "required": [
                          "id",
                          "reason"
                        ]
                      },
                      "description": "Requests Meta did not accept, with the reason."
                    }
                  },
                  "required": [
                    "approved",
                    "failed"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/groups/{id}/join-requests/reject": {
      "post": {
        "operationId": "rejectGroupJoinRequests",
        "summary": "Reject join requests",
        "description": "Rejects join requests; those that did not work come back in `failed`. Permission: `send`.",
        "tags": [
          "groups"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Group ID (`grp_…`); use it as `to` in `POST /messages` to message the group."
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "join_request_ids": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 100,
                    "items": {
                      "type": "string",
                      "minLength": 1
                    },
                    "description": "Join request IDs."
                  }
                },
                "required": [
                  "join_request_ids"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Rejected requests and the failed ones.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "rejected": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      },
                      "description": "Rejected requests."
                    },
                    "failed": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "description": "Join request ID."
                          },
                          "reason": {
                            "type": "string",
                            "description": "Why it failed."
                          }
                        },
                        "required": [
                          "id",
                          "reason"
                        ]
                      },
                      "description": "Requests Meta did not accept, with the reason."
                    }
                  },
                  "required": [
                    "rejected",
                    "failed"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/flows": {
      "get": {
        "operationId": "listFlows",
        "summary": "List Flows",
        "description": "Flows of the organization's messaging accounts (WABA), newest first, filtered by connection and status. Keys restricted to connections must pass `connection_id`. Permission: `read`.",
        "tags": [
          "flows"
        ],
        "parameters": [
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "Next page cursor: the `next_cursor` of the previous response."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50,
              "description": "Items per page, from 1 to 100 (default 50)."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "connection_id",
            "in": "query",
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "WhatsApp connection ID. Optional with a connection key (uses the key's connection)."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "enum": [
                "DRAFT",
                "PUBLISHED",
                "DEPRECATED",
                "BLOCKED",
                "THROTTLED"
              ],
              "type": "string",
              "description": "`DRAFT`, `PUBLISHED`, `DEPRECATED`, `BLOCKED` or `THROTTLED`."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          }
        ],
        "responses": {
          "200": {
            "description": "Page of Flows.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "description": "Flow ID (`flw_…`).",
                            "examples": [
                              "flw_0193a1b2c3d47e8f"
                            ]
                          },
                          "connection_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "WhatsApp connection ID. Optional with a connection key (uses the key's connection)."
                          },
                          "messaging_account_id": {
                            "type": "string",
                            "description": "Messaging account (WABA) ID on Meta."
                          },
                          "external_id": {
                            "type": "string",
                            "description": "Flow ID on Meta."
                          },
                          "name": {
                            "type": "string",
                            "description": "Flow name (unique in the account)."
                          },
                          "categories": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            },
                            "description": "Meta categories (`SIGN_UP`, `APPOINTMENT_BOOKING`, `LEAD_GENERATION`…)."
                          },
                          "status": {
                            "enum": [
                              "DRAFT",
                              "PUBLISHED",
                              "DEPRECATED",
                              "BLOCKED",
                              "THROTTLED"
                            ],
                            "type": "string",
                            "description": "`DRAFT`, `PUBLISHED`, `DEPRECATED`, `BLOCKED` or `THROTTLED`."
                          },
                          "json_version": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "`version` of the Flow JSON."
                          },
                          "data_api_version": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "`data_api_version` of the JSON (Flows with an endpoint)."
                          },
                          "validation_errors": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "error": {
                                  "type": "string"
                                },
                                "error_type": {
                                  "type": "string"
                                },
                                "message": {
                                  "type": "string"
                                },
                                "line_start": {
                                  "anyOf": [
                                    {
                                      "type": "integer",
                                      "minimum": -9007199254740991,
                                      "maximum": 9007199254740991
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "line_end": {
                                  "anyOf": [
                                    {
                                      "type": "integer",
                                      "minimum": -9007199254740991,
                                      "maximum": 9007199254740991
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "column_start": {
                                  "anyOf": [
                                    {
                                      "type": "integer",
                                      "minimum": -9007199254740991,
                                      "maximum": 9007199254740991
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "column_end": {
                                  "anyOf": [
                                    {
                                      "type": "integer",
                                      "minimum": -9007199254740991,
                                      "maximum": 9007199254740991
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                }
                              },
                              "required": [
                                "error",
                                "error_type",
                                "message",
                                "line_start",
                                "line_end",
                                "column_start",
                                "column_end"
                              ]
                            },
                            "description": "Meta's validation errors, with line and column."
                          },
                          "endpoint_mode": {
                            "enum": [
                              "none",
                              "messajo"
                            ],
                            "type": "string",
                            "description": "`none` (no endpoint) or `messajo` (Messajo's data exchange endpoint)."
                          },
                          "handler": {
                            "anyOf": [
                              {
                                "type": "object",
                                "properties": {
                                  "url_preview": {
                                    "type": "string",
                                    "description": "Origin of the handler URL."
                                  },
                                  "secret_last4": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ],
                                    "description": "Last 4 characters of the handler secret."
                                  }
                                },
                                "required": [
                                  "url_preview",
                                  "secret_last4"
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Customer handler, without the full URL or headers."
                          },
                          "health_status": {
                            "anyOf": [
                              {
                                "type": "object",
                                "propertyNames": {
                                  "type": "string"
                                },
                                "additionalProperties": {}
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Endpoint health according to Meta (and alerts from the `flows` webhook)."
                          },
                          "preview": {
                            "anyOf": [
                              {
                                "type": "object",
                                "properties": {
                                  "url": {
                                    "type": "string",
                                    "description": "Meta's preview link."
                                  },
                                  "expires_at": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ],
                                    "description": "When the preview link expires."
                                  }
                                },
                                "required": [
                                  "url",
                                  "expires_at"
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Last generated preview."
                          },
                          "last_synced_at": {
                            "type": "string",
                            "description": "Last read from Meta."
                          },
                          "created_at": {
                            "type": "string",
                            "description": "When it was created."
                          },
                          "updated_at": {
                            "type": "string",
                            "description": "Last change."
                          }
                        },
                        "required": [
                          "id",
                          "connection_id",
                          "messaging_account_id",
                          "external_id",
                          "name",
                          "categories",
                          "status",
                          "json_version",
                          "data_api_version",
                          "validation_errors",
                          "endpoint_mode",
                          "handler",
                          "health_status",
                          "preview",
                          "last_synced_at",
                          "created_at",
                          "updated_at"
                        ]
                      },
                      "description": "Page items, newest first."
                    },
                    "next_cursor": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Cursor for the next page; `null` when there are no more items."
                    }
                  },
                  "required": [
                    "data",
                    "next_cursor"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "createFlow",
        "summary": "Create Flow",
        "description": "Creates the Flow on Meta as `DRAFT`. With `endpoint`, turns on Messajo's data exchange endpoint: Meta calls `/meta/flows/{id}`, Messajo decrypts it and forwards the signed request to your handler. The `handler_secret` (`Messajo-Signature`) is shown only in this response. With `flow_json`, the JSON is uploaded too; Meta's errors come back in `validation_errors`. Permission: `templates`.",
        "tags": [
          "flows"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "connection_id": {
                    "type": "string",
                    "minLength": 1,
                    "description": "WhatsApp connection ID. Optional with a connection key (uses the key's connection)."
                  },
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200,
                    "description": "Flow name (unique in the account)."
                  },
                  "categories": {
                    "type": "array",
                    "minItems": 1,
                    "items": {
                      "enum": [
                        "SIGN_UP",
                        "SIGN_IN",
                        "APPOINTMENT_BOOKING",
                        "LEAD_GENERATION",
                        "CONTACT_US",
                        "CUSTOMER_SUPPORT",
                        "SURVEY",
                        "OTHER"
                      ],
                      "type": "string"
                    },
                    "description": "Meta categories (`SIGN_UP`, `APPOINTMENT_BOOKING`, `LEAD_GENERATION`…)."
                  },
                  "flow_json": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {},
                    "description": "The `flow.json` (object with `version` and `screens`)."
                  },
                  "endpoint": {
                    "type": "object",
                    "properties": {
                      "url": {
                        "type": "string",
                        "minLength": 1,
                        "description": "Handler URL (public `https`)."
                      },
                      "headers": {
                        "type": "array",
                        "maxItems": 20,
                        "items": {
                          "type": "object",
                          "properties": {
                            "name": {
                              "type": "string",
                              "minLength": 1,
                              "description": "Header name."
                            },
                            "value": {
                              "type": "string",
                              "description": "Header value."
                            }
                          },
                          "required": [
                            "name",
                            "value"
                          ]
                        },
                        "description": "Extra headers sent to the handler (up to 20)."
                      }
                    },
                    "required": [
                      "url"
                    ],
                    "description": "Customer handler: turns on Messajo's data exchange endpoint."
                  }
                },
                "required": [
                  "name",
                  "categories"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The created Flow, with the handler secret once.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Flow ID (`flw_…`).",
                      "examples": [
                        "flw_0193a1b2c3d47e8f"
                      ]
                    },
                    "connection_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "WhatsApp connection ID. Optional with a connection key (uses the key's connection)."
                    },
                    "messaging_account_id": {
                      "type": "string",
                      "description": "Messaging account (WABA) ID on Meta."
                    },
                    "external_id": {
                      "type": "string",
                      "description": "Flow ID on Meta."
                    },
                    "name": {
                      "type": "string",
                      "description": "Flow name (unique in the account)."
                    },
                    "categories": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      },
                      "description": "Meta categories (`SIGN_UP`, `APPOINTMENT_BOOKING`, `LEAD_GENERATION`…)."
                    },
                    "status": {
                      "enum": [
                        "DRAFT",
                        "PUBLISHED",
                        "DEPRECATED",
                        "BLOCKED",
                        "THROTTLED"
                      ],
                      "type": "string",
                      "description": "`DRAFT`, `PUBLISHED`, `DEPRECATED`, `BLOCKED` or `THROTTLED`."
                    },
                    "json_version": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "`version` of the Flow JSON."
                    },
                    "data_api_version": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "`data_api_version` of the JSON (Flows with an endpoint)."
                    },
                    "validation_errors": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "error": {
                            "type": "string"
                          },
                          "error_type": {
                            "type": "string"
                          },
                          "message": {
                            "type": "string"
                          },
                          "line_start": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "line_end": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "column_start": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "column_end": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        },
                        "required": [
                          "error",
                          "error_type",
                          "message",
                          "line_start",
                          "line_end",
                          "column_start",
                          "column_end"
                        ]
                      },
                      "description": "Meta's validation errors, with line and column."
                    },
                    "endpoint_mode": {
                      "enum": [
                        "none",
                        "messajo"
                      ],
                      "type": "string",
                      "description": "`none` (no endpoint) or `messajo` (Messajo's data exchange endpoint)."
                    },
                    "handler": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "url_preview": {
                              "type": "string",
                              "description": "Origin of the handler URL."
                            },
                            "secret_last4": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Last 4 characters of the handler secret."
                            }
                          },
                          "required": [
                            "url_preview",
                            "secret_last4"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Customer handler, without the full URL or headers."
                    },
                    "health_status": {
                      "anyOf": [
                        {
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {}
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Endpoint health according to Meta (and alerts from the `flows` webhook)."
                    },
                    "preview": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "url": {
                              "type": "string",
                              "description": "Meta's preview link."
                            },
                            "expires_at": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "When the preview link expires."
                            }
                          },
                          "required": [
                            "url",
                            "expires_at"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Last generated preview."
                    },
                    "last_synced_at": {
                      "type": "string",
                      "description": "Last read from Meta."
                    },
                    "created_at": {
                      "type": "string",
                      "description": "When it was created."
                    },
                    "updated_at": {
                      "type": "string",
                      "description": "Last change."
                    },
                    "handler_secret": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Handler secret (`Messajo-Signature`): shown only when generated."
                    }
                  },
                  "required": [
                    "id",
                    "connection_id",
                    "messaging_account_id",
                    "external_id",
                    "name",
                    "categories",
                    "status",
                    "json_version",
                    "data_api_version",
                    "validation_errors",
                    "endpoint_mode",
                    "handler",
                    "health_status",
                    "preview",
                    "last_synced_at",
                    "created_at",
                    "updated_at",
                    "handler_secret"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ]
      }
    },
    "/flows/{id}": {
      "get": {
        "operationId": "getFlow",
        "summary": "Get Flow",
        "description": "One Flow, without the full handler URL or headers (only the origin and the secret's last 4 characters). Permission: `read`.",
        "tags": [
          "flows"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Flow ID (`flw_…`)."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The Flow.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Flow ID (`flw_…`).",
                      "examples": [
                        "flw_0193a1b2c3d47e8f"
                      ]
                    },
                    "connection_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "WhatsApp connection ID. Optional with a connection key (uses the key's connection)."
                    },
                    "messaging_account_id": {
                      "type": "string",
                      "description": "Messaging account (WABA) ID on Meta."
                    },
                    "external_id": {
                      "type": "string",
                      "description": "Flow ID on Meta."
                    },
                    "name": {
                      "type": "string",
                      "description": "Flow name (unique in the account)."
                    },
                    "categories": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      },
                      "description": "Meta categories (`SIGN_UP`, `APPOINTMENT_BOOKING`, `LEAD_GENERATION`…)."
                    },
                    "status": {
                      "enum": [
                        "DRAFT",
                        "PUBLISHED",
                        "DEPRECATED",
                        "BLOCKED",
                        "THROTTLED"
                      ],
                      "type": "string",
                      "description": "`DRAFT`, `PUBLISHED`, `DEPRECATED`, `BLOCKED` or `THROTTLED`."
                    },
                    "json_version": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "`version` of the Flow JSON."
                    },
                    "data_api_version": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "`data_api_version` of the JSON (Flows with an endpoint)."
                    },
                    "validation_errors": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "error": {
                            "type": "string"
                          },
                          "error_type": {
                            "type": "string"
                          },
                          "message": {
                            "type": "string"
                          },
                          "line_start": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "line_end": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "column_start": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "column_end": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        },
                        "required": [
                          "error",
                          "error_type",
                          "message",
                          "line_start",
                          "line_end",
                          "column_start",
                          "column_end"
                        ]
                      },
                      "description": "Meta's validation errors, with line and column."
                    },
                    "endpoint_mode": {
                      "enum": [
                        "none",
                        "messajo"
                      ],
                      "type": "string",
                      "description": "`none` (no endpoint) or `messajo` (Messajo's data exchange endpoint)."
                    },
                    "handler": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "url_preview": {
                              "type": "string",
                              "description": "Origin of the handler URL."
                            },
                            "secret_last4": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Last 4 characters of the handler secret."
                            }
                          },
                          "required": [
                            "url_preview",
                            "secret_last4"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Customer handler, without the full URL or headers."
                    },
                    "health_status": {
                      "anyOf": [
                        {
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {}
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Endpoint health according to Meta (and alerts from the `flows` webhook)."
                    },
                    "preview": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "url": {
                              "type": "string",
                              "description": "Meta's preview link."
                            },
                            "expires_at": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "When the preview link expires."
                            }
                          },
                          "required": [
                            "url",
                            "expires_at"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Last generated preview."
                    },
                    "last_synced_at": {
                      "type": "string",
                      "description": "Last read from Meta."
                    },
                    "created_at": {
                      "type": "string",
                      "description": "When it was created."
                    },
                    "updated_at": {
                      "type": "string",
                      "description": "Last change."
                    }
                  },
                  "required": [
                    "id",
                    "connection_id",
                    "messaging_account_id",
                    "external_id",
                    "name",
                    "categories",
                    "status",
                    "json_version",
                    "data_api_version",
                    "validation_errors",
                    "endpoint_mode",
                    "handler",
                    "health_status",
                    "preview",
                    "last_synced_at",
                    "created_at",
                    "updated_at"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "patch": {
        "operationId": "updateFlow",
        "summary": "Update Flow",
        "description": "Changes the name, categories or handler (`endpoint`; `null` turns Messajo's endpoint off). `handler_secret` is only filled when a new secret was generated. Permission: `templates`.",
        "tags": [
          "flows"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Flow ID (`flw_…`)."
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200,
                    "description": "Flow name (unique in the account)."
                  },
                  "categories": {
                    "type": "array",
                    "minItems": 1,
                    "items": {
                      "enum": [
                        "SIGN_UP",
                        "SIGN_IN",
                        "APPOINTMENT_BOOKING",
                        "LEAD_GENERATION",
                        "CONTACT_US",
                        "CUSTOMER_SUPPORT",
                        "SURVEY",
                        "OTHER"
                      ],
                      "type": "string"
                    },
                    "description": "Meta categories (`SIGN_UP`, `APPOINTMENT_BOOKING`, `LEAD_GENERATION`…)."
                  },
                  "endpoint": {
                    "anyOf": [
                      {
                        "type": "object",
                        "properties": {
                          "url": {
                            "type": "string",
                            "minLength": 1,
                            "description": "Handler URL (public `https`)."
                          },
                          "headers": {
                            "type": "array",
                            "maxItems": 20,
                            "items": {
                              "type": "object",
                              "properties": {
                                "name": {
                                  "type": "string",
                                  "minLength": 1,
                                  "description": "Header name."
                                },
                                "value": {
                                  "type": "string",
                                  "description": "Header value."
                                }
                              },
                              "required": [
                                "name",
                                "value"
                              ]
                            },
                            "description": "Extra headers sent to the handler (up to 20)."
                          }
                        },
                        "required": [
                          "url"
                        ],
                        "description": "Customer handler: turns on Messajo's data exchange endpoint."
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The updated Flow.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Flow ID (`flw_…`).",
                      "examples": [
                        "flw_0193a1b2c3d47e8f"
                      ]
                    },
                    "connection_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "WhatsApp connection ID. Optional with a connection key (uses the key's connection)."
                    },
                    "messaging_account_id": {
                      "type": "string",
                      "description": "Messaging account (WABA) ID on Meta."
                    },
                    "external_id": {
                      "type": "string",
                      "description": "Flow ID on Meta."
                    },
                    "name": {
                      "type": "string",
                      "description": "Flow name (unique in the account)."
                    },
                    "categories": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      },
                      "description": "Meta categories (`SIGN_UP`, `APPOINTMENT_BOOKING`, `LEAD_GENERATION`…)."
                    },
                    "status": {
                      "enum": [
                        "DRAFT",
                        "PUBLISHED",
                        "DEPRECATED",
                        "BLOCKED",
                        "THROTTLED"
                      ],
                      "type": "string",
                      "description": "`DRAFT`, `PUBLISHED`, `DEPRECATED`, `BLOCKED` or `THROTTLED`."
                    },
                    "json_version": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "`version` of the Flow JSON."
                    },
                    "data_api_version": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "`data_api_version` of the JSON (Flows with an endpoint)."
                    },
                    "validation_errors": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "error": {
                            "type": "string"
                          },
                          "error_type": {
                            "type": "string"
                          },
                          "message": {
                            "type": "string"
                          },
                          "line_start": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "line_end": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "column_start": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "column_end": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        },
                        "required": [
                          "error",
                          "error_type",
                          "message",
                          "line_start",
                          "line_end",
                          "column_start",
                          "column_end"
                        ]
                      },
                      "description": "Meta's validation errors, with line and column."
                    },
                    "endpoint_mode": {
                      "enum": [
                        "none",
                        "messajo"
                      ],
                      "type": "string",
                      "description": "`none` (no endpoint) or `messajo` (Messajo's data exchange endpoint)."
                    },
                    "handler": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "url_preview": {
                              "type": "string",
                              "description": "Origin of the handler URL."
                            },
                            "secret_last4": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Last 4 characters of the handler secret."
                            }
                          },
                          "required": [
                            "url_preview",
                            "secret_last4"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Customer handler, without the full URL or headers."
                    },
                    "health_status": {
                      "anyOf": [
                        {
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {}
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Endpoint health according to Meta (and alerts from the `flows` webhook)."
                    },
                    "preview": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "url": {
                              "type": "string",
                              "description": "Meta's preview link."
                            },
                            "expires_at": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "When the preview link expires."
                            }
                          },
                          "required": [
                            "url",
                            "expires_at"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Last generated preview."
                    },
                    "last_synced_at": {
                      "type": "string",
                      "description": "Last read from Meta."
                    },
                    "created_at": {
                      "type": "string",
                      "description": "When it was created."
                    },
                    "updated_at": {
                      "type": "string",
                      "description": "Last change."
                    },
                    "handler_secret": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Handler secret (`Messajo-Signature`): shown only when generated."
                    }
                  },
                  "required": [
                    "id",
                    "connection_id",
                    "messaging_account_id",
                    "external_id",
                    "name",
                    "categories",
                    "status",
                    "json_version",
                    "data_api_version",
                    "validation_errors",
                    "endpoint_mode",
                    "handler",
                    "health_status",
                    "preview",
                    "last_synced_at",
                    "created_at",
                    "updated_at",
                    "handler_secret"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "operationId": "deleteFlow",
        "summary": "Delete Flow",
        "description": "Deletes a `DRAFT` Flow (Meta does not delete published ones: use `deprecate`). Permission: `templates`.",
        "tags": [
          "flows"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Flow ID (`flw_…`)."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Confirmation.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Flow ID (`flw_…`)."
                    },
                    "deleted": {
                      "const": true,
                      "description": "Always `true`."
                    }
                  },
                  "required": [
                    "id",
                    "deleted"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/flows/{id}/json": {
      "put": {
        "operationId": "uploadFlowJson",
        "summary": "Upload Flow JSON",
        "description": "The body is the raw `flow.json` (up to 10 MiB). `DRAFT` only (otherwise `409 flow_not_editable`; published → `clone`). Meta's errors come back as `422 flow_invalid_json` with line and column in `details`. Permission: `templates`.",
        "tags": [
          "flows"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Flow ID (`flw_…`)."
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "propertyNames": {
                  "type": "string"
                },
                "additionalProperties": {},
                "description": "The `flow.json` (object with `version` and `screens`)."
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The Flow with the new JSON.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Flow ID (`flw_…`).",
                      "examples": [
                        "flw_0193a1b2c3d47e8f"
                      ]
                    },
                    "connection_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "WhatsApp connection ID. Optional with a connection key (uses the key's connection)."
                    },
                    "messaging_account_id": {
                      "type": "string",
                      "description": "Messaging account (WABA) ID on Meta."
                    },
                    "external_id": {
                      "type": "string",
                      "description": "Flow ID on Meta."
                    },
                    "name": {
                      "type": "string",
                      "description": "Flow name (unique in the account)."
                    },
                    "categories": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      },
                      "description": "Meta categories (`SIGN_UP`, `APPOINTMENT_BOOKING`, `LEAD_GENERATION`…)."
                    },
                    "status": {
                      "enum": [
                        "DRAFT",
                        "PUBLISHED",
                        "DEPRECATED",
                        "BLOCKED",
                        "THROTTLED"
                      ],
                      "type": "string",
                      "description": "`DRAFT`, `PUBLISHED`, `DEPRECATED`, `BLOCKED` or `THROTTLED`."
                    },
                    "json_version": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "`version` of the Flow JSON."
                    },
                    "data_api_version": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "`data_api_version` of the JSON (Flows with an endpoint)."
                    },
                    "validation_errors": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "error": {
                            "type": "string"
                          },
                          "error_type": {
                            "type": "string"
                          },
                          "message": {
                            "type": "string"
                          },
                          "line_start": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "line_end": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "column_start": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "column_end": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        },
                        "required": [
                          "error",
                          "error_type",
                          "message",
                          "line_start",
                          "line_end",
                          "column_start",
                          "column_end"
                        ]
                      },
                      "description": "Meta's validation errors, with line and column."
                    },
                    "endpoint_mode": {
                      "enum": [
                        "none",
                        "messajo"
                      ],
                      "type": "string",
                      "description": "`none` (no endpoint) or `messajo` (Messajo's data exchange endpoint)."
                    },
                    "handler": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "url_preview": {
                              "type": "string",
                              "description": "Origin of the handler URL."
                            },
                            "secret_last4": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Last 4 characters of the handler secret."
                            }
                          },
                          "required": [
                            "url_preview",
                            "secret_last4"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Customer handler, without the full URL or headers."
                    },
                    "health_status": {
                      "anyOf": [
                        {
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {}
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Endpoint health according to Meta (and alerts from the `flows` webhook)."
                    },
                    "preview": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "url": {
                              "type": "string",
                              "description": "Meta's preview link."
                            },
                            "expires_at": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "When the preview link expires."
                            }
                          },
                          "required": [
                            "url",
                            "expires_at"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Last generated preview."
                    },
                    "last_synced_at": {
                      "type": "string",
                      "description": "Last read from Meta."
                    },
                    "created_at": {
                      "type": "string",
                      "description": "When it was created."
                    },
                    "updated_at": {
                      "type": "string",
                      "description": "Last change."
                    }
                  },
                  "required": [
                    "id",
                    "connection_id",
                    "messaging_account_id",
                    "external_id",
                    "name",
                    "categories",
                    "status",
                    "json_version",
                    "data_api_version",
                    "validation_errors",
                    "endpoint_mode",
                    "handler",
                    "health_status",
                    "preview",
                    "last_synced_at",
                    "created_at",
                    "updated_at"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/flows/{id}/publish": {
      "post": {
        "operationId": "publishFlow",
        "summary": "Publish Flow",
        "description": "Publishes the Flow. With Messajo's endpoint, it needs a handler and the account key uploaded to an active number (`409 flow_key_not_uploaded`); Meta pings the endpoint. Permission: `templates`.",
        "tags": [
          "flows"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Flow ID (`flw_…`)."
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "description": "The published Flow.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Flow ID (`flw_…`).",
                      "examples": [
                        "flw_0193a1b2c3d47e8f"
                      ]
                    },
                    "connection_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "WhatsApp connection ID. Optional with a connection key (uses the key's connection)."
                    },
                    "messaging_account_id": {
                      "type": "string",
                      "description": "Messaging account (WABA) ID on Meta."
                    },
                    "external_id": {
                      "type": "string",
                      "description": "Flow ID on Meta."
                    },
                    "name": {
                      "type": "string",
                      "description": "Flow name (unique in the account)."
                    },
                    "categories": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      },
                      "description": "Meta categories (`SIGN_UP`, `APPOINTMENT_BOOKING`, `LEAD_GENERATION`…)."
                    },
                    "status": {
                      "enum": [
                        "DRAFT",
                        "PUBLISHED",
                        "DEPRECATED",
                        "BLOCKED",
                        "THROTTLED"
                      ],
                      "type": "string",
                      "description": "`DRAFT`, `PUBLISHED`, `DEPRECATED`, `BLOCKED` or `THROTTLED`."
                    },
                    "json_version": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "`version` of the Flow JSON."
                    },
                    "data_api_version": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "`data_api_version` of the JSON (Flows with an endpoint)."
                    },
                    "validation_errors": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "error": {
                            "type": "string"
                          },
                          "error_type": {
                            "type": "string"
                          },
                          "message": {
                            "type": "string"
                          },
                          "line_start": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "line_end": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "column_start": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "column_end": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        },
                        "required": [
                          "error",
                          "error_type",
                          "message",
                          "line_start",
                          "line_end",
                          "column_start",
                          "column_end"
                        ]
                      },
                      "description": "Meta's validation errors, with line and column."
                    },
                    "endpoint_mode": {
                      "enum": [
                        "none",
                        "messajo"
                      ],
                      "type": "string",
                      "description": "`none` (no endpoint) or `messajo` (Messajo's data exchange endpoint)."
                    },
                    "handler": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "url_preview": {
                              "type": "string",
                              "description": "Origin of the handler URL."
                            },
                            "secret_last4": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Last 4 characters of the handler secret."
                            }
                          },
                          "required": [
                            "url_preview",
                            "secret_last4"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Customer handler, without the full URL or headers."
                    },
                    "health_status": {
                      "anyOf": [
                        {
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {}
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Endpoint health according to Meta (and alerts from the `flows` webhook)."
                    },
                    "preview": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "url": {
                              "type": "string",
                              "description": "Meta's preview link."
                            },
                            "expires_at": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "When the preview link expires."
                            }
                          },
                          "required": [
                            "url",
                            "expires_at"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Last generated preview."
                    },
                    "last_synced_at": {
                      "type": "string",
                      "description": "Last read from Meta."
                    },
                    "created_at": {
                      "type": "string",
                      "description": "When it was created."
                    },
                    "updated_at": {
                      "type": "string",
                      "description": "Last change."
                    }
                  },
                  "required": [
                    "id",
                    "connection_id",
                    "messaging_account_id",
                    "external_id",
                    "name",
                    "categories",
                    "status",
                    "json_version",
                    "data_api_version",
                    "validation_errors",
                    "endpoint_mode",
                    "handler",
                    "health_status",
                    "preview",
                    "last_synced_at",
                    "created_at",
                    "updated_at"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/flows/{id}/deprecate": {
      "post": {
        "operationId": "deprecateFlow",
        "summary": "Deprecate Flow",
        "description": "Stops a published Flow from being sent. Permission: `templates`.",
        "tags": [
          "flows"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Flow ID (`flw_…`)."
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "description": "The deprecated Flow.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Flow ID (`flw_…`).",
                      "examples": [
                        "flw_0193a1b2c3d47e8f"
                      ]
                    },
                    "connection_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "WhatsApp connection ID. Optional with a connection key (uses the key's connection)."
                    },
                    "messaging_account_id": {
                      "type": "string",
                      "description": "Messaging account (WABA) ID on Meta."
                    },
                    "external_id": {
                      "type": "string",
                      "description": "Flow ID on Meta."
                    },
                    "name": {
                      "type": "string",
                      "description": "Flow name (unique in the account)."
                    },
                    "categories": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      },
                      "description": "Meta categories (`SIGN_UP`, `APPOINTMENT_BOOKING`, `LEAD_GENERATION`…)."
                    },
                    "status": {
                      "enum": [
                        "DRAFT",
                        "PUBLISHED",
                        "DEPRECATED",
                        "BLOCKED",
                        "THROTTLED"
                      ],
                      "type": "string",
                      "description": "`DRAFT`, `PUBLISHED`, `DEPRECATED`, `BLOCKED` or `THROTTLED`."
                    },
                    "json_version": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "`version` of the Flow JSON."
                    },
                    "data_api_version": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "`data_api_version` of the JSON (Flows with an endpoint)."
                    },
                    "validation_errors": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "error": {
                            "type": "string"
                          },
                          "error_type": {
                            "type": "string"
                          },
                          "message": {
                            "type": "string"
                          },
                          "line_start": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "line_end": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "column_start": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "column_end": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        },
                        "required": [
                          "error",
                          "error_type",
                          "message",
                          "line_start",
                          "line_end",
                          "column_start",
                          "column_end"
                        ]
                      },
                      "description": "Meta's validation errors, with line and column."
                    },
                    "endpoint_mode": {
                      "enum": [
                        "none",
                        "messajo"
                      ],
                      "type": "string",
                      "description": "`none` (no endpoint) or `messajo` (Messajo's data exchange endpoint)."
                    },
                    "handler": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "url_preview": {
                              "type": "string",
                              "description": "Origin of the handler URL."
                            },
                            "secret_last4": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Last 4 characters of the handler secret."
                            }
                          },
                          "required": [
                            "url_preview",
                            "secret_last4"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Customer handler, without the full URL or headers."
                    },
                    "health_status": {
                      "anyOf": [
                        {
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {}
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Endpoint health according to Meta (and alerts from the `flows` webhook)."
                    },
                    "preview": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "url": {
                              "type": "string",
                              "description": "Meta's preview link."
                            },
                            "expires_at": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "When the preview link expires."
                            }
                          },
                          "required": [
                            "url",
                            "expires_at"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Last generated preview."
                    },
                    "last_synced_at": {
                      "type": "string",
                      "description": "Last read from Meta."
                    },
                    "created_at": {
                      "type": "string",
                      "description": "When it was created."
                    },
                    "updated_at": {
                      "type": "string",
                      "description": "Last change."
                    }
                  },
                  "required": [
                    "id",
                    "connection_id",
                    "messaging_account_id",
                    "external_id",
                    "name",
                    "categories",
                    "status",
                    "json_version",
                    "data_api_version",
                    "validation_errors",
                    "endpoint_mode",
                    "handler",
                    "health_status",
                    "preview",
                    "last_synced_at",
                    "created_at",
                    "updated_at"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/flows/{id}/clone": {
      "post": {
        "operationId": "cloneFlow",
        "summary": "Clone Flow",
        "description": "Creates a `DRAFT` with the same JSON and handler, and a new secret (shown only in this response). This is how a published Flow is edited. Permission: `templates`.",
        "tags": [
          "flows"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Flow ID (`flw_…`)."
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200,
                    "description": "Flow name (unique in the account)."
                  }
                },
                "required": [
                  "name"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The clone, with the handler secret once.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Flow ID (`flw_…`).",
                      "examples": [
                        "flw_0193a1b2c3d47e8f"
                      ]
                    },
                    "connection_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "WhatsApp connection ID. Optional with a connection key (uses the key's connection)."
                    },
                    "messaging_account_id": {
                      "type": "string",
                      "description": "Messaging account (WABA) ID on Meta."
                    },
                    "external_id": {
                      "type": "string",
                      "description": "Flow ID on Meta."
                    },
                    "name": {
                      "type": "string",
                      "description": "Flow name (unique in the account)."
                    },
                    "categories": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      },
                      "description": "Meta categories (`SIGN_UP`, `APPOINTMENT_BOOKING`, `LEAD_GENERATION`…)."
                    },
                    "status": {
                      "enum": [
                        "DRAFT",
                        "PUBLISHED",
                        "DEPRECATED",
                        "BLOCKED",
                        "THROTTLED"
                      ],
                      "type": "string",
                      "description": "`DRAFT`, `PUBLISHED`, `DEPRECATED`, `BLOCKED` or `THROTTLED`."
                    },
                    "json_version": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "`version` of the Flow JSON."
                    },
                    "data_api_version": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "`data_api_version` of the JSON (Flows with an endpoint)."
                    },
                    "validation_errors": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "error": {
                            "type": "string"
                          },
                          "error_type": {
                            "type": "string"
                          },
                          "message": {
                            "type": "string"
                          },
                          "line_start": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "line_end": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "column_start": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "column_end": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        },
                        "required": [
                          "error",
                          "error_type",
                          "message",
                          "line_start",
                          "line_end",
                          "column_start",
                          "column_end"
                        ]
                      },
                      "description": "Meta's validation errors, with line and column."
                    },
                    "endpoint_mode": {
                      "enum": [
                        "none",
                        "messajo"
                      ],
                      "type": "string",
                      "description": "`none` (no endpoint) or `messajo` (Messajo's data exchange endpoint)."
                    },
                    "handler": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "url_preview": {
                              "type": "string",
                              "description": "Origin of the handler URL."
                            },
                            "secret_last4": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Last 4 characters of the handler secret."
                            }
                          },
                          "required": [
                            "url_preview",
                            "secret_last4"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Customer handler, without the full URL or headers."
                    },
                    "health_status": {
                      "anyOf": [
                        {
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {}
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Endpoint health according to Meta (and alerts from the `flows` webhook)."
                    },
                    "preview": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "url": {
                              "type": "string",
                              "description": "Meta's preview link."
                            },
                            "expires_at": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "When the preview link expires."
                            }
                          },
                          "required": [
                            "url",
                            "expires_at"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Last generated preview."
                    },
                    "last_synced_at": {
                      "type": "string",
                      "description": "Last read from Meta."
                    },
                    "created_at": {
                      "type": "string",
                      "description": "When it was created."
                    },
                    "updated_at": {
                      "type": "string",
                      "description": "Last change."
                    },
                    "handler_secret": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Handler secret (`Messajo-Signature`): shown only when generated."
                    }
                  },
                  "required": [
                    "id",
                    "connection_id",
                    "messaging_account_id",
                    "external_id",
                    "name",
                    "categories",
                    "status",
                    "json_version",
                    "data_api_version",
                    "validation_errors",
                    "endpoint_mode",
                    "handler",
                    "health_status",
                    "preview",
                    "last_synced_at",
                    "created_at",
                    "updated_at",
                    "handler_secret"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/flows/{id}/preview": {
      "post": {
        "operationId": "previewFlow",
        "summary": "Preview Flow",
        "description": "Meta's preview link, with an expiry. Permission: `templates`.",
        "tags": [
          "flows"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Flow ID (`flw_…`)."
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "description": "Link and expiry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "preview_url": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Meta's preview link."
                    },
                    "expires_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "When the preview link expires."
                    }
                  },
                  "required": [
                    "preview_url",
                    "expires_at"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/flows/{id}/rotate-handler-secret": {
      "post": {
        "operationId": "rotateFlowHandlerSecret",
        "summary": "Rotate handler secret",
        "description": "Generates a new secret to sign requests to the handler (shown only in this response); the old one stops working right away. Permission: `templates`.",
        "tags": [
          "flows"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Flow ID (`flw_…`)."
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "description": "The Flow, with the new secret once.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Flow ID (`flw_…`).",
                      "examples": [
                        "flw_0193a1b2c3d47e8f"
                      ]
                    },
                    "connection_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "WhatsApp connection ID. Optional with a connection key (uses the key's connection)."
                    },
                    "messaging_account_id": {
                      "type": "string",
                      "description": "Messaging account (WABA) ID on Meta."
                    },
                    "external_id": {
                      "type": "string",
                      "description": "Flow ID on Meta."
                    },
                    "name": {
                      "type": "string",
                      "description": "Flow name (unique in the account)."
                    },
                    "categories": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      },
                      "description": "Meta categories (`SIGN_UP`, `APPOINTMENT_BOOKING`, `LEAD_GENERATION`…)."
                    },
                    "status": {
                      "enum": [
                        "DRAFT",
                        "PUBLISHED",
                        "DEPRECATED",
                        "BLOCKED",
                        "THROTTLED"
                      ],
                      "type": "string",
                      "description": "`DRAFT`, `PUBLISHED`, `DEPRECATED`, `BLOCKED` or `THROTTLED`."
                    },
                    "json_version": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "`version` of the Flow JSON."
                    },
                    "data_api_version": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "`data_api_version` of the JSON (Flows with an endpoint)."
                    },
                    "validation_errors": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "error": {
                            "type": "string"
                          },
                          "error_type": {
                            "type": "string"
                          },
                          "message": {
                            "type": "string"
                          },
                          "line_start": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "line_end": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "column_start": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "column_end": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        },
                        "required": [
                          "error",
                          "error_type",
                          "message",
                          "line_start",
                          "line_end",
                          "column_start",
                          "column_end"
                        ]
                      },
                      "description": "Meta's validation errors, with line and column."
                    },
                    "endpoint_mode": {
                      "enum": [
                        "none",
                        "messajo"
                      ],
                      "type": "string",
                      "description": "`none` (no endpoint) or `messajo` (Messajo's data exchange endpoint)."
                    },
                    "handler": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "url_preview": {
                              "type": "string",
                              "description": "Origin of the handler URL."
                            },
                            "secret_last4": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Last 4 characters of the handler secret."
                            }
                          },
                          "required": [
                            "url_preview",
                            "secret_last4"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Customer handler, without the full URL or headers."
                    },
                    "health_status": {
                      "anyOf": [
                        {
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {}
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Endpoint health according to Meta (and alerts from the `flows` webhook)."
                    },
                    "preview": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "url": {
                              "type": "string",
                              "description": "Meta's preview link."
                            },
                            "expires_at": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "When the preview link expires."
                            }
                          },
                          "required": [
                            "url",
                            "expires_at"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Last generated preview."
                    },
                    "last_synced_at": {
                      "type": "string",
                      "description": "Last read from Meta."
                    },
                    "created_at": {
                      "type": "string",
                      "description": "When it was created."
                    },
                    "updated_at": {
                      "type": "string",
                      "description": "Last change."
                    },
                    "handler_secret": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Handler secret (`Messajo-Signature`): shown only when generated."
                    }
                  },
                  "required": [
                    "id",
                    "connection_id",
                    "messaging_account_id",
                    "external_id",
                    "name",
                    "categories",
                    "status",
                    "json_version",
                    "data_api_version",
                    "validation_errors",
                    "endpoint_mode",
                    "handler",
                    "health_status",
                    "preview",
                    "last_synced_at",
                    "created_at",
                    "updated_at",
                    "handler_secret"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/flows/{id}/sync": {
      "post": {
        "operationId": "syncFlow",
        "summary": "Sync Flow",
        "description": "Reads the Flows of the Flow's account (WABA) from Meta again: status and validation errors. Permission: `templates`.",
        "tags": [
          "flows"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Flow ID (`flw_…`)."
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "description": "The updated Flow.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Flow ID (`flw_…`).",
                      "examples": [
                        "flw_0193a1b2c3d47e8f"
                      ]
                    },
                    "connection_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "WhatsApp connection ID. Optional with a connection key (uses the key's connection)."
                    },
                    "messaging_account_id": {
                      "type": "string",
                      "description": "Messaging account (WABA) ID on Meta."
                    },
                    "external_id": {
                      "type": "string",
                      "description": "Flow ID on Meta."
                    },
                    "name": {
                      "type": "string",
                      "description": "Flow name (unique in the account)."
                    },
                    "categories": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      },
                      "description": "Meta categories (`SIGN_UP`, `APPOINTMENT_BOOKING`, `LEAD_GENERATION`…)."
                    },
                    "status": {
                      "enum": [
                        "DRAFT",
                        "PUBLISHED",
                        "DEPRECATED",
                        "BLOCKED",
                        "THROTTLED"
                      ],
                      "type": "string",
                      "description": "`DRAFT`, `PUBLISHED`, `DEPRECATED`, `BLOCKED` or `THROTTLED`."
                    },
                    "json_version": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "`version` of the Flow JSON."
                    },
                    "data_api_version": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "`data_api_version` of the JSON (Flows with an endpoint)."
                    },
                    "validation_errors": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "error": {
                            "type": "string"
                          },
                          "error_type": {
                            "type": "string"
                          },
                          "message": {
                            "type": "string"
                          },
                          "line_start": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "line_end": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "column_start": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "column_end": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        },
                        "required": [
                          "error",
                          "error_type",
                          "message",
                          "line_start",
                          "line_end",
                          "column_start",
                          "column_end"
                        ]
                      },
                      "description": "Meta's validation errors, with line and column."
                    },
                    "endpoint_mode": {
                      "enum": [
                        "none",
                        "messajo"
                      ],
                      "type": "string",
                      "description": "`none` (no endpoint) or `messajo` (Messajo's data exchange endpoint)."
                    },
                    "handler": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "url_preview": {
                              "type": "string",
                              "description": "Origin of the handler URL."
                            },
                            "secret_last4": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "Last 4 characters of the handler secret."
                            }
                          },
                          "required": [
                            "url_preview",
                            "secret_last4"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Customer handler, without the full URL or headers."
                    },
                    "health_status": {
                      "anyOf": [
                        {
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {}
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Endpoint health according to Meta (and alerts from the `flows` webhook)."
                    },
                    "preview": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "url": {
                              "type": "string",
                              "description": "Meta's preview link."
                            },
                            "expires_at": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "When the preview link expires."
                            }
                          },
                          "required": [
                            "url",
                            "expires_at"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Last generated preview."
                    },
                    "last_synced_at": {
                      "type": "string",
                      "description": "Last read from Meta."
                    },
                    "created_at": {
                      "type": "string",
                      "description": "When it was created."
                    },
                    "updated_at": {
                      "type": "string",
                      "description": "Last change."
                    }
                  },
                  "required": [
                    "id",
                    "connection_id",
                    "messaging_account_id",
                    "external_id",
                    "name",
                    "categories",
                    "status",
                    "json_version",
                    "data_api_version",
                    "validation_errors",
                    "endpoint_mode",
                    "handler",
                    "health_status",
                    "preview",
                    "last_synced_at",
                    "created_at",
                    "updated_at"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/flows/{id}/exchanges": {
      "get": {
        "operationId": "listFlowExchanges",
        "summary": "List endpoint exchanges",
        "description": "Meta's calls to the data exchange endpoint in the last 7 days, newest first: action, screen, result and timings. Never includes `data` or the `flow_token`. Permission: `read`.",
        "tags": [
          "flows"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Flow ID (`flw_…`)."
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "Next page cursor: the `next_cursor` of the previous response."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50,
              "description": "Items per page, from 1 to 100 (default 50)."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          }
        ],
        "responses": {
          "200": {
            "description": "Page of exchanges.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "description": "Exchange ID (`fex_…`)."
                          },
                          "action": {
                            "enum": [
                              "ping",
                              "INIT",
                              "BACK",
                              "data_exchange",
                              "error_notification"
                            ],
                            "type": "string",
                            "description": "`ping`, `INIT`, `BACK`, `data_exchange` or `error_notification`."
                          },
                          "screen": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Flow screen, when there is one."
                          },
                          "result": {
                            "enum": [
                              "ok",
                              "handler_error",
                              "handler_timeout",
                              "handler_invalid",
                              "decrypt_failed",
                              "signature_invalid",
                              "rate_limited",
                              "flow_not_found"
                            ],
                            "type": "string",
                            "description": "Result: `ok`, `handler_error`, `handler_timeout`, `handler_invalid`, `decrypt_failed`, `signature_invalid`, `rate_limited` or `flow_not_found`."
                          },
                          "handler_status": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Handler HTTP status."
                          },
                          "duration_ms": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991,
                            "description": "Total exchange time (ms)."
                          },
                          "handler_duration_ms": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Handler time (ms)."
                          },
                          "request_bytes": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991,
                            "description": "Size of Meta's request."
                          },
                          "response_bytes": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Size of the response."
                          },
                          "error": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Failure reason, without personal data."
                          },
                          "created_at": {
                            "type": "string",
                            "description": "When it was created."
                          }
                        },
                        "required": [
                          "id",
                          "action",
                          "screen",
                          "result",
                          "handler_status",
                          "duration_ms",
                          "handler_duration_ms",
                          "request_bytes",
                          "response_bytes",
                          "error",
                          "created_at"
                        ]
                      },
                      "description": "Page items, newest first."
                    },
                    "next_cursor": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Cursor for the next page; `null` when there are no more items."
                    }
                  },
                  "required": [
                    "data",
                    "next_cursor"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/connections/{id}/flow-key/rotate": {
      "post": {
        "operationId": "rotateFlowKey",
        "summary": "Rotate Flows key",
        "description": "Generates a new RSA 2048 pair for the connection's account (WABA) and uploads it to every active number; the previous key still decrypts for 24 h. Permission: `admin`.",
        "tags": [
          "flows"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "WhatsApp connection ID. Optional with a connection key (uses the key's connection)."
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "description": "Fingerprint and uploads per number.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "fingerprint": {
                      "type": "string",
                      "description": "SHA-256 of the new public key."
                    },
                    "uploads": {
                      "type": "object",
                      "propertyNames": {
                        "type": "string"
                      },
                      "additionalProperties": {
                        "type": "object",
                        "properties": {
                          "uploaded_at": {
                            "type": "string",
                            "description": "When the key was uploaded to the number."
                          },
                          "signature_status": {
                            "enum": [
                              "VALID",
                              "MISMATCH",
                              "unknown"
                            ],
                            "type": "string",
                            "description": "`VALID`, `MISMATCH` or `unknown`."
                          },
                          "error": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Meta's upload error, if any."
                          }
                        },
                        "required": [
                          "uploaded_at",
                          "signature_status",
                          "error"
                        ]
                      },
                      "description": "Key upload per `phone_number_id`."
                    }
                  },
                  "required": [
                    "fingerprint",
                    "uploads"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/catalogs": {
      "get": {
        "operationId": "listCatalogs",
        "summary": "List catalogs",
        "description": "Catalogs known to the organization; with `connection_id`, only those of the connection's messaging account (WABA). Keys restricted to connections must send `connection_id`. Permission: `read`.",
        "tags": [
          "commerce"
        ],
        "parameters": [
          {
            "name": "connection_id",
            "in": "query",
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "WhatsApp connection ID (`con_…`)."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          }
        ],
        "responses": {
          "200": {
            "description": "Catalogs.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "description": "Catalog ID in Messajo (`cat_…`).",
                            "examples": [
                              "cat_0193a1b2c3d47e8f"
                            ]
                          },
                          "external_id": {
                            "type": "string",
                            "description": "Catalog or product ID at Meta."
                          },
                          "messaging_account_id": {
                            "type": "string",
                            "description": "The catalog's messaging account (WABA)."
                          },
                          "name": {
                            "type": "string",
                            "description": "Name."
                          },
                          "vertical": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Catalog vertical at Meta (for example `commerce`)."
                          },
                          "product_count": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Number of products reported by Meta."
                          },
                          "linked": {
                            "type": "boolean",
                            "description": "Whether the catalog is linked to the WABA now."
                          },
                          "linked_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "When it was linked (ISO 8601)."
                          },
                          "commerce_settings": {
                            "type": "object",
                            "propertyNames": {
                              "type": "string"
                            },
                            "additionalProperties": {},
                            "description": "Last commerce settings read, by `phone_number_id`."
                          },
                          "last_synced_at": {
                            "type": "string",
                            "description": "Last read from Meta (ISO 8601)."
                          }
                        },
                        "required": [
                          "id",
                          "external_id",
                          "messaging_account_id",
                          "name",
                          "vertical",
                          "product_count",
                          "linked",
                          "linked_at",
                          "commerce_settings",
                          "last_synced_at"
                        ]
                      },
                      "description": "Page items, newest first."
                    },
                    "next_cursor": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Cursor for the next page; `null` when there are no more items."
                    }
                  },
                  "required": [
                    "data",
                    "next_cursor"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "createCatalog",
        "summary": "Create catalog",
        "description": "Creates the catalog in the connection's business portfolio and links it to the WABA. Needs a token with `catalog_management` (`403 commerce_permission_missing` without it). Permission: `commerce`.",
        "tags": [
          "commerce"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "connection_id": {
                    "type": "string",
                    "minLength": 1,
                    "description": "WhatsApp connection ID (`con_…`)."
                  },
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200,
                    "description": "Name."
                  }
                },
                "required": [
                  "name"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The created and linked catalog.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Catalog ID in Messajo (`cat_…`).",
                      "examples": [
                        "cat_0193a1b2c3d47e8f"
                      ]
                    },
                    "external_id": {
                      "type": "string",
                      "description": "Catalog or product ID at Meta."
                    },
                    "messaging_account_id": {
                      "type": "string",
                      "description": "The catalog's messaging account (WABA)."
                    },
                    "name": {
                      "type": "string",
                      "description": "Name."
                    },
                    "vertical": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Catalog vertical at Meta (for example `commerce`)."
                    },
                    "product_count": {
                      "anyOf": [
                        {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Number of products reported by Meta."
                    },
                    "linked": {
                      "type": "boolean",
                      "description": "Whether the catalog is linked to the WABA now."
                    },
                    "linked_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "When it was linked (ISO 8601)."
                    },
                    "commerce_settings": {
                      "type": "object",
                      "propertyNames": {
                        "type": "string"
                      },
                      "additionalProperties": {},
                      "description": "Last commerce settings read, by `phone_number_id`."
                    },
                    "last_synced_at": {
                      "type": "string",
                      "description": "Last read from Meta (ISO 8601)."
                    }
                  },
                  "required": [
                    "id",
                    "external_id",
                    "messaging_account_id",
                    "name",
                    "vertical",
                    "product_count",
                    "linked",
                    "linked_at",
                    "commerce_settings",
                    "last_synced_at"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ]
      }
    },
    "/catalogs/link": {
      "post": {
        "operationId": "linkCatalog",
        "summary": "Link catalog",
        "description": "Links a catalog that already exists at Meta (`catalog_external_id`) to the connection's WABA. A WABA has at most one linked catalog. Permission: `commerce`.",
        "tags": [
          "commerce"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "connection_id": {
                    "type": "string",
                    "minLength": 1,
                    "description": "WhatsApp connection ID (`con_…`)."
                  },
                  "catalog_external_id": {
                    "type": "string",
                    "minLength": 1,
                    "description": "Catalog or product ID at Meta."
                  }
                },
                "required": [
                  "catalog_external_id"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The linked catalog.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Catalog ID in Messajo (`cat_…`).",
                      "examples": [
                        "cat_0193a1b2c3d47e8f"
                      ]
                    },
                    "external_id": {
                      "type": "string",
                      "description": "Catalog or product ID at Meta."
                    },
                    "messaging_account_id": {
                      "type": "string",
                      "description": "The catalog's messaging account (WABA)."
                    },
                    "name": {
                      "type": "string",
                      "description": "Name."
                    },
                    "vertical": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Catalog vertical at Meta (for example `commerce`)."
                    },
                    "product_count": {
                      "anyOf": [
                        {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Number of products reported by Meta."
                    },
                    "linked": {
                      "type": "boolean",
                      "description": "Whether the catalog is linked to the WABA now."
                    },
                    "linked_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "When it was linked (ISO 8601)."
                    },
                    "commerce_settings": {
                      "type": "object",
                      "propertyNames": {
                        "type": "string"
                      },
                      "additionalProperties": {},
                      "description": "Last commerce settings read, by `phone_number_id`."
                    },
                    "last_synced_at": {
                      "type": "string",
                      "description": "Last read from Meta (ISO 8601)."
                    }
                  },
                  "required": [
                    "id",
                    "external_id",
                    "messaging_account_id",
                    "name",
                    "vertical",
                    "product_count",
                    "linked",
                    "linked_at",
                    "commerce_settings",
                    "last_synced_at"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ]
      }
    },
    "/catalogs/{id}/unlink": {
      "post": {
        "operationId": "unlinkCatalog",
        "summary": "Unlink catalog",
        "description": "Unlinks the catalog from the connection's WABA; the catalog stays in the portfolio. A catalog from another WABA → `409 catalog_not_linked`. Permission: `commerce`.",
        "tags": [
          "commerce"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "Catalog ID in Messajo (`cat_…`)."
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "connection_id": {
                    "type": "string",
                    "minLength": 1,
                    "description": "WhatsApp connection ID (`con_…`)."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The unlinked catalog.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Catalog ID in Messajo (`cat_…`).",
                      "examples": [
                        "cat_0193a1b2c3d47e8f"
                      ]
                    },
                    "external_id": {
                      "type": "string",
                      "description": "Catalog or product ID at Meta."
                    },
                    "messaging_account_id": {
                      "type": "string",
                      "description": "The catalog's messaging account (WABA)."
                    },
                    "name": {
                      "type": "string",
                      "description": "Name."
                    },
                    "vertical": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Catalog vertical at Meta (for example `commerce`)."
                    },
                    "product_count": {
                      "anyOf": [
                        {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Number of products reported by Meta."
                    },
                    "linked": {
                      "type": "boolean",
                      "description": "Whether the catalog is linked to the WABA now."
                    },
                    "linked_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "When it was linked (ISO 8601)."
                    },
                    "commerce_settings": {
                      "type": "object",
                      "propertyNames": {
                        "type": "string"
                      },
                      "additionalProperties": {},
                      "description": "Last commerce settings read, by `phone_number_id`."
                    },
                    "last_synced_at": {
                      "type": "string",
                      "description": "Last read from Meta (ISO 8601)."
                    }
                  },
                  "required": [
                    "id",
                    "external_id",
                    "messaging_account_id",
                    "name",
                    "vertical",
                    "product_count",
                    "linked",
                    "linked_at",
                    "commerce_settings",
                    "last_synced_at"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/catalogs/{id}/sync": {
      "post": {
        "operationId": "syncCatalog",
        "summary": "Sync catalog",
        "description": "Reads the catalog's products again from Meta and refreshes the cache used to check `retailer_id` on send. Permission: `commerce`.",
        "tags": [
          "commerce"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "Catalog ID in Messajo (`cat_…`)."
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "description": "The synced catalog.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Catalog ID in Messajo (`cat_…`).",
                      "examples": [
                        "cat_0193a1b2c3d47e8f"
                      ]
                    },
                    "external_id": {
                      "type": "string",
                      "description": "Catalog or product ID at Meta."
                    },
                    "messaging_account_id": {
                      "type": "string",
                      "description": "The catalog's messaging account (WABA)."
                    },
                    "name": {
                      "type": "string",
                      "description": "Name."
                    },
                    "vertical": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Catalog vertical at Meta (for example `commerce`)."
                    },
                    "product_count": {
                      "anyOf": [
                        {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Number of products reported by Meta."
                    },
                    "linked": {
                      "type": "boolean",
                      "description": "Whether the catalog is linked to the WABA now."
                    },
                    "linked_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "When it was linked (ISO 8601)."
                    },
                    "commerce_settings": {
                      "type": "object",
                      "propertyNames": {
                        "type": "string"
                      },
                      "additionalProperties": {},
                      "description": "Last commerce settings read, by `phone_number_id`."
                    },
                    "last_synced_at": {
                      "type": "string",
                      "description": "Last read from Meta (ISO 8601)."
                    }
                  },
                  "required": [
                    "id",
                    "external_id",
                    "messaging_account_id",
                    "name",
                    "vertical",
                    "product_count",
                    "linked",
                    "linked_at",
                    "commerce_settings",
                    "last_synced_at"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/connections/{id}/commerce-settings": {
      "get": {
        "operationId": "getCommerceSettings",
        "summary": "Get commerce settings",
        "description": "Cart enabled and catalog visible on the number's profile, read from Meta. Permission: `read`.",
        "tags": [
          "commerce"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "WhatsApp connection ID (`con_…`)."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The number's settings.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "is_cart_enabled": {
                      "type": "boolean",
                      "description": "Cart enabled on the number."
                    },
                    "is_catalog_visible": {
                      "type": "boolean",
                      "description": "Catalog visible on the number's profile."
                    }
                  },
                  "required": [
                    "is_cart_enabled",
                    "is_catalog_visible"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "put": {
        "operationId": "updateCommerceSettings",
        "summary": "Update commerce settings",
        "description": "Turns the cart and catalog visibility on or off for the number. Send at least one field. Permission: `commerce`.",
        "tags": [
          "commerce"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "WhatsApp connection ID (`con_…`)."
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "is_cart_enabled": {
                    "type": "boolean",
                    "description": "Cart enabled on the number."
                  },
                  "is_catalog_visible": {
                    "type": "boolean",
                    "description": "Catalog visible on the number's profile."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The settings after the change.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "is_cart_enabled": {
                      "type": "boolean",
                      "description": "Cart enabled on the number."
                    },
                    "is_catalog_visible": {
                      "type": "boolean",
                      "description": "Catalog visible on the number's profile."
                    }
                  },
                  "required": [
                    "is_cart_enabled",
                    "is_catalog_visible"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/catalogs/{id}/products": {
      "get": {
        "operationId": "listProducts",
        "summary": "List products",
        "description": "Catalog products from the Messajo cache (synced daily and on `POST /catalogs/{id}/sync`). Permission: `read`.",
        "tags": [
          "commerce"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "Catalog ID in Messajo (`cat_…`)."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Products.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "description": "Product ID in Messajo (`prd_…`).",
                            "examples": [
                              "prd_0193a1b2c3d47e8f"
                            ]
                          },
                          "catalog_id": {
                            "type": "string",
                            "description": "Catalog ID in Messajo (`cat_…`)."
                          },
                          "external_id": {
                            "type": "string",
                            "description": "Catalog or product ID at Meta."
                          },
                          "retailer_id": {
                            "type": "string",
                            "description": "Product SKU (`retailer_id`), unique in the catalog."
                          },
                          "name": {
                            "type": "string",
                            "description": "Name."
                          },
                          "description": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Description."
                          },
                          "amount_minor": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Price in minor units (cents), integer."
                          },
                          "sale_amount_minor": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Sale price in minor units (cents)."
                          },
                          "currency": {
                            "type": "string",
                            "description": "ISO 4217 currency (for example `BRL`)."
                          },
                          "availability": {
                            "type": "string",
                            "description": "Availability (`in stock`, `out of stock`, …)."
                          },
                          "condition": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Condition: `new`, `refurbished` or `used`."
                          },
                          "visibility": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Visibility at Meta: `published` or `staging`."
                          },
                          "image_url": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Public `https` image URL."
                          },
                          "url": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "`https` URL of the product page."
                          },
                          "brand": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Brand."
                          },
                          "review_status": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Meta review status."
                          },
                          "last_synced_at": {
                            "type": "string",
                            "description": "Last read from Meta (ISO 8601)."
                          }
                        },
                        "required": [
                          "id",
                          "catalog_id",
                          "external_id",
                          "retailer_id",
                          "name",
                          "description",
                          "amount_minor",
                          "sale_amount_minor",
                          "currency",
                          "availability",
                          "condition",
                          "visibility",
                          "image_url",
                          "url",
                          "brand",
                          "review_status",
                          "last_synced_at"
                        ]
                      },
                      "description": "Page items, newest first."
                    },
                    "next_cursor": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Cursor for the next page; `null` when there are no more items."
                    }
                  },
                  "required": [
                    "data",
                    "next_cursor"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "createProduct",
        "summary": "Create product",
        "description": "Creates the product in the Meta catalog. Price in minor units (`amount_minor`, integer: R$ 59.90 = `5990`). Permission: `commerce`.",
        "tags": [
          "commerce"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "Catalog ID in Messajo (`cat_…`)."
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "retailer_id": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100,
                    "description": "Product SKU (`retailer_id`), unique in the catalog."
                  },
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200,
                    "description": "Name."
                  },
                  "description": {
                    "type": "string",
                    "maxLength": 9999,
                    "description": "Description."
                  },
                  "amount_minor": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 9007199254740991,
                    "description": "Price in minor units (cents), integer."
                  },
                  "sale_amount_minor": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 9007199254740991,
                    "description": "Sale price in minor units (cents)."
                  },
                  "currency": {
                    "type": "string",
                    "minLength": 3,
                    "maxLength": 3,
                    "description": "ISO 4217 currency (for example `BRL`)."
                  },
                  "availability": {
                    "enum": [
                      "in stock",
                      "out of stock",
                      "preorder",
                      "available for order",
                      "discontinued"
                    ],
                    "type": "string",
                    "description": "Availability (`in stock`, `out of stock`, …)."
                  },
                  "condition": {
                    "enum": [
                      "new",
                      "refurbished",
                      "used"
                    ],
                    "type": "string",
                    "description": "Condition: `new`, `refurbished` or `used`."
                  },
                  "visibility": {
                    "enum": [
                      "published",
                      "staging"
                    ],
                    "type": "string",
                    "description": "Visibility at Meta: `published` or `staging`."
                  },
                  "image_url": {
                    "type": "string",
                    "format": "uri",
                    "description": "Public `https` image URL."
                  },
                  "url": {
                    "type": "string",
                    "format": "uri",
                    "description": "`https` URL of the product page."
                  },
                  "brand": {
                    "type": "string",
                    "maxLength": 100,
                    "description": "Brand."
                  }
                },
                "required": [
                  "retailer_id",
                  "name",
                  "amount_minor",
                  "currency",
                  "image_url"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The created product.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Product ID in Messajo (`prd_…`).",
                      "examples": [
                        "prd_0193a1b2c3d47e8f"
                      ]
                    },
                    "catalog_id": {
                      "type": "string",
                      "description": "Catalog ID in Messajo (`cat_…`)."
                    },
                    "external_id": {
                      "type": "string",
                      "description": "Catalog or product ID at Meta."
                    },
                    "retailer_id": {
                      "type": "string",
                      "description": "Product SKU (`retailer_id`), unique in the catalog."
                    },
                    "name": {
                      "type": "string",
                      "description": "Name."
                    },
                    "description": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Description."
                    },
                    "amount_minor": {
                      "anyOf": [
                        {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Price in minor units (cents), integer."
                    },
                    "sale_amount_minor": {
                      "anyOf": [
                        {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Sale price in minor units (cents)."
                    },
                    "currency": {
                      "type": "string",
                      "description": "ISO 4217 currency (for example `BRL`)."
                    },
                    "availability": {
                      "type": "string",
                      "description": "Availability (`in stock`, `out of stock`, …)."
                    },
                    "condition": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Condition: `new`, `refurbished` or `used`."
                    },
                    "visibility": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Visibility at Meta: `published` or `staging`."
                    },
                    "image_url": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Public `https` image URL."
                    },
                    "url": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "`https` URL of the product page."
                    },
                    "brand": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Brand."
                    },
                    "review_status": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Meta review status."
                    },
                    "last_synced_at": {
                      "type": "string",
                      "description": "Last read from Meta (ISO 8601)."
                    }
                  },
                  "required": [
                    "id",
                    "catalog_id",
                    "external_id",
                    "retailer_id",
                    "name",
                    "description",
                    "amount_minor",
                    "sale_amount_minor",
                    "currency",
                    "availability",
                    "condition",
                    "visibility",
                    "image_url",
                    "url",
                    "brand",
                    "review_status",
                    "last_synced_at"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/products/{id}": {
      "get": {
        "operationId": "getProduct",
        "summary": "Get product",
        "description": "A cached product, with Meta's review status. Permission: `read`.",
        "tags": [
          "commerce"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "Product ID in Messajo (`prd_…`)."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The product.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Product ID in Messajo (`prd_…`).",
                      "examples": [
                        "prd_0193a1b2c3d47e8f"
                      ]
                    },
                    "catalog_id": {
                      "type": "string",
                      "description": "Catalog ID in Messajo (`cat_…`)."
                    },
                    "external_id": {
                      "type": "string",
                      "description": "Catalog or product ID at Meta."
                    },
                    "retailer_id": {
                      "type": "string",
                      "description": "Product SKU (`retailer_id`), unique in the catalog."
                    },
                    "name": {
                      "type": "string",
                      "description": "Name."
                    },
                    "description": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Description."
                    },
                    "amount_minor": {
                      "anyOf": [
                        {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Price in minor units (cents), integer."
                    },
                    "sale_amount_minor": {
                      "anyOf": [
                        {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Sale price in minor units (cents)."
                    },
                    "currency": {
                      "type": "string",
                      "description": "ISO 4217 currency (for example `BRL`)."
                    },
                    "availability": {
                      "type": "string",
                      "description": "Availability (`in stock`, `out of stock`, …)."
                    },
                    "condition": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Condition: `new`, `refurbished` or `used`."
                    },
                    "visibility": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Visibility at Meta: `published` or `staging`."
                    },
                    "image_url": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Public `https` image URL."
                    },
                    "url": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "`https` URL of the product page."
                    },
                    "brand": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Brand."
                    },
                    "review_status": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Meta review status."
                    },
                    "last_synced_at": {
                      "type": "string",
                      "description": "Last read from Meta (ISO 8601)."
                    }
                  },
                  "required": [
                    "id",
                    "catalog_id",
                    "external_id",
                    "retailer_id",
                    "name",
                    "description",
                    "amount_minor",
                    "sale_amount_minor",
                    "currency",
                    "availability",
                    "condition",
                    "visibility",
                    "image_url",
                    "url",
                    "brand",
                    "review_status",
                    "last_synced_at"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "patch": {
        "operationId": "updateProduct",
        "summary": "Update product",
        "description": "Changes product fields at Meta; only the fields sent change. Permission: `commerce`.",
        "tags": [
          "commerce"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "Product ID in Messajo (`prd_…`)."
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200,
                    "description": "Name."
                  },
                  "description": {
                    "type": "string",
                    "maxLength": 9999,
                    "description": "Description."
                  },
                  "amount_minor": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 9007199254740991,
                    "description": "Price in minor units (cents), integer."
                  },
                  "sale_amount_minor": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 9007199254740991,
                    "description": "Sale price in minor units (cents)."
                  },
                  "currency": {
                    "type": "string",
                    "minLength": 3,
                    "maxLength": 3,
                    "description": "ISO 4217 currency (for example `BRL`)."
                  },
                  "availability": {
                    "enum": [
                      "in stock",
                      "out of stock",
                      "preorder",
                      "available for order",
                      "discontinued"
                    ],
                    "type": "string",
                    "description": "Availability (`in stock`, `out of stock`, …)."
                  },
                  "condition": {
                    "enum": [
                      "new",
                      "refurbished",
                      "used"
                    ],
                    "type": "string",
                    "description": "Condition: `new`, `refurbished` or `used`."
                  },
                  "visibility": {
                    "enum": [
                      "published",
                      "staging"
                    ],
                    "type": "string",
                    "description": "Visibility at Meta: `published` or `staging`."
                  },
                  "image_url": {
                    "type": "string",
                    "format": "uri",
                    "description": "Public `https` image URL."
                  },
                  "url": {
                    "type": "string",
                    "format": "uri",
                    "description": "`https` URL of the product page."
                  },
                  "brand": {
                    "type": "string",
                    "maxLength": 100,
                    "description": "Brand."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The updated product.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Product ID in Messajo (`prd_…`).",
                      "examples": [
                        "prd_0193a1b2c3d47e8f"
                      ]
                    },
                    "catalog_id": {
                      "type": "string",
                      "description": "Catalog ID in Messajo (`cat_…`)."
                    },
                    "external_id": {
                      "type": "string",
                      "description": "Catalog or product ID at Meta."
                    },
                    "retailer_id": {
                      "type": "string",
                      "description": "Product SKU (`retailer_id`), unique in the catalog."
                    },
                    "name": {
                      "type": "string",
                      "description": "Name."
                    },
                    "description": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Description."
                    },
                    "amount_minor": {
                      "anyOf": [
                        {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Price in minor units (cents), integer."
                    },
                    "sale_amount_minor": {
                      "anyOf": [
                        {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Sale price in minor units (cents)."
                    },
                    "currency": {
                      "type": "string",
                      "description": "ISO 4217 currency (for example `BRL`)."
                    },
                    "availability": {
                      "type": "string",
                      "description": "Availability (`in stock`, `out of stock`, …)."
                    },
                    "condition": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Condition: `new`, `refurbished` or `used`."
                    },
                    "visibility": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Visibility at Meta: `published` or `staging`."
                    },
                    "image_url": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Public `https` image URL."
                    },
                    "url": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "`https` URL of the product page."
                    },
                    "brand": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Brand."
                    },
                    "review_status": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Meta review status."
                    },
                    "last_synced_at": {
                      "type": "string",
                      "description": "Last read from Meta (ISO 8601)."
                    }
                  },
                  "required": [
                    "id",
                    "catalog_id",
                    "external_id",
                    "retailer_id",
                    "name",
                    "description",
                    "amount_minor",
                    "sale_amount_minor",
                    "currency",
                    "availability",
                    "condition",
                    "visibility",
                    "image_url",
                    "url",
                    "brand",
                    "review_status",
                    "last_synced_at"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "operationId": "deleteProduct",
        "summary": "Delete product",
        "description": "Deletes the product at Meta and removes it from the cache. Permission: `commerce`.",
        "tags": [
          "commerce"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "Product ID in Messajo (`prd_…`)."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Confirmation.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Product ID in Messajo (`prd_…`)."
                    },
                    "deleted": {
                      "const": true,
                      "description": "Always `true`."
                    }
                  },
                  "required": [
                    "id",
                    "deleted"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/orders": {
      "get": {
        "operationId": "listOrders",
        "summary": "List orders",
        "description": "The organization's orders, newest first: received carts (`cart`) and charges sent with `order_details`. Keys restricted to connections only see their connections' orders. Permission: `read`.",
        "tags": [
          "commerce"
        ],
        "parameters": [
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "Next page cursor: the `next_cursor` of the previous response."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50,
              "description": "Items per page, from 1 to 100 (default 50)."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "connection_id",
            "in": "query",
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "WhatsApp connection ID (`con_…`)."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "enum": [
                "cart_received",
                "pending",
                "processing",
                "partially_shipped",
                "shipped",
                "completed",
                "canceled"
              ],
              "type": "string",
              "description": "Order status."
            },
            "allowEmptyValue": true,
            "allowReserved": true
          }
        ],
        "responses": {
          "200": {
            "description": "Page of orders.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "description": "Order ID (`ord_…`).",
                            "examples": [
                              "ord_0193a1b2c3d47e8f"
                            ]
                          },
                          "connection_id": {
                            "type": "string",
                            "description": "WhatsApp connection ID (`con_…`)."
                          },
                          "origin": {
                            "enum": [
                              "cart",
                              "order_details"
                            ],
                            "type": "string",
                            "description": "Origin: `cart` (customer cart) or `order_details` (charge sent)."
                          },
                          "reference_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "`order_details` `reference_id`, unique per connection."
                          },
                          "catalog_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Catalog ID in Messajo (`cat_…`)."
                          },
                          "items": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "retailer_id": {
                                  "type": "string",
                                  "description": "Product SKU (`retailer_id`), unique in the catalog."
                                },
                                "name": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ],
                                  "description": "Name."
                                },
                                "quantity": {
                                  "type": "integer",
                                  "minimum": -9007199254740991,
                                  "maximum": 9007199254740991,
                                  "description": "Quantity."
                                },
                                "amount_minor": {
                                  "type": "integer",
                                  "minimum": -9007199254740991,
                                  "maximum": 9007199254740991,
                                  "description": "Price in minor units (cents), integer."
                                },
                                "sale_amount_minor": {
                                  "anyOf": [
                                    {
                                      "type": "integer",
                                      "minimum": -9007199254740991,
                                      "maximum": 9007199254740991,
                                      "description": "Sale price in minor units (cents)."
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "currency": {
                                  "type": "string",
                                  "description": "ISO 4217 currency (for example `BRL`)."
                                }
                              },
                              "required": [
                                "retailer_id",
                                "name",
                                "quantity",
                                "amount_minor",
                                "sale_amount_minor",
                                "currency"
                              ]
                            },
                            "description": "Order items."
                          },
                          "currency": {
                            "type": "string",
                            "description": "ISO 4217 currency (for example `BRL`)."
                          },
                          "subtotal_minor": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991,
                            "description": "Subtotal in minor units."
                          },
                          "tax_minor": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991,
                            "description": "Tax in minor units."
                          },
                          "shipping_minor": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991,
                            "description": "Shipping in minor units."
                          },
                          "discount_minor": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991,
                            "description": "Discount in minor units."
                          },
                          "total_minor": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991,
                            "description": "Total in minor units."
                          },
                          "status": {
                            "enum": [
                              "cart_received",
                              "pending",
                              "processing",
                              "partially_shipped",
                              "shipped",
                              "completed",
                              "canceled"
                            ],
                            "type": "string",
                            "description": "Order status."
                          },
                          "status_description": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Text of the last `order_status`."
                          },
                          "payment_status": {
                            "enum": [
                              "none",
                              "pending",
                              "captured",
                              "failed",
                              "expired",
                              "unknown"
                            ],
                            "type": "string",
                            "description": "Payment status."
                          },
                          "payment_method": {
                            "anyOf": [
                              {
                                "enum": [
                                  "pix_dynamic_code",
                                  "payment_link",
                                  "boleto",
                                  "offsite_card"
                                ],
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Reported payment method."
                          },
                          "expires_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "When the charge expires (ISO 8601)."
                          },
                          "created_at": {
                            "type": "string",
                            "description": "Creation (ISO 8601)."
                          }
                        },
                        "required": [
                          "id",
                          "connection_id",
                          "origin",
                          "reference_id",
                          "catalog_id",
                          "items",
                          "currency",
                          "subtotal_minor",
                          "tax_minor",
                          "shipping_minor",
                          "discount_minor",
                          "total_minor",
                          "status",
                          "status_description",
                          "payment_status",
                          "payment_method",
                          "expires_at",
                          "created_at"
                        ]
                      },
                      "description": "Page items, newest first."
                    },
                    "next_cursor": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Cursor for the next page; `null` when there are no more items."
                    }
                  },
                  "required": [
                    "data",
                    "next_cursor"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/orders/{id}": {
      "get": {
        "operationId": "getOrder",
        "summary": "Get order",
        "description": "An order with items, totals in minor units, status and payment status. Permission: `read`.",
        "tags": [
          "commerce"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "Order ID (`ord_…`)."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The order.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Order ID (`ord_…`).",
                      "examples": [
                        "ord_0193a1b2c3d47e8f"
                      ]
                    },
                    "connection_id": {
                      "type": "string",
                      "description": "WhatsApp connection ID (`con_…`)."
                    },
                    "origin": {
                      "enum": [
                        "cart",
                        "order_details"
                      ],
                      "type": "string",
                      "description": "Origin: `cart` (customer cart) or `order_details` (charge sent)."
                    },
                    "reference_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "`order_details` `reference_id`, unique per connection."
                    },
                    "catalog_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Catalog ID in Messajo (`cat_…`)."
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "retailer_id": {
                            "type": "string",
                            "description": "Product SKU (`retailer_id`), unique in the catalog."
                          },
                          "name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Name."
                          },
                          "quantity": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991,
                            "description": "Quantity."
                          },
                          "amount_minor": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991,
                            "description": "Price in minor units (cents), integer."
                          },
                          "sale_amount_minor": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991,
                                "description": "Sale price in minor units (cents)."
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "currency": {
                            "type": "string",
                            "description": "ISO 4217 currency (for example `BRL`)."
                          }
                        },
                        "required": [
                          "retailer_id",
                          "name",
                          "quantity",
                          "amount_minor",
                          "sale_amount_minor",
                          "currency"
                        ]
                      },
                      "description": "Order items."
                    },
                    "currency": {
                      "type": "string",
                      "description": "ISO 4217 currency (for example `BRL`)."
                    },
                    "subtotal_minor": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "Subtotal in minor units."
                    },
                    "tax_minor": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "Tax in minor units."
                    },
                    "shipping_minor": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "Shipping in minor units."
                    },
                    "discount_minor": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "Discount in minor units."
                    },
                    "total_minor": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "Total in minor units."
                    },
                    "status": {
                      "enum": [
                        "cart_received",
                        "pending",
                        "processing",
                        "partially_shipped",
                        "shipped",
                        "completed",
                        "canceled"
                      ],
                      "type": "string",
                      "description": "Order status."
                    },
                    "status_description": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Text of the last `order_status`."
                    },
                    "payment_status": {
                      "enum": [
                        "none",
                        "pending",
                        "captured",
                        "failed",
                        "expired",
                        "unknown"
                      ],
                      "type": "string",
                      "description": "Payment status."
                    },
                    "payment_method": {
                      "anyOf": [
                        {
                          "enum": [
                            "pix_dynamic_code",
                            "payment_link",
                            "boleto",
                            "offsite_card"
                          ],
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Reported payment method."
                    },
                    "expires_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "When the charge expires (ISO 8601)."
                    },
                    "created_at": {
                      "type": "string",
                      "description": "Creation (ISO 8601)."
                    }
                  },
                  "required": [
                    "id",
                    "connection_id",
                    "origin",
                    "reference_id",
                    "catalog_id",
                    "items",
                    "currency",
                    "subtotal_minor",
                    "tax_minor",
                    "shipping_minor",
                    "discount_minor",
                    "total_minor",
                    "status",
                    "status_description",
                    "payment_status",
                    "payment_method",
                    "expires_at",
                    "created_at"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/orders/{id}/payment": {
      "post": {
        "operationId": "markOrderPayment",
        "summary": "Report payment",
        "description": "Pix paid outside WhatsApp has no payment webhook: reconcile with your PSP and report `captured` or `failed` here. With `notify: true` and `captured`, Messajo sends the customer `order_status processing` (text in `message`). Only `pending` orders not yet paid; otherwise `409 order_invalid_transition`. Permission: `commerce`.",
        "tags": [
          "commerce"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "Order ID (`ord_…`)."
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "status": {
                    "enum": [
                      "captured",
                      "failed"
                    ],
                    "type": "string",
                    "description": "Reconciliation result: `captured` or `failed`."
                  },
                  "notify": {
                    "type": "boolean",
                    "description": "With `captured`, sends the customer `order_status processing`."
                  },
                  "message": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 1024,
                    "description": "Notice text for the customer (up to 1024 characters)."
                  }
                },
                "required": [
                  "status"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The updated order and the notice message ID, if any.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Order ID (`ord_…`).",
                      "examples": [
                        "ord_0193a1b2c3d47e8f"
                      ]
                    },
                    "connection_id": {
                      "type": "string",
                      "description": "WhatsApp connection ID (`con_…`)."
                    },
                    "origin": {
                      "enum": [
                        "cart",
                        "order_details"
                      ],
                      "type": "string",
                      "description": "Origin: `cart` (customer cart) or `order_details` (charge sent)."
                    },
                    "reference_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "`order_details` `reference_id`, unique per connection."
                    },
                    "catalog_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Catalog ID in Messajo (`cat_…`)."
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "retailer_id": {
                            "type": "string",
                            "description": "Product SKU (`retailer_id`), unique in the catalog."
                          },
                          "name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Name."
                          },
                          "quantity": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991,
                            "description": "Quantity."
                          },
                          "amount_minor": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991,
                            "description": "Price in minor units (cents), integer."
                          },
                          "sale_amount_minor": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991,
                                "description": "Sale price in minor units (cents)."
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "currency": {
                            "type": "string",
                            "description": "ISO 4217 currency (for example `BRL`)."
                          }
                        },
                        "required": [
                          "retailer_id",
                          "name",
                          "quantity",
                          "amount_minor",
                          "sale_amount_minor",
                          "currency"
                        ]
                      },
                      "description": "Order items."
                    },
                    "currency": {
                      "type": "string",
                      "description": "ISO 4217 currency (for example `BRL`)."
                    },
                    "subtotal_minor": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "Subtotal in minor units."
                    },
                    "tax_minor": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "Tax in minor units."
                    },
                    "shipping_minor": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "Shipping in minor units."
                    },
                    "discount_minor": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "Discount in minor units."
                    },
                    "total_minor": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "Total in minor units."
                    },
                    "status": {
                      "enum": [
                        "cart_received",
                        "pending",
                        "processing",
                        "partially_shipped",
                        "shipped",
                        "completed",
                        "canceled"
                      ],
                      "type": "string",
                      "description": "Order status."
                    },
                    "status_description": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Text of the last `order_status`."
                    },
                    "payment_status": {
                      "enum": [
                        "none",
                        "pending",
                        "captured",
                        "failed",
                        "expired",
                        "unknown"
                      ],
                      "type": "string",
                      "description": "Payment status."
                    },
                    "payment_method": {
                      "anyOf": [
                        {
                          "enum": [
                            "pix_dynamic_code",
                            "payment_link",
                            "boleto",
                            "offsite_card"
                          ],
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Reported payment method."
                    },
                    "expires_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "When the charge expires (ISO 8601)."
                    },
                    "created_at": {
                      "type": "string",
                      "description": "Creation (ISO 8601)."
                    },
                    "notification_message_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "ID of the notice message sent, or `null`."
                    }
                  },
                  "required": [
                    "id",
                    "connection_id",
                    "origin",
                    "reference_id",
                    "catalog_id",
                    "items",
                    "currency",
                    "subtotal_minor",
                    "tax_minor",
                    "shipping_minor",
                    "discount_minor",
                    "total_minor",
                    "status",
                    "status_description",
                    "payment_status",
                    "payment_method",
                    "expires_at",
                    "created_at",
                    "notification_message_id"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/templates/authentication": {
      "post": {
        "operationId": "createAuthTemplate",
        "summary": "Create authentication template",
        "description": "Creates (or updates) an `AUTHENTICATION` template in each language, with a copy code, one-tap or zero-tap button. The text is Meta's fixed text. Then send the code with `POST /messages` `type: \"otp\"`: the code only goes to Meta and is stored masked. Permission: `templates`.",
        "tags": [
          "templates"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "connection_id": {
                    "type": "string",
                    "minLength": 1,
                    "description": "WhatsApp connection ID (`con_…`)."
                  },
                  "languages": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 20,
                    "items": {
                      "type": "string",
                      "pattern": "^[a-z]{2,3}(_[A-Z]{2})?$"
                    },
                    "description": "Languages (1 to 20), for example `en_US`."
                  },
                  "add_security_recommendation": {
                    "type": "boolean",
                    "description": "Adds Meta's security notice to the body."
                  },
                  "code_expiration_minutes": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 90,
                    "description": "Code validity in minutes (1 to 90), shown in the footer."
                  },
                  "name": {
                    "type": "string",
                    "pattern": "^[a-z0-9_]{1,512}$",
                    "description": "Template name (lowercase, digits and `_`)."
                  },
                  "message_send_ttl_seconds": {
                    "type": "integer",
                    "minimum": 30,
                    "maximum": 900,
                    "description": "Delivery deadline in seconds (30 to 900)."
                  },
                  "button": {
                    "anyOf": [
                      {
                        "type": "object",
                        "properties": {
                          "otp_type": {
                            "const": "COPY_CODE"
                          },
                          "text": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 25
                          }
                        },
                        "required": [
                          "otp_type"
                        ]
                      },
                      {
                        "type": "object",
                        "properties": {
                          "otp_type": {
                            "const": "ONE_TAP"
                          },
                          "text": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 25
                          },
                          "autofill_text": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 25
                          },
                          "supported_apps": {
                            "type": "array",
                            "minItems": 1,
                            "maxItems": 5,
                            "items": {
                              "type": "object",
                              "properties": {
                                "package_name": {
                                  "type": "string",
                                  "maxLength": 224,
                                  "pattern": "^[A-Za-z]\\w*(\\.[A-Za-z]\\w*)+$"
                                },
                                "signature_hash": {
                                  "type": "string",
                                  "minLength": 11,
                                  "maxLength": 11
                                }
                              },
                              "required": [
                                "package_name",
                                "signature_hash"
                              ]
                            }
                          }
                        },
                        "required": [
                          "otp_type",
                          "supported_apps"
                        ]
                      },
                      {
                        "type": "object",
                        "properties": {
                          "otp_type": {
                            "const": "ZERO_TAP"
                          },
                          "text": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 25
                          },
                          "autofill_text": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 25
                          },
                          "supported_apps": {
                            "type": "array",
                            "minItems": 1,
                            "maxItems": 5,
                            "items": {
                              "type": "object",
                              "properties": {
                                "package_name": {
                                  "type": "string",
                                  "maxLength": 224,
                                  "pattern": "^[A-Za-z]\\w*(\\.[A-Za-z]\\w*)+$"
                                },
                                "signature_hash": {
                                  "type": "string",
                                  "minLength": 11,
                                  "maxLength": 11
                                }
                              },
                              "required": [
                                "package_name",
                                "signature_hash"
                              ]
                            }
                          },
                          "zero_tap_terms_accepted": {
                            "const": true
                          }
                        },
                        "required": [
                          "otp_type",
                          "supported_apps",
                          "zero_tap_terms_accepted"
                        ]
                      }
                    ],
                    "description": "OTP button: `COPY_CODE`, `ONE_TAP` or `ZERO_TAP` (the last two with `supported_apps`)."
                  }
                },
                "required": [
                  "languages",
                  "add_security_recommendation",
                  "name",
                  "button"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "One template per language.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "description": "Template ID at Messajo (`tpl_…`).",
                            "examples": [
                              "tpl_0193a1b2c3d47e8f9a0b1c2d3e4f5a6b"
                            ]
                          },
                          "messaging_account_id": {
                            "type": "string",
                            "description": "WhatsApp Business account (WABA) of the template."
                          },
                          "external_id": {
                            "type": "string",
                            "description": "Template ID at Meta."
                          },
                          "name": {
                            "type": "string",
                            "description": "Name (lowercase letters, digits and `_`)."
                          },
                          "language": {
                            "type": "string",
                            "description": "Language, e.g. `en_US`."
                          },
                          "category": {
                            "enum": [
                              "MARKETING",
                              "UTILITY",
                              "AUTHENTICATION"
                            ],
                            "type": "string",
                            "description": "Category: `MARKETING`, `UTILITY` or `AUTHENTICATION`."
                          },
                          "previous_category": {
                            "anyOf": [
                              {
                                "enum": [
                                  "MARKETING",
                                  "UTILITY",
                                  "AUTHENTICATION"
                                ],
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Previous category, when Meta reclassified it."
                          },
                          "status": {
                            "enum": [
                              "APPROVED",
                              "PENDING",
                              "REJECTED",
                              "PAUSED",
                              "DISABLED",
                              "IN_APPEAL",
                              "PENDING_DELETION",
                              "DELETED",
                              "ARCHIVED",
                              "LIMIT_EXCEEDED",
                              "LOCKED",
                              "FLAGGED",
                              "REINSTATED"
                            ],
                            "type": "string",
                            "description": "Status at Meta, e.g. `APPROVED`, `PENDING`, `REJECTED`."
                          },
                          "rejected_reason": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Rejection reason, when there is one."
                          },
                          "quality_score": {
                            "enum": [
                              "GREEN",
                              "YELLOW",
                              "RED",
                              "UNKNOWN"
                            ],
                            "type": "string",
                            "description": "Quality: `GREEN`, `YELLOW`, `RED` or `UNKNOWN`."
                          },
                          "parameter_format": {
                            "enum": [
                              "POSITIONAL",
                              "NAMED"
                            ],
                            "type": "string",
                            "description": "Variable format: `POSITIONAL` or `NAMED`."
                          },
                          "components": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "propertyNames": {
                                "type": "string"
                              },
                              "additionalProperties": {}
                            },
                            "description": "Components in Meta's format (`HEADER`, `BODY`, `FOOTER`, `BUTTONS`)."
                          },
                          "last_synced_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Last read from Meta (ISO 8601, UTC)."
                          },
                          "status_updated_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Last status change (ISO 8601, UTC)."
                          },
                          "created_at": {
                            "type": "string",
                            "description": "When it was created at Messajo (ISO 8601, UTC)."
                          },
                          "updated_at": {
                            "type": "string",
                            "description": "Last change (ISO 8601, UTC)."
                          }
                        },
                        "required": [
                          "id",
                          "messaging_account_id",
                          "external_id",
                          "name",
                          "language",
                          "category",
                          "previous_category",
                          "status",
                          "rejected_reason",
                          "quality_score",
                          "parameter_format",
                          "components",
                          "last_synced_at",
                          "status_updated_at",
                          "created_at",
                          "updated_at"
                        ]
                      },
                      "description": "Created templates, one per language."
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ]
      }
    },
    "/templates/authentication/preview": {
      "post": {
        "operationId": "previewAuthTemplate",
        "summary": "Preview authentication template",
        "description": "The texts Meta will use in each language with the chosen options. Permission: `templates`.",
        "tags": [
          "templates"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "connection_id": {
                    "type": "string",
                    "minLength": 1,
                    "description": "WhatsApp connection ID (`con_…`)."
                  },
                  "languages": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 20,
                    "items": {
                      "type": "string",
                      "pattern": "^[a-z]{2,3}(_[A-Z]{2})?$"
                    },
                    "description": "Languages (1 to 20), for example `en_US`."
                  },
                  "add_security_recommendation": {
                    "type": "boolean",
                    "description": "Adds Meta's security notice to the body."
                  },
                  "code_expiration_minutes": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 90,
                    "description": "Code validity in minutes (1 to 90), shown in the footer."
                  }
                },
                "required": [
                  "languages",
                  "add_security_recommendation"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Previews per language.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "previews": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "language": {
                            "type": "string",
                            "description": "Language."
                          },
                          "body": {
                            "type": "string",
                            "description": "Body."
                          },
                          "footer": {
                            "type": "string",
                            "description": "Footer."
                          },
                          "buttons": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "text": {
                                  "type": "string"
                                },
                                "autofill_text": {
                                  "type": "string"
                                }
                              },
                              "required": [
                                "text"
                              ]
                            },
                            "description": "Buttons."
                          }
                        },
                        "required": [
                          "language",
                          "body",
                          "buttons"
                        ]
                      },
                      "description": "Previews per language."
                    }
                  },
                  "required": [
                    "previews"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ]
      }
    },
    "/usage/costs": {
      "get": {
        "operationId": "getUsageCosts",
        "summary": "WhatsApp costs",
        "description": "Cost charged by Meta in the period, in the WhatsApp account currency. `estimate` is computed by Messajo when each message is delivered; `official` is the approximate amount reported by Meta (up to 3 days late).",
        "tags": [
          "usage"
        ],
        "parameters": [
          {
            "name": "from",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date",
              "description": "First day (UTC, `YYYY-MM-DD`). Default: first day of the current month"
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "to",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date",
              "description": "Last day, inclusive. Default: today. At most 366 days"
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "connection_id",
            "in": "query",
            "schema": {
              "type": "string",
              "description": "Only this connection"
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "currency",
            "in": "query",
            "schema": {
              "type": "string",
              "pattern": "^[A-Z]{3}$",
              "description": "Currency (ISO 4217). Required when the organization has accounts in more than one currency"
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "name": "group_by",
            "in": "query",
            "schema": {
              "enum": [
                "day",
                "campaign",
                "template",
                "category",
                "connection"
              ],
              "type": "string",
              "default": "day",
              "description": "Grouping: day, campaign, template, connection or category"
            },
            "allowEmptyValue": true,
            "allowReserved": true
          }
        ],
        "responses": {
          "200": {
            "description": "Items for the requested grouping",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "currency": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Currency of the amounts; `null` when the organization has no cost yet"
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "key": {
                            "type": "string",
                            "description": "Day (`YYYY-MM-DD`), campaign id, template `name:language`, connection id or category"
                          },
                          "estimate": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Messajo estimate (decimal string); `null` when it cannot be estimated"
                          },
                          "official": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Approximate amount from Meta (decimal string); `null` until Meta reports it. Absent when grouping by campaign or template"
                          }
                        },
                        "required": [
                          "key",
                          "estimate"
                        ]
                      }
                    }
                  },
                  "required": [
                    "currency",
                    "items"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/whatsapp/{id}/{path}": {
      "get": {
        "operationId": "mirrorGet",
        "summary": "Meta mirror (read)",
        "description": "Passes a `GET` through to Meta's Graph API with the connection's token, without changing the body or the response (Meta errors come back as Meta sent them). `{id}` is the `phone_number_id` or the `messaging_account_id` (WABA) of a connection of the organization; standalone nodes live under `{phone_number_id}/nodes/{node_id}`. Path reference: https://developers.facebook.com/docs/whatsapp/cloud-api. Permission: `read` (templates: `templates`).",
        "tags": [
          "whatsapp-mirror"
        ],
        "externalDocs": {
          "url": "https://developers.facebook.com/docs/whatsapp/cloud-api"
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "`phone_number_id` or `messaging_account_id` of a connection of the organization.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "path",
            "in": "path",
            "required": true,
            "description": "Rest of the Graph API path, e.g. `messages`, `message_templates` or `nodes/{node_id}`.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Meta's response, as it came.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "mirrorPost",
        "summary": "Meta mirror (write)",
        "description": "Passes a `POST` through to Meta's Graph API with the connection's token. `POST …/messages` respects the number's messages-per-second limit, stores the message and returns its ID in the `X-Messajo-Message-Id` header. Paths that break the connection (`register`, `deregister`, `request_code`, `verify_code`, `smb_app_data`, `subscribed_apps` with `override_callback_uri`) are refused with `403 mirror_path_blocked`. Permission: `send` for messages, `templates` for templates, `admin` for the rest.",
        "tags": [
          "whatsapp-mirror"
        ],
        "externalDocs": {
          "url": "https://developers.facebook.com/docs/whatsapp/cloud-api"
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "`phone_number_id` or `messaging_account_id` of a connection of the organization.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "path",
            "in": "path",
            "required": true,
            "description": "Rest of the Graph API path, e.g. `messages`, `message_templates` or `nodes/{node_id}`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": false,
          "description": "Body in the Graph API format, passed through as is.",
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Meta's response, as it came.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "operationId": "mirrorDelete",
        "summary": "Meta mirror (delete)",
        "description": "Passes a `DELETE` through to Meta's Graph API with the connection's token. `DELETE …/subscribed_apps` is refused (`403 mirror_path_blocked`). Permission: `templates` for templates, `admin` for the rest.",
        "tags": [
          "whatsapp-mirror"
        ],
        "externalDocs": {
          "url": "https://developers.facebook.com/docs/whatsapp/cloud-api"
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "`phone_number_id` or `messaging_account_id` of a connection of the organization.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "path",
            "in": "path",
            "required": true,
            "description": "Rest of the Graph API path, e.g. `messages`, `message_templates` or `nodes/{node_id}`.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Meta's response, as it came.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/instagram/{ig_user_id}/{path}": {
      "get": {
        "operationId": "instagramMirrorGet",
        "summary": "Instagram mirror (read)",
        "description": "Passes a `GET` through to the Instagram Graph API with the account's token, without changing the body or the response (Meta errors come back as Meta sent them). `{ig_user_id}` is an account of the organization; standalone nodes (media, comment, container) live under `{ig_user_id}/nodes/{node_id}`. Reference: https://developers.facebook.com/docs/instagram-platform. Permission: `read`.",
        "tags": [
          "instagram-mirror"
        ],
        "externalDocs": {
          "url": "https://developers.facebook.com/docs/instagram-platform"
        },
        "parameters": [
          {
            "name": "ig_user_id",
            "in": "path",
            "required": true,
            "description": "`ig_user_id` of an Instagram account of the organization.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "path",
            "in": "path",
            "required": true,
            "description": "Rest of the Graph API path, e.g. `messages`, `media` or `nodes/{node_id}`.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Meta's response, as it came.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "instagramMirrorPost",
        "summary": "Instagram mirror (write)",
        "description": "Passes a `POST` through to the Instagram Graph API with the account's token. `POST …/messages` respects the messages-per-second limit, stores the message and returns its ID in the `X-Messajo-Message-Id` header. `media_publish` through the mirror does not become a schedulable publication (use `POST /publications`). Paths that break the connection (`subscribed_apps`, `access_token`, `oauth/*`) are refused with `403 mirror_path_blocked`. Permission: `send` for messages, media, publishing and comments; `admin` for the rest.",
        "tags": [
          "instagram-mirror"
        ],
        "externalDocs": {
          "url": "https://developers.facebook.com/docs/instagram-platform"
        },
        "parameters": [
          {
            "name": "ig_user_id",
            "in": "path",
            "required": true,
            "description": "`ig_user_id` of an Instagram account of the organization.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "path",
            "in": "path",
            "required": true,
            "description": "Rest of the Graph API path, e.g. `messages`, `media` or `nodes/{node_id}`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": false,
          "description": "Body in the Graph API format, passed through as is.",
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Meta's response, as it came.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "operationId": "instagramMirrorDelete",
        "summary": "Instagram mirror (delete)",
        "description": "Passes a `DELETE` through to the Instagram Graph API with the account's token. Deleting a comment needs `send`; the rest, `admin`. `subscribed_apps` is refused (`403 mirror_path_blocked`).",
        "tags": [
          "instagram-mirror"
        ],
        "externalDocs": {
          "url": "https://developers.facebook.com/docs/instagram-platform"
        },
        "parameters": [
          {
            "name": "ig_user_id",
            "in": "path",
            "required": true,
            "description": "`ig_user_id` of an Instagram account of the organization.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "path",
            "in": "path",
            "required": true,
            "description": "Rest of the Graph API path, e.g. `messages`, `media` or `nodes/{node_id}`.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Meta's response, as it came.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/messenger/{page_id}/{path}": {
      "get": {
        "operationId": "messengerMirrorGet",
        "summary": "Messenger mirror (read)",
        "description": "Passes a `GET` through to the Facebook Graph API with the Page's token, without changing the body or the response. `{page_id}` is a Page of the organization; standalone nodes live under `{page_id}/nodes/{node_id}`. Reference: https://developers.facebook.com/docs/messenger-platform. Permission: `read`.",
        "tags": [
          "messenger-mirror"
        ],
        "externalDocs": {
          "url": "https://developers.facebook.com/docs/messenger-platform"
        },
        "parameters": [
          {
            "name": "page_id",
            "in": "path",
            "required": true,
            "description": "`page_id` of a Facebook Page of the organization.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "path",
            "in": "path",
            "required": true,
            "description": "Rest of the Graph API path, e.g. `messages`, `media` or `nodes/{node_id}`.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Meta's response, as it came.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "messengerMirrorPost",
        "summary": "Messenger mirror (write)",
        "description": "Passes a `POST` through to the Facebook Graph API with the Page's token. `POST …/messages` respects the messages-per-second limit, stores the message and returns its ID in `X-Messajo-Message-Id`. `subscribed_apps`, `access_token` and `oauth/*` are refused (`403 mirror_path_blocked`); `pass_thread_control`/`take_thread_control` need `admin`. Permission: `send` for messages and attachments, `admin` for the rest.",
        "tags": [
          "messenger-mirror"
        ],
        "externalDocs": {
          "url": "https://developers.facebook.com/docs/messenger-platform"
        },
        "parameters": [
          {
            "name": "page_id",
            "in": "path",
            "required": true,
            "description": "`page_id` of a Facebook Page of the organization.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "path",
            "in": "path",
            "required": true,
            "description": "Rest of the Graph API path, e.g. `messages`, `media` or `nodes/{node_id}`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": false,
          "description": "Body in the Graph API format, passed through as is.",
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Meta's response, as it came.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "operationId": "messengerMirrorDelete",
        "summary": "Messenger mirror (delete)",
        "description": "Passes a `DELETE` through to the Facebook Graph API with the Page's token. `subscribed_apps` is refused (`403 mirror_path_blocked`). Permission: `admin`.",
        "tags": [
          "messenger-mirror"
        ],
        "externalDocs": {
          "url": "https://developers.facebook.com/docs/messenger-platform"
        },
        "parameters": [
          {
            "name": "page_id",
            "in": "path",
            "required": true,
            "description": "`page_id` of a Facebook Page of the organization.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "path",
            "in": "path",
            "required": true,
            "description": "Rest of the Graph API path, e.g. `messages`, `media` or `nodes/{node_id}`.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Meta's response, as it came.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    }
  }
}
