{"openapi":"3.1.0","info":{"title":"AsysConnect API for developers","version":"1.0.0","description":"Connect your website, online store, CRM or app to AsysConnect: add and update\ncontacts, send WhatsApp, SMS and email, read chats, manage deals, and get told the moment\nsomething happens through webhooks.\n\nThis lists every endpoint an **API key** can call, with the permission each one needs\n(`x-permissions`).\n\n## Getting a key\n\nA workspace owner or admin makes a key in AsysConnect under **Settings → Developers**, picks what\nit may do, and copies it (it is shown once). Send it on every request:\n\n    Authorization: Bearer ask_live_...\n\n(`X-API-Key: ask_live_...` works too). A key acts as the teammate who made it and never has\nmore than their role allows. It stops working when it is revoked, when it expires, or when that\nteammate leaves the workspace. `GET /v1/api-key` tells you which workspace a key is for and\nwhat it can do.\n\n## Limits and retries\n\n- Each key can make 300 requests a minute. Over that you get `429` with a\n  `Retry-After` header in seconds.\n- Send an `Idempotency-Key` header (any unique string, up to 255 characters) with a POST to make\n  it safe to retry: a repeat within 24 hours returns the first answer (with\n  `Idempotent-Replayed: true`) instead of sending a second message. Reusing a key with a\n  different body returns `422 IDEMPOTENCY_KEY_REUSED`.\n- Errors are `{\"error\": {\"code\", \"message\", \"request_id\", \"details\"}}`. Quote the\n  `request_id` when asking for help.\n\n## Webhooks\n\nAdd an endpoint under **Settings → Developers** or with `POST /v1/webhook-endpoints`. AsysConnect posts\neach event as JSON, `{\"id\", \"type\", \"created_at\", \"workspace_id\", \"data\"}`, with these headers:\n\n- `X-AsysSuite-Event`: the event type, e.g. `message.received`\n- `X-AsysSuite-Delivery`: the delivery id (the same on retries)\n- `X-AsysSuite-Signature`: `t=<unix time>,v1=<signature>`\n\nCheck the signature before trusting the body: compute HMAC-SHA256 of `<t>.<raw body>` with the\nendpoint's secret (`whsec_...`), compare it in constant time with `v1`, and refuse times more\nthan five minutes old. Answer with any 2xx within 10 seconds; do slow work afterwards. Anything\nelse is tried again after 1 minute, 5 minutes, 30 minutes, 2, 6 and 12 hours. An event can\narrive more than once, so use `id` to skip repeats. The developer guide has PHP and Node.js\nexamples."},"servers":[{"url":"https://asysconnect.online"}],"security":[{"apiKey":[]}],"tags":[{"name":"Contacts"},{"name":"Tags"},{"name":"Custom fields"},{"name":"Segments"},{"name":"Imports"},{"name":"Team"},{"name":"Inbox"},{"name":"Messages"},{"name":"Broadcasts"},{"name":"WhatsApp"},{"name":"SMS","description":"SMS through DLT (India), on the workspace's own DLT registration or Asyscraft's."},{"name":"Email","description":"Email through Amazon SES (SMTP as a backup), from the workspace's own domain or AsysConnect's shared one."},{"name":"Sales","description":"Pipelines, deals that move through their stages, and follow-up tasks."},{"name":"AI","description":"Claude answers customer chats from the workspace's knowledge base, suggests replies and hands off to the team."},{"name":"Publishing","description":"Posts to Facebook Pages and Instagram, published now or on a schedule."},{"name":"Social","description":"Facebook Pages (Messenger) and Instagram accounts, their comments, comment-to-DM rules, and Lead Ads."},{"name":"Developers","description":"API keys and webhooks, for connecting other systems. GET /v1/openapi.json is the public guide."}],"paths":{"/v1/members":{"get":{"operationId":"listMembers","tags":["Team"],"summary":"List the workspace's members","x-required-permission":"members.read","responses":{"200":{"description":"All members, oldest first (not paginated).","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Member"}}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"apiKey":[]}],"x-permissions":["members.read"]}},"/v1/contacts":{"get":{"operationId":"listContacts","tags":["Contacts"],"summary":"List contacts, newest first, with search and filters","x-required-permission":"contacts.read","parameters":[{"name":"q","in":"query","description":"Matches the display name or any phone number or email (substring).","schema":{"type":"string","maxLength":120}},{"name":"tag_id","in":"query","schema":{"type":"string","format":"uuid"}},{"name":"segment_id","in":"query","schema":{"type":"string","format":"uuid"}},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":200,"default":50}},{"$ref":"#/components/parameters/Cursor"}],"responses":{"200":{"description":"A page of contacts.","content":{"application/json":{"schema":{"type":"object","required":["data","next_cursor"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Contact"}},"next_cursor":{"$ref":"#/components/schemas/NextCursor"}}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}},"security":[{"apiKey":[]}],"x-permissions":["contacts.read"]},"post":{"operationId":"createContact","tags":["Contacts"],"summary":"Create a contact","x-required-permission":"contacts.write","requestBody":{"required":true,"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/ContactFields"},{"type":"object","properties":{"channels":{"type":"array","maxItems":10,"default":[],"items":{"$ref":"#/components/schemas/ContactChannelInput"}},"tag_ids":{"type":"array","maxItems":50,"items":{"type":"string","format":"uuid"}}}}]}}}},"responses":{"201":{"description":"The new contact.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Contact"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"409":{"$ref":"#/components/responses/Conflict"}},"security":[{"apiKey":[]}],"x-permissions":["contacts.write"]}},"/v1/contacts/bulk/tags":{"post":{"operationId":"bulkTagContacts","tags":["Contacts"],"summary":"Add and remove tags on many contacts at once","x-required-permission":"contacts.write","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["contact_ids"],"description":"At least one of add or remove must be non-empty.","properties":{"contact_ids":{"type":"array","minItems":1,"maxItems":1000,"items":{"type":"string","format":"uuid"}},"add":{"type":"array","maxItems":50,"default":[],"items":{"type":"string","format":"uuid"}},"remove":{"type":"array","maxItems":50,"default":[],"items":{"type":"string","format":"uuid"}}}}}}},"responses":{"200":{"description":"Done.","content":{"application/json":{"schema":{"type":"object","required":["updated"],"properties":{"updated":{"type":"integer","description":"Number of contact ids sent."}}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}},"security":[{"apiKey":[]}],"x-permissions":["contacts.write"]}},"/v1/contacts/{id}":{"get":{"operationId":"getContact","tags":["Contacts"],"summary":"Get a contact","x-required-permission":"contacts.read","responses":{"200":{"description":"The contact.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Contact"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}},"security":[{"apiKey":[]}],"x-permissions":["contacts.read"]},"patch":{"operationId":"updateContact","tags":["Contacts"],"summary":"Update a contact's fields","description":"Only the fields sent change. `custom` is merged into the existing values; a key set to\nnull is removed. Phone numbers and emails are changed with PUT /v1/contacts/{id}/channels.\n","x-required-permission":"contacts.write","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContactFields"}}}},"responses":{"200":{"description":"The updated contact.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Contact"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}},"security":[{"apiKey":[]}],"x-permissions":["contacts.write"]},"delete":{"operationId":"deleteContact","tags":["Contacts"],"summary":"Permanently delete a contact with its channels, tags, consents and messages","x-required-permission":"contacts.delete","responses":{"204":{"description":"Deleted."},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}},"security":[{"apiKey":[]}],"x-permissions":["contacts.delete"]}},"/v1/contacts/{id}/channels":{"put":{"operationId":"setContactChannels","tags":["Contacts"],"summary":"Replace a contact's phone numbers and email addresses","x-required-permission":"contacts.write","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["channels"],"properties":{"channels":{"type":"array","maxItems":10,"items":{"$ref":"#/components/schemas/ContactChannelInput"}}}}}}},"responses":{"200":{"description":"The updated contact.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Contact"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"$ref":"#/components/responses/Conflict"}},"security":[{"apiKey":[]}],"x-permissions":["contacts.write"]}},"/v1/contacts/{id}/consents":{"get":{"operationId":"listContactConsents","tags":["Contacts"],"summary":"Get a contact's consent history, newest first","x-required-permission":"contacts.read","responses":{"200":{"description":"Every consent record.","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/ConsentRecord"}}}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}},"security":[{"apiKey":[]}],"x-permissions":["contacts.read"]},"post":{"operationId":"recordContactConsent","tags":["Contacts"],"summary":"Record an opt-in or opt-out for a contact","description":"The caller's user id is added to `evidence.recorded_by`.","x-required-permission":"contacts.write","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["channel","status"],"properties":{"channel":{"$ref":"#/components/schemas/ConsentChannel"},"status":{"type":"string","enum":["opted_in","opted_out"]},"purpose":{"type":"string","enum":["marketing","transactional"],"default":"marketing"},"source":{"type":"string","maxLength":40,"default":"agent"},"evidence":{"type":"object","additionalProperties":true}}}}}},"responses":{"201":{"description":"The contact with its updated consent.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Contact"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}},"security":[{"apiKey":[]}],"x-permissions":["contacts.write"]}},"/v1/contacts/{id}/tags":{"post":{"operationId":"addContactTags","tags":["Contacts"],"summary":"Add tags to a contact","x-required-permission":"contacts.write","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["tag_ids"],"properties":{"tag_ids":{"type":"array","minItems":1,"maxItems":50,"items":{"type":"string","format":"uuid"}}}}}}},"responses":{"200":{"description":"The updated contact.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Contact"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}},"security":[{"apiKey":[]}],"x-permissions":["contacts.write"]}},"/v1/contacts/{id}/tags/{tagId}":{"delete":{"operationId":"removeContactTag","tags":["Contacts"],"summary":"Remove a tag from a contact","x-required-permission":"contacts.write","responses":{"200":{"description":"The updated contact (this DELETE returns a body, not 204).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Contact"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}},"security":[{"apiKey":[]}],"x-permissions":["contacts.write"]}},"/v1/tags":{"get":{"operationId":"listTags","tags":["Tags"],"summary":"List tags with their contact counts, by name","x-required-permission":"contacts.read","responses":{"200":{"description":"All tags (not paginated).","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"array","items":{"allOf":[{"$ref":"#/components/schemas/Tag"},{"type":"object","required":["contact_count"],"properties":{"contact_count":{"type":"integer"}}}]}}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"apiKey":[]}],"x-permissions":["contacts.read"]},"post":{"operationId":"createTag","tags":["Tags"],"summary":"Create a tag","x-required-permission":"contacts.write","requestBody":{"required":true,"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/TagInput"},{"required":["name"]}]}}}},"responses":{"201":{"description":"The new tag.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Tag"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"409":{"$ref":"#/components/responses/Conflict"}},"security":[{"apiKey":[]}],"x-permissions":["contacts.write"]}},"/v1/tags/{id}":{"patch":{"operationId":"updateTag","tags":["Tags"],"summary":"Rename or recolor a tag","x-required-permission":"contacts.write","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TagInput"}}}},"responses":{"200":{"description":"The updated tag.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Tag"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"$ref":"#/components/responses/Conflict"}},"security":[{"apiKey":[]}],"x-permissions":["contacts.write"]},"delete":{"operationId":"deleteTag","tags":["Tags"],"summary":"Delete a tag, removing it from every contact","x-required-permission":"contacts.delete","responses":{"204":{"description":"Deleted."},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}},"security":[{"apiKey":[]}],"x-permissions":["contacts.delete"]}},"/v1/custom-fields":{"get":{"operationId":"listCustomFields","tags":["Custom fields"],"summary":"List the workspace's custom contact fields","x-required-permission":"contacts.read","responses":{"200":{"description":"All fields, oldest first.","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/CustomField"}}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"apiKey":[]}],"x-permissions":["contacts.read"]}},"/v1/segments":{"get":{"operationId":"listSegments","tags":["Segments"],"summary":"List saved segments, by name","x-required-permission":"contacts.read","responses":{"200":{"description":"All segments.","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Segment"}}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"apiKey":[]}],"x-permissions":["contacts.read"]},"post":{"operationId":"createSegment","tags":["Segments"],"summary":"Save a segment","x-required-permission":"contacts.write","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["name","filter"],"properties":{"name":{"type":"string","minLength":1,"maxLength":120},"filter":{"$ref":"#/components/schemas/SegmentFilter"}}}}}},"responses":{"201":{"description":"The new segment.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Segment"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"apiKey":[]}],"x-permissions":["contacts.write"]}},"/v1/segments/preview":{"post":{"operationId":"previewSegment","tags":["Segments"],"summary":"Count the contacts matching an unsaved filter, with a sample of 5","x-required-permission":"contacts.read","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["filter"],"properties":{"filter":{"$ref":"#/components/schemas/SegmentFilter"}}}}}},"responses":{"200":{"description":"Matching count and newest matches.","content":{"application/json":{"schema":{"type":"object","required":["count","sample"],"properties":{"count":{"type":"integer"},"sample":{"type":"array","maxItems":5,"items":{"$ref":"#/components/schemas/Contact"}}}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"apiKey":[]}],"x-permissions":["contacts.read"]}},"/v1/segments/{id}":{"get":{"operationId":"getSegment","tags":["Segments"],"summary":"Get a segment with its current contact count","x-required-permission":"contacts.read","responses":{"200":{"description":"The segment.","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/Segment"},{"type":"object","required":["contact_count"],"properties":{"contact_count":{"type":"integer"}}}]}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}},"security":[{"apiKey":[]}],"x-permissions":["contacts.read"]},"patch":{"operationId":"updateSegment","tags":["Segments"],"summary":"Rename a segment or change its filter","x-required-permission":"contacts.write","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":120},"filter":{"$ref":"#/components/schemas/SegmentFilter"}}}}}},"responses":{"200":{"description":"The updated segment (without contact_count).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Segment"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}},"security":[{"apiKey":[]}],"x-permissions":["contacts.write"]},"delete":{"operationId":"deleteSegment","tags":["Segments"],"summary":"Delete a segment","x-required-permission":"contacts.write","responses":{"204":{"description":"Deleted."},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}},"security":[{"apiKey":[]}],"x-permissions":["contacts.write"]}},"/v1/imports":{"post":{"operationId":"uploadImport","tags":["Imports"],"summary":"Upload a CSV or Excel file of contacts (step 1 of 2)","description":"Parses the file and returns its headers, the first 5 rows and a suggested column\nmapping. Nothing is imported until POST /v1/imports/{id}/start. Files up to 20 MB and\n100,000 rows; `.csv`, `.txt` (CSV) or `.xlsx`, judged by the file name.\n","x-required-permission":"contacts.write","requestBody":{"required":true,"content":{"multipart/form-data":{"schema":{"type":"object","required":["file"],"properties":{"file":{"type":"string","format":"binary","contentMediaType":"application/octet-stream"}}},"encoding":{"file":{"contentType":"text/csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}}}}},"responses":{"201":{"description":"The file was parsed.","content":{"application/json":{"schema":{"type":"object","required":["id","file_name","headers","total_rows","preview","suggested_mapping"],"properties":{"id":{"type":"string","format":"uuid"},"file_name":{"type":"string"},"headers":{"type":"array","items":{"type":"string"}},"total_rows":{"type":"integer"},"preview":{"type":"array","description":"Up to 5 data rows, each an array of cell strings.","items":{"type":"array","items":{"type":"string"}}},"suggested_mapping":{"$ref":"#/components/schemas/ImportMapping"}}}}}},"400":{"description":"`FILE_INVALID` (missing, wrong type, too large or unreadable).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"apiKey":[]}],"x-permissions":["contacts.write"]},"get":{"operationId":"listImports","tags":["Imports"],"summary":"List the 50 most recent imports","x-required-permission":"contacts.read","responses":{"200":{"description":"Newest first (not paginated).","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Import"}}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"apiKey":[]}],"x-permissions":["contacts.read"]}},"/v1/imports/{id}":{"get":{"operationId":"getImport","tags":["Imports"],"summary":"Get an import's progress, counts and row errors","x-required-permission":"contacts.read","responses":{"200":{"description":"The import. Poll it while status is queued or processing.","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/Import"},{"type":"object","required":["errors"],"properties":{"errors":{"type":"array","description":"The first 1,000 row errors.","items":{"type":"object","properties":{"row":{"type":"integer"},"message":{"type":"string"}}}}}}]}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}},"security":[{"apiKey":[]}],"x-permissions":["contacts.read"]}},"/v1/imports/{id}/start":{"post":{"operationId":"startImport","tags":["Imports"],"summary":"Save the column mapping and queue the import (step 2 of 2)","description":"At least one column must map to phone or email.","x-required-permission":"contacts.write","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["mapping"],"properties":{"mapping":{"$ref":"#/components/schemas/ImportMapping"},"dedupe_mode":{"type":"string","enum":["skip","update"],"default":"skip","description":"What to do with rows matching an existing contact's phone or email."},"tag_ids":{"type":"array","maxItems":10,"default":[],"description":"Tags added to every imported contact.","items":{"type":"string","format":"uuid"}}}}}}},"responses":{"202":{"description":"Queued; the worker processes it in the background.","content":{"application/json":{"schema":{"type":"object","required":["id","status"],"properties":{"id":{"type":"string","format":"uuid"},"status":{"type":"string","const":"queued"}}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"description":"`IMPORT_INVALID_STATE`: the import was already started.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"security":[{"apiKey":[]}],"x-permissions":["contacts.write"]}},"/v1/conversations":{"get":{"operationId":"listConversations","tags":["Inbox"],"summary":"List conversations, most recent activity first","x-required-permission":"conversations.read","parameters":[{"name":"status","in":"query","schema":{"type":"string","enum":["open","closed"]}},{"name":"assigned_to","in":"query","description":"A member's user id, `me`, or `none` for unassigned.","schema":{"anyOf":[{"type":"string","format":"uuid"},{"type":"string","enum":["me","none"]}]}},{"name":"q","in":"query","description":"Matches the contact's name or phone number.","schema":{"type":"string","minLength":1,"maxLength":100}},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":100,"default":30}},{"$ref":"#/components/parameters/Cursor"}],"responses":{"200":{"description":"A page of conversations.","content":{"application/json":{"schema":{"type":"object","required":["data","next_cursor"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Conversation"}},"next_cursor":{"$ref":"#/components/schemas/NextCursor"}}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"apiKey":[]}],"x-permissions":["conversations.read"]}},"/v1/conversations/{id}":{"get":{"operationId":"getConversation","tags":["Inbox"],"summary":"Get a conversation","x-required-permission":"conversations.read","responses":{"200":{"description":"The conversation.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Conversation"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}},"security":[{"apiKey":[]}],"x-permissions":["conversations.read"]},"patch":{"operationId":"updateConversation","tags":["Inbox"],"summary":"Assign, unassign, open or close a conversation","x-required-permission":"conversations.write","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","description":"At least one field is required.","properties":{"status":{"type":"string","enum":["open","closed"]},"assigned_to":{"type":["string","null"],"format":"uuid","description":"An active member's user id, or null to unassign."}}}}}},"responses":{"200":{"description":"The updated conversation.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Conversation"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}},"security":[{"apiKey":[]}],"x-permissions":["conversations.write"]}},"/v1/conversations/{id}/messages":{"get":{"operationId":"listConversationMessages","tags":["Inbox"],"summary":"List a conversation's messages, newest first, and mark it read","description":"Resets the conversation's unread_count to 0.","x-required-permission":"conversations.read","parameters":[{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":100,"default":50}},{"$ref":"#/components/parameters/Cursor"}],"responses":{"200":{"description":"A page of messages.","content":{"application/json":{"schema":{"type":"object","required":["data","window_open","next_cursor"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Message"}},"window_open":{"type":"boolean","description":"True while the customer's last message is under 24 hours old, so free-form\ntext can be sent. Otherwise only approved templates can be sent.\n"},"next_cursor":{"$ref":"#/components/schemas/NextCursor"}}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}},"security":[{"apiKey":[]}],"x-permissions":["conversations.read"]},"post":{"operationId":"replyInConversation","tags":["Inbox"],"summary":"Reply with text in the conversation's own channel","description":"WhatsApp (from the number the thread is on), Instagram or Messenger. All of them allow\nfree text only within 24 hours of the customer's last message; after that, WhatsApp\nneeds a template (POST /v1/messages) and Instagram and Messenger cannot be messaged.\n","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["text"],"properties":{"text":{"type":"string","minLength":1,"maxLength":4096}}}}}},"responses":{"202":{"description":"Queued. The message has status `queued`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Message"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"description":"`WHATSAPP_WINDOW_CLOSED` or `SOCIAL_WINDOW_CLOSED` (no customer message in 24 hours),\n`SOCIAL_NOT_CONNECTED` or `WHATSAPP_NOT_CONNECTED`.\n","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"security":[{"apiKey":[]}],"x-permissions":["conversations.write"]}},"/v1/messages":{"post":{"operationId":"sendMessage","tags":["Messages"],"summary":"Queue a WhatsApp text or template message","description":"Give exactly one of `contact_id` or `to` (a phone number; the contact is created if\nnew). Free-form text only works inside the 24-hour window after the customer's last\nmessage. Templates must be approved; marketing templates need the contact's WhatsApp\nopt-in, and templates are charged to the wallet (refunded if they fail). Delivery\nstatus updates arrive later; re-fetch the conversation's messages to see them. Only JSON\nis accepted: sending media from the app is not supported by this API.\n","x-required-permission":"conversations.write","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SendMessageRequest"}}}},"responses":{"202":{"description":"Queued. The message has status `queued`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Message"}}}},"400":{"description":"`VALIDATION_FAILED` or `TEMPLATE_PARAMS_INVALID` (template variables do not match).\n","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"402":{"description":"`INSUFFICIENT_BALANCE`: the wallet cannot pay for this template.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"`FORBIDDEN`, or `WORKSPACE_SUSPENDED`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"$ref":"#/components/responses/NotFound"},"409":{"description":"`WHATSAPP_NOT_CONNECTED`, `WHATSAPP_WINDOW_CLOSED`, `TEMPLATE_NOT_APPROVED` or\n`CONSENT_REQUIRED`.\n","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"security":[{"apiKey":[]}],"x-permissions":["conversations.write"]}},"/v1/messages/{id}/media":{"get":{"operationId":"downloadMessageMedia","tags":["Messages"],"summary":"Download the photo, video, voice note, sticker or file of an inbound message","description":"Streams the file from Meta. Needs the Authorization header like every other call, so an\nimage loader must add it. Meta keeps media for about 30 days. Images, audio and video are\nserved `inline`; other files as an attachment with their file name. Files up to 25 MB.\n","x-required-permission":"conversations.read","responses":{"200":{"description":"The file, with Meta's content type.","headers":{"Content-Disposition":{"schema":{"type":"string"},"description":"`inline`, or `attachment; filename=\"...\"`."},"Cache-Control":{"schema":{"type":"string","example":"private, max-age=3600"}}},"content":{"application/octet-stream":{"schema":{"type":"string","format":"binary"}},"image/*":{"schema":{"type":"string","format":"binary"}},"audio/*":{"schema":{"type":"string","format":"binary"}},"video/*":{"schema":{"type":"string","format":"binary"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"description":"Not an inbound message with media.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"$ref":"#/components/responses/MetaError"}},"security":[{"apiKey":[]}],"x-permissions":["conversations.read"]}},"/v1/broadcasts":{"get":{"operationId":"listBroadcasts","tags":["Broadcasts"],"summary":"List the 100 most recent broadcasts","x-required-permission":"broadcasts.manage","responses":{"200":{"description":"Newest first (not paginated).","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"array","items":{"allOf":[{"$ref":"#/components/schemas/Broadcast"},{"type":"object","required":["recipients","delivered","read"],"properties":{"recipients":{"type":"integer"},"delivered":{"type":"integer"},"read":{"type":"integer"}}}]}}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"apiKey":[]}],"x-permissions":["broadcasts.manage"]},"post":{"operationId":"createBroadcast","tags":["Broadcasts"],"summary":"Create a draft broadcast","x-required-permission":"broadcasts.manage","requestBody":{"required":true,"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/BroadcastInput"},{"required":["name","template_id","audience"]}]}}}},"responses":{"201":{"description":"The new draft.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BroadcastDetail"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"description":"`WHATSAPP_NOT_CONNECTED` or `TEMPLATE_NOT_APPROVED`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"security":[{"apiKey":[]}],"x-permissions":["broadcasts.manage"]}},"/v1/broadcasts/{id}":{"get":{"operationId":"getBroadcast","tags":["Broadcasts"],"summary":"Get a broadcast with live counts, audience size, cost and a message preview","x-required-permission":"broadcasts.manage","responses":{"200":{"description":"The broadcast.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BroadcastDetail"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}},"security":[{"apiKey":[]}],"x-permissions":["broadcasts.manage"]},"patch":{"operationId":"updateBroadcast","tags":["Broadcasts"],"summary":"Edit a draft broadcast","x-required-permission":"broadcasts.manage","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BroadcastInput"}}}},"responses":{"200":{"description":"The updated draft.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BroadcastDetail"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"description":"`BROADCAST_INVALID_STATE` (not a draft), `WHATSAPP_NOT_CONNECTED` or\n`TEMPLATE_NOT_APPROVED`.\n","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"security":[{"apiKey":[]}],"x-permissions":["broadcasts.manage"]},"delete":{"operationId":"deleteBroadcast","tags":["Broadcasts"],"summary":"Delete a draft broadcast","x-required-permission":"broadcasts.manage","responses":{"204":{"description":"Deleted."},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"description":"`BROADCAST_INVALID_STATE`: only drafts can be deleted.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"security":[{"apiKey":[]}],"x-permissions":["broadcasts.manage"]}},"/v1/broadcasts/{id}/schedule":{"post":{"operationId":"scheduleBroadcast","tags":["Broadcasts"],"summary":"Send a draft broadcast now or schedule it (up to 90 days ahead)","description":"Sending now needs enough wallet balance for every eligible recipient\n(`402 INSUFFICIENT_BALANCE`, with `details.cost_paise` and `details.balance_paise`).\n","x-required-permission":"broadcasts.manage","requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"scheduled_at":{"type":"string","format":"date-time","description":"Omit to send now."}}}}}},"responses":{"201":{"description":"Scheduled (status `scheduled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BroadcastDetail"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"402":{"description":"`INSUFFICIENT_BALANCE`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"description":"`BROADCAST_INVALID_STATE` (not a draft), `WHATSAPP_NOT_CONNECTED` or\n`TEMPLATE_NOT_APPROVED`.\n","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"security":[{"apiKey":[]}],"x-permissions":["broadcasts.manage"]}},"/v1/broadcasts/{id}/cancel":{"post":{"operationId":"cancelBroadcast","tags":["Broadcasts"],"summary":"Stop a scheduled or sending broadcast","description":"Messages not yet handed to Meta are not sent.","x-required-permission":"broadcasts.manage","responses":{"201":{"description":"Cancelled (status `cancelled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BroadcastDetail"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"description":"`BROADCAST_INVALID_STATE`: nothing left to stop.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"security":[{"apiKey":[]}],"x-permissions":["broadcasts.manage"]}},"/v1/broadcasts/{id}/recipients":{"get":{"operationId":"listBroadcastRecipients","tags":["Broadcasts"],"summary":"List a broadcast's recipients and their outcome, by name","x-required-permission":"broadcasts.manage","parameters":[{"name":"status","in":"query","schema":{"$ref":"#/components/schemas/RecipientStatus"}},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":500,"default":100}}],"responses":{"200":{"description":"Up to `limit` recipients (no cursor).","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/BroadcastRecipient"}}}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}},"security":[{"apiKey":[]}],"x-permissions":["broadcasts.manage"]}},"/v1/whatsapp/accounts":{"get":{"operationId":"listWhatsAppAccounts","tags":["WhatsApp"],"summary":"List connected WhatsApp Business accounts and their numbers","x-required-permission":"conversations.read","responses":{"200":{"description":"Active accounts, oldest first.","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/WhatsAppAccount"}}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"apiKey":[]}],"x-permissions":["conversations.read"]}},"/v1/whatsapp/templates":{"get":{"operationId":"listTemplates","tags":["WhatsApp"],"summary":"List message templates, by name and language","x-required-permission":"conversations.read","parameters":[{"name":"account_id","in":"query","description":"Only this WhatsApp account's templates.","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"All templates (not paginated).","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Template"}}}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"apiKey":[]}],"x-permissions":["conversations.read"]}},"/v1/sms/settings":{"get":{"operationId":"getSmsSettings","tags":["SMS"],"summary":"The workspace's DLT choice, whether Asyscraft's DLT is offered, and SMS prices","x-required-permission":"sms.send","responses":{"200":{"description":"SMS settings. `dlt_mode` is null until the workspace chooses.","content":{"application/json":{"schema":{"type":"object","required":["dlt_mode","dlt_entity_id","business_name","platform_dlt","providers_connected","rates"],"properties":{"dlt_mode":{"type":["string","null"],"enum":["own","platform",null]},"dlt_entity_id":{"type":["string","null"]},"business_name":{"type":["string","null"]},"platform_dlt":{"type":"object","description":"Asyscraft's own DLT registration, which workspaces can send under.","properties":{"available":{"type":"boolean"},"business_name":{"type":["string","null"]}}},"providers_connected":{"type":"boolean","description":"False while no SMS provider is connected on the server."},"rates":{"type":"array","items":{"type":"object","properties":{"category":{"type":"string","enum":["TRANSACTIONAL","SERVICE","PROMOTIONAL"]},"price_paise":{"type":"integer","description":"Price per SMS part."}}}}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"apiKey":[]}],"x-permissions":["sms.send"]},"put":{"operationId":"saveSmsSettings","tags":["SMS"],"summary":"Choose the workspace's own DLT registration or Asyscraft's","description":"`own` needs the workspace's Principal Entity ID. `platform` sends under Asyscraft's\nregistration (409 `SMS_NOT_SET_UP` until AsysConnect has entered it). Switching keeps the\nworkspace's own entity ID for switching back. Sender IDs and templates belong to the\nregistration they were added under.\n","x-required-permission":"sms.manage","requestBody":{"required":true,"content":{"application/json":{"schema":{"oneOf":[{"type":"object","required":["dlt_mode","dlt_entity_id"],"properties":{"dlt_mode":{"type":"string","const":"own"},"dlt_entity_id":{"type":"string","pattern":"^[0-9]{10,25}$"},"business_name":{"type":"string","maxLength":150}}},{"type":"object","required":["dlt_mode"],"properties":{"dlt_mode":{"type":"string","const":"platform"},"business_name":{"type":"string","maxLength":150}}}]}}}},"responses":{"200":{"description":"The saved settings.","content":{"application/json":{"schema":{"type":"object","properties":{"dlt_mode":{"type":"string","enum":["own","platform"]},"dlt_entity_id":{"type":["string","null"]},"business_name":{"type":["string","null"]}}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"409":{"description":"`SMS_NOT_SET_UP`: Asyscraft's DLT is not available yet.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"security":[{"apiKey":[]}],"x-permissions":["sms.manage"]}},"/v1/sms/sender-ids":{"get":{"operationId":"listSmsSenderIds","tags":["SMS"],"summary":"List the workspace's sender IDs (headers)","x-required-permission":"sms.send","responses":{"200":{"description":"Sender IDs by header.","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/SmsSenderId"}}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"apiKey":[]}],"x-permissions":["sms.send"]},"post":{"operationId":"addSmsSenderId","tags":["SMS"],"summary":"Add a sender ID registered on DLT","description":"Promotional headers are 6 digits; transactional and service headers are 6 letters. It\nstarts `pending` until AsysConnect approves it. Needs the DLT choice saved first (409\n`SMS_NOT_SET_UP`).\n","x-required-permission":"sms.manage","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["header","type"],"properties":{"header":{"type":"string","pattern":"^([A-Za-z]{6}|[0-9]{6})$"},"type":{"type":"string","enum":["transactional","service","promotional"]}}}}}},"responses":{"201":{"description":"The sender ID, pending review.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SmsSenderId"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"409":{"$ref":"#/components/responses/SmsNotSetUp"}},"security":[{"apiKey":[]}],"x-permissions":["sms.manage"]}},"/v1/sms/sender-ids/{id}":{"delete":{"operationId":"removeSmsSenderId","tags":["SMS"],"summary":"Remove a sender ID and its templates","x-required-permission":"sms.manage","responses":{"204":{"description":"Removed."},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}},"security":[{"apiKey":[]}],"x-permissions":["sms.manage"]}},"/v1/sms/templates":{"get":{"operationId":"listSmsTemplates","tags":["SMS"],"summary":"List the workspace's DLT content templates","x-required-permission":"sms.send","responses":{"200":{"description":"Templates by name.","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/SmsTemplate"}}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"apiKey":[]}],"x-permissions":["sms.send"]},"post":{"operationId":"addSmsTemplate","tags":["SMS"],"summary":"Add a DLT content template","description":"Mark each variable with `{#var#}`, exactly as on the DLT portal. On the workspace's own\nDLT, `dlt_template_id` is required. On Asyscraft's DLT it is ignored: AsysConnect registers\nthe text and enters the id when approving. Promotional templates need a promotional\nsender ID and the other categories need a letter header.\n","x-required-permission":"sms.manage","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["sender_id","name","category","body"],"properties":{"sender_id":{"type":"string","format":"uuid"},"name":{"type":"string","minLength":1,"maxLength":100},"dlt_template_id":{"type":"string","pattern":"^[0-9]{10,25}$"},"category":{"$ref":"#/components/schemas/SmsCategory"},"body":{"type":"string","minLength":1,"maxLength":2000}}}}}},"responses":{"201":{"description":"The template, pending review.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SmsTemplate"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"$ref":"#/components/responses/SmsNotSetUp"}},"security":[{"apiKey":[]}],"x-permissions":["sms.manage"]}},"/v1/sms/templates/{id}":{"delete":{"operationId":"removeSmsTemplate","tags":["SMS"],"summary":"Remove a template","x-required-permission":"sms.manage","responses":{"204":{"description":"Removed."},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}},"security":[{"apiKey":[]}],"x-permissions":["sms.manage"]}},"/v1/sms/preview":{"post":{"operationId":"previewSms","tags":["SMS"],"summary":"The finished text, its parts and price, before sending","x-required-permission":"sms.send","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SmsTemplateValues"}}}},"responses":{"200":{"description":"The preview.","content":{"application/json":{"schema":{"type":"object","properties":{"body":{"type":"string"},"length":{"type":"integer"},"parts":{"type":"integer","description":"160 characters for one part (153 each when longer); 70 and 67 with Unicode."},"unicode":{"type":"boolean"},"price_paise":{"type":"integer"},"sendable_now":{"type":"boolean","description":"False for promotional SMS outside 9 am to 9 pm IST."}}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"$ref":"#/components/responses/SmsTemplateNotReady"}},"security":[{"apiKey":[]}],"x-permissions":["sms.send"]}},"/v1/sms/messages":{"get":{"operationId":"listSms","tags":["SMS"],"summary":"SMS history, newest first","x-required-permission":"sms.send","parameters":[{"name":"contact_id","in":"query","schema":{"type":"string","format":"uuid"}},{"name":"broadcast_id","in":"query","schema":{"type":"string","format":"uuid"}},{"name":"status","in":"query","schema":{"$ref":"#/components/schemas/SmsStatus"}},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":200,"default":50}}],"responses":{"200":{"description":"SMS.","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/SmsMessage"}}}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"apiKey":[]}],"x-permissions":["sms.send"]},"post":{"operationId":"sendSms","tags":["SMS"],"summary":"Send one SMS from an approved template","description":"Give `contact_id` or `to` (an Indian mobile; a contact is created for a new number). The\nprice times the number of parts is charged from the wallet at once and refunded if the\nSMS fails. Promotional SMS go only from 9 am to 9 pm IST (409 `SMS_OUTSIDE_HOURS`) and\nnot to contacts who opted out of SMS marketing (409 `CONSENT_REQUIRED`).\n","x-required-permission":"sms.send","requestBody":{"required":true,"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/SmsTemplateValues"},{"type":"object","properties":{"contact_id":{"type":"string","format":"uuid"},"to":{"type":"string","minLength":6,"maxLength":20}}}]}}}},"responses":{"201":{"description":"The queued SMS.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SmsMessage"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"402":{"$ref":"#/components/responses/InsufficientBalance"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"$ref":"#/components/responses/SmsTemplateNotReady"}},"security":[{"apiKey":[]}],"x-permissions":["sms.send"]}},"/v1/sms/broadcasts/estimate":{"post":{"operationId":"estimateSmsBroadcast","tags":["SMS"],"summary":"How many contacts can get an SMS broadcast and what it costs","x-required-permission":"sms.manage","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["template_id","audience"],"properties":{"template_id":{"type":"string","format":"uuid"},"audience":{"$ref":"#/components/schemas/Audience"}}}}}},"responses":{"200":{"description":"The estimate.","content":{"application/json":{"schema":{"type":"object","properties":{"total":{"type":"integer"},"with_mobile":{"type":"integer"},"eligible":{"type":"integer"},"parts_per_sms":{"type":"integer"},"cost_paise":{"type":"integer"},"balance_paise":{"type":"integer"}}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"$ref":"#/components/responses/SmsTemplateNotReady"}},"security":[{"apiKey":[]}],"x-permissions":["sms.manage"]}},"/v1/sms/broadcasts":{"get":{"operationId":"listSmsBroadcasts","tags":["SMS"],"summary":"The latest 100 SMS broadcasts with their numbers","x-required-permission":"sms.manage","responses":{"200":{"description":"Broadcasts, newest first.","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/SmsBroadcast"}}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"apiKey":[]}],"x-permissions":["sms.manage"]},"post":{"operationId":"createSmsBroadcast","tags":["SMS"],"summary":"Create and schedule an SMS broadcast","description":"Omit `scheduled_at` to send now. A promotional broadcast set outside 9 am to 9 pm IST\nmoves to the next 9 am (`moved_to_allowed_hours`). Sending now needs enough balance for\nevery eligible contact (402).\n","x-required-permission":"sms.manage","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["name","template_id","audience"],"properties":{"name":{"type":"string","minLength":1,"maxLength":120},"template_id":{"type":"string","format":"uuid"},"audience":{"$ref":"#/components/schemas/Audience"},"params":{"type":"array","description":"One value source per `{#var#}`, in order.","maxItems":20,"items":{"$ref":"#/components/schemas/VariableSource"}},"scheduled_at":{"type":"string","format":"date-time"}}}}}},"responses":{"201":{"description":"The scheduled broadcast.","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/SmsBroadcast"},{"type":"object","properties":{"moved_to_allowed_hours":{"type":"boolean"}}}]}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"402":{"$ref":"#/components/responses/InsufficientBalance"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"$ref":"#/components/responses/SmsTemplateNotReady"}},"security":[{"apiKey":[]}],"x-permissions":["sms.manage"]}},"/v1/sms/broadcasts/{id}":{"get":{"operationId":"getSmsBroadcast","tags":["SMS"],"summary":"One SMS broadcast with its numbers and skip reasons","x-required-permission":"sms.manage","responses":{"200":{"description":"The broadcast.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SmsBroadcast"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}},"security":[{"apiKey":[]}],"x-permissions":["sms.manage"]}},"/v1/sms/broadcasts/{id}/cancel":{"post":{"operationId":"cancelSmsBroadcast","tags":["SMS"],"summary":"Stop an SMS broadcast; SMS not yet sent are refunded","x-required-permission":"sms.manage","responses":{"200":{"description":"The cancelled broadcast.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SmsBroadcast"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"description":"`BROADCAST_INVALID_STATE`: already finished or cancelled.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"security":[{"apiKey":[]}],"x-permissions":["sms.manage"]}},"/v1/email/settings":{"get":{"operationId":"getEmailSettings","tags":["Email"],"summary":"The workspace's sending setup, domains, whether the shared domain is offered, and prices","x-required-permission":"email.send","responses":{"200":{"description":"Email settings. `settings` is null until the workspace saves them.","content":{"application/json":{"schema":{"type":"object","required":["settings","domains","platform","sender","providers_connected","rates"],"properties":{"settings":{"oneOf":[{"$ref":"#/components/schemas/EmailSettings"},{"type":"null"}]},"domains":{"type":"array","items":{"$ref":"#/components/schemas/EmailDomain"}},"platform":{"type":"object","description":"AsysConnect's shared sending domain.","properties":{"domain":{"type":["string","null"]},"available":{"type":["boolean","null"]}}},"sender":{"$ref":"#/components/schemas/EmailSender"},"providers_connected":{"type":"boolean","description":"False while no email provider is connected on the server."},"rates":{"type":"array","items":{"type":"object","properties":{"category":{"type":"string","enum":["MARKETING","TRANSACTIONAL"]},"price_paise":{"type":"integer"}}}}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"apiKey":[]}],"x-permissions":["email.send"]},"put":{"operationId":"saveEmailSettings","tags":["Email"],"summary":"Choose own domain or the shared AsysConnect domain, and the From name and address","description":"With `own`, `from_email` must be on a domain added under sending domains (it sends once\nthat domain is verified). With `platform`, `reply_to` is required and the shared domain\nmust be verified.\n","x-required-permission":"email.manage","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["sending_mode","from_name"],"properties":{"sending_mode":{"type":"string","enum":["own","platform"]},"from_name":{"type":"string","maxLength":100},"from_email":{"type":"string","format":"email"},"reply_to":{"type":"string","format":"email"},"postal_address":{"type":"string","maxLength":300,"description":"Shown in the footer of marketing emails."}}}}}},"responses":{"200":{"description":"The saved settings.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EmailSettings"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"409":{"$ref":"#/components/responses/EmailNotSetUp"}},"security":[{"apiKey":[]}],"x-permissions":["email.manage"]}},"/v1/email/domains":{"get":{"operationId":"listEmailDomains","tags":["Email"],"summary":"The workspace's sending domains with the DNS records to add","x-required-permission":"email.send","responses":{"200":{"description":"Domains, oldest first.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/EmailDomain"}}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"apiKey":[]}],"x-permissions":["email.send"]},"post":{"operationId":"addEmailDomain","tags":["Email"],"summary":"Add a sending domain; its DNS records appear shortly after","x-required-permission":"email.manage","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["domain"],"properties":{"domain":{"type":"string","example":"kurtahouse.in"}}}}}},"responses":{"201":{"description":"The domain, pending until its records check out.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EmailDomain"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"apiKey":[]}],"x-permissions":["email.manage"]}},"/v1/email/domains/{id}":{"delete":{"operationId":"removeEmailDomain","tags":["Email"],"summary":"Remove a sending domain","x-required-permission":"email.manage","responses":{"204":{"description":"Removed."},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}},"security":[{"apiKey":[]}],"x-permissions":["email.manage"]}},"/v1/email/domains/{id}/check":{"post":{"operationId":"checkEmailDomain","tags":["Email"],"summary":"Look up the domain's DNS records again","x-required-permission":"email.manage","responses":{"200":{"description":"The domain as it is now; the check result follows shortly.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EmailDomain"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}},"security":[{"apiKey":[]}],"x-permissions":["email.manage"]}},"/v1/email/templates":{"get":{"operationId":"listEmailTemplates","tags":["Email"],"summary":"Email templates","x-required-permission":"email.send","responses":{"200":{"description":"Templates by name.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/EmailTemplate"}}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"apiKey":[]}],"x-permissions":["email.send"]},"post":{"operationId":"createEmailTemplate","tags":["Email"],"summary":"Save an email template","x-required-permission":"email.manage","requestBody":{"$ref":"#/components/requestBodies/EmailTemplateInput"},"responses":{"201":{"description":"The template.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EmailTemplate"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"apiKey":[]}],"x-permissions":["email.manage"]}},"/v1/email/templates/{id}":{"put":{"operationId":"updateEmailTemplate","tags":["Email"],"summary":"Change a template; campaigns already scheduled keep their copy","x-required-permission":"email.manage","requestBody":{"$ref":"#/components/requestBodies/EmailTemplateInput"},"responses":{"200":{"description":"The template.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EmailTemplate"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}},"security":[{"apiKey":[]}],"x-permissions":["email.manage"]},"delete":{"operationId":"deleteEmailTemplate","tags":["Email"],"summary":"Delete a template","x-required-permission":"email.manage","responses":{"204":{"description":"Deleted."},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}},"security":[{"apiKey":[]}],"x-permissions":["email.manage"]}},"/v1/email/preview":{"post":{"operationId":"previewEmail","tags":["Email"],"summary":"The email as the recipient will see it, with sample values or a contact's","x-required-permission":"email.send","requestBody":{"required":true,"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/EmailContent"},{"type":"object","properties":{"contact_id":{"type":"string","format":"uuid"}}}]}}}},"responses":{"200":{"description":"Subject, finished HTML (with the footer), the sender and the price.","content":{"application/json":{"schema":{"type":"object","properties":{"subject":{"type":"string"},"html":{"type":"string"},"category":{"$ref":"#/components/schemas/EmailCategory"},"sender":{"$ref":"#/components/schemas/EmailSender"},"price_paise":{"type":"integer"}}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}},"security":[{"apiKey":[]}],"x-permissions":["email.send"]}},"/v1/email/messages":{"get":{"operationId":"listEmails","tags":["Email"],"summary":"Sent emails, newest first","x-required-permission":"email.send","parameters":[{"name":"contact_id","in":"query","schema":{"type":"string","format":"uuid"}},{"name":"campaign_id","in":"query","schema":{"type":"string","format":"uuid"}},{"name":"status","in":"query","schema":{"$ref":"#/components/schemas/EmailStatus"}},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":200,"default":50}}],"responses":{"200":{"description":"Emails.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/EmailMessage"}}}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"apiKey":[]}],"x-permissions":["email.send"]},"post":{"operationId":"sendEmail","tags":["Email"],"summary":"Send one email from a template, or with a subject and message written now","description":"Charged from the wallet when queued and refunded if it never leaves. Bounced and\ncomplained addresses get nothing; unsubscribed ones get transactional email only.\n","x-required-permission":"email.send","requestBody":{"required":true,"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/EmailContent"},{"type":"object","properties":{"contact_id":{"type":"string","format":"uuid"},"to":{"type":"string","format":"email","description":"A contact is created for a new address."}}}]}}}},"responses":{"201":{"description":"The queued email.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EmailMessage"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"402":{"$ref":"#/components/responses/InsufficientBalance"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"description":"`EMAIL_NOT_SET_UP`, `EMAIL_SUPPRESSED`, `CONSENT_REQUIRED` or `WORKSPACE_SUSPENDED`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"security":[{"apiKey":[]}],"x-permissions":["email.send"]}},"/v1/email/campaigns/estimate":{"post":{"operationId":"estimateEmailCampaign","tags":["Email"],"summary":"How many in an audience can get the email, and what it costs","x-required-permission":"email.manage","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["template_id","audience"],"properties":{"template_id":{"type":"string","format":"uuid"},"audience":{"$ref":"#/components/schemas/Audience"}}}}}},"responses":{"200":{"description":"Counts and cost.","content":{"application/json":{"schema":{"type":"object","properties":{"total":{"type":"integer"},"with_email":{"type":"integer"},"eligible":{"type":"integer"},"cost_paise":{"type":"integer"},"balance_paise":{"type":"integer"}}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}},"security":[{"apiKey":[]}],"x-permissions":["email.manage"]}},"/v1/email/campaigns":{"get":{"operationId":"listEmailCampaigns","tags":["Email"],"summary":"Email campaigns with their numbers","x-required-permission":"email.manage","responses":{"200":{"description":"The latest 100 campaigns.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/EmailCampaign"}}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"apiKey":[]}],"x-permissions":["email.manage"]},"post":{"operationId":"createEmailCampaign","tags":["Email"],"summary":"Schedule a campaign to a tag, segment or list of contacts","x-required-permission":"email.manage","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["name","template_id","audience"],"properties":{"name":{"type":"string","maxLength":120},"template_id":{"type":"string","format":"uuid"},"audience":{"$ref":"#/components/schemas/Audience"},"scheduled_at":{"type":"string","format":"date-time","description":"Omit to send now. At most 90 days ahead."}}}}}},"responses":{"201":{"description":"The scheduled campaign.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EmailCampaign"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"402":{"$ref":"#/components/responses/InsufficientBalance"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"$ref":"#/components/responses/EmailNotSetUp"}},"security":[{"apiKey":[]}],"x-permissions":["email.manage"]}},"/v1/email/campaigns/{id}":{"get":{"operationId":"getEmailCampaign","tags":["Email"],"summary":"One campaign with its numbers and why people were skipped","x-required-permission":"email.manage","responses":{"200":{"description":"The campaign.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EmailCampaign"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}},"security":[{"apiKey":[]}],"x-permissions":["email.manage"]}},"/v1/email/campaigns/{id}/cancel":{"post":{"operationId":"cancelEmailCampaign","tags":["Email"],"summary":"Stop a campaign; emails not yet sent are refunded","x-required-permission":"email.manage","responses":{"200":{"description":"The cancelled campaign.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EmailCampaign"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"description":"`BROADCAST_INVALID_STATE`: already finished or cancelled.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"security":[{"apiKey":[]}],"x-permissions":["email.manage"]}},"/v1/email/suppressions":{"get":{"operationId":"listEmailSuppressions","tags":["Email"],"summary":"Addresses the workspace no longer emails (bounces, spam complaints, unsubscribes)","x-required-permission":"email.send","responses":{"200":{"description":"The latest 500.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/EmailSuppression"}}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"apiKey":[]}],"x-permissions":["email.send"]},"post":{"operationId":"addEmailSuppression","tags":["Email"],"summary":"Block an address by hand","x-required-permission":"email.manage","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["email"],"properties":{"email":{"type":"string","format":"email"},"detail":{"type":"string","maxLength":300}}}}}},"responses":{"201":{"description":"The entry.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EmailSuppression"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"apiKey":[]}],"x-permissions":["email.manage"]}},"/v1/email/suppressions/{email}":{"delete":{"operationId":"removeEmailSuppression","tags":["Email"],"summary":"Unblock an address; unsubscribes and spam complaints cannot be removed","x-required-permission":"email.manage","responses":{"204":{"description":"Removed."},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}},"security":[{"apiKey":[]}],"x-permissions":["email.manage"]}},"/v1/social/accounts":{"get":{"operationId":"listSocialAccounts","tags":["Social"],"summary":"The workspace's connected Pages and Instagram accounts","responses":{"200":{"description":"Connected accounts.","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/SocialAccount"}}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"apiKey":[]}],"x-permissions":["conversations.read"]}},"/v1/social/rules":{"get":{"operationId":"listSocialRules","tags":["Social"],"summary":"Comment-to-DM rules, oldest first (the first match wins)","responses":{"200":{"description":"Rules.","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/SocialRule"}}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"apiKey":[]}],"x-permissions":["conversations.read"]}},"/v1/social/comments":{"get":{"operationId":"listSocialComments","tags":["Social"],"summary":"Comments on the connected accounts' posts, newest first","parameters":[{"name":"account_id","in":"query","schema":{"type":"string","format":"uuid"}},{"name":"filter","in":"query","description":"`auto`: answered by a rule. `unanswered`: no reply or DM sent.","schema":{"type":"string","enum":["all","auto","unanswered"],"default":"all"}},{"$ref":"#/components/parameters/Cursor"},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":100,"default":50}}],"responses":{"200":{"description":"A page of comments.","content":{"application/json":{"schema":{"type":"object","required":["data","next_cursor"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/SocialComment"}},"next_cursor":{"type":["string","null"]}}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"apiKey":[]}],"x-permissions":["conversations.read"]}},"/v1/social/comments/{id}/reply":{"post":{"operationId":"replyToSocialComment","tags":["Social"],"summary":"Reply to a comment publicly, or privately by DM","description":"A private reply is allowed once per comment, within 7 days of it.","parameters":[{"$ref":"#/components/parameters/Id"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["text"],"properties":{"text":{"type":"string","minLength":1,"maxLength":1000},"private":{"type":"boolean","default":false}}}}}},"responses":{"202":{"description":"Queued; the worker sends it.","content":{"application/json":{"schema":{"type":"object","required":["queued"],"properties":{"queued":{"type":"boolean"}}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"description":"`SOCIAL_REPLY_NOT_ALLOWED` or `SOCIAL_NOT_CONNECTED`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"security":[{"apiKey":[]}],"x-permissions":["conversations.write"]}},"/v1/social/lead-forms":{"get":{"operationId":"listLeadForms","tags":["Social"],"summary":"Lead Ads forms on the connected Pages, with how their answers fill contacts","responses":{"200":{"description":"Forms.","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/LeadForm"}}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"apiKey":[]}],"x-permissions":["contacts.read"]}},"/v1/social/leads":{"get":{"operationId":"listLeads","tags":["Social"],"summary":"Leads from Lead Ads, newest first, with the contact each became","parameters":[{"name":"form_id","in":"query","schema":{"type":"string","format":"uuid"}},{"name":"status","in":"query","schema":{"type":"string","enum":["pending","added","updated","failed"]}},{"$ref":"#/components/parameters/Cursor"},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":100,"default":50}}],"responses":{"200":{"description":"A page of leads.","content":{"application/json":{"schema":{"type":"object","required":["data","next_cursor"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Lead"}},"next_cursor":{"type":["string","null"]}}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"apiKey":[]}],"x-permissions":["contacts.read"]}},"/v1/social/leads/{id}/retry":{"post":{"operationId":"retryLead","tags":["Social"],"summary":"Try a failed lead again","parameters":[{"$ref":"#/components/parameters/Id"}],"responses":{"202":{"description":"Queued.","content":{"application/json":{"schema":{"type":"object","required":["queued"],"properties":{"queued":{"type":"boolean"}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"description":"`NOT_FOUND`: no failed lead with this id.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"security":[{"apiKey":[]}],"x-permissions":["contacts.write"]}},"/v1/social/media":{"post":{"operationId":"uploadPostPhoto","tags":["Publishing"],"summary":"Upload a photo for a post","description":"JPEG or PNG, up to 8 MB. Instagram accepts JPEG only. The returned `url` is a public,\nunguessable link (under `/v1/public/post-media`) that Meta downloads the photo from.\n","x-required-permission":"social.publish","requestBody":{"required":true,"content":{"multipart/form-data":{"schema":{"type":"object","required":["file"],"properties":{"file":{"type":"string","format":"binary","contentMediaType":"application/octet-stream"}}},"encoding":{"file":{"contentType":"image/jpeg, image/png"}}}}},"responses":{"201":{"description":"Stored.","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/PostPhoto"},{"type":"object","required":["size_bytes"],"properties":{"size_bytes":{"type":"integer"}}}]}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"apiKey":[]}],"x-permissions":["social.publish"]}},"/v1/social/posts":{"get":{"operationId":"listPosts","tags":["Publishing"],"summary":"Posts for the calendar between two dates","description":"By publish time, else scheduled time, else creation time. At most 100 days per\nrequest and 500 posts.\n","x-required-permission":"social.publish","parameters":[{"name":"from","in":"query","required":true,"schema":{"type":"string","format":"date-time"}},{"name":"to","in":"query","required":true,"schema":{"type":"string","format":"date-time"}}],"responses":{"200":{"description":"Posts, oldest first.","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Post"}}}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"apiKey":[]}],"x-permissions":["social.publish"]},"post":{"operationId":"createPost","tags":["Publishing"],"summary":"Save a draft, or schedule a post (now when no time is given)","description":"Unless `draft` is true, Meta's rules are checked first: Instagram needs 1 to 10 JPEG\nphotos between 4:5 and 1.91:1 and at most 2,200 characters and 30 hashtags; a Facebook\npost has text, a link or photos (a link and photos cannot be combined). Posts can be\nscheduled up to 180 days ahead. The worker publishes at `scheduled_at`.\n","x-required-permission":"social.publish","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PostInput"}}}},"responses":{"201":{"description":"Saved.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Post"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"apiKey":[]}],"x-permissions":["social.publish"]}},"/v1/social/posts/{id}":{"get":{"operationId":"getPost","tags":["Publishing"],"summary":"One post, with the outcome per account","x-required-permission":"social.publish","responses":{"200":{"description":"The post.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Post"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}},"security":[{"apiKey":[]}],"x-permissions":["social.publish"]},"patch":{"operationId":"updatePost","tags":["Publishing"],"summary":"Change a draft or scheduled post","description":"Fields left out keep their value. `draft: false` schedules a draft; `scheduled_at: null`\npublishes now. Published posts cannot be changed (`POST_INVALID_STATE`).\n","x-required-permission":"social.publish","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PostInput"}}}},"responses":{"200":{"description":"The updated post.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Post"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"$ref":"#/components/responses/Conflict"}},"security":[{"apiKey":[]}],"x-permissions":["social.publish"]},"delete":{"operationId":"deletePost","tags":["Publishing"],"summary":"Remove a post from AsysConnect","description":"Anything already published stays on Facebook and Instagram. Photos no other post\nuses are deleted too.\n","x-required-permission":"social.publish","responses":{"204":{"description":"Deleted."},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"$ref":"#/components/responses/Conflict"}},"security":[{"apiKey":[]}],"x-permissions":["social.publish"]}},"/v1/social/posts/{id}/unschedule":{"post":{"operationId":"unschedulePost","tags":["Publishing"],"summary":"Turn a scheduled post back into a draft","x-required-permission":"social.publish","parameters":[{"$ref":"#/components/parameters/Id"}],"responses":{"200":{"description":"The post, now a draft.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Post"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"$ref":"#/components/responses/Conflict"}},"security":[{"apiKey":[]}],"x-permissions":["social.publish"]}},"/v1/social/posts/{id}/retry":{"post":{"operationId":"retryPost","tags":["Publishing"],"summary":"Publish again, now, to the accounts that failed","description":"Accounts where the post already went out are not posted to again.","x-required-permission":"social.publish","parameters":[{"$ref":"#/components/parameters/Id"}],"responses":{"200":{"description":"Scheduled for now.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Post"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"$ref":"#/components/responses/Conflict"}},"security":[{"apiKey":[]}],"x-permissions":["social.publish"]}},"/v1/ai/replies/{id}":{"get":{"operationId":"getAiReply","tags":["AI"],"summary":"One answer, to poll a suggestion or test question until it is no longer pending","x-required-permission":"conversations.read","responses":{"200":{"description":"The answer.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AiReply"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}},"security":[{"apiKey":[]}],"x-permissions":["conversations.read"]}},"/v1/conversations/{id}/ai-suggest":{"post":{"operationId":"suggestAiReply","tags":["AI"],"summary":"Ask the AI to suggest a reply for this chat; nothing is sent","description":"Answered in the background; poll GET /v1/ai/replies/{id}.","x-required-permission":"conversations.write","responses":{"202":{"description":"Asked.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AiReply"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}},"security":[{"apiKey":[]}],"x-permissions":["conversations.write"]}},"/v1/conversations/{id}/ai-pause":{"post":{"operationId":"pauseAiInConversation","tags":["AI"],"summary":"Stop the AI answering this chat by itself","x-required-permission":"conversations.write","responses":{"200":{"description":"Paused.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AiPaused"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}},"security":[{"apiKey":[]}],"x-permissions":["conversations.write"]}},"/v1/conversations/{id}/ai-resume":{"post":{"operationId":"resumeAiInConversation","tags":["AI"],"summary":"Let the AI answer this chat again","x-required-permission":"conversations.write","responses":{"200":{"description":"Resumed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AiPaused"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}},"security":[{"apiKey":[]}],"x-permissions":["conversations.write"]}},"/v1/pipelines":{"get":{"operationId":"listPipelines","tags":["Sales"],"summary":"Pipelines with their stages, in order","description":"A workspace without one gets a \"Sales\" pipeline with the usual stages.","x-required-permission":"deals.read","responses":{"200":{"description":"Pipelines.","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Pipeline"}}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"apiKey":[]}],"x-permissions":["deals.read"]}},"/v1/deals":{"get":{"operationId":"listDeals","tags":["Sales"],"summary":"Deals, as a board or a list","description":"`view=board` returns every deal of one pipeline (the first if `pipeline_id` is left out)\nin board order, with won and lost deals only from the last `closed_days`, up to 1,000.\nOtherwise newest first, paged with `cursor`.\n","x-required-permission":"deals.read","parameters":[{"name":"view","in":"query","schema":{"type":"string","enum":["list","board"],"default":"list"}},{"name":"pipeline_id","in":"query","schema":{"type":"string","format":"uuid"}},{"name":"stage_id","in":"query","schema":{"type":"string","format":"uuid"}},{"name":"status","in":"query","schema":{"$ref":"#/components/schemas/StageKind"}},{"name":"owner_id","in":"query","description":"A teammate's id, `me` or `none`.","schema":{"type":"string"}},{"name":"contact_id","in":"query","schema":{"type":"string","format":"uuid"}},{"name":"q","in":"query","description":"Part of the title or the contact's name.","schema":{"type":"string","maxLength":100}},{"name":"closed_days","in":"query","schema":{"type":"integer","minimum":1,"maximum":3650,"default":30}},{"$ref":"#/components/parameters/Cursor"},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":200,"default":50}}],"responses":{"200":{"description":"Deals.","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Deal"}},"next_cursor":{"type":["string","null"],"description":"List view only."},"pipeline_id":{"type":"string","format":"uuid","description":"Board view only."},"truncated":{"type":"boolean","description":"Board view only; more than 1,000 deals."}}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"apiKey":[]}],"x-permissions":["deals.read"]},"post":{"operationId":"createDeal","tags":["Sales"],"summary":"Add a deal","description":"It goes at the bottom of its stage. Without a stage it goes in the pipeline's first open\nstage; without a pipeline, the workspace's first. The owner defaults to you.\n","x-required-permission":"deals.write","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DealInput"}}}},"responses":{"201":{"description":"Added.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DealDetail"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}},"security":[{"apiKey":[]}],"x-permissions":["deals.write"]}},"/v1/deals/summary":{"get":{"operationId":"dealSummary","tags":["Sales"],"summary":"Pipeline totals and forecast","description":"Open deals per stage (count, value, and value weighted by the stage's probability),\nopen value by expected close month and by owner, and what was won and lost this month\n(India time).\n","x-required-permission":"deals.read","parameters":[{"name":"pipeline_id","in":"query","schema":{"type":"string","format":"uuid"}},{"name":"owner_id","in":"query","description":"A teammate's id, `me` or `none`.","schema":{"type":"string"}}],"responses":{"200":{"description":"Totals. Amounts are in paise.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DealSummary"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"apiKey":[]}],"x-permissions":["deals.read"]}},"/v1/deals/{id}":{"get":{"operationId":"getDeal","tags":["Sales"],"summary":"A deal with its history, time in each stage and tasks","x-required-permission":"deals.read","responses":{"200":{"description":"The deal.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DealDetail"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}},"security":[{"apiKey":[]}],"x-permissions":["deals.read"]},"patch":{"operationId":"updateDeal","tags":["Sales"],"summary":"Change a deal","description":"To change its stage use /move. A new owner gets a phone notification.","x-required-permission":"deals.write","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DealUpdate"}}}},"responses":{"200":{"description":"Changed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DealDetail"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}},"security":[{"apiKey":[]}],"x-permissions":["deals.write"]},"delete":{"operationId":"deleteDeal","tags":["Sales"],"summary":"Delete a deal with its history and tasks","x-required-permission":"deals.write","responses":{"204":{"description":"Deleted."},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}},"security":[{"apiKey":[]}],"x-permissions":["deals.write"]}},"/v1/deals/{id}/move":{"post":{"operationId":"moveDeal","tags":["Sales"],"summary":"Move a deal to a stage and a place in it","description":"Any stage of any pipeline. A won or lost stage closes the deal; an open one reopens it.\nMoving to another stage can start automations with the deal_stage_changed trigger.\n","x-required-permission":"deals.write","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["stage_id"],"properties":{"stage_id":{"type":"string","format":"uuid"},"before_id":{"type":["string","null"],"format":"uuid","description":"Put it above this deal in the stage; leave out for the bottom."},"lost_reason":{"type":"string","maxLength":300}}}}}},"responses":{"200":{"description":"Moved.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DealDetail"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}},"security":[{"apiKey":[]}],"x-permissions":["deals.write"]}},"/v1/deals/{id}/notes":{"post":{"operationId":"addDealNote","tags":["Sales"],"summary":"Add a note to a deal's history","x-required-permission":"deals.write","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["text"],"properties":{"text":{"type":"string","maxLength":5000}}}}}},"responses":{"201":{"description":"Added.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DealDetail"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}},"security":[{"apiKey":[]}],"x-permissions":["deals.write"]}},"/v1/tasks":{"get":{"operationId":"listTasks","tags":["Sales"],"summary":"Follow-up tasks","description":"Open tasks soonest due first (undated last), then done ones newest first.","x-required-permission":"deals.read","parameters":[{"name":"assigned_to","in":"query","description":"`me`, `anyone`, `none` or a teammate's id. Defaults to `me`, or `anyone` with\n`deal_id` or `contact_id`.\n","schema":{"type":"string"}},{"name":"status","in":"query","description":"today and overdue are open tasks due by the end of today (India time) or before now.","schema":{"type":"string","enum":["open","overdue","today","done","all"],"default":"open"}},{"name":"deal_id","in":"query","schema":{"type":"string","format":"uuid"}},{"name":"contact_id","in":"query","schema":{"type":"string","format":"uuid"}},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":500,"default":200}}],"responses":{"200":{"description":"Tasks.","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Task"}}}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"apiKey":[]}],"x-permissions":["deals.read"]},"post":{"operationId":"createTask","tags":["Sales"],"summary":"Add a task","description":"Assigned to you unless `assigned_to` says otherwise. A task on a deal is linked to the\ndeal's contact too. The assignee gets a phone notification when it is due.\n","x-required-permission":"deals.write","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TaskInput"}}}},"responses":{"201":{"description":"Added.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Task"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}},"security":[{"apiKey":[]}],"x-permissions":["deals.write"]}},"/v1/tasks/counts":{"get":{"operationId":"taskCounts","tags":["Sales"],"summary":"How many of your open tasks there are, due today and overdue","x-required-permission":"deals.read","responses":{"200":{"description":"Counts.","content":{"application/json":{"schema":{"type":"object","required":["open","today","overdue"],"properties":{"open":{"type":"integer"},"today":{"type":"integer"},"overdue":{"type":"integer"}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"apiKey":[]}],"x-permissions":["deals.read"]}},"/v1/tasks/{id}":{"patch":{"operationId":"updateTask","tags":["Sales"],"summary":"Change a task, or mark it done","x-required-permission":"deals.write","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"title":{"type":"string","maxLength":200},"notes":{"type":"string","maxLength":5000},"due_at":{"type":["string","null"],"format":"date-time"},"priority":{"$ref":"#/components/schemas/TaskPriority"},"assigned_to":{"type":["string","null"],"format":"uuid"},"done":{"type":"boolean","description":"true completes it; false opens it again."}}}}}},"responses":{"200":{"description":"Changed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Task"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}},"security":[{"apiKey":[]}],"x-permissions":["deals.write"]},"delete":{"operationId":"deleteTask","tags":["Sales"],"summary":"Delete a task","x-required-permission":"deals.write","responses":{"204":{"description":"Deleted."},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}},"security":[{"apiKey":[]}],"x-permissions":["deals.write"]}},"/v1/api-key":{"get":{"operationId":"getCurrentApiKey","tags":["Developers"],"summary":"The API key making this call","security":[{"apiKey":[]}],"description":"Which workspace the key is for, whom it acts as, and what it can do right now. A good\nfirst call to check a key works. Only for API keys; a signed-in member gets 403.\n","responses":{"200":{"description":"The key.","content":{"application/json":{"schema":{"type":"object","required":["id","name","prefix","workspace","acts_as","permissions","rate_limit_per_minute"],"properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"prefix":{"type":"string"},"expires_at":{"type":["string","null"],"format":"date-time"},"created_at":{"type":"string","format":"date-time"},"workspace":{"$ref":"#/components/schemas/NamedRef"},"acts_as":{"$ref":"#/components/schemas/NamedRef"},"permissions":{"type":"array","items":{"$ref":"#/components/schemas/ApiKeyScope"}},"rate_limit_per_minute":{"type":"integer","example":300}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"x-permissions":[]}},"/v1/webhook-events":{"get":{"operationId":"listWebhookEvents","tags":["Developers"],"summary":"Events a webhook can subscribe to","x-required-permission":"api.manage","responses":{"200":{"description":"Events.","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"array","items":{"type":"object","required":["type","description"],"properties":{"type":{"$ref":"#/components/schemas/WebhookEventType"},"description":{"type":"string"}}}}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"apiKey":[]}],"x-permissions":["api.manage"]}},"/v1/webhook-endpoints":{"get":{"operationId":"listWebhooks","tags":["Developers"],"summary":"Webhook endpoints","x-required-permission":"api.manage","responses":{"200":{"description":"Endpoints.","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/WebhookEndpoint"}}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"apiKey":[]}],"x-permissions":["api.manage"]},"post":{"operationId":"createWebhook","tags":["Developers"],"summary":"Add a webhook endpoint","description":"The address must be public and start with https://. Up to 20 per workspace. The answer\nhas the signing secret; GET /v1/webhook-endpoints/{id}/secret shows it again.\n","x-required-permission":"api.manage","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookInput"}}}},"responses":{"201":{"description":"Added.","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/WebhookEndpoint"},{"$ref":"#/components/schemas/WebhookSecret"}]}}}},"400":{"description":"`VALIDATION_FAILED`, or `WEBHOOK_URL_INVALID` for an address that is not public https.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"apiKey":[]}],"x-permissions":["api.manage"]}},"/v1/webhook-endpoints/{id}":{"get":{"operationId":"getWebhook","tags":["Developers"],"summary":"One webhook endpoint","x-required-permission":"api.manage","responses":{"200":{"description":"The endpoint.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookEndpoint"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}},"security":[{"apiKey":[]}],"x-permissions":["api.manage"]},"patch":{"operationId":"updateWebhook","tags":["Developers"],"summary":"Change a webhook endpoint, or turn it off or on","description":"An endpoint that fails every delivery for 3 days is turned off; turning it back on clears\nits failure count.\n","x-required-permission":"api.manage","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"url":{"type":"string","format":"uri"},"description":{"type":"string","maxLength":200},"events":{"type":"array","minItems":1,"items":{"$ref":"#/components/schemas/WebhookEventType"}},"enabled":{"type":"boolean"}}}}}},"responses":{"200":{"description":"Changed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookEndpoint"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}},"security":[{"apiKey":[]}],"x-permissions":["api.manage"]},"delete":{"operationId":"deleteWebhook","tags":["Developers"],"summary":"Delete a webhook endpoint and its delivery log","x-required-permission":"api.manage","responses":{"204":{"description":"Deleted."},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}},"security":[{"apiKey":[]}],"x-permissions":["api.manage"]}},"/v1/webhook-endpoints/{id}/secret":{"get":{"operationId":"getWebhookSecret","tags":["Developers"],"summary":"The endpoint's signing secret","x-required-permission":"api.manage","responses":{"200":{"description":"The secret.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookSecret"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}},"security":[{"apiKey":[]}],"x-permissions":["api.manage"]},"post":{"operationId":"rollWebhookSecret","tags":["Developers"],"summary":"Make a new signing secret","description":"Takes over at once; every delivery after this is signed with it.","x-required-permission":"api.manage","responses":{"201":{"description":"The new secret.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookSecret"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}},"security":[{"apiKey":[]}],"x-permissions":["api.manage"]}},"/v1/webhook-endpoints/{id}/test":{"post":{"operationId":"testWebhook","tags":["Developers"],"summary":"Send a test \"ping\" event","description":"The outcome shows in the delivery log.","x-required-permission":"api.manage","responses":{"201":{"description":"Queued.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookDelivery"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}},"security":[{"apiKey":[]}],"x-permissions":["api.manage"]}},"/v1/webhook-endpoints/{id}/deliveries":{"get":{"operationId":"listWebhookDeliveries","tags":["Developers"],"summary":"Delivery log, newest first","x-required-permission":"api.manage","parameters":[{"name":"status","in":"query","schema":{"type":"string","enum":["pending","succeeded","failed"]}},{"name":"cursor","in":"query","schema":{"type":"string"}},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":100,"default":50}}],"responses":{"200":{"description":"Deliveries.","content":{"application/json":{"schema":{"type":"object","required":["data","next_cursor"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/WebhookDelivery"}},"next_cursor":{"type":["string","null"]}}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}},"security":[{"apiKey":[]}],"x-permissions":["api.manage"]}},"/v1/webhook-deliveries/{id}":{"get":{"operationId":"getWebhookDelivery","tags":["Developers"],"summary":"One delivery, with what was sent and what came back","x-required-permission":"api.manage","responses":{"200":{"description":"The delivery.","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/WebhookDelivery"},{"type":"object","properties":{"payload":{"$ref":"#/components/schemas/WebhookEvent"},"response_body":{"type":["string","null"],"description":"The start of the receiver's answer."}}}]}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}},"security":[{"apiKey":[]}],"x-permissions":["api.manage"]}},"/v1/webhook-deliveries/{id}/retry":{"post":{"operationId":"retryWebhookDelivery","tags":["Developers"],"summary":"Send a delivery again now","x-required-permission":"api.manage","responses":{"201":{"description":"Queued.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookDelivery"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"description":"`FORBIDDEN`: the endpoint is turned off.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"$ref":"#/components/responses/NotFound"}},"security":[{"apiKey":[]}],"x-permissions":["api.manage"]}},"/v1/oauth/token":{"post":{"operationId":"exchangeOAuthCode","tags":["Developers"],"summary":"Trade an approval code for an API key (OAuth 2.0)","description":"For apps registered with AsysConnect (\"Connect with AsysConnect\"). Your server sends the\n`code` from the return address, as a form (`application/x-www-form-urlencoded`) or JSON.\nAuthenticate with `client_id` and `client_secret` in the body or as HTTP Basic; public\napps send `code_verifier` instead of a secret. The answer's `access_token` is an API key\nfor that workspace with the approved permissions. It doesn't expire; the workspace can\ndisconnect it at any time, and approving again replaces it. Errors follow RFC 6749:\n`{\"error\": \"invalid_grant\", \"error_description\": \"…\"}`.\n","security":[],"requestBody":{"required":true,"content":{"application/x-www-form-urlencoded":{"schema":{"$ref":"#/components/schemas/OAuthTokenRequest"}},"application/json":{"schema":{"$ref":"#/components/schemas/OAuthTokenRequest"}}}},"responses":{"200":{"description":"The key.","content":{"application/json":{"schema":{"type":"object","required":["access_token","token_type","scope","workspace"],"properties":{"access_token":{"type":"string","example":"ask_live_3kq9ZcVw1bT0pXr7yLmN2aHs5dEu8fGj"},"token_type":{"const":"Bearer"},"scope":{"type":"string","example":"contacts.read contacts.write"},"workspace":{"$ref":"#/components/schemas/NamedRef"}}}}}},"400":{"description":"`invalid_request`, `invalid_grant` or `unsupported_grant_type`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OAuthError"}}}},"401":{"description":"`invalid_client`: the client secret is wrong.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OAuthError"}}}},"429":{"description":"`slow_down`: more than 30 requests a minute from one address.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OAuthError"}}}}}}}},"components":{"securitySchemes":{"apiKey":{"type":"http","scheme":"bearer","description":"An API key from Settings → Developers (`ask_live_...`), as `Authorization: Bearer <key>`\nor `X-API-Key: <key>`. Works on the endpoints listed in GET /v1/openapi.json.\n"}},"parameters":{"OAuthClientId":{"name":"client_id","in":"query","required":true,"schema":{"type":"string"}},"OAuthRedirectUri":{"name":"redirect_uri","in":"query","required":true,"description":"Must match one of the app's registered return addresses exactly.","schema":{"type":"string"}},"OAuthScope":{"name":"scope","in":"query","required":true,"description":"Space-separated permissions, e.g. `contacts.read contacts.write`.","schema":{"type":"string"}},"OAuthState":{"name":"state","in":"query","description":"Sent back unchanged; use it to stop cross-site request forgery.","schema":{"type":"string"}},"OAuthCodeChallenge":{"name":"code_challenge","in":"query","description":"PKCE, base64url(sha256(code_verifier)). Required for public apps.","schema":{"type":"string"}},"OAuthCodeChallengeMethod":{"name":"code_challenge_method","in":"query","schema":{"const":"S256"}},"Id":{"name":"id","in":"path","required":true,"description":"A UUID. A malformed id returns 400.","schema":{"type":"string","format":"uuid"}},"Cursor":{"name":"cursor","in":"query","description":"The `next_cursor` of the previous page. Omit for the first page.","schema":{"type":"string"}},"TicketStatusFilter":{"name":"status","in":"query","schema":{"$ref":"#/components/schemas/TicketStatus"}},"TicketSearch":{"name":"q","in":"query","description":"A ticket number (\"#1042\" or \"1042\") or words from the subject.","schema":{"type":"string","maxLength":100}},"EmailLinkToken":{"name":"token","in":"path","required":true,"description":"The email's id and a signature, from the link in the email.","schema":{"type":"string"}},"SmsReviewStatus":{"name":"status","in":"query","schema":{"type":"string","enum":["pending","approved","rejected"]}}},"requestBodies":{"SocialUserToken":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["user_token"],"properties":{"user_token":{"type":"string","description":"The access token from Facebook Login."}}}}}},"EmailTemplateInput":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["name","category","subject","html"],"properties":{"name":{"type":"string","maxLength":100},"category":{"$ref":"#/components/schemas/EmailCategory"},"subject":{"type":"string","maxLength":200},"html":{"type":"string","description":"HTML, or plain text that becomes paragraphs. Merge fields: {{first_name}},\n{{last_name}}, {{name}}, {{email}}, {{custom.<key>}}, with a fallback after a\nbar, e.g. {{first_name|there}}.\n"}}}}}},"TicketReply":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["body"],"properties":{"body":{"type":"string","minLength":1,"maxLength":5000}}}}}}},"responses":{"BadRequest":{"description":"`VALIDATION_FAILED` (the zod issues are in `details`). A malformed UUID in the path\nreturns 400 with code `INTERNAL` (see the Error schema).\n","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Unauthorized":{"description":"`UNAUTHENTICATED`: missing, invalid or expired access token, or the membership was disabled. Refresh and retry once.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Forbidden":{"description":"`FORBIDDEN`: the caller lacks the required permission.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"NotFound":{"description":"`NOT_FOUND`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Conflict":{"description":"`CONTACT_CHANNEL_TAKEN`, `TAG_NAME_TAKEN` or `CUSTOM_FIELD_KEY_TAKEN`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"PipelineInUse":{"description":"`PIPELINE_IN_USE`: it still has deals (move them first), or it is the last one.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"RateLimited":{"description":"`RATE_LIMITED`; `details.retry_after` is the wait in seconds.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"MetaError":{"description":"`META_API_ERROR`: Meta rejected or failed the request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"InternalError":{"description":"`INTERNAL`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"WebhookOk":{"description":"Acknowledged.","content":{"application/json":{"schema":{"type":"object","required":["ok"],"properties":{"ok":{"type":"boolean","const":true}}}}}},"SmsReportOk":{"description":"Acknowledged, with how many SMS changed.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","const":true},"updated":{"type":"integer"}}}}}},"SmsNotSetUp":{"description":"`SMS_NOT_SET_UP`: choose the DLT registration in SMS settings first.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"SmsTemplateNotReady":{"description":"`TEMPLATE_NOT_APPROVED` (template or sender ID not approved, or made under the other DLT\nregistration), `SMS_NOT_SET_UP`, `SMS_OUTSIDE_HOURS` or `CONSENT_REQUIRED`.\n","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"EmailNotSetUp":{"description":"`EMAIL_NOT_SET_UP`: the sender is not ready (settings missing or the domain not verified).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"InsufficientBalance":{"description":"`INSUFFICIENT_BALANCE`: the wallet cannot pay for it; `details` has the cost and balance.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"schemas":{"Report":{"type":"object","required":["kind","range","tiles","chart","tables"],"properties":{"kind":{"type":"string","enum":["messaging","inbox","contacts","sales"]},"range":{"type":"object","required":["from","to","previous_from","previous_to","timezone"],"properties":{"from":{"type":"string","format":"date"},"to":{"type":"string","format":"date"},"previous_from":{"type":"string","format":"date"},"previous_to":{"type":"string","format":"date"},"timezone":{"type":"string","example":"Asia/Kolkata"}}},"tiles":{"type":"array","items":{"type":"object","required":["key","label","value","previous","format"],"properties":{"key":{"type":"string"},"label":{"type":"string"},"value":{"type":"number","nullable":true},"previous":{"type":"number","nullable":true,"description":"The same figure for the previous period; null when it has no meaning."},"format":{"type":"string","enum":["number","percent","money","duration"]},"better":{"type":"string","enum":["up","down"],"description":"Which direction is good news."},"hint":{"type":"string"}}}},"chart":{"type":"object","required":["title","format","bucket","series","points"],"properties":{"title":{"type":"string"},"format":{"type":"string","enum":["number","percent","money","duration"]},"bucket":{"type":"string","enum":["day","week"]},"series":{"type":"array","items":{"type":"object","required":["key","label"],"properties":{"key":{"type":"string"},"label":{"type":"string"}}}},"points":{"type":"array","items":{"type":"object","required":["date","values"],"properties":{"date":{"type":"string","format":"date"},"values":{"type":"object","additionalProperties":{"type":"number"}}}}}}},"tables":{"type":"array","items":{"type":"object","required":["key","title","columns","rows","empty"],"properties":{"key":{"type":"string"},"title":{"type":"string"},"columns":{"type":"array","items":{"type":"object","required":["key","label"],"properties":{"key":{"type":"string"},"label":{"type":"string"},"format":{"type":"string","enum":["number","percent","money","duration"]}}}},"rows":{"type":"array","items":{"type":"object","additionalProperties":true}},"empty":{"type":"string","description":"What to show when there are no rows."}}}}}},"LeadForm":{"type":"object","required":["id","account_id","page_name","form_id","name","status","questions","field_map","mapping","tag_ids","whatsapp_opt_in","lead_count","last_lead_at","synced_at"],"properties":{"id":{"type":"string","format":"uuid"},"account_id":{"type":"string","format":"uuid","description":"The connected Page (SocialAccount.id)."},"page_name":{"type":["string","null"]},"form_id":{"type":"string","description":"Meta's form id."},"name":{"type":["string","null"]},"status":{"type":["string","null"],"description":"Meta's status, e.g. ACTIVE or ARCHIVED."},"questions":{"type":"array","items":{"type":"object","properties":{"key":{"type":"string"},"label":{"type":"string"},"type":{"type":"string"}}}},"field_map":{"type":"object","description":"The choices the workspace made.","additionalProperties":{"type":"string"}},"mapping":{"type":"object","description":"Where every question's answer goes, defaults included.","additionalProperties":{"type":"string"}},"tag_ids":{"type":"array","items":{"type":"string","format":"uuid"}},"whatsapp_opt_in":{"type":"boolean"},"lead_count":{"type":"integer"},"last_lead_at":{"type":["string","null"],"format":"date-time"},"synced_at":{"type":["string","null"],"format":"date-time"}}},"AutomationInput":{"type":"object","description":"`trigger.type` is one of contact_created (optional `sources`), tag_added (`tag_id`),\nmessage_received (`channels`, `match` any/contains/exact, `keywords`), lead_received\n(optional `form_ids`) or deal_stage_changed (optional `pipeline_id`, `stage_id`). Each step has an `id`, a `type` and `on_error` (continue or stop).\nStep types: wait (`minutes`), condition (`check`: has_tag, missing_tag, field_equals,\nhas_phone, has_email, whatsapp_opted_in), send_whatsapp (`template_id`, `params`),\nsend_sms (`template_id`, `variables`), send_email (`template_id`), reply (`text`),\nadd_tag / remove_tag (`tag_id`), assign (`user_id`), close_conversation, set_field\n(`field`, `value`), create_deal (`pipeline_id`, optional `stage_id`, `title`,\n`value_paise`, `owner_id`, `skip_if_open`) and create_task (`title`, `due_in_minutes`,\noptional `assign_to`, `priority`; linked to the run's deal).\n","properties":{"name":{"type":"string","maxLength":100},"trigger":{"type":"object","required":["type"],"properties":{"type":{"type":"string","enum":["contact_created","tag_added","message_received","lead_received","deal_stage_changed"]}},"additionalProperties":true},"steps":{"type":"array","maxItems":30,"items":{"type":"object","required":["id","type"],"properties":{"id":{"type":"string"},"type":{"type":"string","enum":["wait","condition","send_whatsapp","send_sms","send_email","reply","add_tag","remove_tag","assign","close_conversation","set_field","create_deal","create_task"]},"on_error":{"type":"string","enum":["continue","stop"]}},"additionalProperties":true}},"allow_reentry":{"type":"boolean","description":"Whether a contact can go through it again after an earlier run ended."}}},"Automation":{"allOf":[{"$ref":"#/components/schemas/AutomationInput"},{"type":"object","required":["id","name","status","trigger","steps","allow_reentry","version","stats"],"properties":{"id":{"type":"string","format":"uuid"},"status":{"type":"string","enum":["draft","active","paused"]},"version":{"type":"integer"},"activated_at":{"type":["string","null"],"format":"date-time"},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"},"stats":{"type":"object","properties":{"live":{"type":"integer"},"completed":{"type":"integer"},"stopped":{"type":"integer"},"failed":{"type":"integer"},"started_30d":{"type":"integer"}}},"problems":{"type":"array","description":"What must be fixed before it can be turned on (single automation only).","items":{"type":"string"}}}}]},"AutomationRun":{"type":"object","required":["id","status","step_index","step_count","started_at","contact","log"],"properties":{"id":{"type":"string","format":"uuid"},"status":{"type":"string","enum":["running","waiting","completed","stopped","failed"]},"step_index":{"type":"integer"},"step_count":{"type":"integer"},"next_at":{"type":["string","null"],"format":"date-time"},"error":{"type":["string","null"]},"trigger_type":{"type":"string"},"started_at":{"type":"string","format":"date-time"},"finished_at":{"type":["string","null"],"format":"date-time"},"contact":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"display_name":{"type":["string","null"]}}},"log":{"type":"array","items":{"type":"object","properties":{"step_index":{"type":"integer"},"step_type":{"type":"string"},"outcome":{"type":"string","enum":["done","skipped","failed","stopped","waiting"]},"detail":{"type":["string","null"]},"at":{"type":"string","format":"date-time"}}}}}},"PostPhoto":{"type":"object","required":["id","file_name","mime_type","width","height","url"],"properties":{"id":{"type":"string","format":"uuid"},"file_name":{"type":"string"},"mime_type":{"type":"string","enum":["image/jpeg","image/png"]},"width":{"type":["integer","null"]},"height":{"type":["integer","null"]},"url":{"type":"string","description":"Path of the public link, relative to the API's address."}}},"PostInput":{"type":"object","properties":{"caption":{"type":"string","maxLength":5000},"link":{"type":["string","null"],"format":"uri","description":"Facebook only, for posts without photos."},"media_ids":{"type":"array","maxItems":10,"items":{"type":"string","format":"uuid"},"description":"Uploaded photos, in the order they show."},"account_ids":{"type":"array","items":{"type":"string","format":"uuid"},"description":"Connected Pages and Instagram accounts to publish to."},"scheduled_at":{"type":["string","null"],"format":"date-time","description":"When to publish; null or left out means now."},"draft":{"type":"boolean","description":"Save without scheduling."}}},"Post":{"type":"object","required":["id","caption","link","status","scheduled_at","published_at","media","targets","created_at"],"properties":{"id":{"type":"string","format":"uuid"},"caption":{"type":"string"},"link":{"type":["string","null"]},"status":{"type":"string","enum":["draft","scheduled","publishing","published","partly_failed","failed"]},"scheduled_at":{"type":["string","null"],"format":"date-time"},"published_at":{"type":["string","null"],"format":"date-time"},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"},"created_by":{"type":["string","null"],"format":"uuid"},"media":{"type":"array","items":{"$ref":"#/components/schemas/PostPhoto"}},"targets":{"type":"array","items":{"type":"object","required":["id","account_id","platform","status"],"properties":{"id":{"type":"string","format":"uuid"},"account_id":{"type":"string","format":"uuid"},"platform":{"type":"string","enum":["messenger","instagram"]},"name":{"type":["string","null"]},"username":{"type":["string","null"]},"status":{"type":"string","enum":["pending","publishing","published","failed"]},"permalink":{"type":["string","null"]},"error":{"type":["string","null"]},"published_at":{"type":["string","null"],"format":"date-time"}}}}}},"Lead":{"type":"object","required":["id","form_id","form_name","external_id","status","error","submitted_at","contact"],"properties":{"id":{"type":"string","format":"uuid"},"form_id":{"type":["string","null"],"format":"uuid"},"form_name":{"type":["string","null"]},"external_id":{"type":"string"},"ad_name":{"type":["string","null"]},"campaign_name":{"type":["string","null"]},"platform":{"type":["string","null"],"description":"`fb` or `ig`."},"field_data":{"type":["array","null"],"description":"The answers, as Meta sent them.","items":{"type":"object","properties":{"name":{"type":"string"},"values":{"type":"array","items":{"type":"string"}}}}},"status":{"type":"string","enum":["pending","added","updated","failed"]},"error":{"type":["string","null"]},"submitted_at":{"type":"string","format":"date-time"},"contact":{"type":["object","null"],"properties":{"id":{"type":"string","format":"uuid"},"display_name":{"type":["string","null"]}}}}},"SocialPlatform":{"type":"string","enum":["messenger","instagram"]},"ConnectablePage":{"type":"object","required":["page_id","name","picture_url","can_message","instagram"],"properties":{"page_id":{"type":"string"},"name":{"type":"string"},"picture_url":{"type":["string","null"]},"can_message":{"type":"boolean","description":"False when the person lacks the Page's messaging task."},"instagram":{"type":["object","null"],"required":["id","username","picture_url"],"properties":{"id":{"type":"string"},"username":{"type":["string","null"]},"picture_url":{"type":["string","null"]}}}}},"SocialAccount":{"type":"object","required":["id","platform","external_id","page_id","name","username","picture_url","status","created_at"],"properties":{"id":{"type":"string","format":"uuid"},"platform":{"$ref":"#/components/schemas/SocialPlatform"},"external_id":{"type":"string","description":"The Page id, or the Instagram account id."},"page_id":{"type":"string"},"name":{"type":["string","null"]},"username":{"type":["string","null"],"description":"Instagram @handle."},"picture_url":{"type":["string","null"]},"status":{"type":"string","enum":["active"]},"created_at":{"type":"string","format":"date-time"}}},"SocialRuleInput":{"type":"object","description":"All fields are required on create except as noted; PATCH takes any of them.","properties":{"name":{"type":"string","maxLength":100},"account_id":{"type":["string","null"],"format":"uuid","description":"One connected account, or null for all of them."},"match_type":{"type":"string","enum":["contains","exact","any"],"default":"contains","description":"`contains`: any keyword appears as a whole word or phrase. `exact`: the whole comment\nis a keyword. `any`: every top-level comment.\n"},"keywords":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":100}},"dm_text":{"type":"string","maxLength":1000,"description":"The private reply. `{{name}}` becomes the commenter's first name."},"reply_text":{"type":["string","null"],"maxLength":1000,"description":"Optional public reply under the comment."},"active":{"type":"boolean","default":true}}},"SocialRule":{"type":"object","required":["id","account_id","name","match_type","keywords","dm_text","reply_text","active","sent_count","created_at","updated_at"],"properties":{"id":{"type":"string","format":"uuid"},"account_id":{"type":["string","null"],"format":"uuid"},"name":{"type":"string"},"match_type":{"type":"string","enum":["contains","exact","any"]},"keywords":{"type":"array","items":{"type":"string"}},"dm_text":{"type":"string"},"reply_text":{"type":["string","null"]},"active":{"type":"boolean"},"sent_count":{"type":"integer","description":"DMs this rule has sent."},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}}},"SocialComment":{"type":"object","required":["id","account_id","platform","external_id","text","commented_at","dm_status","reply_status","rule"],"properties":{"id":{"type":"string","format":"uuid"},"account_id":{"type":"string","format":"uuid"},"platform":{"$ref":"#/components/schemas/SocialPlatform"},"account_name":{"type":["string","null"]},"account_username":{"type":["string","null"]},"external_id":{"type":"string"},"post_id":{"type":["string","null"]},"parent_id":{"type":["string","null"]},"from_id":{"type":["string","null"]},"from_name":{"type":["string","null"],"description":"Name on Facebook, @handle on Instagram."},"text":{"type":["string","null"]},"commented_at":{"type":"string","format":"date-time"},"dm_status":{"type":"string","enum":["none","queued","sending","sent","failed","skipped"]},"dm_text":{"type":["string","null"]},"dm_error":{"type":["string","null"]},"reply_status":{"type":"string","enum":["none","queued","sending","sent","failed"]},"reply_text":{"type":["string","null"]},"reply_error":{"type":["string","null"]},"rule":{"type":["object","null"],"properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"}}}}},"EmailCategory":{"type":"string","enum":["marketing","transactional"]},"EmailStatus":{"type":"string","enum":["queued","sending","sent","delivered","bounced","complained","failed"]},"DnsRecord":{"type":"object","properties":{"type":{"type":"string","enum":["TXT","CNAME"]},"name":{"type":"string"},"value":{"type":"string"},"purpose":{"type":"string"},"required":{"type":"boolean"}}},"EmailDomain":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"domain":{"type":"string"},"status":{"type":"string","enum":["pending","verified","failed"]},"dns_records":{"type":"array","items":{"$ref":"#/components/schemas/DnsRecord"}},"status_detail":{"type":["string","null"]},"checked_at":{"type":["string","null"],"format":"date-time"},"verified_at":{"type":["string","null"],"format":"date-time"},"created_at":{"type":"string","format":"date-time"}}},"EmailPlatform":{"type":"object","properties":{"domain":{"type":["string","null"]},"status":{"type":"string","enum":["none","pending","verified","failed"]},"dns_records":{"type":"array","items":{"$ref":"#/components/schemas/DnsRecord"}},"status_detail":{"type":["string","null"]},"providers":{"type":"array","items":{"type":"string"}},"route":{"type":"array","description":"The order emails actually use.","items":{"type":"string"}},"connected":{"type":"array","items":{"type":"string"}}}},"EmailSettings":{"type":"object","properties":{"sending_mode":{"type":"string","enum":["own","platform"]},"from_name":{"type":"string"},"from_email":{"type":["string","null"]},"reply_to":{"type":["string","null"]},"postal_address":{"type":["string","null"]},"updated_at":{"type":"string","format":"date-time"}}},"EmailSender":{"type":"object","description":"Who emails come from right now, or why they cannot be sent.","properties":{"ready":{"type":"boolean"},"from":{"type":["string","null"]},"problem":{"type":["string","null"]}}},"EmailContent":{"type":"object","description":"A saved template, or a subject and message written now.","properties":{"template_id":{"type":"string","format":"uuid"},"subject":{"type":"string","maxLength":200},"html":{"type":"string"},"category":{"$ref":"#/components/schemas/EmailCategory"}}},"EmailTemplate":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"category":{"$ref":"#/components/schemas/EmailCategory"},"subject":{"type":"string"},"html":{"type":"string"},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}}},"EmailMessage":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"contact_id":{"type":["string","null"],"format":"uuid"},"to_email":{"type":"string"},"campaign_id":{"type":["string","null"]},"template_id":{"type":["string","null"]},"category":{"$ref":"#/components/schemas/EmailCategory"},"from_address":{"type":"string"},"from_name":{"type":"string"},"reply_to":{"type":["string","null"]},"subject":{"type":"string"},"status":{"$ref":"#/components/schemas/EmailStatus"},"provider":{"type":["string","null"]},"error":{"type":["string","null"]},"open_count":{"type":"integer"},"click_count":{"type":"integer"},"created_at":{"type":"string","format":"date-time"},"sent_at":{"type":["string","null"],"format":"date-time"},"delivered_at":{"type":["string","null"],"format":"date-time"},"opened_at":{"type":["string","null"],"format":"date-time"}}},"EmailCampaign":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"template_id":{"type":["string","null"]},"template_name":{"type":["string","null"]},"category":{"$ref":"#/components/schemas/EmailCategory"},"subject":{"type":"string"},"from_address":{"type":"string"},"audience":{"$ref":"#/components/schemas/Audience"},"status":{"type":"string","enum":["scheduled","sending","sent","cancelled","failed"]},"scheduled_at":{"type":"string","format":"date-time"},"finished_at":{"type":["string","null"],"format":"date-time"},"failure":{"type":["string","null"]},"stats":{"type":"object","properties":{"recipients":{"type":"integer"},"pending":{"type":"integer"},"skipped":{"type":"integer"},"queued":{"type":"integer"},"sent":{"type":"integer"},"delivered":{"type":"integer"},"opened":{"type":"integer"},"clicked":{"type":"integer"},"bounced":{"type":"integer"},"failed":{"type":"integer"}}},"skipped":{"type":"array","description":"On the detail only; why people were skipped.","items":{"type":"object","properties":{"reason":{"type":"string"},"count":{"type":"integer"}}}}}},"EmailSuppression":{"type":"object","properties":{"email":{"type":"string"},"reason":{"type":"string","enum":["bounce","complaint","unsubscribe","manual"]},"detail":{"type":["string","null"]},"created_at":{"type":"string","format":"date-time"}}},"SmsCategory":{"type":"string","enum":["transactional","service_implicit","service_explicit","promotional"]},"SmsStatus":{"type":"string","enum":["queued","sending","sent","delivered","failed"]},"SmsReviewState":{"type":"string","enum":["pending","approved","rejected"]},"SmsSenderId":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"header":{"type":"string"},"type":{"type":"string","enum":["transactional","service","promotional"]},"dlt_mode":{"type":"string","enum":["own","platform"]},"status":{"$ref":"#/components/schemas/SmsReviewState"},"review_note":{"type":["string","null"]},"created_at":{"type":"string","format":"date-time"}}},"SmsTemplate":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"sender_id":{"type":"string","format":"uuid"},"header":{"type":"string"},"name":{"type":"string"},"dlt_template_id":{"type":["string","null"],"description":"Null for a template on Asyscraft's DLT until AsysConnect approves it."},"dlt_mode":{"type":"string","enum":["own","platform"]},"category":{"$ref":"#/components/schemas/SmsCategory"},"body":{"type":"string"},"variables":{"type":"integer"},"status":{"$ref":"#/components/schemas/SmsReviewState"},"review_note":{"type":["string","null"]},"linked":{"type":"boolean","description":"Whether MSG91's template id is set."},"created_at":{"type":"string","format":"date-time"}}},"SmsTemplateValues":{"type":"object","required":["template_id"],"properties":{"template_id":{"type":"string","format":"uuid"},"variables":{"type":"array","description":"One value per `{#var#}`, in order, each at most 30 characters.","maxItems":20,"items":{"type":"string"}}}},"SmsMessage":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"contact_id":{"type":["string","null"],"format":"uuid"},"to_phone":{"type":"string"},"template_id":{"type":["string","null"],"format":"uuid"},"broadcast_id":{"type":["string","null"],"format":"uuid"},"header":{"type":"string"},"category":{"$ref":"#/components/schemas/SmsCategory"},"body":{"type":"string"},"parts":{"type":"integer"},"unicode":{"type":"boolean"},"status":{"$ref":"#/components/schemas/SmsStatus"},"provider":{"type":["string","null"],"description":"The provider that took the SMS."},"external_id":{"type":["string","null"]},"error":{"type":["string","null"]},"sent_by":{"type":["string","null"],"format":"uuid"},"created_at":{"type":"string","format":"date-time"},"sent_at":{"type":["string","null"],"format":"date-time"},"delivered_at":{"type":["string","null"],"format":"date-time"},"failed_at":{"type":["string","null"],"format":"date-time"}}},"SmsBroadcast":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"template_id":{"type":"string","format":"uuid"},"template_name":{"type":"string"},"audience":{"$ref":"#/components/schemas/Audience"},"params":{"type":"array","items":{"$ref":"#/components/schemas/VariableSource"}},"status":{"type":"string","enum":["scheduled","sending","sent","cancelled","failed"]},"scheduled_at":{"type":"string","format":"date-time"},"started_at":{"type":["string","null"],"format":"date-time"},"finished_at":{"type":["string","null"],"format":"date-time"},"failure":{"type":["string","null"]},"stats":{"type":"object","description":"SMS by status, and recipients skipped.","additionalProperties":{"type":"integer"}},"skipped":{"type":"array","description":"Skip reasons with counts (detail only).","items":{"type":"object","properties":{"reason":{"type":"string"},"count":{"type":"integer"}}}},"created_at":{"type":"string","format":"date-time"}}},"SmsPlatform":{"type":"object","properties":{"dlt_entity_id":{"type":["string","null"],"description":"Asyscraft's own Principal Entity ID."},"business_name":{"type":["string","null"]},"providers":{"type":"array","description":"The saved order; empty means the server's order.","items":{"type":"string"}},"route":{"type":"array","description":"The order SMS actually try, connected providers only.","items":{"type":"string"}},"connected":{"type":"array","items":{"type":"string"}},"updated_at":{"type":"string","format":"date-time"}}},"AdminSmsSenderId":{"allOf":[{"$ref":"#/components/schemas/SmsSenderId"},{"type":"object","properties":{"tenant_id":{"type":"string","format":"uuid"},"workspace":{"type":"string"},"dlt_entity_id":{"type":["string","null"],"description":"The entity it sends under (the workspace's, or Asyscraft's)."}}}]},"AdminSmsTemplate":{"allOf":[{"$ref":"#/components/schemas/SmsTemplate"},{"type":"object","properties":{"tenant_id":{"type":"string","format":"uuid"},"workspace":{"type":"string"},"dlt_entity_id":{"type":["string","null"]},"gateway_template_id":{"type":["string","null"]}}}]},"AdminRateList":{"type":"object","required":["data"],"properties":{"data":{"type":"array","items":{"type":"object","properties":{"channel":{"type":"string","enum":["whatsapp","sms","email","ai"]},"category":{"type":"string"},"price_paise":{"type":"integer"}}}}}},"Error":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["code","message","request_id"],"properties":{"code":{"$ref":"#/components/schemas/ErrorCode"},"message":{"type":"string","description":"Human-readable; may be shown to the user but can change."},"request_id":{"type":"string","description":"The request's id (your `X-Request-Id`, or `req_<uuid>`)."},"details":{"description":"Extra data for some codes: the zod issues for VALIDATION_FAILED from request\nvalidation, `{ retry_after }` for RATE_LIMITED, `{ cost_paise, balance_paise }`\nfor INSUFFICIENT_BALANCE.\n"}}}},"example":{"error":{"code":"VALIDATION_FAILED","message":"Request validation failed","request_id":"req_0b6f3c1e-8a52-4a55-9d0e-0c7d2b8f1a11","details":[{"code":"too_small","path":["password"],"message":"String must contain at least 10 character(s)"}]}}},"ErrorCode":{"type":"string","description":"Stable error codes. `INTERNAL` is also used, with the real HTTP status, for framework\nerrors such as a malformed UUID path parameter (400).\n","enum":["VALIDATION_FAILED","UNAUTHENTICATED","INVALID_CREDENTIALS","INVALID_REFRESH_TOKEN","FORBIDDEN","NOT_FOUND","EMAIL_TAKEN","CONTACT_CHANNEL_TAKEN","INVITATION_INVALID","TOKEN_INVALID","RATE_LIMITED","TAG_NAME_TAKEN","CUSTOM_FIELD_KEY_TAKEN","IMPORT_INVALID_STATE","FILE_INVALID","WHATSAPP_NOT_CONFIGURED","WHATSAPP_NOT_CONNECTED","WHATSAPP_ACCOUNT_TAKEN","WHATSAPP_WINDOW_CLOSED","CONSENT_REQUIRED","TEMPLATE_NOT_APPROVED","TEMPLATE_PARAMS_INVALID","META_API_ERROR","WEBHOOK_SIGNATURE_INVALID","BROADCAST_INVALID_STATE","INSUFFICIENT_BALANCE","WORKSPACE_SUSPENDED","PAYMENTS_NOT_CONFIGURED","PAYMENT_INVALID","NOT_A_MEMBER","SMS_NOT_SET_UP","SMS_OUTSIDE_HOURS","EMAIL_NOT_SET_UP","EMAIL_SUPPRESSED","INTERNAL"]},"NextCursor":{"type":["string","null"],"description":"Opaque cursor for the next page, or null on the last page."},"TokenPair":{"type":"object","required":["access_token","token_type","expires_in","refresh_token"],"properties":{"access_token":{"type":"string","description":"JWT for the Authorization header."},"token_type":{"type":"string","const":"Bearer"},"expires_in":{"type":"integer","description":"Access token lifetime in seconds (900 by default).","example":900},"refresh_token":{"type":"string","description":"Opaque; valid 30 days by default; single use (rotated on refresh)."}}},"RefreshTokenBody":{"type":"object","properties":{"refresh_token":{"type":"string","minLength":20}}},"TokenBody":{"type":"object","required":["token"],"properties":{"token":{"type":"string","minLength":20,"maxLength":200}}},"TenantSummary":{"type":"object","required":["id","name","role"],"properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"role":{"$ref":"#/components/schemas/Role"}}},"Role":{"type":"string","description":"A system role key (owner, admin, agent).","examples":["owner","admin","agent"]},"Permission":{"type":"string","enum":["tenant.manage","members.read","members.manage","contacts.read","contacts.write","contacts.delete","contacts.export","conversations.read","conversations.write","broadcasts.manage","sms.manage","sms.send","email.manage","email.send","billing.manage","integrations.manage","social.publish","automations.manage","ai.manage","deals.read","deals.write","pipelines.manage","api.manage"]},"StageKind":{"type":"string","description":"open is still being worked; won and lost close the deal.","enum":["open","won","lost"]},"PipelineStageInput":{"type":"object","required":["name"],"properties":{"name":{"type":"string","maxLength":60},"probability":{"type":"integer","minimum":0,"maximum":100,"description":"Chance a deal here is won, for the weighted forecast. Defaults to 100 for won, else 0."},"color":{"type":["string","null"],"pattern":"^#[0-9a-fA-F]{6}$"},"kind":{"$ref":"#/components/schemas/StageKind"}}},"PipelineStage":{"type":"object","required":["id","name","position","probability","color","kind"],"properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"position":{"type":"integer"},"probability":{"type":"integer"},"color":{"type":["string","null"]},"kind":{"$ref":"#/components/schemas/StageKind"}}},"Pipeline":{"type":"object","required":["id","name","position","stages","deal_count","created_at"],"properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"position":{"type":"integer"},"stages":{"type":"array","items":{"$ref":"#/components/schemas/PipelineStage"}},"deal_count":{"type":"integer"},"created_at":{"type":"string","format":"date-time"}}},"DealInput":{"type":"object","required":["title"],"properties":{"title":{"type":"string","maxLength":200},"pipeline_id":{"type":"string","format":"uuid"},"stage_id":{"type":"string","format":"uuid"},"value_paise":{"type":"integer","minimum":0,"description":"The deal's value in paise (₹1 = 100)."},"contact_id":{"type":["string","null"],"format":"uuid"},"conversation_id":{"type":["string","null"],"format":"uuid","description":"The chat it came from."},"owner_id":{"type":["string","null"],"format":"uuid","description":"Defaults to you; null for nobody."},"expected_close":{"type":["string","null"],"format":"date"},"source":{"type":["string","null"],"maxLength":60},"notes":{"type":"string","maxLength":10000}}},"DealUpdate":{"type":"object","minProperties":1,"properties":{"title":{"type":"string","maxLength":200},"value_paise":{"type":"integer","minimum":0},"contact_id":{"type":["string","null"],"format":"uuid"},"conversation_id":{"type":["string","null"],"format":"uuid"},"owner_id":{"type":["string","null"],"format":"uuid"},"expected_close":{"type":["string","null"],"format":"date"},"source":{"type":["string","null"],"maxLength":60},"notes":{"type":"string","maxLength":10000}}},"Deal":{"type":"object","required":["id","title","value_paise","currency","status","pipeline_id","stage_id","position","created_at"],"properties":{"id":{"type":"string","format":"uuid"},"title":{"type":"string"},"value_paise":{"type":"integer"},"currency":{"type":"string","enum":["INR"]},"status":{"$ref":"#/components/schemas/StageKind"},"pipeline_id":{"type":"string","format":"uuid"},"stage_id":{"type":"string","format":"uuid"},"contact_id":{"type":["string","null"],"format":"uuid"},"contact":{"type":["object","null"],"properties":{"id":{"type":"string","format":"uuid"},"display_name":{"type":"string"},"phone":{"type":["string","null"]}}},"conversation_id":{"type":["string","null"],"format":"uuid"},"owner_id":{"type":["string","null"],"format":"uuid"},"owner_name":{"type":["string","null"]},"expected_close":{"type":["string","null"],"format":"date"},"source":{"type":["string","null"]},"lost_reason":{"type":["string","null"]},"position":{"type":"number","description":"Order within the stage on the board, smaller first."},"open_tasks":{"type":"integer"},"next_task_due":{"type":["string","null"],"format":"date-time"},"stage_changed_at":{"type":"string","format":"date-time"},"closed_at":{"type":["string","null"],"format":"date-time"},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}}},"DealDetail":{"allOf":[{"$ref":"#/components/schemas/Deal"},{"type":"object","required":["notes","events","time_in_stages","tasks"],"properties":{"notes":{"type":"string"},"events":{"type":"array","description":"Everything that happened to it, oldest first.","items":{"type":"object","properties":{"id":{"type":"string"},"kind":{"type":"string","enum":["created","stage_changed","value_changed","owner_changed","updated","note"]},"from_stage_id":{"type":["string","null"]},"to_stage_id":{"type":["string","null"]},"from_stage":{"type":["string","null"]},"to_stage":{"type":["string","null"]},"detail":{"type":"object","description":"note: `text`; value_changed and owner_changed: `from`, `to`; updated:\n`fields`; stage_changed: `seconds_in_stage` and `lost_reason`.\n","additionalProperties":true},"user_id":{"type":["string","null"],"description":"Null when an automation did it."},"user_name":{"type":["string","null"]},"created_at":{"type":"string","format":"date-time"}}}},"time_in_stages":{"type":"array","items":{"type":"object","properties":{"stage_id":{"type":"string","format":"uuid"},"name":{"type":"string"},"seconds":{"type":"integer"}}}},"tasks":{"type":"array","items":{"$ref":"#/components/schemas/Task"}}}}]},"DealTotals":{"type":"object","properties":{"count":{"type":"integer"},"value_paise":{"type":"number"},"weighted_paise":{"type":"number"}}},"DealSummary":{"type":"object","required":["pipeline_id","open","this_month","stages","forecast","owners"],"properties":{"pipeline_id":{"type":"string","format":"uuid"},"open":{"$ref":"#/components/schemas/DealTotals"},"this_month":{"type":"object","properties":{"won_count":{"type":"integer"},"won_paise":{"type":"number"},"lost_count":{"type":"integer"},"lost_paise":{"type":"number"}}},"stages":{"type":"array","items":{"allOf":[{"$ref":"#/components/schemas/DealTotals"},{"type":"object","properties":{"stage_id":{"type":"string","format":"uuid"}}}]}},"forecast":{"type":"array","description":"Open deals by expected close month (YYYY-MM); null month for undated.","items":{"allOf":[{"$ref":"#/components/schemas/DealTotals"},{"type":"object","properties":{"month":{"type":["string","null"]}}}]}},"owners":{"type":"array","items":{"allOf":[{"$ref":"#/components/schemas/DealTotals"},{"type":"object","properties":{"owner_id":{"type":["string","null"]},"owner_name":{"type":["string","null"]}}}]}}}},"TaskPriority":{"type":"string","enum":["low","normal","high"]},"TaskInput":{"type":"object","required":["title"],"properties":{"title":{"type":"string","maxLength":200},"notes":{"type":"string","maxLength":5000},"due_at":{"type":["string","null"],"format":"date-time"},"priority":{"$ref":"#/components/schemas/TaskPriority"},"assigned_to":{"type":["string","null"],"format":"uuid","description":"Leave out for yourself; null for nobody."},"deal_id":{"type":["string","null"],"format":"uuid"},"contact_id":{"type":["string","null"],"format":"uuid"}}},"Task":{"type":"object","required":["id","title","notes","priority","created_at"],"properties":{"id":{"type":"string","format":"uuid"},"title":{"type":"string"},"notes":{"type":"string"},"due_at":{"type":["string","null"],"format":"date-time"},"priority":{"$ref":"#/components/schemas/TaskPriority"},"assigned_to":{"type":["string","null"],"format":"uuid"},"assigned_name":{"type":["string","null"]},"deal_id":{"type":["string","null"],"format":"uuid"},"deal_title":{"type":["string","null"]},"contact_id":{"type":["string","null"],"format":"uuid"},"contact_name":{"type":["string","null"]},"done_at":{"type":["string","null"],"format":"date-time"},"done_by":{"type":["string","null"],"format":"uuid"},"created_by":{"type":["string","null"],"format":"uuid"},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}}},"AiSettingsInput":{"type":"object","required":["auto_reply","channels","only_unassigned","business_name","instructions","handoff_message","daily_limit"],"properties":{"auto_reply":{"type":"boolean","description":"Answer incoming chats without a person."},"channels":{"type":"array","minItems":1,"items":{"type":"string","enum":["whatsapp","instagram","messenger"]}},"only_unassigned":{"type":"boolean","description":"Leave chats assigned to a teammate alone."},"business_name":{"type":["string","null"],"maxLength":120},"instructions":{"type":"string","maxLength":4000,"description":"Tone, languages, what to say and not to say."},"handoff_message":{"type":"string","maxLength":500,"description":"Sent when the AI hands the chat to the team; empty sends nothing."},"daily_limit":{"type":"integer","minimum":1,"maximum":200,"description":"Most automatic answers in one chat per day."}}},"AiSettings":{"allOf":[{"$ref":"#/components/schemas/AiSettingsInput"},{"type":"object","required":["server_ready","price_paise","knowledge_chars","max_knowledge_chars"],"properties":{"server_ready":{"type":"boolean","description":"Whether AI replies are switched on on the server."},"price_paise":{"type":"integer","description":"Charged from the wallet for each answer."},"knowledge_chars":{"type":"integer"},"max_knowledge_chars":{"type":"integer"}}}]},"AiKnowledgeInput":{"type":"object","required":["title","content"],"properties":{"title":{"type":"string","maxLength":200},"content":{"type":"string","maxLength":20000},"enabled":{"type":"boolean","default":true}}},"AiKnowledge":{"type":"object","required":["id","title","content","enabled","created_at","updated_at"],"properties":{"id":{"type":"string","format":"uuid"},"title":{"type":"string"},"content":{"type":"string"},"enabled":{"type":"boolean"},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}}},"AiReplyStatus":{"type":"string","enum":["pending","sent","suggested","answered","handed_off","skipped","failed"]},"AiReply":{"type":"object","required":["id","kind","conversation_id","status","reply","reason","error","price_paise","created_at"],"properties":{"id":{"type":"string","format":"uuid"},"kind":{"type":"string","enum":["auto","suggest","test"]},"conversation_id":{"type":["string","null"],"format":"uuid"},"status":{"$ref":"#/components/schemas/AiReplyStatus"},"question":{"type":["string","null"]},"reply":{"type":["string","null"]},"reason":{"type":["string","null"],"description":"What the answer came from, or why a person is needed."},"error":{"type":["string","null"]},"message_id":{"type":["string","null"],"format":"uuid"},"price_paise":{"type":"integer"},"input_tokens":{"type":["integer","null"]},"output_tokens":{"type":["integer","null"]},"cache_read_tokens":{"type":["integer","null"]},"created_at":{"type":"string","format":"date-time"},"finished_at":{"type":["string","null"],"format":"date-time"}}},"AiPaused":{"type":"object","required":["ai_paused"],"properties":{"ai_paused":{"type":"boolean"}}},"Member":{"type":"object","required":["user_id","name","email","role","status","created_at"],"properties":{"user_id":{"type":"string","format":"uuid"},"name":{"type":"string"},"email":{"type":"string","format":"email"},"role":{"$ref":"#/components/schemas/Role"},"status":{"type":"string","enum":["active","disabled"]},"created_at":{"type":"string","format":"date-time"}}},"ContactFields":{"type":"object","properties":{"first_name":{"type":"string","maxLength":120},"last_name":{"type":"string","maxLength":120},"lifecycle_stage":{"type":"string","maxLength":40,"description":"Free text; defaults to `contact` on create."},"source":{"type":"string","maxLength":80},"owner_id":{"type":["string","null"],"format":"uuid","description":"A member's user id."},"custom":{"type":"object","additionalProperties":true,"description":"Values keyed by custom field key, checked against the field's type."}}},"ContactChannelInput":{"type":"object","required":["type","value"],"properties":{"type":{"type":"string","enum":["phone","email"]},"value":{"type":"string","minLength":3,"maxLength":254,"description":"Phone numbers are normalized to E.164; numbers without a country code are read as Indian (+91)."},"is_primary":{"type":"boolean","description":"Defaults to true for the first channel of each type."}}},"ContactChannel":{"type":"object","required":["id","type","value","normalized_value","is_primary"],"properties":{"id":{"type":"string","format":"uuid"},"type":{"type":"string","enum":["phone","email"]},"value":{"type":"string"},"normalized_value":{"type":"string"},"is_primary":{"type":"boolean"}}},"TagRef":{"type":"object","required":["id","name","color"],"properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"color":{"type":["string","null"]}}},"ConsentChannel":{"type":"string","enum":["whatsapp","sms","email"]},"Contact":{"type":"object","required":["id","first_name","last_name","display_name","owner_id","lifecycle_stage","source","custom","last_activity_at","created_at","updated_at","channels","tags","consent"],"properties":{"id":{"type":"string","format":"uuid"},"first_name":{"type":["string","null"]},"last_name":{"type":["string","null"]},"display_name":{"type":["string","null"],"description":"Computed by the server from the name fields."},"owner_id":{"type":["string","null"],"format":"uuid"},"lifecycle_stage":{"type":"string"},"source":{"type":["string","null"]},"custom":{"type":"object","additionalProperties":true},"last_activity_at":{"type":["string","null"],"format":"date-time"},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"},"channels":{"type":"array","description":"Primary first.","items":{"$ref":"#/components/schemas/ContactChannel"}},"tags":{"type":"array","items":{"$ref":"#/components/schemas/TagRef"}},"consent":{"type":"object","description":"Latest marketing consent per channel; channels never recorded are absent.","propertyNames":{"$ref":"#/components/schemas/ConsentChannel"},"additionalProperties":{"type":"string","enum":["opted_in","opted_out"]},"example":{"whatsapp":"opted_in"}}}},"ConsentRecord":{"type":"object","required":["id","channel","purpose","status","source","evidence","recorded_at"],"properties":{"id":{"type":"string","format":"uuid"},"channel":{"$ref":"#/components/schemas/ConsentChannel"},"purpose":{"type":"string","enum":["marketing","transactional"]},"status":{"type":"string","enum":["opted_in","opted_out"]},"source":{"type":["string","null"]},"evidence":{"type":["object","null"],"additionalProperties":true},"recorded_at":{"type":"string","format":"date-time"}}},"TagInput":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":60},"color":{"type":"string","pattern":"^#[0-9a-fA-F]{6}$"}}},"Tag":{"type":"object","required":["id","name","color","created_at"],"properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"color":{"type":["string","null"]},"created_at":{"type":"string","format":"date-time"}}},"CustomFieldType":{"type":"string","enum":["text","number","date","boolean","select","multiselect"]},"CustomField":{"type":"object","required":["id","key","label","type","options","created_at"],"properties":{"id":{"type":"string","format":"uuid"},"key":{"type":"string"},"label":{"type":"string"},"type":{"$ref":"#/components/schemas/CustomFieldType"},"options":{"type":["array","null"],"items":{"type":"string"}},"created_at":{"type":"string","format":"date-time"}}},"SegmentFilter":{"type":"object","required":["conditions"],"properties":{"match":{"type":"string","enum":["all","any"],"default":"all"},"conditions":{"type":"array","minItems":1,"maxItems":20,"items":{"$ref":"#/components/schemas/SegmentCondition"}}}},"SegmentCondition":{"oneOf":[{"type":"object","required":["field","op","value"],"properties":{"field":{"const":"tag"},"op":{"enum":["has","not_has"]},"value":{"type":"string","format":"uuid"}}},{"type":"object","required":["field","op","value"],"properties":{"field":{"const":"lifecycle_stage"},"op":{"enum":["eq","neq"]},"value":{"type":"string","maxLength":40}}},{"type":"object","required":["field","op","value"],"properties":{"field":{"const":"source"},"op":{"enum":["eq","neq"]},"value":{"type":"string","maxLength":80}}},{"type":"object","required":["field","op"],"properties":{"field":{"const":"owner"},"op":{"enum":["eq","is_empty","is_not_empty"]},"value":{"type":"string","format":"uuid"}}},{"type":"object","required":["field","op","value"],"properties":{"field":{"const":"channel"},"op":{"enum":["has","not_has"]},"value":{"enum":["phone","email"]}}},{"type":"object","required":["field","op","value"],"properties":{"field":{"const":"consent"},"op":{"enum":["opted_in","opted_out","unknown"]},"value":{"$ref":"#/components/schemas/ConsentChannel"}}},{"type":"object","required":["field","op","value"],"properties":{"field":{"const":"created_at"},"op":{"enum":["after","before"]},"value":{"type":"string","format":"date-time"}}},{"type":"object","required":["field","key","op"],"properties":{"field":{"const":"custom"},"key":{"type":"string","pattern":"^[a-z][a-z0-9_]{0,39}$"},"op":{"enum":["eq","neq","contains","gt","lt","is_empty","is_not_empty"]},"value":{"oneOf":[{"type":"string","maxLength":200},{"type":"number"},{"type":"boolean"}]}}}]},"Segment":{"type":"object","required":["id","name","filter","created_by","created_at","updated_at"],"properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"filter":{"$ref":"#/components/schemas/SegmentFilter"},"created_by":{"type":["string","null"],"format":"uuid"},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}}},"ImportMapping":{"type":"object","description":"File column header to target. Targets: ignore, first_name, last_name, full_name, phone,\nemail, lifecycle_stage, source, consent.whatsapp, consent.sms, consent.email, or\n`custom.<field key>`. Headers not listed are ignored.\n","additionalProperties":{"type":"string","anyOf":[{"enum":["ignore","first_name","last_name","full_name","phone","email","lifecycle_stage","source","consent.whatsapp","consent.sms","consent.email"]},{"pattern":"^custom\\.[a-z][a-z0-9_]{0,39}$"}]},"example":{"Name":"full_name","Mobile":"phone","City":"custom.city"}},"Import":{"type":"object","required":["id","file_name","file_type","headers","total_rows","processed_rows","status","created_at"],"properties":{"id":{"type":"string","format":"uuid"},"file_name":{"type":"string"},"file_type":{"type":"string","enum":["csv","xlsx"]},"headers":{"type":"array","items":{"type":"string"}},"total_rows":{"type":"integer"},"processed_rows":{"type":"integer"},"status":{"type":"string","enum":["uploaded","queued","processing","completed","failed"]},"mapping":{"oneOf":[{"$ref":"#/components/schemas/ImportMapping"},{"type":"null"}]},"dedupe_mode":{"type":["string","null"],"enum":["skip","update",null]},"tag_ids":{"type":"array","items":{"type":"string","format":"uuid"}},"created_rows":{"type":"integer"},"updated_rows":{"type":"integer"},"skipped_rows":{"type":"integer"},"error_rows":{"type":"integer"},"failure":{"type":["string","null"]},"created_by":{"type":["string","null"],"format":"uuid"},"created_at":{"type":"string","format":"date-time"},"started_at":{"type":["string","null"],"format":"date-time"},"completed_at":{"type":["string","null"],"format":"date-time"}}},"Conversation":{"type":"object","required":["id","channel","status","assigned_to","unread_count","last_message_at","last_inbound_at","created_at","channel_number_id","social_account_id","social","assignee","contact","last_message","window_open","ai_paused"],"properties":{"ai_paused":{"type":"boolean","description":"The AI does not answer this chat by itself (it handed off, or a teammate replied)."},"id":{"type":"string","format":"uuid"},"channel":{"type":"string","enum":["whatsapp","sms","email","instagram","messenger"]},"status":{"type":"string","enum":["open","closed"]},"assigned_to":{"type":["string","null"],"format":"uuid"},"unread_count":{"type":"integer"},"last_message_at":{"type":["string","null"],"format":"date-time"},"last_inbound_at":{"type":["string","null"],"format":"date-time"},"created_at":{"type":"string","format":"date-time"},"channel_number_id":{"type":["string","null"],"format":"uuid","description":"Our WhatsApp number (see WhatsAppNumber.id)."},"social_account_id":{"type":["string","null"],"format":"uuid","description":"The connected Page or Instagram account (see SocialAccount.id)."},"social":{"type":["object","null"],"description":"For Instagram and Messenger threads.","properties":{"platform":{"$ref":"#/components/schemas/SocialPlatform"},"account_name":{"type":["string","null"]},"account_username":{"type":["string","null"]},"username":{"type":["string","null"],"description":"The customer's Instagram @handle."}}},"assignee":{"type":["object","null"],"required":["user_id","name"],"properties":{"user_id":{"type":"string","format":"uuid"},"name":{"type":"string"}}},"contact":{"type":"object","required":["id","display_name","phone"],"properties":{"id":{"type":"string","format":"uuid"},"display_name":{"type":["string","null"]},"phone":{"type":["string","null"],"description":"Primary phone number, E.164."}}},"last_message":{"type":["object","null"],"required":["direction","type","body","status","created_at"],"properties":{"direction":{"type":"string","enum":["inbound","outbound"]},"type":{"type":"string"},"body":{"type":["string","null"]},"status":{"$ref":"#/components/schemas/MessageStatus"},"created_at":{"type":"string","format":"date-time"}}},"window_open":{"type":"boolean","description":"True while free-form text can be sent (customer wrote in the last 24 hours)."}}},"MessageStatus":{"type":"string","enum":["queued","sending","sent","delivered","read","failed","received"],"description":"Inbound messages have status `received`."},"Message":{"type":"object","required":["id","conversation_id","contact_id","direction","type","body","content","template_id","status","external_id","error","sent_by","ai_reply_id","created_at","sent_at","delivered_at","read_at","failed_at"],"properties":{"ai_reply_id":{"type":["string","null"],"format":"uuid","description":"Set when the AI wrote this message."},"id":{"type":"string","format":"uuid"},"conversation_id":{"type":"string","format":"uuid"},"contact_id":{"type":"string","format":"uuid"},"direction":{"type":"string","enum":["inbound","outbound"]},"type":{"type":"string","description":"text, template, image, video, audio, document, sticker, or another WhatsApp type.\nFor image, video, audio, document and sticker messages that are inbound, fetch the\nfile with GET /v1/messages/{id}/media.\n"},"body":{"type":["string","null"],"description":"Displayable text (the text, the rendered template body, or a caption)."},"content":{"type":"object","additionalProperties":true,"description":"The raw WhatsApp message object (Cloud API format)."},"template_id":{"type":["string","null"],"format":"uuid"},"status":{"$ref":"#/components/schemas/MessageStatus"},"external_id":{"type":["string","null"],"description":"WhatsApp message id (wamid)."},"error":{"type":["object","null"],"additionalProperties":true,"description":"Why sending failed, e.g. `{ \"code\", \"message\" }`."},"sent_by":{"type":["string","null"],"format":"uuid"},"created_at":{"type":"string","format":"date-time"},"sent_at":{"type":["string","null"],"format":"date-time"},"delivered_at":{"type":["string","null"],"format":"date-time"},"read_at":{"type":["string","null"],"format":"date-time"},"failed_at":{"type":["string","null"],"format":"date-time"}}},"TemplateParams":{"type":"object","description":"Values for a template's variables, in placeholder order.","properties":{"header":{"type":"array","maxItems":1,"items":{"type":"string","maxLength":1024}},"header_media":{"$ref":"#/components/schemas/MediaLink"},"body":{"type":"array","maxItems":50,"items":{"type":"string","maxLength":1024}},"buttons":{"type":"array","items":{"type":"object","required":["index","text"],"properties":{"index":{"type":"integer","minimum":0,"maximum":9},"text":{"type":"string"}}}}}},"MediaLink":{"type":"object","required":["link"],"properties":{"link":{"type":"string","format":"uri","maxLength":2000},"filename":{"type":"string"}}},"SendMessageRequest":{"oneOf":[{"type":"object","title":"Text message","required":["type","text"],"properties":{"type":{"const":"text"},"text":{"type":"string","minLength":1,"maxLength":4096},"contact_id":{"type":"string","format":"uuid"},"to":{"type":"string","minLength":5,"maxLength":30,"description":"Phone number; alternative to contact_id."},"number_id":{"type":"string","format":"uuid","description":"Our sending number; defaults to the workspace's default number."}}},{"type":"object","title":"Template message","required":["type","template_id"],"properties":{"type":{"const":"template"},"template_id":{"type":"string","format":"uuid"},"params":{"$ref":"#/components/schemas/TemplateParams"},"contact_id":{"type":"string","format":"uuid"},"to":{"type":"string","minLength":5,"maxLength":30},"number_id":{"type":"string","format":"uuid"}}}],"description":"Exactly one of contact_id or to is required."},"VariableSource":{"oneOf":[{"type":"object","title":"Static value","required":["type","value"],"properties":{"type":{"const":"static"},"value":{"type":"string","minLength":1,"maxLength":1024}}},{"type":"object","title":"Contact field","required":["type","field","fallback"],"properties":{"type":{"const":"field"},"field":{"type":"string","pattern":"^(first_name|last_name|display_name|phone|custom\\.[a-z][a-z0-9_]{0,39})$"},"fallback":{"type":"string","minLength":1,"maxLength":1024,"description":"Used when the contact has no value for the field."}}}]},"BroadcastParams":{"type":"object","properties":{"header":{"type":"array","maxItems":1,"items":{"$ref":"#/components/schemas/VariableSource"}},"header_media":{"$ref":"#/components/schemas/MediaLink"},"body":{"type":"array","maxItems":50,"items":{"$ref":"#/components/schemas/VariableSource"}},"buttons":{"type":"array","items":{"type":"object","required":["index","value"],"properties":{"index":{"type":"integer","minimum":0,"maximum":9},"value":{"$ref":"#/components/schemas/VariableSource"}}}}}},"Audience":{"description":"Exactly one of a segment, tags (any of) or a contact list.","oneOf":[{"type":"object","required":["segment_id"],"additionalProperties":false,"properties":{"segment_id":{"type":"string","format":"uuid"}}},{"type":"object","required":["tag_ids"],"additionalProperties":false,"properties":{"tag_ids":{"type":"array","minItems":1,"maxItems":20,"items":{"type":"string","format":"uuid"}}}},{"type":"object","required":["contact_ids"],"additionalProperties":false,"properties":{"contact_ids":{"type":"array","minItems":1,"maxItems":10000,"items":{"type":"string","format":"uuid"}}}}]},"BroadcastInput":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":120},"template_id":{"type":"string","format":"uuid"},"number_id":{"type":"string","format":"uuid","description":"Sending number; defaults to the workspace's default number."},"audience":{"$ref":"#/components/schemas/Audience"},"params":{"$ref":"#/components/schemas/BroadcastParams"}}},"BroadcastStatus":{"type":"string","enum":["draft","scheduled","sending","sent","cancelled","failed"]},"Broadcast":{"type":"object","required":["id","name","number_id","template_id","audience","params","status","scheduled_at","started_at","finished_at","failure","created_by","created_at","updated_at","template"],"properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"number_id":{"type":"string","format":"uuid"},"template_id":{"type":"string","format":"uuid"},"audience":{"$ref":"#/components/schemas/Audience"},"params":{"$ref":"#/components/schemas/BroadcastParams"},"status":{"$ref":"#/components/schemas/BroadcastStatus"},"scheduled_at":{"type":["string","null"],"format":"date-time"},"started_at":{"type":["string","null"],"format":"date-time"},"finished_at":{"type":["string","null"],"format":"date-time"},"failure":{"type":["string","null"]},"created_by":{"type":["string","null"],"format":"uuid"},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"},"template":{"type":"object","required":["id","name","language","category","status"],"properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"language":{"type":"string"},"category":{"$ref":"#/components/schemas/TemplateCategory"},"status":{"type":"string"}}}}},"BroadcastDetail":{"allOf":[{"$ref":"#/components/schemas/Broadcast"},{"type":"object","required":["preview","audience_counts","cost","stats"],"properties":{"preview":{"type":["string","null"],"description":"The message body rendered for a sample contact."},"audience_counts":{"type":["object","null"],"description":"Only for draft and scheduled broadcasts.","required":["total","with_phone","eligible"],"properties":{"total":{"type":"integer"},"with_phone":{"type":"integer"},"eligible":{"type":"integer","description":"Has a phone and, for marketing templates, a WhatsApp opt-in."}}},"cost":{"type":["object","null"],"required":["price_paise","estimate_paise","balance_paise"],"properties":{"price_paise":{"type":"integer"},"estimate_paise":{"type":"integer"},"balance_paise":{"type":"integer"}}},"stats":{"type":"object","required":["recipients","pending","skipped","queued","sent","delivered","read","failed"],"properties":{"recipients":{"type":"integer"},"pending":{"type":"integer"},"skipped":{"type":"integer"},"queued":{"type":"integer"},"sent":{"type":"integer"},"delivered":{"type":"integer"},"read":{"type":"integer"},"failed":{"type":"integer"}}}}}]},"RecipientStatus":{"type":"string","enum":["pending","skipped","queued","sending","sent","delivered","read","failed"],"description":"As a filter, `sending` is not accepted (queued includes it)."},"BroadcastRecipient":{"type":"object","required":["contact_id","display_name","phone","status","skip_reason","error","sent_at","delivered_at","read_at"],"properties":{"contact_id":{"type":"string","format":"uuid"},"display_name":{"type":["string","null"]},"phone":{"type":["string","null"]},"status":{"$ref":"#/components/schemas/RecipientStatus"},"skip_reason":{"type":["string","null"]},"error":{"type":["object","null"],"additionalProperties":true},"sent_at":{"type":["string","null"],"format":"date-time"},"delivered_at":{"type":["string","null"],"format":"date-time"},"read_at":{"type":["string","null"],"format":"date-time"}}},"MetaId":{"type":"string","pattern":"^\\d{5,25}$","description":"A numeric Meta id."},"ConnectResult":{"type":"object","required":["account_id","warnings"],"properties":{"account_id":{"type":"string","format":"uuid"},"warnings":{"type":"array","items":{"type":"string"}}}},"WhatsAppNumber":{"type":"object","required":["id","phone_number_id","display_phone_number","verified_name","quality_rating","messaging_limit","status","is_default"],"properties":{"id":{"type":"string","format":"uuid"},"phone_number_id":{"type":"string","description":"Meta's phone number id."},"display_phone_number":{"type":["string","null"]},"verified_name":{"type":["string","null"]},"quality_rating":{"type":["string","null"]},"messaging_limit":{"type":["string","null"]},"status":{"type":["string","null"]},"is_default":{"type":"boolean"}}},"WhatsAppAccount":{"type":"object","required":["id","waba_id","name","currency","connection_type","status","created_at","numbers"],"properties":{"id":{"type":"string","format":"uuid"},"waba_id":{"type":"string"},"name":{"type":["string","null"]},"currency":{"type":["string","null"]},"connection_type":{"type":"string","enum":["embedded_signup","manual"]},"status":{"type":"string","const":"active"},"created_at":{"type":"string","format":"date-time"},"numbers":{"type":"array","items":{"$ref":"#/components/schemas/WhatsAppNumber"}}}},"TemplateCategory":{"type":"string","enum":["MARKETING","UTILITY","AUTHENTICATION"]},"Template":{"type":"object","required":["id","account_id","meta_template_id","name","language","category","status","components","rejected_reason","quality_score","synced_at","created_at","updated_at"],"properties":{"id":{"type":"string","format":"uuid"},"account_id":{"type":"string","format":"uuid"},"meta_template_id":{"type":["string","null"]},"name":{"type":"string"},"language":{"type":"string","example":"en_US"},"category":{"$ref":"#/components/schemas/TemplateCategory"},"status":{"type":"string","description":"Meta's review status.","examples":["PENDING","APPROVED","REJECTED","PAUSED","DISABLED"]},"components":{"type":"array","description":"The template in Meta's component format (HEADER, BODY, FOOTER, BUTTONS).","items":{"type":"object","additionalProperties":true}},"rejected_reason":{"type":["string","null"]},"quality_score":{"type":["string","null"]},"synced_at":{"type":["string","null"],"format":"date-time"},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}}},"CreateTemplateRequest":{"type":"object","required":["name","language","category","body"],"description":"Meta requires examples whenever the text has {{1}}-style variables.","properties":{"account_id":{"type":"string","format":"uuid","description":"Defaults to the workspace's first active account."},"name":{"type":"string","pattern":"^[a-z0-9_]{1,512}$"},"language":{"type":"string","pattern":"^[a-z]{2,3}(_[A-Z]{2})?$","examples":["en","en_US","hi"]},"category":{"$ref":"#/components/schemas/TemplateCategory"},"header":{"oneOf":[{"type":"object","required":["format","text"],"properties":{"format":{"const":"TEXT"},"text":{"type":"string","minLength":1,"maxLength":60},"example":{"type":"array","maxItems":1,"items":{"type":"string"}}}},{"type":"object","required":["format"],"properties":{"format":{"enum":["IMAGE","VIDEO","DOCUMENT"]},"example_handle":{"type":"string","minLength":1}}}]},"body":{"type":"object","required":["text"],"properties":{"text":{"type":"string","minLength":1,"maxLength":1024},"example":{"type":"array","maxItems":50,"items":{"type":"string"}}}},"footer":{"type":"string","minLength":1,"maxLength":60},"buttons":{"type":"array","maxItems":10,"items":{"oneOf":[{"type":"object","required":["type","text"],"properties":{"type":{"const":"QUICK_REPLY"},"text":{"type":"string","minLength":1,"maxLength":25}}},{"type":"object","required":["type","text","url"],"properties":{"type":{"const":"URL"},"text":{"type":"string","minLength":1,"maxLength":25},"url":{"type":"string","format":"uri","maxLength":2000},"example":{"type":"array","maxItems":1,"items":{"type":"string"}}}},{"type":"object","required":["type","text","phone_number"],"properties":{"type":{"const":"PHONE_NUMBER"},"text":{"type":"string","minLength":1,"maxLength":25},"phone_number":{"type":"string","minLength":5,"maxLength":20}}}]}}}},"Rate":{"type":"object","required":["channel","category","price_paise"],"properties":{"channel":{"type":"string","example":"whatsapp"},"category":{"$ref":"#/components/schemas/TemplateCategory"},"price_paise":{"type":"integer","description":"Price of one message."}}},"WalletEntry":{"type":"object","required":["id","kind","amount_paise","balance_after","message_id","note","created_at","tax_paise","provider_payment_id"],"properties":{"id":{"type":"string","format":"uuid"},"kind":{"type":"string","enum":["recharge","charge","refund","adjustment"]},"amount_paise":{"type":"number","description":"Signed; charges are negative."},"balance_after":{"type":"number","description":"Balance in paise after this entry."},"message_id":{"type":["string","null"],"format":"uuid"},"note":{"type":["string","null"]},"created_at":{"type":"string","format":"date-time"},"tax_paise":{"type":["number","null"],"description":"GST paid, for recharges."},"provider_payment_id":{"type":["string","null"],"description":"Razorpay payment id, for recharges."}}},"RechargeOrder":{"type":"object","required":["payment_id","order_id","key_id","amount_paise","tax_paise","total_paise","currency"],"properties":{"payment_id":{"type":"string","format":"uuid","description":"Our payment record id (not Razorpay's payment id)."},"order_id":{"type":"string","description":"Razorpay order id, for the checkout."},"key_id":{"type":"string","description":"Razorpay public key id, for the checkout."},"amount_paise":{"type":"integer","description":"Credited to the wallet."},"tax_paise":{"type":"integer","description":"GST."},"total_paise":{"type":"integer","description":"Charged to the customer (amount plus GST)."},"currency":{"type":"string","const":"INR"}}},"WorkspaceStatus":{"type":"string","enum":["trial","active","past_due","suspended","closed"]},"AdminTotals":{"type":"object","properties":{"workspaces":{"type":"integer"},"active_workspaces":{"type":"integer"},"contacts":{"type":"integer"},"messages_30d":{"type":"integer"},"revenue_30d_paise":{"type":"integer"},"balances_paise":{"type":"integer"}}},"AdminWorkspace":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"status":{"$ref":"#/components/schemas/WorkspaceStatus"},"created_at":{"type":"string","format":"date-time"},"owner_name":{"type":["string","null"]},"owner_email":{"type":["string","null"]},"members":{"type":"integer"},"contacts":{"type":"integer"},"balance_paise":{"type":"integer"},"messages_30d":{"type":"integer"},"spent_30d_paise":{"type":"integer"},"whatsapp_numbers":{"type":"integer"},"last_message_at":{"type":["string","null"],"format":"date-time"}}},"AdminRate":{"type":"object","properties":{"channel":{"type":"string","enum":["whatsapp","sms","email","ai"]},"category":{"type":"string"},"price_paise":{"type":"integer"},"is_custom":{"type":"boolean","description":"True when the workspace has its own price."}}},"AdminPayment":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"amount_paise":{"type":"integer"},"tax_paise":{"type":"integer"},"status":{"type":"string","enum":["created","paid","failed"]},"provider_payment_id":{"type":["string","null"]},"created_at":{"type":"string","format":"date-time"},"paid_at":{"type":["string","null"],"format":"date-time"}}},"TicketCategory":{"type":"string","enum":["whatsapp","billing","technical","account","other"]},"TicketStatus":{"type":"string","description":"`open` waits on AsysConnect, `waiting` waits on the customer, `closed` is done.","enum":["open","waiting","closed"]},"SupportTicket":{"type":"object","required":["id","number","subject","category","status","created_by","created_at","last_reply_at"],"properties":{"id":{"type":"string","format":"uuid"},"tenant_id":{"type":"string","format":"uuid"},"number":{"type":"integer","description":"The reference people quote, like \"ticket 1042\".","example":1042},"subject":{"type":"string"},"category":{"$ref":"#/components/schemas/TicketCategory"},"status":{"$ref":"#/components/schemas/TicketStatus"},"last_reply_at":{"type":"string","format":"date-time"},"last_reply_by_staff":{"type":"boolean","description":"True when the latest message is the AsysConnect team's."},"created_by":{"type":"object","properties":{"user_id":{"type":"string","format":"uuid"},"name":{"type":"string"},"email":{"type":"string","format":"email"}}},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}}},"SupportMessage":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"body":{"type":"string"},"is_staff":{"type":"boolean"},"author":{"type":"object","properties":{"user_id":{"type":"string","format":"uuid"},"name":{"type":"string","description":"\"AsysConnect support\" for the team's replies."}}},"created_at":{"type":"string","format":"date-time"}}},"SupportTicketDetail":{"allOf":[{"$ref":"#/components/schemas/SupportTicket"},{"type":"object","required":["messages"],"properties":{"messages":{"type":"array","items":{"$ref":"#/components/schemas/SupportMessage"}}}}]},"TicketWorkspace":{"type":"object","properties":{"workspace":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"}}}}},"AdminSupportTicketDetail":{"allOf":[{"$ref":"#/components/schemas/SupportTicketDetail"},{"$ref":"#/components/schemas/TicketWorkspace"}]},"NamedRef":{"type":"object","required":["id","name"],"properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"}}},"ApiKeyScope":{"type":"string","description":"Permissions an API key can be given. Managing the team, billing, connected accounts,\nautomations, AI and pipelines stays with people. api.manage lets a key manage webhooks.\n","enum":["contacts.read","contacts.write","contacts.delete","contacts.export","conversations.read","conversations.write","members.read","broadcasts.manage","sms.send","sms.manage","email.send","email.manage","deals.read","deals.write","social.publish","api.manage"]},"ApiKey":{"type":"object","required":["id","name","prefix","scopes","created_by","created_at"],"properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"prefix":{"type":"string","description":"The start of the key, to tell keys apart.","example":"ask_live_3kq9Zc"},"scopes":{"type":"array","items":{"$ref":"#/components/schemas/ApiKeyScope"}},"created_by":{"type":"string","format":"uuid","description":"The member the key acts as."},"created_by_name":{"type":["string","null"]},"last_used_at":{"type":["string","null"],"format":"date-time","description":"Updated at most once a minute."},"last_used_ip":{"type":["string","null"]},"expires_at":{"type":["string","null"],"format":"date-time"},"revoked_at":{"type":["string","null"],"format":"date-time"},"created_at":{"type":"string","format":"date-time"}}},"WebhookEventType":{"type":"string","description":"message.received: a customer sent a message (WhatsApp, Instagram or Messenger).\nmessage.sent: your team, an automation or the AI sent one. message.status: a sent\nmessage was delivered, read or failed. contact.created / contact.updated /\ncontact.deleted. lead.received: a Lead Ads form came in. deal.created /\ndeal.stage_changed (including won and lost).\n","enum":["message.received","message.sent","message.status","contact.created","contact.updated","contact.deleted","lead.received","deal.created","deal.stage_changed"]},"WebhookInput":{"type":"object","required":["url","events"],"properties":{"url":{"type":"string","format":"uri","example":"https://shop.example.com/asysconnect/webhook"},"description":{"type":"string","maxLength":200},"events":{"type":"array","minItems":1,"items":{"$ref":"#/components/schemas/WebhookEventType"}}}},"WebhookSecret":{"type":"object","required":["secret"],"properties":{"secret":{"type":"string","description":"Signs each delivery (see X-AsysSuite-Signature in the guide).","example":"whsec_Qm9vZ2xlIGl0IGlmIHlvdSB3YW50"}}},"WebhookEndpoint":{"type":"object","required":["id","url","description","events","enabled","failure_count","created_at"],"properties":{"id":{"type":"string","format":"uuid"},"url":{"type":"string"},"description":{"type":"string"},"events":{"type":"array","items":{"$ref":"#/components/schemas/WebhookEventType"}},"enabled":{"type":"boolean"},"failing_since":{"type":["string","null"],"format":"date-time","description":"When the current run of failed deliveries began."},"failure_count":{"type":"integer","description":"Failed tries in a row; any success resets it."},"created_by":{"type":["string","null"],"format":"uuid"},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"},"last_delivery":{"type":["object","null"],"properties":{"status":{"type":"string","enum":["pending","succeeded","failed"]},"response_code":{"type":["integer","null"]},"created_at":{"type":"string","format":"date-time"}}}}},"WebhookDelivery":{"type":"object","required":["id","endpoint_id","event_id","event_type","status","attempts","created_at"],"properties":{"id":{"type":"string","format":"uuid","description":"Also sent as X-AsysSuite-Delivery."},"endpoint_id":{"type":"string","format":"uuid"},"event_id":{"type":"string","format":"uuid","description":"The same for every endpoint that gets this event; use it to skip repeats."},"event_type":{"type":"string","description":"A WebhookEventType, or ping for a test."},"object_id":{"type":["string","null"],"format":"uuid"},"status":{"type":"string","enum":["pending","succeeded","failed"]},"attempts":{"type":"integer"},"next_attempt_at":{"type":["string","null"],"format":"date-time"},"response_code":{"type":["integer","null"]},"error":{"type":["string","null"]},"created_at":{"type":"string","format":"date-time"},"delivered_at":{"type":["string","null"],"format":"date-time"}}},"WebhookEvent":{"type":"object","description":"The JSON body AsysConnect posts.","required":["id","type","created_at","workspace_id","data"],"properties":{"id":{"type":"string","format":"uuid"},"type":{"type":"string"},"created_at":{"type":"string","format":"date-time"},"workspace_id":{"type":"string","format":"uuid"},"data":{"type":"object","description":"The message (with its contact), contact, lead (with fields and contact) or deal (with\npipeline, stage and contact). contact.deleted carries only the id; deal.stage_changed\nadds from_stage.\n"}}},"OAuthTokenRequest":{"type":"object","required":["grant_type","code","redirect_uri"],"properties":{"grant_type":{"const":"authorization_code"},"code":{"type":"string"},"redirect_uri":{"type":"string","description":"The same one used to ask."},"client_id":{"type":"string","description":"Or in HTTP Basic."},"client_secret":{"type":"string","description":"Or in HTTP Basic. Not for public apps."},"code_verifier":{"type":"string","description":"Needed when the request had a code_challenge (always for public apps)."}}},"OAuthError":{"type":"object","required":["error"],"properties":{"error":{"type":"string","enum":["invalid_request","invalid_client","invalid_grant","unsupported_grant_type","slow_down"]},"error_description":{"type":"string"}}},"PartnerAppInput":{"type":"object","required":["name","redirect_uris","scopes"],"properties":{"name":{"type":"string","maxLength":80},"description":{"type":"string","maxLength":500},"developer_name":{"type":"string","maxLength":120},"website":{"type":["string","null"],"format":"uri"},"client_type":{"type":"string","enum":["confidential","public"],"default":"confidential","description":"public apps (a plugin on many sites) have no secret and must use PKCE."},"redirect_uris":{"type":"array","minItems":1,"maxItems":20,"items":{"type":"string","description":"https, or http://localhost for development."}},"scopes":{"type":"array","minItems":1,"items":{"$ref":"#/components/schemas/ApiKeyScope"}}}},"PartnerApp":{"type":"object","required":["id","name","client_id","client_type","redirect_uris","scopes","status"],"properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"description":{"type":"string"},"website":{"type":["string","null"]},"developer_name":{"type":"string"},"client_id":{"type":"string","example":"asa_Zk3v9QpL2mXw8rTb"},"client_type":{"type":"string","enum":["confidential","public"]},"redirect_uris":{"type":"array","items":{"type":"string"}},"scopes":{"type":"array","items":{"$ref":"#/components/schemas/ApiKeyScope"}},"status":{"type":"string","enum":["active","disabled"]},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}}}}}}