{"openapi":"3.1.0","info":{"title":"personal-whatsapp Project API","version":"1.0.0","description":"HTTP API used by your projects to forward messages to their WhatsApp groups."},"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"Per-project bearer token issued via the admin UI."}},"schemas":{"Health":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]},"paired":{"type":"boolean"},"projects":{"type":"integer","minimum":0}},"required":["ok","paired","projects"]},"PostResponse":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]},"project":{"type":"string","example":"blog"},"mediaCount":{"type":"integer","minimum":0,"description":"Number of Media items that were sent as part of the Album."}},"required":["ok","project","mediaCount"]},"Error":{"type":"object","properties":{"error":{"type":"string","example":"unauthorized"},"detail":{"type":"string"}},"required":["error"]},"PostBody":{"type":"object","properties":{"groupJid":{"type":"string","pattern":"^[^@\\s]+@g\\.us$","example":"1234567890-1612345678@g.us"},"title":{"type":"string","minLength":1,"example":"New post on the blog"},"permalink":{"type":"string","format":"uri","example":"https://example.com/posts/123","description":"Optional canonical URL. When present, rendered as the last line of the Text card."},"caption":{"type":"string","example":"A short summary."},"media":{"type":"array","items":{"$ref":"#/components/schemas/MediaItem"},"maxItems":10,"description":"Ordered list of media items (mixed image/* and video/* allowed, up to 10). Omitted or [] produces a text-only Post."}},"required":["groupJid","title"]},"MediaItem":{"type":"object","properties":{"url":{"type":"string","format":"uri","example":"https://example.com/cover.jpg"},"type":{"type":"string","pattern":"^(image|video)\\/[A-Za-z0-9.+-]+$","example":"image/jpeg"}},"required":["url","type"]},"PostFileResponse":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]},"project":{"type":"string","example":"receipts"}},"required":["ok","project"]},"PostFileBody":{"type":"object","properties":{"groupJid":{"type":"string","pattern":"^[^@\\s]+@g\\.us$","example":"1234567890-1612345678@g.us"},"media":{"$ref":"#/components/schemas/DmMedia"},"caption":{"type":"string","minLength":1,"maxLength":4096}},"required":["groupJid","media"]},"DmMedia":{"type":"object","properties":{"data":{"type":"string","minLength":1,"maxLength":34952538,"description":"File contents, base64-encoded. Max 5 MB decoded for images, 16 MB for video sent as video, 25 MB for anything else."},"mimetype":{"type":"string","maxLength":255,"pattern":"^[a-z0-9][a-z0-9!#$&^_.+-]{0,126}\\/[a-z0-9][a-z0-9!#$&^_.+-]{0,126}(\\s*;\\s*[^;]+)*$/i","example":"application/pdf","description":"Any MIME type. image/jpeg|png|webp go as images; video/mp4 and audio (ogg, mpeg, mp4, aac, amr) play inline when sendAs is auto; everything else is sent as a document."},"filename":{"type":"string","minLength":1,"maxLength":200,"description":"Shown as the document name; ignored for images, video and audio. Defaults to file.<ext> from the MIME type."},"sendAs":{"type":"string","enum":["auto","document","voiceNote"],"default":"auto","description":"auto: image/video/audio play inline where WhatsApp supports it, otherwise document. document: always a downloadable file (up to 25 MB, images included). voiceNote: send audio/ogg (Opus) as a push-to-talk voice note."}},"required":["data","mimetype"]},"PermittedGroups":{"type":"object","properties":{"groups":{"type":"array","items":{"$ref":"#/components/schemas/PermittedGroup"}}},"required":["groups"]},"PermittedGroup":{"type":"object","properties":{"jid":{"type":"string","pattern":"^[^@\\s]+@g\\.us$","example":"1234567890-1612345678@g.us"},"subject":{"type":"string","nullable":true,"description":"Human-readable WhatsApp group name. null when the bot isn't paired or the JID isn't in the live group list yet."}},"required":["jid","subject"]},"GroupCreateResponse":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]},"groupJid":{"type":"string","pattern":"^[^@\\s]+@g\\.us$","example":"1234567890-1612345678@g.us"},"subject":{"type":"string"},"inviteCode":{"type":"string","nullable":true},"inviteLink":{"type":"string","nullable":true},"participants":{"type":"array","items":{"$ref":"#/components/schemas/ParticipantResult"}},"settings":{"type":"object","properties":{"announce":{"type":"boolean"}},"required":["announce"]},"warnings":{"type":"array","items":{"type":"string"}}},"required":["ok","groupJid","subject","inviteCode","inviteLink","participants","settings","warnings"]},"ParticipantResult":{"type":"object","properties":{"jid":{"type":"string"},"status":{"type":"string","example":"200"},"added":{"type":"boolean"},"note":{"type":"string","description":"Human-readable hint when an add did not succeed (non-200 status)."}},"required":["jid","status","added"]},"GroupCreateBody":{"type":"object","properties":{"subject":{"type":"string","minLength":1,"maxLength":100,"example":"Launch crew"},"participants":{"type":"array","items":{"type":"string","minLength":1,"example":"6191234567","description":"Phone number (digits, any formatting) or an explicit user JID (@s.whatsapp.net or @lid)."},"maxItems":20,"default":[],"description":"Optional members to add after creation (max 20). Phone numbers or user JIDs."},"announce":{"type":"boolean","default":false,"description":"When true, set the new group to announcement-only (admins post)."},"description":{"type":"string","maxLength":512,"example":"Coordination for the launch."}},"required":["subject"]},"ParticipantsResponse":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]},"results":{"type":"array","items":{"$ref":"#/components/schemas/ParticipantResult"}}},"required":["ok","results"]},"AddParticipantsBody":{"type":"object","properties":{"groupJid":{"type":"string","pattern":"^[^@\\s]+@g\\.us$","example":"1234567890-1612345678@g.us"},"participants":{"type":"array","items":{"type":"string","minLength":1,"example":"6191234567","description":"Phone number (digits, any formatting) or an explicit user JID (@s.whatsapp.net or @lid)."},"minItems":1,"maxItems":20}},"required":["groupJid","participants"]},"RemoveParticipantsBody":{"type":"object","properties":{"groupJid":{"type":"string","pattern":"^[^@\\s]+@g\\.us$","example":"1234567890-1612345678@g.us"},"participants":{"type":"array","items":{"type":"string","minLength":1,"example":"6191234567","description":"Phone number (digits, any formatting) or an explicit user JID (@s.whatsapp.net or @lid)."},"minItems":1,"maxItems":20}},"required":["groupJid","participants"]},"InviteResponse":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]},"code":{"type":"string","nullable":true},"link":{"type":"string","nullable":true}},"required":["ok","code","link"]},"GroupRef":{"type":"object","properties":{"groupJid":{"type":"string","pattern":"^[^@\\s]+@g\\.us$","example":"1234567890-1612345678@g.us"}},"required":["groupJid"]},"SettingResponse":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]},"setting":{"type":"string","enum":["announcement","not_announcement","locked","unlocked"]}},"required":["ok","setting"]},"GroupSettingBody":{"type":"object","properties":{"groupJid":{"type":"string","pattern":"^[^@\\s]+@g\\.us$","example":"1234567890-1612345678@g.us"},"setting":{"type":"string","enum":["announcement","not_announcement","locked","unlocked"],"example":"announcement"}},"required":["groupJid","setting"]},"Ok":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]}},"required":["ok"]},"GroupSubjectBody":{"type":"object","properties":{"groupJid":{"type":"string","pattern":"^[^@\\s]+@g\\.us$","example":"1234567890-1612345678@g.us"},"subject":{"type":"string","minLength":1,"maxLength":100,"example":"Launch crew"}},"required":["groupJid","subject"]},"GroupDescriptionBody":{"type":"object","properties":{"groupJid":{"type":"string","pattern":"^[^@\\s]+@g\\.us$","example":"1234567890-1612345678@g.us"},"description":{"type":"string","maxLength":512,"example":"Coordination for the launch.","description":"Pass \"\" to clear the description."}},"required":["groupJid","description"]},"LeaveResponse":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]},"leftGroup":{"type":"string","pattern":"^[^@\\s]+@g\\.us$","example":"1234567890-1612345678@g.us"},"removedFromProject":{"type":"boolean"},"note":{"type":"string"}},"required":["ok","leftGroup","removedFromProject","note"]},"CommunityCreateResponse":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]},"communityJid":{"type":"string","pattern":"^[^@\\s]+@g\\.us$","example":"1234567890-1612345678@g.us"},"subject":{"type":"string"},"inviteCode":{"type":"string","nullable":true},"inviteLink":{"type":"string","nullable":true},"warnings":{"type":"array","items":{"type":"string"}}},"required":["ok","communityJid","subject","inviteCode","inviteLink","warnings"]},"CommunityCreateBody":{"type":"object","properties":{"subject":{"type":"string","minLength":1,"maxLength":100,"example":"Launch HQ"},"description":{"type":"string","maxLength":512,"example":"Hub for all launch coordination."}},"required":["subject"]},"CommunityCreateGroupResponse":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]},"groupJid":{"type":"string","pattern":"^[^@\\s]+@g\\.us$","example":"1234567890-1612345678@g.us"},"parentJid":{"type":"string","pattern":"^[^@\\s]+@g\\.us$","example":"1234567890-1612345678@g.us"},"subject":{"type":"string"},"inviteCode":{"type":"string","nullable":true},"inviteLink":{"type":"string","nullable":true},"participants":{"type":"array","items":{"$ref":"#/components/schemas/ParticipantResult"}},"settings":{"type":"object","properties":{"announce":{"type":"boolean"}},"required":["announce"]},"warnings":{"type":"array","items":{"type":"string"}}},"required":["ok","groupJid","parentJid","subject","inviteCode","inviteLink","participants","settings","warnings"]},"CommunityCreateGroupBody":{"type":"object","properties":{"parentJid":{"type":"string","pattern":"^[^@\\s]+@g\\.us$","example":"1234567890-1612345678@g.us"},"subject":{"type":"string","minLength":1,"maxLength":100,"example":"Launch crew"},"participants":{"type":"array","items":{"type":"string","minLength":1,"example":"6191234567","description":"Phone number (digits, any formatting) or an explicit user JID (@s.whatsapp.net or @lid)."},"maxItems":20,"default":[],"description":"Optional members to add after creation (max 20). Phone numbers or user JIDs."},"announce":{"type":"boolean","default":false,"description":"When true, set the new subgroup to announcement-only (admins post)."},"description":{"type":"string","maxLength":512,"example":"Coordination for the launch."}},"required":["parentJid","subject"]},"CommunityLinkResponse":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]},"linked":{"type":"boolean","enum":[true]},"groupJid":{"type":"string","pattern":"^[^@\\s]+@g\\.us$","example":"1234567890-1612345678@g.us"},"parentJid":{"type":"string","pattern":"^[^@\\s]+@g\\.us$","example":"1234567890-1612345678@g.us"}},"required":["ok","linked","groupJid","parentJid"]},"CommunityLinkBody":{"type":"object","properties":{"parentJid":{"type":"string","pattern":"^[^@\\s]+@g\\.us$","example":"1234567890-1612345678@g.us"},"groupJid":{"type":"string","pattern":"^[^@\\s]+@g\\.us$","example":"1234567890-1612345678@g.us"}},"required":["parentJid","groupJid"]},"CommunityUnlinkResponse":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]},"unlinked":{"type":"boolean","enum":[true]},"groupJid":{"type":"string","pattern":"^[^@\\s]+@g\\.us$","example":"1234567890-1612345678@g.us"},"parentJid":{"type":"string","pattern":"^[^@\\s]+@g\\.us$","example":"1234567890-1612345678@g.us"}},"required":["ok","unlinked","groupJid","parentJid"]},"CommunityListResponse":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]},"communities":{"type":"array","items":{"type":"object","properties":{"jid":{"type":"string","pattern":"^[^@\\s]+@g\\.us$","example":"1234567890-1612345678@g.us"},"subject":{"type":"string","nullable":true},"size":{"type":"integer","nullable":true},"permitted":{"type":"boolean"}},"required":["jid","subject","size","permitted"]}}},"required":["ok","communities"]},"CommunitySubgroupsResponse":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]},"communityJid":{"type":"string"},"isCommunity":{"type":"boolean"},"subgroups":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"subject":{"type":"string"},"creation":{"type":"number"},"owner":{"type":"string"},"size":{"type":"integer"}},"required":["id"]}}},"required":["ok","communityJid","isCommunity","subgroups"]},"CommunityRef":{"type":"object","properties":{"communityJid":{"type":"string","pattern":"^[^@\\s]+@g\\.us$","example":"1234567890-1612345678@g.us"}},"required":["communityJid"]},"CommunityMetadataResponse":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]},"jid":{"type":"string"},"subject":{"type":"string","nullable":true},"desc":{"type":"string","nullable":true},"isCommunity":{"type":"boolean"},"linkedParent":{"type":"string","nullable":true},"announce":{"type":"boolean"},"size":{"type":"integer","nullable":true}},"required":["ok","jid","subject","desc","isCommunity","linkedParent","announce","size"]},"DmResultResponse":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]},"toJid":{"type":"string"},"status":{"type":"string","enum":["sent"]}},"required":["ok","toJid","status"]},"DmBody":{"type":"object","properties":{"toJid":{"type":"string","minLength":1,"example":"6191234567","description":"Phone number (digits, any formatting) or an explicit user JID (@s.whatsapp.net or @lid). Normalized server-side; must be on the DM allowlist."},"text":{"type":"string","minLength":1,"maxLength":4096,"example":"Hi — thanks for opting in.","description":"Message body, or the caption when media is sent."},"media":{"$ref":"#/components/schemas/DmMedia"}},"required":["toJid"]},"DmBatchResponse":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]},"batchId":{"type":"string"},"enqueued":{"type":"integer","minimum":0},"duplicates":{"type":"integer","minimum":0},"skipped":{"type":"array","items":{"type":"object","properties":{"jid":{"type":"string"},"reason":{"type":"string"}},"required":["jid","reason"]}}},"required":["ok","batchId","enqueued","duplicates","skipped"]},"DmBatchBody":{"type":"object","properties":{"recipients":{"type":"array","items":{"type":"string","minLength":1,"example":"6191234567","description":"Phone number (digits, any formatting) or an explicit user JID (@s.whatsapp.net or @lid). Normalized server-side; must be on the DM allowlist."},"minItems":1,"maxItems":50,"description":"Up to 50 recipients. Non-allowlisted recipients are skipped, not sent. Sends happen in the background with server-side jitter — nothing is sent synchronously and the rate cannot be raised by the caller."},"text":{"type":"string","minLength":1,"maxLength":4096,"example":"Hi — thanks for opting in."}},"required":["recipients","text"]},"DmStatusResponse":{"type":"object","properties":{"paused":{"type":"boolean"},"pauseReason":{"type":"string","nullable":true},"pending":{"type":"integer","minimum":0},"sentLastMin":{"type":"integer","minimum":0},"sentLastDay":{"type":"integer","minimum":0},"caps":{"type":"object","properties":{"perMin":{"type":"integer","minimum":0},"perDay":{"type":"integer","minimum":0}},"required":["perMin","perDay"]},"batch":{"type":"object","properties":{"batchId":{"type":"string"},"pending":{"type":"integer","minimum":0},"sent":{"type":"integer","minimum":0},"failed":{"type":"integer","minimum":0},"skipped":{"type":"integer","minimum":0}},"required":["batchId","pending","sent","failed","skipped"]}},"required":["paused","pauseReason","pending","sentLastMin","sentLastDay","caps"]},"DmCancelResponse":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]},"cancelled":{"type":"integer","minimum":0}},"required":["ok","cancelled"]},"DmCancelBody":{"type":"object","properties":{"batchId":{"type":"string","minLength":1}},"required":["batchId"]}},"parameters":{}},"paths":{"/":{"get":{"tags":["health"],"summary":"Liveness probe","description":"Reports whether the bot is paired with WhatsApp and how many projects exist.","responses":{"200":{"description":"Server up","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Health"}}}}}}},"/v1/post":{"post":{"tags":["messages"],"summary":"Post a message to a WhatsApp group","description":"Sends a Text card carrying title/caption/permalink, optionally followed by an Album of 1–10 ordered Media items (mixed image/* and video/*). Validates the target group is in this project's access × global allowlist. Videos over 16 MB are transcoded in-process before sending.","security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PostBody"}}}},"responses":{"200":{"description":"Sent","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PostResponse"}}}},"400":{"description":"Invalid request or media item","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid project token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Target group not permitted for this project","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"Upstream send failure: WhatsApp media fetch failure, ffmpeg transcode failure, or relay failure. Detail may indicate partial state when the Text card sent but the Album did not.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Bot is not paired with WhatsApp","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"504":{"description":"Total Post deadline (270 s) or per-transcode deadline (120 s) exceeded.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/post/file":{"post":{"tags":["messages"],"summary":"Post one image or PDF to a WhatsApp group","description":"Sends one file of any type, base64-encoded inline, with an optional caption and no text card in front of it. JPEG/PNG/WebP go as images (max 5 MB); with sendAs auto, MP4 up to 16 MB goes as video and audio (ogg, mpeg, mp4, aac, amr) as an audio message; anything else (or sendAs document) goes as a document (max 25 MB). Audio takes no caption. Same group check as POST /v1/post: the group must be in this project's access and in the global allowlist.","security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PostFileBody"}}}},"responses":{"200":{"description":"Sent","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PostFileResponse"}}}},"400":{"description":"Invalid media","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid project token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Target group not permitted for this project","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"Upstream WhatsApp send failure","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Bot is not paired with WhatsApp","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/groups":{"get":{"tags":["messages"],"summary":"List groups this project can send to","description":"Returns the intersection of the project's configured group access and the global allowlist — i.e. the groups that POST /v1/post will accept right now. Each entry includes the WhatsApp subject when available (best-effort, null when the bot isn't paired or the group is not in the live cache).","security":[{"bearerAuth":[]}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PermittedGroups"}}}},"401":{"description":"Missing or invalid project token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/groups/create":{"post":{"tags":["groups"],"summary":"Create a WhatsApp group","description":"Creates an empty group, then appends the new JID to the global allowlist and this project's access so the project can immediately post to and manage it. Optional participants/announce/description steps run best-effort: their failures are collected into warnings[] rather than failing the call.","security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/GroupCreateBody"}}}},"responses":{"200":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GroupCreateResponse"}}}},"400":{"description":"Invalid request or participant","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid project token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Target group not permitted for this project","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"Upstream WhatsApp failure","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Bot is not paired with WhatsApp","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/groups/participants/add":{"post":{"tags":["groups"],"summary":"Add participants to a group","description":"Adds up to 20 participants. Privacy-blocked recipients return a non-200 status with a note; share the invite link instead.","security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AddParticipantsBody"}}}},"responses":{"200":{"description":"Processed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ParticipantsResponse"}}}},"400":{"description":"Invalid request or participant","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid project token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Target group not permitted for this project","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"Upstream WhatsApp failure","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Bot is not paired with WhatsApp","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/groups/participants/remove":{"post":{"tags":["groups"],"summary":"Remove participants from a group","description":"Removes up to 20 participants. Destructive: removed members lose access immediately.","security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RemoveParticipantsBody"}}}},"responses":{"200":{"description":"Processed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ParticipantsResponse"}}}},"400":{"description":"Invalid request or participant","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid project token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Target group not permitted for this project","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"Upstream WhatsApp failure","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Bot is not paired with WhatsApp","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/groups/invite/code":{"post":{"tags":["groups"],"summary":"Get a group invite code","description":"Returns the current invite code and shareable link for a permitted group.","security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/GroupRef"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InviteResponse"}}}},"400":{"description":"Invalid request or participant","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid project token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Target group not permitted for this project","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"Upstream WhatsApp failure","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Bot is not paired with WhatsApp","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/groups/invite/revoke":{"post":{"tags":["groups"],"summary":"Revoke and rotate a group invite code","description":"Invalidates the existing invite link and returns a fresh code/link.","security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/GroupRef"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InviteResponse"}}}},"400":{"description":"Invalid request or participant","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid project token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Target group not permitted for this project","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"Upstream WhatsApp failure","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Bot is not paired with WhatsApp","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/groups/setting":{"post":{"tags":["groups"],"summary":"Change a group setting","description":"Sets announcement/not_announcement (who may post) or locked/unlocked (who may edit group info).","security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/GroupSettingBody"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SettingResponse"}}}},"400":{"description":"Invalid request or participant","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid project token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Target group not permitted for this project","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"Upstream WhatsApp failure","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Bot is not paired with WhatsApp","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/groups/subject":{"post":{"tags":["groups"],"summary":"Rename a group","description":"Updates the group subject (name).","security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/GroupSubjectBody"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Ok"}}}},"400":{"description":"Invalid request or participant","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid project token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Target group not permitted for this project","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"Upstream WhatsApp failure","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Bot is not paired with WhatsApp","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/groups/description":{"post":{"tags":["groups"],"summary":"Set a group description","description":"Updates the group description. Pass \"\" to clear it.","security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/GroupDescriptionBody"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Ok"}}}},"400":{"description":"Invalid request or participant","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid project token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Target group not permitted for this project","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"Upstream WhatsApp failure","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Bot is not paired with WhatsApp","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/groups/leave":{"post":{"tags":["groups"],"summary":"Leave a group","description":"Destructive: the bot leaves the group and the JID is removed from this project's access. The global allowlist is left unchanged (remove via admin UI if desired).","security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/GroupRef"}}}},"responses":{"200":{"description":"Left","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LeaveResponse"}}}},"400":{"description":"Invalid request or participant","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid project token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Target group not permitted for this project","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"Upstream WhatsApp failure","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Bot is not paired with WhatsApp","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/communities/create":{"post":{"tags":["communities"],"summary":"Create a WhatsApp community","description":"Creates a community, then appends the new JID to the global allowlist and this project's access so the project can immediately manage it. The invite-code fetch runs best-effort: its failure is collected into warnings[] rather than failing the call.","security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CommunityCreateBody"}}}},"responses":{"200":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CommunityCreateResponse"}}}},"400":{"description":"Invalid request or participant","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid project token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Target group not permitted for this project","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"Upstream WhatsApp failure","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Bot is not paired with WhatsApp","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/communities/create-group":{"post":{"tags":["communities"],"summary":"Create a subgroup under a community","description":"Creates a subgroup under a permitted parent community, then appends the new JID to the global allowlist and this project's access. Optional participants/announce/description steps run best-effort: their failures are collected into warnings[] rather than failing the call.","security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CommunityCreateGroupBody"}}}},"responses":{"200":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CommunityCreateGroupResponse"}}}},"400":{"description":"Invalid request or participant","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid project token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Target group not permitted for this project","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"Upstream WhatsApp failure","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Bot is not paired with WhatsApp","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/communities/link":{"post":{"tags":["communities"],"summary":"Link a group into a community","description":"Links a permitted group into a permitted parent community.","security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CommunityLinkBody"}}}},"responses":{"200":{"description":"Linked","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CommunityLinkResponse"}}}},"400":{"description":"Invalid request or participant","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid project token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Target group not permitted for this project","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"Upstream WhatsApp failure","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Bot is not paired with WhatsApp","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/communities/unlink":{"post":{"tags":["communities"],"summary":"Unlink a group from a community","description":"Unlinks a permitted group from a permitted parent community.","security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CommunityLinkBody"}}}},"responses":{"200":{"description":"Unlinked","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CommunityUnlinkResponse"}}}},"400":{"description":"Invalid request or participant","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid project token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Target group not permitted for this project","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"Upstream WhatsApp failure","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Bot is not paired with WhatsApp","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/communities":{"get":{"tags":["communities"],"summary":"List communities the bot participates in","description":"Read-only discovery: lists every community the bot belongs to, annotating each with whether it is permitted for this project (in project access × global allowlist). No 403 — non-permitted communities are returned with permitted:false.","security":[{"bearerAuth":[]}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CommunityListResponse"}}}},"401":{"description":"Missing or invalid project token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"Upstream WhatsApp failure","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Bot is not paired with WhatsApp","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/communities/subgroups":{"post":{"tags":["communities"],"summary":"List subgroups linked under a community","description":"Returns the groups linked under a permitted community.","security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CommunityRef"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CommunitySubgroupsResponse"}}}},"400":{"description":"Invalid request or participant","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid project token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Target group not permitted for this project","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"Upstream WhatsApp failure","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Bot is not paired with WhatsApp","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/communities/metadata":{"post":{"tags":["communities"],"summary":"Fetch community metadata","description":"Returns subject/description/settings for a permitted community.","security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CommunityRef"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CommunityMetadataResponse"}}}},"400":{"description":"Invalid request or participant","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid project token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Target group not permitted for this project","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"Upstream WhatsApp failure","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Bot is not paired with WhatsApp","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/dm":{"post":{"tags":["dm"],"summary":"Send a 1:1 direct message (high ban-risk)","description":"Sends a single DM to one recipient: text, or one file of any type (base64; images max 5 MB, other files 25 MB) with an optional caption. Video and audio play inline where WhatsApp allows; see DmMedia.sendAs. HIGH BAN-RISK: direct messaging is throttled server-side (per-minute + per-day caps and randomized jitter) and the rate cannot be raised by the caller. The recipient must be on the DM allowlist. Prefer an invite-link group Post (POST /v1/post) for distribution.","security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DmBody"}}}},"responses":{"200":{"description":"Sent","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DmResultResponse"}}}},"400":{"description":"Invalid recipient","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid project token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Recipient not on the DM allowlist","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"423":{"description":"DM sending is paused (operator or auto-pause)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"DM cap reached, or WhatsApp restricted the account (auto-paused)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"Upstream WhatsApp send failure","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Bot is not paired with WhatsApp","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/dm/batch":{"post":{"tags":["dm"],"summary":"Enqueue a batch of 1:1 DMs (background, throttled)","description":"Enqueues up to 50 text DMs. HIGH BAN-RISK: nothing is sent synchronously — the queue drains in the background with server-side caps and randomized jitter that the caller cannot raise. Recipients not on the DM allowlist are returned in skipped[] and never sent. Duplicate (batch, recipient) pairs are de-duplicated via an idempotency key. Prefer an invite-link group Post for distribution.","security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DmBatchBody"}}}},"responses":{"200":{"description":"Enqueued","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DmBatchResponse"}}}},"400":{"description":"Invalid recipient","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid project token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Bot is not paired with WhatsApp","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/dm/status":{"get":{"tags":["dm"],"summary":"DM sender status and caps","description":"Reports pause state, pending count, recent send volume, and the server-side caps (read-only — caps cannot be changed via the API). Pass batchId to also get that batch's pending/sent/failed/skipped counts.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string"},"required":false,"name":"batchId","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DmStatusResponse"}}}},"401":{"description":"Missing or invalid project token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/dm/cancel":{"post":{"tags":["dm"],"summary":"Cancel pending DMs in a batch","description":"Marks every still-pending row in the batch as skipped (already-sent rows are untouched).","security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DmCancelBody"}}}},"responses":{"200":{"description":"Cancelled","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DmCancelResponse"}}}},"401":{"description":"Missing or invalid project token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}}}