{"openapi":"3.1.0","info":{"title":"Fiwano API","description":"Unified REST API for WhatsApp, Instagram and Facebook Messenger.\n\nAuthenticate every request with the `X-API-Key` header (keys start with `mip_live_`, created on the API Keys page in the portal); `Authorization: Bearer <key>` is accepted when `X-API-Key` is absent. Keys are secret: call the API from your server, not from browser code. Base URL: `https://fiwano.com`.\n\nHuman-readable guides: https://fiwano.com/documentation","version":"2.0.0"},"servers":[{"url":"https://fiwano.com"}],"paths":{"/api/v1/subscriptions":{"get":{"tags":["api"],"summary":"List Subscriptions","description":"List subscriptions and free channel slots for the authenticated user.\n\nUse this endpoint before starting a channel setup flow to check whether a\nnew WhatsApp, Instagram, or Facebook channel can be connected right now.\nA positive `available_slots.<type>.total` means a new channel can be added.\nPOST /api/v1/channels/setup-url also permits reconnecting an existing\ninactive channel that still has an operable reserved slot.","operationId":"list_subscriptions_api_v1_subscriptions_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionsResponse"}}}}},"security":[{"ApiKeyAuth":[]},{"BearerAuth":[]}]}},"/api/v1/channels":{"get":{"tags":["api"],"summary":"List Channels","description":"List all channels for the authenticated user.\n\nReturns both active and inactive channels. Each channel includes its current\n`subscription` (billing) state and the channel-type-specific identifiers\n(WhatsApp: phone_number_id/waba_id; Instagram: ig_account_id/ig_username;\nInstagram & Facebook: page_id).","operationId":"list_channels_api_v1_channels_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChannelListResponse"}}}}},"security":[{"ApiKeyAuth":[]},{"BearerAuth":[]}]}},"/api/v1/channels/{channel_id}":{"get":{"tags":["api"],"summary":"Get Channel","description":"Get one channel by ID.\n\nSame shape as the list endpoint — a single channel object including its\n`subscription` (billing) state. Returns 404 if the channel does not belong\nto the authenticated account.","operationId":"get_channel_api_v1_channels__channel_id__get","security":[{"ApiKeyAuth":[]},{"BearerAuth":[]}],"parameters":[{"name":"channel_id","in":"path","required":true,"schema":{"type":"string","title":"Channel Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChannelOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"patch":{"tags":["api"],"summary":"Update Channel","description":"Update channel webhook settings, or move the channel between subscriptions.\n\nSet webhook_url to receive incoming messages. Must use HTTPS and cannot target loopback.\nOptionally provide a custom webhook_secret for HMAC verification.\n\n`subscription_id` binds the channel to another subscription, or — when sent as\nan empty string — releases its subscription slot so a different channel of the\nsame type can be connected. Releasing a slot requires the channel to be\ndeactivated first via DELETE /api/v1/channels/{channel_id}; this is deliberate,\nso a slot is never freed as a side effect of an unrelated settings update.\n\nFields left out (or sent as null) are not changed, and the whole request is\napplied atomically: if the subscription change is rejected, the webhook settings\nare not updated either.","operationId":"update_channel_api_v1_channels__channel_id__patch","security":[{"ApiKeyAuth":[]},{"BearerAuth":[]}],"parameters":[{"name":"channel_id","in":"path","required":true,"schema":{"type":"string","title":"Channel Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChannelUpdateRequest"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChannelUpdateResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"delete":{"tags":["api"],"summary":"Deactivate channel","description":"Deactivate a channel (soft delete).\n\nThe channel stops sending and receiving, but is not erased — its channel_id,\nhistory and ownership claim are preserved so the same Fiwano account can\nreconnect it later via a new OAuth flow. Another Fiwano account cannot claim\nthe Meta identity after deactivation; ownership release requires support.\nFiwano unsubscribes the channel's Meta webhook resource only when safe:\na WABA subscription is kept if another active WhatsApp channel uses the same\nWABA, and a Page subscription is kept if another active Instagram/Facebook\nchannel uses the same Page.","operationId":"delete_channel_api_v1_channels__channel_id__delete","security":[{"ApiKeyAuth":[]},{"BearerAuth":[]}],"parameters":[{"name":"channel_id","in":"path","required":true,"schema":{"type":"string","title":"Channel Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/channels/setup-url":{"post":{"tags":["api"],"summary":"Create Setup Url","description":"Generate a URL for connecting or reconnecting a channel on behalf of a user.\n\nThe client opens the returned `setup_url` in a popup or browser. After the\nuser completes Meta OAuth (or WhatsApp Embedded Signup), they are redirected\nto `redirect_uri` with a one-time `code`. Exchange that code via\nPOST /api/v1/channels/exchange-code to obtain the channel_id.\n\n`redirect_uri` must already be whitelisted for this API key (add it via\nPOST /api/v1/redirects), otherwise the request is rejected. The setup URL is\nvalid until the `expires_at` returned in the response.\n\nThere is intentionally no separate API reconnect endpoint. When Meta returns\nthe identity of an existing channel of yours, setup updates that same\nchannel row and returns its existing channel_id: an inactive channel is\nreactivated, an active one gets its credentials refreshed in place (this is\nhow a channel that lost Meta access is repaired). A genuinely new eligible\nidentity is preferred when both new and inactive assets are available.\n\nRefused with 402 when the account has no active subscription, and with 409\n(`detail.code` = `no_free_slot`, `detail.occupied_by` = channel ids) when\nevery subscription slot of this type is already taken and none of the\noccupying channels can be reconnected through this flow.","operationId":"create_setup_url_api_v1_channels_setup_url_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SetupUrlRequest"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SetupUrlResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"ApiKeyAuth":[]},{"BearerAuth":[]}]}},"/api/v1/channels/exchange-code":{"post":{"tags":["api"],"summary":"Exchange Code","description":"Exchange a one-time completion code for channel data.\n\nAfter the user completes the OAuth flow, the redirect_uri receives a `code` parameter.\nThis endpoint exchanges that code for the channel_id and basic details.\n\nThe code is one-time use and expires after 5 minutes.","operationId":"exchange_code_api_v1_channels_exchange_code_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ExchangeCodeRequest"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ExchangeCodeResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"ApiKeyAuth":[]},{"BearerAuth":[]}]}},"/api/v1/channels/{channel_id}/profile/{user_id}":{"get":{"tags":["api"],"summary":"Get Sender Profile","description":"Fetch sender profile from Meta Graph API.\n\nReturns profile data for a user who messaged your channel.\nSuccessful results are cached for 5 minutes to reduce Meta API calls.\nUnavailable results are cached briefly so newly indexed conversations recover quickly.\n\n- Instagram: username, name, profile_pic, follower_count, is_verified_user\n- Facebook: display name in first_name; last_name and profile_pic when available\n- WhatsApp: not supported (name comes inline in webhooks via data.from_name)\n\nArgs:\n    channel_id: Channel ID\n    user_id: Sender identifier (IGSID for Instagram, PSID for Facebook)\n\nReturns:\n    SenderProfileResponse with profile data\n\nRaises:\n    HTTPException 404: Channel not found or WhatsApp (not supported)\n    HTTPException 400: Channel inactive or missing token\n    HTTPException 502: Meta API error","operationId":"get_sender_profile_api_v1_channels__channel_id__profile__user_id__get","security":[{"ApiKeyAuth":[]},{"BearerAuth":[]}],"parameters":[{"name":"channel_id","in":"path","required":true,"schema":{"type":"string","title":"Channel Id"}},{"name":"user_id","in":"path","required":true,"schema":{"type":"string","title":"User Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SenderProfileResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/redirects":{"get":{"tags":["api"],"summary":"List Redirects","description":"List the redirect URIs whitelisted for this API key.\n\nThese gate the programmatic channel-connection flow — the `redirect_uri` in\nPOST /api/v1/channels/setup-url must match one of these patterns.","operationId":"list_redirects_api_v1_redirects_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RedirectListResponse"}}}}},"security":[{"ApiKeyAuth":[]},{"BearerAuth":[]}]},"post":{"tags":["api"],"summary":"Add Redirect","description":"Add an allowed redirect URI.\n\nMust be HTTPS. Explicit ports are supported. Exact URIs are preferred;\nconstrained wildcard patterns like https://*.example.com/* remain supported.","operationId":"add_redirect_api_v1_redirects_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RedirectCreateRequest"}}},"required":true},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RedirectCreateResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"ApiKeyAuth":[]},{"BearerAuth":[]}]}},"/api/v1/redirects/{redirect_id}":{"delete":{"tags":["api"],"summary":"Remove Redirect","description":"Remove an allowed redirect URI.","operationId":"remove_redirect_api_v1_redirects__redirect_id__delete","security":[{"ApiKeyAuth":[]},{"BearerAuth":[]}],"parameters":[{"name":"redirect_id","in":"path","required":true,"schema":{"type":"string","title":"Redirect Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/messages/send":{"post":{"tags":["api"],"summary":"Send Message","description":"Send a text message through a connected channel.\n\nRecipient format is a phone number without `+` for WhatsApp, an IGSID for\nInstagram, and a PSID for Messenger. Text must be non-blank and stay within\nthe platform limit. Transient failures are queued for background retry;\npermanent errors return `success: false` and are not retried. Two caller\nmistakes are rejected before reaching Meta with `400` and a structured\ndetail: `invalid_recipient` (recipient empty, without digits, or not a\nnumeric PSID/IGSID on Instagram/Facebook; `reason` and `hint` included) and\n`recipient_equals_sender` (a WhatsApp send addressed to the channel's own\nnumber). Surrounding whitespace in `recipient` is trimmed.","operationId":"send_message_api_v1_messages_send_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SendMessageRequest"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SendMessageResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"ApiKeyAuth":[]},{"BearerAuth":[]}]}},"/api/v1/media/{media_id}":{"get":{"tags":["api"],"summary":"Download Media","description":"Download a media file previously received via webhook.\n\nRequires a Pro license. Files are temporary and expire after\nthe configured TTL (default 60 minutes).\n\nResponse: raw file bytes with appropriate Content-Type header.","operationId":"download_media_api_v1_media__media_id__get","security":[{"ApiKeyAuth":[]},{"BearerAuth":[]}],"parameters":[{"name":"media_id","in":"path","required":true,"schema":{"type":"string","title":"Media Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/messages/send-media":{"post":{"tags":["api"],"summary":"Send Media Message","description":"Send a media message through a connected Pro channel.\n\nMeta fetches `media_url` directly; Fiwano does not store the outbound file.\nUse a signed URL for non-public content and keep it valid for the retry\nwindow. Supported types are image, audio, video, document, and sticker\n(WhatsApp: WebP `media_url`; Facebook Messenger: `sticker_id`; Instagram:\nnot available — `400 invalid_media_request`). Transient failures are\nqueued; permanent payload or policy errors are not retried. `recipient`\nfollows the same preflight as the text endpoint: trimmed, then\n`400 invalid_recipient` / `recipient_equals_sender` before any Meta call.","operationId":"send_media_message_api_v1_messages_send_media_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SendMediaRequest"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SendMessageResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"ApiKeyAuth":[]},{"BearerAuth":[]}]}},"/api/v1/messages/send-interactive":{"post":{"tags":["api"],"summary":"Send Interactive Message","description":"Send buttons, cards, quick replies or a list through a connected Pro channel.\n\nOne request shape for every channel; each channel gets its native message\n(WhatsApp interactive message, Instagram/Messenger template or quick\nreplies). Only inside the 24-hour customer service window. A tap arrives as\n`message.received` of `type: \"text\"` with `button_id` = the `id` you set.\nCard images are downloaded by Meta during the call, like `send-media`.\nShapes the channel cannot send are refused with\n`400 invalid_interactive_request` (`reason`, `message`, `hint`) before Meta\nis called; `recipient` follows the text endpoint's preflight. Transient\nfailures are queued; permanent errors return `success: false`.","operationId":"send_interactive_message_api_v1_messages_send_interactive_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SendInteractiveRequest"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SendMessageResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"ApiKeyAuth":[]},{"BearerAuth":[]}]}},"/api/v1/channels/{channel_id}/templates":{"get":{"tags":["api"],"summary":"List Templates","description":"List message templates for a WhatsApp channel.\n\nStatuses are refreshed from Meta. `synced` is false when Meta could not be\nreached and the last known data is returned.\n\nTemplates are tied to the WhatsApp Business Account (WABA): every channel\nof the same WABA lists the same templates.","operationId":"list_templates_api_v1_channels__channel_id__templates_get","security":[{"ApiKeyAuth":[]},{"BearerAuth":[]}],"parameters":[{"name":"channel_id","in":"path","required":true,"schema":{"type":"string","title":"Channel Id"}},{"name":"sync","in":"query","required":false,"schema":{"type":"boolean","description":"Has no effect. Templates are refreshed from Meta automatically.","default":true,"title":"Sync"},"description":"Has no effect. Templates are refreshed from Meta automatically.","deprecated":true},{"name":"status","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Filter by status: APPROVED, PENDING, REJECTED, PAUSED, ...","title":"Status"},"description":"Filter by status: APPROVED, PENDING, REJECTED, PAUSED, ..."}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TemplateListResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"post":{"tags":["api"],"summary":"Create Template","description":"Create a new WhatsApp message template.\n\nThe template is submitted to Meta for review (status=PENDING).\nReview typically takes up to 24 hours.\n\nTemplate name must be lowercase alphanumeric with underscores.\nBODY component is required. HEADER (TEXT only), FOOTER, and BUTTONS are optional.\n\nVariables use {{1}}, {{2}} syntax (positional) or {{name}} (named).\nExample values are required for Meta review.\n\nRate limit: 100 templates created per WABA per hour.","operationId":"create_template_api_v1_channels__channel_id__templates_post","security":[{"ApiKeyAuth":[]},{"BearerAuth":[]}],"parameters":[{"name":"channel_id","in":"path","required":true,"schema":{"type":"string","title":"Channel Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TemplateCreateRequest"}}}},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TemplateOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/channels/{channel_id}/templates/{template_id}":{"get":{"tags":["api"],"summary":"Get Template","description":"Get a specific template by its ID.\n\nReturns the template refreshed from Meta (the last known data if Meta\ncannot be reached), including variable definitions with example values.","operationId":"get_template_api_v1_channels__channel_id__templates__template_id__get","security":[{"ApiKeyAuth":[]},{"BearerAuth":[]}],"parameters":[{"name":"channel_id","in":"path","required":true,"schema":{"type":"string","title":"Channel Id"}},{"name":"template_id","in":"path","required":true,"schema":{"type":"string","title":"Template Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TemplateOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"put":{"tags":["api"],"summary":"Update Template","description":"Update a template's components.\n\nAll components are replaced entirely — partial update is not supported by Meta.\n\nRestrictions:\n- Only APPROVED, REJECTED, or PAUSED templates can be edited\n- Approved templates: max 10 edits per 30 days, 1 per 24 hours\n- Cannot change category of an approved template\n\nAfter editing an approved template, it goes back to PENDING for re-review.","operationId":"update_template_api_v1_channels__channel_id__templates__template_id__put","security":[{"ApiKeyAuth":[]},{"BearerAuth":[]}],"parameters":[{"name":"channel_id","in":"path","required":true,"schema":{"type":"string","title":"Channel Id"}},{"name":"template_id","in":"path","required":true,"schema":{"type":"string","title":"Template Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TemplateUpdateRequest"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TemplateOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"delete":{"tags":["api"],"summary":"Delete Template","description":"Delete a message template.\n\nBy default, deletes only the specific language version.\nSet all_languages=true to delete ALL language versions of this template.\n\nWARNING: After deleting an approved template, you cannot create a template\nwith the same name for 30 days.","operationId":"delete_template_api_v1_channels__channel_id__templates__template_id__delete","security":[{"ApiKeyAuth":[]},{"BearerAuth":[]}],"parameters":[{"name":"channel_id","in":"path","required":true,"schema":{"type":"string","title":"Channel Id"}},{"name":"template_id","in":"path","required":true,"schema":{"type":"string","title":"Template Id"}},{"name":"all_languages","in":"query","required":false,"schema":{"type":"boolean","description":"Delete all language versions of this template, not just this one.","default":false,"title":"All Languages"},"description":"Delete all language versions of this template, not just this one."}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/messages/send-template":{"post":{"tags":["api"],"summary":"Send Template Message","description":"Send an approved WhatsApp template without automatic retry.\n\nVariables must match the cached template definition. Positional variables\nuse arrays such as `{\"body\": [\"Pablo\", \"ORD-123\"]}`; named variables use\nobjects such as `{\"body\": {\"customer_name\": \"Pablo\"}}`. `recipient` follows\nthe same preflight as the text endpoint: trimmed, then `400 invalid_recipient`\n/ `recipient_equals_sender` before any Meta call.","operationId":"send_template_message_api_v1_messages_send_template_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SendTemplateRequest"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SendMessageResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"ApiKeyAuth":[]},{"BearerAuth":[]}]}}},"components":{"schemas":{"AvailableSlotsByTier":{"properties":{"total":{"type":"integer","title":"Total","description":"Total free active slots for this channel type."},"starter":{"type":"integer","title":"Starter","description":"Free Starter subscription slots for this channel type."},"pro":{"type":"integer","title":"Pro","description":"Free Pro subscription slots for this channel type."}},"type":"object","required":["total","starter","pro"],"title":"AvailableSlotsByTier","description":"Free active subscription slots for one channel type."},"ChannelHealth":{"properties":{"status":{"type":"string","enum":["ok","action_required"],"title":"Status","description":"'ok', or 'action_required' when Meta no longer lets Fiwano work with this account or number (access or a permission revoked, number removed or not connected to the WhatsApp Business Platform, account blocked or number banned by Meta). The channel is not deactivated, but messages may fail until the owner fixes the cause — in Meta, or by running the connect flow again for the same account. Clears automatically once Meta's checks pass, and on reconnect."},"reason":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Reason","description":"Human-readable text, usually Meta's own error as '(#<code>) <text>'. Not a code: branch on `status`. Null when status is 'ok'."},"since":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Since","description":"ISO-8601 UTC timestamp when the problem was detected. Null when status is 'ok'."}},"type":"object","required":["status"],"title":"ChannelHealth","description":"Meta-side state of a channel: whether Meta still lets Fiwano work with the\naccount and number. Failures of individual messages are not reflected here —\nthey come in the send response and the `message.failed` webhook."},"ChannelListResponse":{"properties":{"channels":{"items":{"$ref":"#/components/schemas/ChannelOut"},"type":"array","title":"Channels"},"total":{"type":"integer","title":"Total"}},"type":"object","required":["channels","total"],"title":"ChannelListResponse","description":"List of channels."},"ChannelOut":{"properties":{"id":{"type":"string","title":"Id","description":"Channel ID. Use this value in every other channel/message API call."},"channel_type":{"type":"string","title":"Channel Type","description":"Channel type: 'whatsapp', 'instagram', or 'facebook'."},"name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Name","description":"Display name: business name (WhatsApp), username (Instagram), or Page name (Facebook)."},"is_active":{"type":"boolean","title":"Is Active","description":"False only after the channel was deactivated (DELETE, or its subscription ended). An active channel can still have a Meta-side problem — see `health`."},"health":{"$ref":"#/components/schemas/ChannelHealth","description":"Meta-side state of the channel."},"phone_number_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Phone Number Id","description":"WhatsApp only — Meta's phone number ID."},"phone_number":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Phone Number","description":"WhatsApp only — human-readable phone number."},"waba_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Waba Id","description":"WhatsApp only — WhatsApp Business Account (WABA) ID."},"quality_rating":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Quality Rating","description":"WhatsApp only — Meta's current quality rating for the number, when available."},"ig_account_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Ig Account Id","description":"Instagram only — Instagram account ID."},"ig_username":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Ig Username","description":"Instagram only — Instagram username."},"page_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Page Id","description":"Instagram/Facebook — linked Facebook Page ID."},"webhook_url":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Webhook Url","description":"Where incoming messages and delivery statuses are delivered."},"has_webhook_secret":{"type":"boolean","title":"Has Webhook Secret","description":"Whether a webhook secret is configured for HMAC signature verification.","default":false},"webhook_events":{"anyOf":[{"items":{"type":"string"},"type":"array"},{"type":"null"}],"title":"Webhook Events","description":"Enabled event types, e.g. [\"message.received\", \"message.delivered\"]."},"echo_statuses":{"type":"boolean","title":"Echo Statuses","description":"message.echo status mode: true = tracked (echoed external messages get a durable identity and their delivered/read/failed statuses are delivered per your webhook_events), false = relay-only (echo events without status tracking; the default). Has no effect until \"message.echo\" is enabled in webhook_events.","default":false},"connected_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Connected At","description":"ISO-8601 UTC timestamp when the channel was connected."},"created_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Created At","description":"ISO-8601 UTC timestamp when the channel record was first created."},"subscription":{"$ref":"#/components/schemas/SubscriptionInfo","description":"Current subscription/billing state. The channel can send/receive only while status='active'."}},"type":"object","required":["id","channel_type","is_active","health","subscription"],"title":"ChannelOut","description":"A connected channel — one WhatsApp number, Instagram account, or Facebook\nPage. Channel-type-specific fields are populated only for the relevant type\n(e.g. `phone_number_id`/`waba_id` for WhatsApp, `ig_username` for Instagram);\nthe rest are null."},"ChannelUpdateRequest":{"properties":{"webhook_url":{"anyOf":[{"type":"string","maxLength":500},{"type":"null"}],"title":"Webhook Url","description":"HTTPS URL for incoming webhook delivery. Explicit ports are supported."},"webhook_secret":{"anyOf":[{"type":"string","maxLength":64},{"type":"null"}],"title":"Webhook Secret","description":"Set a specific HMAC secret (max 64 characters; also use this to rotate to a new value). Omit to keep the current secret — except that setting webhook_url for the first time with no secret auto-generates one, returned in the response."},"webhook_events":{"anyOf":[{"items":{"type":"string"},"type":"array"},{"type":"null"}],"title":"Webhook Events","description":"List of event types to deliver. Available events depend on channel type."},"echo_statuses":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Echo Statuses","description":"message.echo status mode: true = tracked (echoed external messages get a durable identity and their delivered/read/failed statuses are delivered per your webhook_events), false = relay-only (echo events without status tracking; the default). Has no effect until \"message.echo\" is enabled in webhook_events."},"subscription_id":{"anyOf":[{"type":"string","maxLength":16},{"type":"null"}],"title":"Subscription Id","description":"Move the channel to another subscription, or release its subscription slot. Pass a subscription ID from GET /api/v1/subscriptions to bind the channel to it — allowed for an active or a deactivated channel, and the target subscription must be active with a free slot for this channel type. Pass an empty string (\"\") to unbind: this frees the slot so a different channel of the same type can be connected, and is allowed only for a channel already deactivated via DELETE /api/v1/channels/{channel_id}. Omit the field (or send null) to leave the current binding untouched. Note that moving a channel from a Pro to a Starter subscription immediately removes access to media and template sending, and that unbinding is effectively permanent: reconnecting that channel later requires a free slot again."}},"type":"object","title":"ChannelUpdateRequest","description":"Request to update channel settings."},"ChannelUpdateResponse":{"properties":{"id":{"type":"string","title":"Id"},"webhook_url":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Webhook Url"},"webhook_secret":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Webhook Secret","description":"The channel's webhook secret, returned only when this request set or changed it (auto-generated, or the value you passed). null when the secret was left as it was. It is never returned again — store it now; has_webhook_secret on GET tells whether one is configured."},"webhook_events":{"anyOf":[{"items":{"type":"string"},"type":"array"},{"type":"null"}],"title":"Webhook Events"},"echo_statuses":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Echo Statuses"},"subscription":{"anyOf":[{"$ref":"#/components/schemas/SubscriptionInfo"},{"type":"null"}],"description":"Subscription state of the channel after the update. Same shape as `subscription` on GET /api/v1/channels/{channel_id}."}},"type":"object","required":["id"],"title":"ChannelUpdateResponse","description":"Response after channel update."},"ExchangeCodeRequest":{"properties":{"code":{"type":"string","title":"Code","description":"One-time completion code from OAuth redirect"},"webhook_url":{"anyOf":[{"type":"string","maxLength":500},{"type":"null"}],"title":"Webhook Url","description":"HTTPS URL for incoming webhook delivery. Explicit ports are supported. If provided, webhook is configured automatically — no separate PATCH needed."},"webhook_secret":{"anyOf":[{"type":"string","maxLength":64},{"type":"null"}],"title":"Webhook Secret","description":"HMAC secret used to sign webhook deliveries (verify it via the X-Webhook-Signature header). Optional: if you set webhook_url without supplying this, Fiwano auto-generates a secret and returns it in the response. Pass your own value (max 64 characters) to use a specific secret instead."},"webhook_events":{"anyOf":[{"items":{"type":"string"},"type":"array"},{"type":"null"}],"title":"Webhook Events","description":"List of event types to deliver. Available events depend on channel type. If omitted, no events are delivered until configured."},"echo_statuses":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Echo Statuses","description":"message.echo status mode: true = tracked (echoed external messages get a durable identity and their delivered/read/failed statuses are delivered per your webhook_events), false = relay-only (echo events without status tracking; the default). Has no effect until \"message.echo\" is enabled in webhook_events."}},"type":"object","required":["code"],"title":"ExchangeCodeRequest","description":"Request to exchange completion code for channel data."},"ExchangeCodeResponse":{"properties":{"channel_id":{"type":"string","title":"Channel Id"},"channel_type":{"type":"string","title":"Channel Type"},"name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Name"},"phone_number_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Phone Number Id"},"phone_number":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Phone Number"},"ig_account_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Ig Account Id"},"ig_username":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Ig Username"},"page_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Page Id"},"webhook_url":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Webhook Url"},"webhook_secret":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Webhook Secret","description":"The channel's webhook secret, returned only when this call set or changed it (auto-generated, or the value you passed). null when the channel kept its existing secret, e.g. on reconnect. It is never returned again — store it now."},"webhook_events":{"anyOf":[{"items":{"type":"string"},"type":"array"},{"type":"null"}],"title":"Webhook Events"},"echo_statuses":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Echo Statuses"}},"type":"object","required":["channel_id","channel_type"],"title":"ExchangeCodeResponse","description":"Response with channel data after code exchange."},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"InteractiveButton":{"properties":{"type":{"type":"string","enum":["reply","url"],"title":"Type","description":"'reply' — tapping sends `title` back as a text message with `button_id` = `id`; 'url' — opens `url`, no webhook."},"title":{"type":"string","maxLength":20,"minLength":1,"title":"Title","description":"Button label, up to 20 characters"},"id":{"anyOf":[{"type":"string","maxLength":256,"minLength":1},{"type":"null"}],"title":"Id","description":"Reply buttons only: your identifier, returned as `button_id` when the user taps"},"url":{"anyOf":[{"type":"string","maxLength":2000},{"type":"null"}],"title":"Url","description":"URL buttons only: HTTPS link opened by the button"}},"type":"object","required":["type","title"],"title":"InteractiveButton","description":"One button: a reply the user taps, or a link that opens in the browser."},"InteractiveCard":{"properties":{"image_url":{"type":"string","maxLength":2048,"title":"Image Url","description":"HTTPS URL of a JPEG or PNG image; Meta downloads it while sending"},"title":{"type":"string","maxLength":80,"minLength":1,"title":"Title","description":"Card title, one line, up to 80 characters"},"subtitle":{"anyOf":[{"type":"string","maxLength":80},{"type":"null"}],"title":"Subtitle","description":"Second line, up to 80 characters"},"buttons":{"items":{"$ref":"#/components/schemas/InteractiveButton"},"type":"array","maxItems":3,"minItems":1,"title":"Buttons"}},"type":"object","required":["image_url","title","buttons"],"title":"InteractiveCard","description":"One card: picture, title, optional subtitle, 1–3 buttons."},"InteractiveList":{"properties":{"button":{"type":"string","maxLength":20,"minLength":1,"title":"Button","description":"Label of the button that opens the list"},"sections":{"items":{"$ref":"#/components/schemas/InteractiveListSection"},"type":"array","maxItems":10,"minItems":1,"title":"Sections"}},"type":"object","required":["button","sections"],"title":"InteractiveList","description":"WhatsApp list: a button that opens up to 10 rows in up to 10 sections."},"InteractiveListRow":{"properties":{"id":{"type":"string","maxLength":200,"minLength":1,"title":"Id","description":"Returned as `button_id` when the user picks the row"},"title":{"type":"string","maxLength":24,"minLength":1,"title":"Title"},"description":{"anyOf":[{"type":"string","maxLength":72},{"type":"null"}],"title":"Description"}},"type":"object","required":["id","title"],"title":"InteractiveListRow","description":"One selectable row of a WhatsApp list."},"InteractiveListSection":{"properties":{"title":{"type":"string","maxLength":24,"minLength":1,"title":"Title"},"rows":{"items":{"$ref":"#/components/schemas/InteractiveListRow"},"type":"array","maxItems":10,"minItems":1,"title":"Rows"}},"type":"object","required":["title","rows"],"title":"InteractiveListSection"},"InteractiveQuickReply":{"properties":{"id":{"type":"string","maxLength":256,"minLength":1,"title":"Id","description":"Returned as `button_id` when the user taps"},"title":{"type":"string","maxLength":20,"minLength":1,"title":"Title","description":"Chip label, up to 20 characters"}},"type":"object","required":["id","title"],"title":"InteractiveQuickReply","description":"One quick reply chip (Instagram / Messenger)."},"RedirectCreateRequest":{"properties":{"uri_pattern":{"type":"string","maxLength":500,"title":"Uri Pattern","description":"HTTPS redirect URI. Explicit ports are supported. Prefer an exact URI; wildcards are limited to paths, queries, or a complete left-most hostname label such as https://*.example.com/*"}},"type":"object","required":["uri_pattern"],"title":"RedirectCreateRequest","description":"Request to add redirect URI."},"RedirectCreateResponse":{"properties":{"id":{"type":"string","title":"Id"},"uri_pattern":{"type":"string","title":"Uri Pattern"}},"type":"object","required":["id","uri_pattern"],"title":"RedirectCreateResponse","description":"Response after creating redirect."},"RedirectListResponse":{"properties":{"redirects":{"items":{"$ref":"#/components/schemas/RedirectOut"},"type":"array","title":"Redirects"}},"type":"object","required":["redirects"],"title":"RedirectListResponse","description":"List of redirect URIs."},"RedirectOut":{"properties":{"id":{"type":"string","title":"Id"},"uri_pattern":{"type":"string","title":"Uri Pattern"},"created_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Created At"}},"type":"object","required":["id","uri_pattern"],"title":"RedirectOut","description":"Allowed redirect URI."},"SendInteractiveRequest":{"properties":{"channel_id":{"type":"string","title":"Channel Id","description":"Channel ID to send from"},"recipient":{"type":"string","maxLength":100,"title":"Recipient","description":"Recipient identifier"},"text":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Text","description":"Message text. Required with buttons, quick_replies and list; with cards — required on WhatsApp for 2+ cards, not accepted on Instagram/Messenger."},"buttons":{"anyOf":[{"items":{"$ref":"#/components/schemas/InteractiveButton"},"type":"array","maxItems":3,"minItems":1},{"type":"null"}],"title":"Buttons","description":"1–3 buttons under the text"},"cards":{"anyOf":[{"items":{"$ref":"#/components/schemas/InteractiveCard"},"type":"array","maxItems":10,"minItems":1},{"type":"null"}],"title":"Cards","description":"1–10 cards; 2+ scroll as a carousel"},"quick_replies":{"anyOf":[{"items":{"$ref":"#/components/schemas/InteractiveQuickReply"},"type":"array","maxItems":13,"minItems":1},{"type":"null"}],"title":"Quick Replies","description":"Instagram/Messenger: 1–13 chips that disappear after a tap"},"list":{"anyOf":[{"$ref":"#/components/schemas/InteractiveList"},{"type":"null"}],"description":"WhatsApp: a list of up to 10 rows"}},"type":"object","required":["channel_id","recipient"],"title":"SendInteractiveRequest","description":"Send a message the user answers with a tap. Requires a Pro license.\n\nExactly one of `buttons`, `cards`, `quick_replies` or `list`. Every\nchannel sends its native message; a shape the channel does not have is\nrefused with `400 invalid_interactive_request` before Meta is called:\n`quick_replies` are Instagram/Messenger only, `list` is WhatsApp only,\nWhatsApp sends either reply buttons or one url button (not a mix), and\nInstagram/Messenger cards carry no `text`."},"SendMediaRequest":{"properties":{"channel_id":{"type":"string","title":"Channel Id","description":"Channel ID to send from"},"recipient":{"type":"string","maxLength":100,"title":"Recipient","description":"Recipient identifier"},"media_type":{"type":"string","title":"Media Type","description":"Media type: image, audio, video, document, or sticker"},"media_url":{"anyOf":[{"type":"string","maxLength":2048},{"type":"null"}],"title":"Media Url","description":"HTTPS URL of the media file. For non-public content, use a signed URL (S3 presigned, GCS Signed, R2 signed, or HMAC). Max length 2048. Required for every media_type except a Facebook Messenger sticker."},"sticker_id":{"anyOf":[{"type":"string","maxLength":32},{"type":"null"}],"title":"Sticker Id","description":"Meta sticker id (digits) — Facebook Messenger only, with media_type 'sticker' instead of media_url. A catalog sticker or 369239263222822 (thumbs up); reuse media.sticker_id from an inbound event."},"caption":{"anyOf":[{"type":"string","maxLength":1024},{"type":"null"}],"title":"Caption","description":"Caption (WhatsApp image/video/document)"},"filename":{"anyOf":[{"type":"string","maxLength":255},{"type":"null"}],"title":"Filename","description":"Filename (WhatsApp document only)"}},"type":"object","required":["channel_id","recipient","media_type"],"title":"SendMediaRequest","description":"Request to send a media message. Requires a Pro license.\n\nMeta fetches the file directly from `media_url`. For non-public\ncontent, use a signed URL — presigned S3, GCS Signed URL, Cloudflare\nR2 signed URL, or HMAC-signed URL on your own server. Public URLs\nare accessible to anyone who learns them; only use them for\nnon-sensitive content.\n\nUse image, audio, video, or document across all supported channels.\nProvider-specific attachment names are handled internally.\n\n`sticker` is channel-specific: WhatsApp takes a WebP `media_url`,\nFacebook Messenger takes a Meta catalog `sticker_id` instead of a URL,\nInstagram has no sticker message. Which field is required is decided\nagainst the channel in the send preflight (`400 invalid_media_request`);\nthe schema only checks that exactly one of them is given."},"SendMessageRequest":{"properties":{"channel_id":{"type":"string","title":"Channel Id","description":"Channel ID to send from"},"recipient":{"type":"string","maxLength":100,"title":"Recipient","description":"Recipient identifier (phone number for WhatsApp, IGSID for Instagram, PSID for Facebook)"},"text":{"type":"string","minLength":1,"title":"Text","description":"Message text containing at least one non-whitespace character"}},"type":"object","required":["channel_id","recipient","text"],"title":"SendMessageRequest","description":"Request to send a message. Only text messages are supported."},"SendMessageResponse":{"properties":{"success":{"type":"boolean","title":"Success"},"message_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Message Id"},"error":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Error","description":"Readable reason for a failed send: Meta's text, plus a Fiwano hint where Meta's text does not explain the problem."},"error_code":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Error Code","description":"Meta's error code, unchanged, when Meta rejected the send (https://fiwano.com/documentation/errors#send-error-codes). Null for 'sent'/'queued' and for a failure without a Meta error (network, Meta 5xx without a body)."},"status":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Status","description":"Delivery state: 'sent' (accepted by Meta), 'queued' (Fiwano is completing the send in the background after a temporary Meta failure on text/media or a slow Meta response on any send; the outcome follows as webhooks), or 'failed' (not sent and not retried; see error/error_code)."}},"type":"object","required":["success"],"title":"SendMessageResponse","description":"Response after sending a message."},"SendTemplateRequest":{"properties":{"channel_id":{"type":"string","title":"Channel Id","description":"WhatsApp channel ID to send from"},"template_name":{"type":"string","title":"Template Name","description":"Template name (e.g., 'order_confirmation')"},"language":{"type":"string","title":"Language","description":"Template language code (e.g., 'en_US')"},"recipient":{"type":"string","maxLength":100,"title":"Recipient","description":"Recipient phone number (without +, e.g., '1234567890')"},"variables":{"anyOf":[{"type":"object"},{"type":"null"}],"title":"Variables","description":"Variable values keyed by component type. Positional: {\"header\": [\"Sale\"], \"body\": [\"Pablo\", \"ORD-123\"], \"buttons\": [{\"index\": 0, \"value\": \"promo\"}]}. Buttons: `value` fills a URL or copy-code button's variable; `id` (optional, quick-reply buttons only, up to 256 characters) is returned as `button_id` when the user taps the button — without it `button_id` is the button text. Named: {\"body\": {\"customer_name\": \"Pablo\", \"order_number\": \"ORD-123\"}}. Authentication: {\"body\": [\"123456\"]} — the code also fills the copy-code button. Omit if template has no variables."},"header_media_url":{"anyOf":[{"type":"string","maxLength":2048},{"type":"null"}],"title":"Header Media Url","description":"HTTPS URL of the header image, video or document — required when the template header is media (see variables.header_media), not allowed otherwise. Meta downloads the file, as in send-media."}},"type":"object","required":["channel_id","template_name","language","recipient"],"title":"SendTemplateRequest","description":"Request to send a WhatsApp template message.\n\nVariables must match the template's parameter definitions.\nOnly APPROVED templates can be sent.\n\nFor positional templates, provide variables as arrays:\n    {\"body\": [\"Pablo\", \"ORD-123\"]}\n\nFor named templates, provide variables as objects:\n    {\"body\": {\"customer_name\": \"Pablo\", \"order_number\": \"ORD-123\"}}"},"SenderProfileResponse":{"properties":{"channel_id":{"type":"string","title":"Channel Id"},"channel_type":{"type":"string","title":"Channel Type"},"user_id":{"type":"string","title":"User Id"},"profile":{"anyOf":[{"type":"object"},{"type":"null"}],"title":"Profile","description":"Profile data from Meta, normalized and minimized by channel type. null if profile is unavailable. Instagram: username, name, profile_pic, follower_count, is_verified_user. Facebook: display name in first_name; last_name and profile_pic when available from Meta. WhatsApp is not supported.","examples":[{"follower_count":46,"is_verified_user":false,"name":"Roman Babakin","profile_pic":"https://scontent.cdninstagram.com/v/t51.2885-19/...","username":"winnerzzz"},{"first_name":"Roman","last_name":"Babakin","profile_pic":"https://platform-lookaside.fbsbx.com/platform/profilepic/..."}]},"cached":{"type":"boolean","title":"Cached","description":"Whether the result was served from cache","default":false}},"type":"object","required":["channel_id","channel_type","user_id"],"title":"SenderProfileResponse","description":"Sender profile from Meta Graph API."},"SetupUrlRequest":{"properties":{"channel_type":{"type":"string","pattern":"^(whatsapp|instagram|facebook)$","title":"Channel Type","description":"Channel type: whatsapp, instagram, or facebook"},"redirect_uri":{"type":"string","maxLength":500,"title":"Redirect Uri","description":"Exact HTTPS URL to redirect after OAuth completion. Explicit ports are supported. Must match allowed_redirects."}},"type":"object","required":["channel_type","redirect_uri"],"title":"SetupUrlRequest","description":"Request to generate channel setup URL."},"SetupUrlResponse":{"properties":{"setup_url":{"type":"string","title":"Setup Url","description":"URL to open in popup/browser for channel setup"},"session_id":{"type":"string","title":"Session Id"},"expires_at":{"type":"string","title":"Expires At"}},"type":"object","required":["setup_url","session_id","expires_at"],"title":"SetupUrlResponse","description":"Response with channel setup URL."},"SubscriptionAssignedChannel":{"properties":{"channel_id":{"type":"string","title":"Channel Id","description":"Fiwano channel ID assigned to this subscription."},"channel_type":{"type":"string","title":"Channel Type","description":"Channel type: whatsapp, instagram, or facebook."},"name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Name","description":"Human-readable channel name when available."},"is_active":{"type":"boolean","title":"Is Active","description":"Whether the bound channel is currently active."}},"type":"object","required":["channel_id","channel_type","is_active"],"title":"SubscriptionAssignedChannel","description":"Channel currently assigned to this subscription for one channel type.\n\nAn inactive channel still occupies its slot while it remains bound to an\nactive subscription. This preserves the owner's reconnect path and matches\nthe billing gate used by channel setup."},"SubscriptionInfo":{"properties":{"id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Id","description":"Subscription ID this channel is bound to — the same value as `subscriptions[].id` in GET /api/v1/subscriptions. Pass it back in PATCH /api/v1/channels/{channel_id} to move the channel between subscriptions. Null when status='none'."},"status":{"type":"string","title":"Status","description":"Subscription status: 'active', 'expired', 'canceled', or 'none' (no license bound — channel cannot send/receive messages)."},"source":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Source","description":"Origin of the license: 'trial' (auto-created on signup), 'paddle' (paid subscription), or 'enterprise' (admin-granted custom subscription). Null when status='none'."},"tier":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Tier","description":"License tier: 'starter' or 'pro'. Null when status='none'."},"expires_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Expires At","description":"ISO-8601 UTC timestamp when the current billing period / license ends. Null when status='none' or for perpetual enterprise licenses."},"auto_renew":{"type":"boolean","title":"Auto Renew","description":"True only for an active Paddle subscription that is set to renew automatically at `expires_at`. False for trial, enterprise, or any Paddle subscription where the user has scheduled/performed a cancellation.","default":false}},"type":"object","required":["status"],"title":"SubscriptionInfo","description":"Subscription/license state for a channel.\n\nAlways present on ChannelOut. When the channel is not bound to any license\n(orphaned after expiry/cancellation, or briefly between connect and\nauto-assign), `status` is `\"none\"` and all other fields are null/false.\n\n`expires_at` is `null` when no license is bound; in normal operation\nevery active license (trial / Paddle / Enterprise) carries an explicit\nexpiration date. (The schema still permits `NULL` for legacy admin-\ngranted rows — clients should treat that as \"no announced end date\".)\n\n`auto_renew` is `true` only for an active Paddle subscription with no\nscheduled cancellation. Once the user cancels in Paddle (or the\nsubscription enters a non-renewing state) it flips to `false` and the\nlicense will lapse at `expires_at` unless resumed."},"SubscriptionOut":{"properties":{"id":{"type":"string","title":"Id","description":"Fiwano subscription ID."},"status":{"type":"string","title":"Status","description":"Subscription status: active, expired, or canceled."},"source":{"type":"string","title":"Source","description":"Origin: trial, paddle, or enterprise."},"tier":{"type":"string","title":"Tier","description":"Subscription tier: starter or pro."},"starts_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Starts At","description":"ISO-8601 UTC timestamp when the subscription started."},"expires_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Expires At","description":"ISO-8601 UTC timestamp when the current period ends. Treat status as the source of truth for operability; Paddle grace can leave an active subscription with expires_at in the past."},"auto_renew":{"type":"boolean","title":"Auto Renew","description":"True only for an active Paddle subscription set to renew automatically.","default":false},"assigned_channels":{"additionalProperties":{"anyOf":[{"$ref":"#/components/schemas/SubscriptionAssignedChannel"},{"type":"null"}]},"type":"object","title":"Assigned Channels","description":"Channels assigned to this subscription by channel type. Values are null when no channel is assigned for that type. Use top-level available_slots for current connection availability."}},"type":"object","required":["id","status","source","tier","assigned_channels"],"title":"SubscriptionOut","description":"A Fiwano subscription/license and its channel-slot availability.\n\nPublic API uses the product term \"subscription\"; internally this maps to a\nLicense row. One subscription grants one slot for each channel type."},"SubscriptionsResponse":{"properties":{"subscriptions":{"items":{"$ref":"#/components/schemas/SubscriptionOut"},"type":"array","title":"Subscriptions"},"total":{"type":"integer","title":"Total","description":"Total number of subscriptions returned."},"active_total":{"type":"integer","title":"Active Total","description":"Number of currently active subscriptions."},"available_slots":{"additionalProperties":{"$ref":"#/components/schemas/AvailableSlotsByTier"},"type":"object","title":"Available Slots","description":"Free active subscription slots by channel type, split by tier. `total` is the sum of Starter and Pro free slots."}},"type":"object","required":["subscriptions","total","active_total","available_slots"],"title":"SubscriptionsResponse","description":"Subscriptions and aggregate slot availability for the authenticated user."},"TemplateComponentInput":{"properties":{"type":{"type":"string","title":"Type","description":"Component type: HEADER, BODY, FOOTER, BUTTONS"},"format":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Format","description":"Header format: TEXT (media not yet supported)"},"text":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Text","description":"Component text. Use {{1}}, {{2}} for positional or {{name}} for named variables"},"example":{"anyOf":[{"type":"object"},{"type":"null"}],"title":"Example","description":"Example values for variables (required by Meta for review)"},"buttons":{"anyOf":[{"items":{"type":"object"},"type":"array"},{"type":"null"}],"title":"Buttons","description":"Button definitions (for BUTTONS component)"},"add_security_recommendation":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Add Security Recommendation","description":"AUTHENTICATION BODY only: add Meta's 'do not share this code' note."},"code_expiration_minutes":{"anyOf":[{"type":"integer","maximum":90.0,"minimum":1.0},{"type":"null"}],"title":"Code Expiration Minutes","description":"AUTHENTICATION FOOTER only: show 'This code expires in N minutes' (1–90)."}},"type":"object","required":["type"],"title":"TemplateComponentInput","description":"A single template component for creation/update.\n\nComponents define the structure of a WhatsApp message template."},"TemplateCreateRequest":{"properties":{"name":{"type":"string","maxLength":512,"pattern":"^[a-z0-9_]+$","title":"Name","description":"Template name. Lowercase alphanumeric and underscores only. Max 512 chars."},"category":{"type":"string","pattern":"^(MARKETING|UTILITY|AUTHENTICATION)$","title":"Category","description":"Template category: MARKETING, UTILITY, or AUTHENTICATION"},"language":{"type":"string","title":"Language","description":"Language code (e.g., en_US, ru, es)"},"components":{"items":{"$ref":"#/components/schemas/TemplateComponentInput"},"type":"array","title":"Components","description":"Template components (HEADER, BODY, FOOTER, BUTTONS). BODY is required."},"parameter_format":{"type":"string","pattern":"^(positional|named)$","title":"Parameter Format","description":"Variable format: 'positional' for {{1}}, {{2}} or 'named' for {{customer_name}}","default":"positional"},"message_send_ttl_seconds":{"anyOf":[{"type":"integer","minimum":1.0},{"type":"null"}],"title":"Message Send Ttl Seconds","description":"How long Meta keeps trying to deliver a message sent with this template, in seconds (Meta's allowed range depends on the category)."}},"type":"object","required":["name","category","language","components"],"title":"TemplateCreateRequest","description":"Request to create a WhatsApp message template.\n\nThe template will be submitted to Meta for review (status=PENDING).\nReview typically takes up to 24 hours."},"TemplateListResponse":{"properties":{"templates":{"items":{"$ref":"#/components/schemas/TemplateOut"},"type":"array","title":"Templates"},"total":{"type":"integer","title":"Total"},"synced":{"type":"boolean","title":"Synced","default":false}},"type":"object","required":["templates","total"],"title":"TemplateListResponse","description":"List of templates."},"TemplateOut":{"properties":{"id":{"type":"string","title":"Id"},"meta_template_id":{"type":"string","title":"Meta Template Id"},"name":{"type":"string","title":"Name"},"language":{"type":"string","title":"Language"},"category":{"type":"string","title":"Category"},"status":{"type":"string","title":"Status"},"rejected_reason":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Rejected Reason","description":"Meta's reason when status is REJECTED (e.g. INVALID_FORMAT, PROMOTIONAL, TAG_CONTENT_MISMATCH). Null otherwise."},"quality_score":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Quality Score","description":"Meta's quality rating: GREEN, YELLOW, RED or UNKNOWN. Null if not reported."},"components":{"items":{},"type":"array","title":"Components"},"parameter_format":{"type":"string","title":"Parameter Format","default":"positional"},"variables":{"anyOf":[{"$ref":"#/components/schemas/TemplateVariablesSummary"},{"type":"null"}]},"synced_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Synced At"},"created_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Created At"}},"type":"object","required":["id","meta_template_id","name","language","category","status","components"],"title":"TemplateOut","description":"Template data returned by API."},"TemplateUpdateRequest":{"properties":{"components":{"items":{"$ref":"#/components/schemas/TemplateComponentInput"},"type":"array","title":"Components","description":"New components (replaces all existing)"},"category":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Category","description":"New category (only for REJECTED or PAUSED templates)"}},"type":"object","required":["components"],"title":"TemplateUpdateRequest","description":"Request to update a template's components.\n\nAll components are replaced entirely (partial update not supported by Meta).\nApproved templates: max 10 edits per 30 days, 1 per 24 hours."},"TemplateVariableInfo":{"properties":{"position":{"type":"integer","title":"Position"},"name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Name"},"example":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Example"}},"type":"object","required":["position"],"title":"TemplateVariableInfo","description":"Variable info for display/documentation."},"TemplateVariablesSummary":{"properties":{"total_count":{"type":"integer","title":"Total Count","default":0},"parameter_format":{"type":"string","title":"Parameter Format","default":"positional"},"header_media":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Header Media","description":"'image', 'video' or 'document' when the header is media: send it with header_media_url. Null otherwise."},"header":{"anyOf":[{"items":{"$ref":"#/components/schemas/TemplateVariableInfo"},"type":"array"},{"type":"null"}],"title":"Header"},"body":{"anyOf":[{"items":{"$ref":"#/components/schemas/TemplateVariableInfo"},"type":"array"},{"type":"null"}],"title":"Body"},"buttons":{"anyOf":[{"items":{"type":"object"},"type":"array"},{"type":"null"}],"title":"Buttons"}},"type":"object","title":"TemplateVariablesSummary","description":"Summary of all variables in a template."},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"}},"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","description":"API key in the format mip_live_xxx. Create one on the API Keys page in the portal.","in":"header","name":"X-API-Key"},"BearerAuth":{"type":"http","description":"The same API key sent as `Authorization: Bearer mip_live_xxx`. Used only when `X-API-Key` is absent.","scheme":"bearer"}}}}