{"openapi":"3.1.0","info":{"title":"Wataki API","version":"1.0.0","description":"Wataki is a programmable messaging platform centered on WhatsApp using the Baileys connection.\nThis spec defines the full HTTP API surface for managing WhatsApp instances, sending messages,\nhandling media, and receiving webhooks for inbound messages and delivery events.\n"},"servers":[{"url":"https://api.wataki.example.com"}],"security":[{"ApiKeyAuth":[]}],"x-rate-limits":{"default":{"limit":60,"window":60,"unit":"second"},"burst":{"limit":300,"window":60,"unit":"second"}},"tags":[{"name":"Auth"},{"name":"Instances"},{"name":"Messages"},{"name":"Media"},{"name":"Webhooks"},{"name":"Chats"},{"name":"Groups"},{"name":"Presence"},{"name":"Receipts"},{"name":"Billing"},{"name":"Observability"}],"paths":{"/v1/auth/signup":{"post":{"tags":["Auth"],"summary":"Sign up a new tenant","security":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SignupRequest"}}}},"responses":{"201":{"description":"Tenant created with API key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SignupResponse"}}}},"409":{"description":"Email already exists"}}}},"/v1/auth/me":{"get":{"tags":["Auth"],"summary":"Get current tenant info","responses":{"200":{"description":"Tenant details","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Tenant"}}}}}}},"/v1/auth/api-keys":{"get":{"tags":["Auth"],"summary":"List API keys (prefix only)","responses":{"200":{"description":"API key list","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiKeyList"}}}}}},"post":{"tags":["Auth"],"summary":"Create an additional API key","requestBody":{"required":false,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiKeyCreateRequest"}}}},"responses":{"201":{"description":"API key created (raw key returned once)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiKeyCreateResponse"}}}}}}},"/v1/auth/api-keys/{key_id}":{"delete":{"tags":["Auth"],"summary":"Revoke an API key","parameters":[{"$ref":"#/components/parameters/ApiKeyId"}],"responses":{"204":{"description":"API key revoked"}}}},"/health":{"get":{"summary":"Health check","security":[],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string"},"uptime_s":{"type":"integer"},"checks":{"type":"object","additionalProperties":true}}}}}},"503":{"description":"Degraded"}}}},"/v1/instances":{"get":{"tags":["Instances"],"summary":"List WhatsApp instances","parameters":[{"$ref":"#/components/parameters/Limit"},{"$ref":"#/components/parameters/Cursor"}],"responses":{"200":{"description":"A page of instances","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InstanceList"}}}}}},"post":{"tags":["Instances"],"summary":"Create a WhatsApp instance","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/InstanceCreateRequest"}}}},"responses":{"201":{"description":"Instance created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Instance"}}}}}}},"/v1/instances/{instance_id}":{"get":{"tags":["Instances"],"summary":"Get an instance","parameters":[{"$ref":"#/components/parameters/InstanceId"}],"responses":{"200":{"description":"Instance details","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Instance"}}}}}},"patch":{"tags":["Instances"],"summary":"Update an instance","parameters":[{"$ref":"#/components/parameters/InstanceId"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/InstanceUpdateRequest"}}}},"responses":{"200":{"description":"Instance updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Instance"}}}}}},"delete":{"tags":["Instances"],"summary":"Delete an instance","parameters":[{"$ref":"#/components/parameters/InstanceId"}],"responses":{"204":{"description":"Instance deleted"}}}},"/v1/instances/{instance_id}/connect":{"post":{"tags":["Instances"],"summary":"Start WhatsApp connection and return QR (if needed)","parameters":[{"$ref":"#/components/parameters/InstanceId"}],"responses":{"200":{"description":"Connection status","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectResponse"}}}}}}},"/v1/instances/{instance_id}/status":{"get":{"tags":["Instances"],"summary":"Get current connection status","parameters":[{"$ref":"#/components/parameters/InstanceId"}],"responses":{"200":{"description":"Status","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InstanceStatus"}}}}}}},"/v1/instances/{instance_id}/disconnect":{"post":{"tags":["Instances"],"summary":"Disconnect WhatsApp session","parameters":[{"$ref":"#/components/parameters/InstanceId"}],"responses":{"200":{"description":"Disconnected","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InstanceStatus"}}}}}}},"/v1/instances/{instance_id}/chats":{"get":{"tags":["Chats"],"summary":"List chats","parameters":[{"$ref":"#/components/parameters/InstanceId"},{"$ref":"#/components/parameters/Limit"},{"$ref":"#/components/parameters/Cursor"}],"responses":{"200":{"description":"A page of chats","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChatList"}}}}}}},"/v1/instances/{instance_id}/chats/{chat_id}":{"get":{"tags":["Chats"],"summary":"Get chat metadata","parameters":[{"$ref":"#/components/parameters/InstanceId"},{"$ref":"#/components/parameters/ChatId"}],"responses":{"200":{"description":"Chat details","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Chat"}}}}}}},"/v1/instances/{instance_id}/groups":{"get":{"tags":["Groups"],"summary":"List groups","parameters":[{"$ref":"#/components/parameters/InstanceId"},{"$ref":"#/components/parameters/Limit"},{"$ref":"#/components/parameters/Cursor"}],"responses":{"200":{"description":"A page of groups","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GroupList"}}}}}}},"/v1/instances/{instance_id}/messages":{"get":{"tags":["Messages"],"summary":"List messages in a chat","parameters":[{"$ref":"#/components/parameters/InstanceId"},{"$ref":"#/components/parameters/ChatIdQuery"},{"$ref":"#/components/parameters/Limit"},{"$ref":"#/components/parameters/Cursor"}],"responses":{"200":{"description":"A page of messages","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessageList"}}}}}},"post":{"tags":["Messages"],"summary":"Send a message","parameters":[{"$ref":"#/components/parameters/InstanceId"},{"$ref":"#/components/parameters/IdempotencyKey"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessageSendRequest"}}}},"responses":{"202":{"description":"Message accepted","headers":{"X-Quota-Used":{"schema":{"type":"integer"},"description":"Outbound messages sent in current billing cycle"},"X-Quota-Remaining":{"schema":{"type":"integer"},"description":"Outbound messages remaining in current billing cycle"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Message"}}}},"402":{"description":"Message quota exceeded","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/instances/{instance_id}/messages/{message_id}":{"get":{"tags":["Messages"],"summary":"Get message by id","parameters":[{"$ref":"#/components/parameters/InstanceId"},{"$ref":"#/components/parameters/MessageId"}],"responses":{"200":{"description":"Message","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Message"}}}}}}},"/v1/instances/{instance_id}/messages/{message_id}/react":{"post":{"tags":["Messages"],"summary":"React to a message","parameters":[{"$ref":"#/components/parameters/InstanceId"},{"$ref":"#/components/parameters/MessageId"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReactionRequest"}}}},"responses":{"202":{"description":"Reaction accepted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Message"}}}}}}},"/v1/instances/{instance_id}/messages/{message_id}/read":{"post":{"tags":["Receipts"],"summary":"Mark a message as read","parameters":[{"$ref":"#/components/parameters/InstanceId"},{"$ref":"#/components/parameters/MessageId"}],"responses":{"202":{"description":"Read receipt accepted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Receipt"}}}}}}},"/v1/instances/{instance_id}/presence":{"post":{"tags":["Presence"],"summary":"Update typing/presence for a chat","parameters":[{"$ref":"#/components/parameters/InstanceId"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PresenceRequest"}}}},"responses":{"202":{"description":"Presence accepted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Presence"}}}}}}},"/v1/instances/{instance_id}/media":{"post":{"tags":["Media"],"summary":"Upload media","parameters":[{"$ref":"#/components/parameters/InstanceId"}],"requestBody":{"required":true,"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/MediaUploadRequest"}}}},"responses":{"201":{"description":"Media created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MediaObject"}}}}}}},"/v1/instances/{instance_id}/media/{media_id}":{"get":{"tags":["Media"],"summary":"Get media metadata","parameters":[{"$ref":"#/components/parameters/InstanceId"},{"$ref":"#/components/parameters/MediaId"}],"responses":{"200":{"description":"Media metadata","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MediaObject"}}}}}}},"/v1/instances/{instance_id}/media/{media_id}/content":{"get":{"tags":["Media"],"summary":"Download media content","parameters":[{"$ref":"#/components/parameters/InstanceId"},{"$ref":"#/components/parameters/MediaId"}],"responses":{"200":{"description":"Media content","content":{"application/octet-stream":{"schema":{"type":"string","format":"binary"}}}},"404":{"description":"Media not found"}}}},"/v1/instances/{instance_id}/webhooks":{"get":{"tags":["Webhooks"],"summary":"List webhooks","parameters":[{"$ref":"#/components/parameters/InstanceId"}],"responses":{"200":{"description":"Webhook list","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookList"}}}}}},"post":{"tags":["Webhooks"],"summary":"Create a webhook endpoint","parameters":[{"$ref":"#/components/parameters/InstanceId"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookCreateRequest"}}}},"responses":{"201":{"description":"Webhook created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Webhook"}}}}}}},"/v1/instances/{instance_id}/webhooks/{webhook_id}":{"patch":{"tags":["Webhooks"],"summary":"Update a webhook endpoint","parameters":[{"$ref":"#/components/parameters/InstanceId"},{"$ref":"#/components/parameters/WebhookId"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookUpdateRequest"}}}},"responses":{"200":{"description":"Webhook updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Webhook"}}}}}},"delete":{"tags":["Webhooks"],"summary":"Delete a webhook endpoint","parameters":[{"$ref":"#/components/parameters/InstanceId"},{"$ref":"#/components/parameters/WebhookId"}],"responses":{"204":{"description":"Webhook deleted"}}}},"/v1/billing/checkout-sessions":{"post":{"tags":["Billing"],"summary":"Create a billing checkout session","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BillingCheckoutSessionRequest"}}}},"responses":{"201":{"description":"Checkout session created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BillingCheckoutSession"}}}},"503":{"description":"Payments not configured"}}}},"/v1/billing/checkout-sessions/{session_id}":{"get":{"tags":["Billing"],"summary":"Get a billing checkout session","parameters":[{"$ref":"#/components/parameters/BillingSessionId"}],"responses":{"200":{"description":"Checkout session","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BillingCheckoutSession"}}}},"404":{"description":"Not found"}}}},"/v1/billing/plans":{"get":{"tags":["Billing"],"summary":"List available billing plans","security":[],"responses":{"200":{"description":"All available plan tiers","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BillingPlans"}}}}}}},"/v1/billing/usage":{"get":{"tags":["Billing"],"summary":"Get current billing usage for the authenticated tenant","responses":{"200":{"description":"Plan info, billing cycle, and usage stats","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BillingUsage"}}}}}}},"/v1/billing/upgrade":{"post":{"tags":["Billing"],"summary":"Upgrade to a paid plan","description":"Creates a Dodo checkout session for the selected plan and returns the checkout URL.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["plan"],"properties":{"plan":{"type":"string","enum":["growth","scale"]}}}}}},"responses":{"201":{"description":"Checkout session created for upgrade","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BillingUpgradeResponse"}}}},"409":{"description":"Already on the requested plan"},"503":{"description":"Payments not configured"}}}},"/v1/observability/overview":{"get":{"tags":["Observability"],"summary":"Get combined observability overview","parameters":[{"$ref":"#/components/parameters/Since"},{"$ref":"#/components/parameters/Until"},{"$ref":"#/components/parameters/Bucket"}],"responses":{"200":{"description":"Combined snapshot of messages, instances, webhooks, API usage","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ObservabilityOverview"}}}}}}},"/v1/observability/messages":{"get":{"tags":["Observability"],"summary":"Get message statistics and time series","parameters":[{"$ref":"#/components/parameters/Since"},{"$ref":"#/components/parameters/Until"},{"$ref":"#/components/parameters/Bucket"},{"$ref":"#/components/parameters/ObsInstanceId"}],"responses":{"200":{"description":"Message stats and time series","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ObservabilityMessageStats"}}}}}}},"/v1/observability/webhooks":{"get":{"tags":["Observability"],"summary":"Get webhook delivery stats, time series, and recent failures","parameters":[{"$ref":"#/components/parameters/Since"},{"$ref":"#/components/parameters/Until"},{"$ref":"#/components/parameters/Bucket"}],"responses":{"200":{"description":"Webhook delivery stats","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ObservabilityWebhookStats"}}}}}}},"/v1/observability/api-usage":{"get":{"tags":["Observability"],"summary":"Get API usage stats and time series","parameters":[{"$ref":"#/components/parameters/Since"},{"$ref":"#/components/parameters/Until"},{"$ref":"#/components/parameters/Bucket"}],"responses":{"200":{"description":"API usage stats","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ObservabilityApiUsage"}}}}}}},"/v1/observability/instances":{"get":{"tags":["Observability"],"summary":"Get per-instance health summary","responses":{"200":{"description":"Instance health list","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ObservabilityInstanceHealthList"}}}}}}},"/v1/observability/errors":{"get":{"tags":["Observability"],"summary":"Get error summary across all categories","parameters":[{"$ref":"#/components/parameters/Since"},{"$ref":"#/components/parameters/Until"}],"responses":{"200":{"description":"Error summary","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ObservabilityErrors"}}}}}}},"/v1/billing/webhooks/dodo":{"post":{"tags":["Billing"],"summary":"Dodo Payments webhook receiver","security":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"responses":{"200":{"description":"OK"},"401":{"description":"Invalid signature"}}}}},"webhooks":{"message.received":{"post":{"summary":"Inbound message received","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookMessageReceived"}}}},"responses":{"200":{"description":"OK"}}}},"message.status":{"post":{"summary":"Delivery or failure status update","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookMessageStatus"}}}},"responses":{"200":{"description":"OK"}}}},"message.reaction":{"post":{"summary":"Message reaction received","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookMessageReaction"}}}},"responses":{"200":{"description":"OK"}}}},"message.read":{"post":{"summary":"Message read receipt","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookMessageRead"}}}},"responses":{"200":{"description":"OK"}}}},"connection.update":{"post":{"summary":"Connection status update","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookConnectionUpdate"}}}},"responses":{"200":{"description":"OK"}}}},"qr.updated":{"post":{"summary":"New QR code available","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookQrUpdated"}}}},"responses":{"200":{"description":"OK"}}}}},"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"X-API-Key"}},"parameters":{"InstanceId":{"name":"instance_id","in":"path","required":true,"schema":{"type":"string"}},"ChatId":{"name":"chat_id","in":"path","required":true,"schema":{"type":"string"}},"ChatIdQuery":{"name":"chat_id","in":"query","required":true,"schema":{"type":"string"}},"MessageId":{"name":"message_id","in":"path","required":true,"schema":{"type":"string"}},"MediaId":{"name":"media_id","in":"path","required":true,"schema":{"type":"string"}},"WebhookId":{"name":"webhook_id","in":"path","required":true,"schema":{"type":"string"}},"BillingSessionId":{"name":"session_id","in":"path","required":true,"schema":{"type":"string"}},"Limit":{"name":"limit","in":"query","required":false,"schema":{"type":"integer","minimum":1,"maximum":200,"default":50}},"Cursor":{"name":"cursor","in":"query","required":false,"schema":{"type":"string"}},"ApiKeyId":{"name":"key_id","in":"path","required":true,"schema":{"type":"string"}},"IdempotencyKey":{"name":"Idempotency-Key","in":"header","required":false,"schema":{"type":"string","description":"Idempotency key for safely retrying requests."}},"Since":{"name":"since","in":"query","required":false,"schema":{"type":"string","format":"date-time","description":"Start of time range (ISO 8601)"}},"Until":{"name":"until","in":"query","required":false,"schema":{"type":"string","format":"date-time","description":"End of time range (ISO 8601)"}},"Bucket":{"name":"bucket","in":"query","required":false,"schema":{"type":"string","enum":["hour","day"],"default":"hour","description":"Time series bucket granularity"}},"ObsInstanceId":{"name":"instance_id","in":"query","required":false,"schema":{"type":"string","description":"Filter by instance ID"}}},"schemas":{"ErrorResponse":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":true}}}}},"PageInfo":{"type":"object","properties":{"next_cursor":{"type":"string","nullable":true}}},"InstanceList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Instance"}},"page":{"$ref":"#/components/schemas/PageInfo"}}},"Instance":{"type":"object","required":["id","name","status","created_at"],"properties":{"id":{"type":"string"},"name":{"type":"string"},"description":{"type":"string"},"status":{"$ref":"#/components/schemas/InstanceStatus"},"config":{"$ref":"#/components/schemas/InstanceConfig"},"phone_number":{"type":"string","nullable":true},"jid":{"type":"string","nullable":true},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}}},"InstanceConfig":{"type":"object","properties":{"allowed_groups":{"type":"array","items":{"type":"string"},"description":"Allowlist for group chats; use '*' to allow all."},"allowed_dms":{"type":"array","items":{"type":"string"},"description":"Allowlist for DMs; use '*' to allow all."},"respond_to_mentions_only":{"type":"boolean"},"auto_reconnect":{"type":"boolean"},"download_media":{"type":"boolean"},"emit_raw":{"type":"boolean"}}},"InstanceCreateRequest":{"type":"object","required":["name"],"properties":{"name":{"type":"string"},"description":{"type":"string"},"config":{"$ref":"#/components/schemas/InstanceConfig"}}},"InstanceUpdateRequest":{"type":"object","properties":{"name":{"type":"string"},"description":{"type":"string"},"config":{"$ref":"#/components/schemas/InstanceConfig"}}},"InstanceStatus":{"type":"object","required":["state"],"properties":{"state":{"type":"string","enum":["disconnected","connecting","qr_required","connected","reconnecting","logged_out","error"]},"last_error":{"type":"string","nullable":true},"updated_at":{"type":"string","format":"date-time"}}},"ConnectResponse":{"type":"object","required":["status"],"properties":{"status":{"$ref":"#/components/schemas/InstanceStatus"},"qr":{"type":"string","nullable":true,"description":"QR code content to be rendered by clients when needed."},"qr_image_data_url":{"type":"string","nullable":true,"description":"Optional data URL for quick display."}}},"ChatList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Chat"}},"page":{"$ref":"#/components/schemas/PageInfo"}}},"Chat":{"type":"object","required":["id","name","is_group"],"properties":{"id":{"type":"string"},"name":{"type":"string"},"is_group":{"type":"boolean"},"participant_count":{"type":"integer","nullable":true},"last_message_id":{"type":"string","nullable":true}}},"GroupList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Group"}},"page":{"$ref":"#/components/schemas/PageInfo"}}},"Group":{"type":"object","required":["id","name"],"properties":{"id":{"type":"string"},"name":{"type":"string"},"description":{"type":"string","nullable":true},"participant_count":{"type":"integer"}}},"MessageList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Message"}},"page":{"$ref":"#/components/schemas/PageInfo"}}},"Message":{"type":"object","required":["id","chat_id","from","to","direction","type","timestamp"],"properties":{"id":{"type":"string"},"chat_id":{"type":"string"},"from":{"type":"string"},"to":{"type":"string"},"direction":{"type":"string","enum":["inbound","outbound"]},"type":{"$ref":"#/components/schemas/MessageType"},"content":{"$ref":"#/components/schemas/MessageContent"},"status":{"$ref":"#/components/schemas/MessageStatus"},"timestamp":{"type":"string","format":"date-time"},"raw":{"type":"object","additionalProperties":true}}},"MessageType":{"type":"string","enum":["text","image","video","audio","document","sticker","location","contacts","buttons","list","template","reaction"]},"MessageStatus":{"type":"string","enum":["queued","sent","delivered","read","failed"]},"MessageSendRequest":{"type":"object","required":["chat_id","type","content"],"properties":{"chat_id":{"type":"string"},"type":{"$ref":"#/components/schemas/MessageType"},"content":{"$ref":"#/components/schemas/MessageContent"},"metadata":{"type":"object","additionalProperties":true}}},"MessageContent":{"type":"object","oneOf":[{"$ref":"#/components/schemas/TextContent"},{"$ref":"#/components/schemas/ImageContent"},{"$ref":"#/components/schemas/VideoContent"},{"$ref":"#/components/schemas/AudioContent"},{"$ref":"#/components/schemas/DocumentContent"},{"$ref":"#/components/schemas/StickerContent"},{"$ref":"#/components/schemas/LocationContent"},{"$ref":"#/components/schemas/ContactsContent"},{"$ref":"#/components/schemas/ButtonsContent"},{"$ref":"#/components/schemas/ListContent"},{"$ref":"#/components/schemas/TemplateContent"},{"$ref":"#/components/schemas/ReactionContent"}]},"TextContent":{"type":"object","required":["text"],"properties":{"text":{"type":"string"},"preview_url":{"type":"boolean","default":false}}},"ImageContent":{"type":"object","required":["media"],"properties":{"media":{"$ref":"#/components/schemas/MediaRef"},"caption":{"type":"string"}}},"VideoContent":{"type":"object","required":["media"],"properties":{"media":{"$ref":"#/components/schemas/MediaRef"},"caption":{"type":"string"},"gif_playback":{"type":"boolean","default":false}}},"AudioContent":{"type":"object","required":["media"],"properties":{"media":{"$ref":"#/components/schemas/MediaRef"},"ptt":{"type":"boolean","description":"True for push-to-talk voice note."}}},"DocumentContent":{"type":"object","required":["media"],"properties":{"media":{"$ref":"#/components/schemas/MediaRef"},"filename":{"type":"string"},"caption":{"type":"string"}}},"StickerContent":{"type":"object","required":["media"],"properties":{"media":{"$ref":"#/components/schemas/MediaRef"}}},"LocationContent":{"type":"object","required":["latitude","longitude"],"properties":{"latitude":{"type":"number","format":"double"},"longitude":{"type":"number","format":"double"},"name":{"type":"string"},"address":{"type":"string"}}},"ContactsContent":{"type":"object","required":["contacts"],"properties":{"contacts":{"type":"array","items":{"$ref":"#/components/schemas/Contact"}}}},"Contact":{"type":"object","required":["name","phone"],"properties":{"name":{"type":"string"},"phone":{"type":"string"},"organization":{"type":"string","nullable":true},"email":{"type":"string","nullable":true}}},"ButtonsContent":{"type":"object","required":["text","buttons"],"properties":{"text":{"type":"string"},"buttons":{"type":"array","items":{"$ref":"#/components/schemas/Button"}}}},"Button":{"type":"object","required":["id","title"],"properties":{"id":{"type":"string"},"title":{"type":"string"}}},"ListContent":{"type":"object","required":["text","sections"],"properties":{"text":{"type":"string"},"title":{"type":"string"},"button_text":{"type":"string"},"sections":{"type":"array","items":{"$ref":"#/components/schemas/ListSection"}}}},"ListSection":{"type":"object","required":["title","rows"],"properties":{"title":{"type":"string"},"rows":{"type":"array","items":{"$ref":"#/components/schemas/ListRow"}}}},"ListRow":{"type":"object","required":["id","title"],"properties":{"id":{"type":"string"},"title":{"type":"string"},"description":{"type":"string"}}},"TemplateContent":{"type":"object","required":["name","language"],"properties":{"name":{"type":"string"},"language":{"type":"string"},"components":{"type":"array","items":{"type":"object","additionalProperties":true}}}},"ReactionContent":{"type":"object","required":["emoji","message_id"],"properties":{"emoji":{"type":"string"},"message_id":{"type":"string"}}},"ReactionRequest":{"type":"object","required":["emoji"],"properties":{"emoji":{"type":"string"}}},"PresenceRequest":{"type":"object","required":["chat_id","state"],"properties":{"chat_id":{"type":"string"},"state":{"type":"string","enum":["composing","paused","recording"]}}},"Presence":{"type":"object","required":["chat_id","state","timestamp"],"properties":{"chat_id":{"type":"string"},"state":{"type":"string"},"timestamp":{"type":"string","format":"date-time"}}},"Receipt":{"type":"object","required":["message_id","status","timestamp"],"properties":{"message_id":{"type":"string"},"status":{"type":"string","enum":["read"]},"timestamp":{"type":"string","format":"date-time"}}},"MediaUploadRequest":{"type":"object","required":["file"],"properties":{"file":{"type":"string","format":"binary"}}},"MediaObject":{"type":"object","required":["id","mime_type","size_bytes"],"properties":{"id":{"type":"string"},"mime_type":{"type":"string"},"size_bytes":{"type":"integer"},"url":{"type":"string","description":"Signed URL for download"},"created_at":{"type":"string","format":"date-time"}}},"MediaRef":{"type":"object","required":["media_id"],"properties":{"media_id":{"type":"string"}}},"WebhookList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Webhook"}}}},"Webhook":{"type":"object","required":["id","url","events","active"],"properties":{"id":{"type":"string"},"url":{"type":"string"},"events":{"type":"array","items":{"type":"string"}},"active":{"type":"boolean"},"secret":{"type":"string","nullable":true}}},"WebhookCreateRequest":{"type":"object","required":["url","events"],"properties":{"url":{"type":"string"},"events":{"type":"array","items":{"type":"string"}},"secret":{"type":"string"},"active":{"type":"boolean","default":true}}},"WebhookUpdateRequest":{"type":"object","properties":{"url":{"type":"string"},"events":{"type":"array","items":{"type":"string"}},"secret":{"type":"string"},"active":{"type":"boolean"}}},"BillingCheckoutSessionRequest":{"type":"object","required":["product_cart"],"properties":{"product_cart":{"type":"array","items":{"type":"object","additionalProperties":true}},"customer":{"type":"object","additionalProperties":true},"return_url":{"type":"string"},"metadata":{"type":"object","additionalProperties":true}},"additionalProperties":true},"BillingCheckoutSession":{"type":"object","required":["id","status"],"properties":{"id":{"type":"string"},"dodo_session_id":{"type":"string"},"status":{"type":"string"},"checkout_url":{"type":"string","nullable":true},"customer_email":{"type":"string","nullable":true},"customer_name":{"type":"string","nullable":true},"product_cart":{"type":"array","items":{"type":"object","additionalProperties":true}},"metadata":{"type":"object","additionalProperties":true,"nullable":true},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}}},"BillingPlan":{"type":"object","required":["id","name","price_cents","included_messages"],"properties":{"id":{"type":"string","description":"Plan identifier (free, growth, scale)"},"name":{"type":"string"},"price_cents":{"type":"integer","description":"Monthly price in cents"},"included_messages":{"type":"integer","description":"Outbound messages included per month"}}},"BillingPlans":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/BillingPlan"}}}},"BillingUsage":{"type":"object","properties":{"plan":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"price_cents":{"type":"integer"},"included_messages":{"type":"integer"},"cancels_at_cycle_end":{"type":"boolean","description":"Whether the plan will downgrade to free at the end of the current billing cycle"}}},"billing_cycle":{"type":"object","properties":{"start":{"type":"string","format":"date-time","nullable":true},"end":{"type":"string","format":"date-time","nullable":true},"days_remaining":{"type":"integer"}}},"usage":{"type":"object","properties":{"sent":{"type":"integer"},"included":{"type":"integer"},"remaining":{"type":"integer"}}}}},"BillingUpgradeResponse":{"type":"object","required":["plan","session_id"],"properties":{"plan":{"type":"string","description":"The plan being upgraded to"},"checkout_url":{"type":"string","nullable":true,"description":"URL to redirect the user to for payment"},"session_id":{"type":"string","description":"Wataki checkout session ID for tracking"}}},"SignupRequest":{"type":"object","required":["name","email"],"properties":{"name":{"type":"string"},"email":{"type":"string","format":"email"}}},"SignupResponse":{"type":"object","required":["tenant","api_key"],"properties":{"tenant":{"$ref":"#/components/schemas/Tenant"},"api_key":{"type":"string","description":"Raw API key (shown only once)"}}},"Tenant":{"type":"object","required":["id","name","email","plan","status"],"properties":{"id":{"type":"string"},"name":{"type":"string"},"email":{"type":"string"},"plan":{"type":"string"},"status":{"type":"string"},"dodo_customer_id":{"type":"string","nullable":true},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}}},"ApiKeyList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/ApiKeySummary"}}}},"ApiKeySummary":{"type":"object","required":["id","key_prefix","name"],"properties":{"id":{"type":"string"},"key_prefix":{"type":"string"},"name":{"type":"string"},"created_at":{"type":"string","format":"date-time"},"last_used_at":{"type":"string","format":"date-time","nullable":true}}},"ApiKeyCreateRequest":{"type":"object","properties":{"name":{"type":"string"}}},"ApiKeyCreateResponse":{"type":"object","required":["id","api_key","key_prefix","name"],"properties":{"id":{"type":"string"},"api_key":{"type":"string","description":"Raw API key (shown only once)"},"key_prefix":{"type":"string"},"name":{"type":"string"},"created_at":{"type":"string","format":"date-time"}}},"ObservabilityOverview":{"type":"object","properties":{"messages":{"type":"object","properties":{"total":{"type":"integer"},"breakdown":{"type":"array","items":{"type":"object","properties":{"direction":{"type":"string"},"type":{"type":"string"},"status":{"type":"string"},"count":{"type":"integer"}}}}}},"instances":{"type":"object","properties":{"total":{"type":"integer"},"connected":{"type":"integer"},"health":{"type":"array","items":{"$ref":"#/components/schemas/ObservabilityInstanceHealth"}}}},"webhooks":{"type":"object","properties":{"success_rate":{"type":"number"},"total":{"type":"integer"},"success_count":{"type":"integer"},"failure_count":{"type":"integer"},"avg_latency_ms":{"type":"integer"}}},"api":{"type":"object","properties":{"total_requests":{"type":"integer"},"breakdown":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string"},"path":{"type":"string"},"status_bucket":{"type":"string"},"count":{"type":"integer"},"avg_latency_ms":{"type":"integer"}}}}}}}},"ObservabilityMessageStats":{"type":"object","properties":{"stats":{"type":"array","items":{"type":"object","properties":{"direction":{"type":"string"},"type":{"type":"string"},"status":{"type":"string"},"count":{"type":"integer"}}}},"time_series":{"type":"array","items":{"type":"object","properties":{"bucket":{"type":"string","format":"date-time"},"direction":{"type":"string"},"count":{"type":"integer"}}}}}},"ObservabilityWebhookStats":{"type":"object","properties":{"stats":{"type":"object","properties":{"total":{"type":"integer"},"success_count":{"type":"integer"},"failure_count":{"type":"integer"},"avg_latency_ms":{"type":"integer"}}},"time_series":{"type":"array","items":{"type":"object","properties":{"bucket":{"type":"string","format":"date-time"},"success":{"type":"integer"},"failed":{"type":"integer"},"avg_latency_ms":{"type":"integer"}}}},"recent_failures":{"type":"array","items":{"$ref":"#/components/schemas/WebhookDelivery"}}}},"WebhookDelivery":{"type":"object","properties":{"id":{"type":"string"},"webhook_id":{"type":"string"},"instance_id":{"type":"string"},"event":{"type":"string"},"event_id":{"type":"string"},"url":{"type":"string"},"status_code":{"type":"integer","nullable":true},"success":{"type":"boolean"},"latency_ms":{"type":"integer","nullable":true},"error":{"type":"string","nullable":true},"attempt":{"type":"integer"},"created_at":{"type":"string","format":"date-time"}}},"ObservabilityApiUsage":{"type":"object","properties":{"stats":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string"},"path":{"type":"string"},"status_bucket":{"type":"string"},"count":{"type":"integer"},"avg_latency_ms":{"type":"integer"}}}},"time_series":{"type":"array","items":{"type":"object","properties":{"bucket":{"type":"string","format":"date-time"},"count":{"type":"integer"},"avg_latency_ms":{"type":"integer"}}}}}},"ObservabilityInstanceHealth":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"status":{"$ref":"#/components/schemas/InstanceStatus"},"phone_number":{"type":"string","nullable":true},"jid":{"type":"string","nullable":true},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"},"message_count":{"type":"integer"},"inbound_count":{"type":"integer"},"outbound_count":{"type":"integer"},"media_count":{"type":"integer"}}},"ObservabilityInstanceHealthList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/ObservabilityInstanceHealth"}}}},"ObservabilityErrors":{"type":"object","properties":{"failed_messages":{"type":"integer"},"failed_webhooks":{"type":"integer"},"api_5xx":{"type":"integer"},"errored_instances":{"type":"integer"}}},"WebhookEnvelope":{"type":"object","required":["id","event","data","timestamp"],"properties":{"id":{"type":"string"},"event":{"type":"string"},"data":{"type":"object","additionalProperties":true},"timestamp":{"type":"string","format":"date-time"},"instance_id":{"type":"string"}}},"WebhookMessageReceived":{"allOf":[{"$ref":"#/components/schemas/WebhookEnvelope"},{"type":"object","properties":{"event":{"type":"string","enum":["message.received"]},"data":{"$ref":"#/components/schemas/Message"}}}]},"WebhookMessageStatus":{"allOf":[{"$ref":"#/components/schemas/WebhookEnvelope"},{"type":"object","properties":{"event":{"type":"string","enum":["message.status"]},"data":{"type":"object","required":["message_id","status"],"properties":{"message_id":{"type":"string"},"status":{"$ref":"#/components/schemas/MessageStatus"},"error":{"type":"string","nullable":true}}}}}]},"WebhookMessageReaction":{"allOf":[{"$ref":"#/components/schemas/WebhookEnvelope"},{"type":"object","properties":{"event":{"type":"string","enum":["message.reaction"]},"data":{"type":"object","required":["message_id","emoji","from"],"properties":{"message_id":{"type":"string"},"emoji":{"type":"string"},"from":{"type":"string"}}}}}]},"WebhookMessageRead":{"allOf":[{"$ref":"#/components/schemas/WebhookEnvelope"},{"type":"object","properties":{"event":{"type":"string","enum":["message.read"]},"data":{"type":"object","required":["message_id","read_at"],"properties":{"message_id":{"type":"string"},"read_at":{"type":"string","format":"date-time"}}}}}]},"WebhookConnectionUpdate":{"allOf":[{"$ref":"#/components/schemas/WebhookEnvelope"},{"type":"object","properties":{"event":{"type":"string","enum":["connection.update"]},"data":{"$ref":"#/components/schemas/InstanceStatus"}}}]},"WebhookQrUpdated":{"allOf":[{"$ref":"#/components/schemas/WebhookEnvelope"},{"type":"object","properties":{"event":{"type":"string","enum":["qr.updated"]},"data":{"type":"object","required":["qr"],"properties":{"qr":{"type":"string"}}}}}]}}}}