{"openapi":"3.0.3","info":{"title":"Blooio API v2","description":"RESTful API for iMessage automation. Send messages, manage contacts, groups, and webhooks.","version":"2.0.0","contact":{"name":"Blooio Support","url":"https://blooio.com","email":"support@blooio.com"}},"servers":[{"url":"https://api.blooio.com/v2/api","description":"Production"}],"security":[{"BearerAuth":[]}],"tags":[{"name":"Account","description":"Authentication and account information"},{"name":"Numbers","description":"Manage phone numbers linked to your account"},{"name":"Contact Card","description":"Manage and share your iMessage contact card (Name & Photo)"},{"name":"Contacts","description":"Manage contacts (phone numbers and emails)"},{"name":"Groups","description":"Manage contact groups"},{"name":"Group Members","description":"Manage group membership"},{"name":"Webhooks","description":"Manage webhook subscriptions"},{"name":"Webhook Logs","description":"View and replay webhook deliveries"},{"name":"Chats","description":"View conversations and messages"},{"name":"Messages","description":"View individual messages and their status"},{"name":"Typing Indicators","description":"Control typing indicators for conversations"},{"name":"Read Receipts","description":"Mark conversations as read"},{"name":"Reactions","description":"Add or remove reactions to messages. Supports classic iMessage tapbacks (love, like, dislike, laugh, emphasize, question) and emoji reactions (e.g. +😂, -😂)."},{"name":"Polls","description":"Send native iMessage polls and retrieve poll results with vote counts. Poll events are delivered via separate webhook event types (poll.received, poll.created, poll.voted) and require webhook_type 'poll' or 'all'."},{"name":"Location","description":"FindMy contact location tracking"},{"name":"FaceTime","description":"Initiate FaceTime calls"},{"name":"Phone Numbers","description":"Phone number validation, formatting, and NANPA geocoding. Requires an Enterprise plan (Dedicated Enterprise)."},{"name":"Analytics","description":"Deliverability and risk-tolerance reporting for your numbers.\n\n**Scope** — Reports are organization-scoped: any API key in the organization returns the whole organization's scorable fleet, regardless of which numbers a particular key is attached to.\n\n**Eligibility** — Risk scoring is available for dedicated numbers (Dedicated Commercial or Dedicated Enterprise) and inbound numbers (Inbound Basic); shared and trial numbers return `403 dedicated_plan_required`. Those are the only lines whose per-number usage is meaningful to score.\n\n**What the score means** — Each number gets a `risk_score` from 0 (lowest risk) to 100 (highest), mapped to a `risk_level`: `low` (0-29, healthy), `medium` (30-59, monitor), `high` (60-100, likely to be filtered/suspended by carriers). The score is the clamped sum of ten additive risk factors (see `RiskFactors`); positive factor scores raise risk, negative scores (bonuses) lower it. High **inbound** volume and engagement lower risk; high **outbound** volume, bursts, low reply rates, and templated content raise it. Risk is attributed to what a number does rather than to the traffic it receives, so `newConversationBursts` counts only the conversations the number itself opened — on every line type, a rush of customers texting in is never read as a blast.\n\n**Inbound lines are scored differently** — Inbound numbers are reply-only, so the factors that assume cold outreach are re-scoped for them: `outboundConversations` and `inboundPercentage` report `status: \"not_applicable\"` with a score of 0 (they are structurally fixed on a reply-only line), `inboundConversations` earns no volume bonus, and `inboundMsgCount` uses a relaxed threshold worth fewer points. The remaining factors — reply rate, total contacts, message balance, message bursts, and message similarity — are scored identically to dedicated lines. Each report entry carries a `line_type` so you can tell which profile was applied.\n\n**How it's computed** — Fully real-time: every request recomputes from Postgres over the requested window (there is no cache on the report endpoints). The metric fan-out is collapsed into a handful of org-wide `GROUP BY allocation_id` queries that run on a single database connection, so cost is roughly independent of fleet size. Conversation-initiation signals read the `channel_thread_stats` rollup (one row per conversation, holding its earliest message + direction); engagement, contacts, and bursts scan the windowed `messages`; message similarity derives a SimHash per outbound message at read time.\n\n**Window** — Defaults to the trailing 30 days; override with `days` or an explicit `from`/`to` epoch-ms range (see the per-endpoint query params)."}],"paths":{"/me":{"get":{"tags":["Account"],"summary":"Get current authentication context","description":"Returns details about the authenticated API key or dashboard user, including organization info, devices, and usage statistics.","operationId":"getMe","responses":{"200":{"description":"Authentication context","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MeResponse"}}}},"401":{"$ref":"#/components/responses/Unauthorized"}}}},"/me/numbers":{"get":{"tags":["Numbers"],"summary":"List phone numbers","description":"List all phone numbers bound to this API key with their availability status. Banned and suspended numbers stay in the list. `status` is `banned`, `suspended`, or `active`; a ban takes precedence when both apply. `is_active` is false when the line is banned, suspended, or the underlying account is blocked. Use the returned phone numbers as the `:number` path parameter for other `/me/numbers/` endpoints.","operationId":"listNumbers","responses":{"200":{"description":"List of phone numbers","content":{"application/json":{"schema":{"type":"object","properties":{"numbers":{"type":"array","items":{"type":"object","properties":{"phone_number":{"type":"string","example":"+15551234567"},"is_active":{"type":"boolean","description":"False when the line is banned, suspended, or the underlying account is blocked."},"banned":{"type":"boolean","description":"True when the phone number is banned (`phone_numbers.banned_at` is set)."},"suspended":{"type":"boolean","description":"True when the phone number is suspended. Independent of `status`: a line can be both banned and suspended, in which case `status` is `banned`."},"status":{"type":"string","enum":["active","suspended","banned"],"description":"`banned` if the number is banned, otherwise `suspended` if it is suspended, otherwise `active`. An account block does not change this field; it only sets `is_active` to false."},"last_active":{"type":"string","format":"date-time","nullable":true},"plan_kind":{"type":"string","nullable":true,"enum":["shared","dedicated","inbound","trial","2fa",null],"description":"Plan type the underlying allocation runs on. Sourced directly from `allocation_pool.type` — the enum mirrors the DB `CHECK` constraint (see migration 2026-05-09-inbound-plan.sql), so any value here is also a valid type stored in the database. `inbound` numbers are reply-only — outbound to a recipient (a contact for 1:1 chats, the group for group chats) requires that recipient to have messaged the number first (otherwise the send returns `403 inbound_only_no_prior_inbound`). `null` indicates the underlying allocation predates the type column or is unattributed; clients should treat `null` the same as `dedicated` for routing decisions."}}}}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"}}}},"/me/numbers/{number}/contact-card":{"get":{"tags":["Contact Card"],"summary":"Get contact card (Coming Soon)","description":"⚠️ **COMING SOON** - This endpoint is temporarily disabled while we stabilize this feature.\n\nGet the personal contact card (Name & Photo) for the specified phone number. This is the identity that gets shared with contacts in iMessage.","operationId":"getMyContactCard","parameters":[{"name":"number","in":"path","required":true,"description":"E.164 phone number (URL-encoded, e.g., %2B15551234567)","schema":{"type":"string"}}],"responses":{"200":{"description":"Contact card data","content":{"application/json":{"schema":{"type":"object","properties":{"phone_number":{"type":"string"},"first_name":{"type":"string","nullable":true},"last_name":{"type":"string","nullable":true},"name":{"type":"string","nullable":true,"description":"Display name"},"avatar":{"type":"string","nullable":true,"description":"Base64-encoded JPEG/PNG image"},"has_wallpaper":{"type":"boolean"},"sharing":{"type":"object","properties":{"enabled":{"type":"boolean","description":"Whether Name & Photo sharing is enabled"},"audience":{"type":"integer","description":"0 = Contacts Only, 1 = Always Ask"},"name_format":{"type":"integer","description":"0 = First & Last, 1 = First Only"}}}}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"description":"Phone number not accessible with this API key"},"404":{"$ref":"#/components/responses/NotFound"}}},"put":{"tags":["Contact Card"],"summary":"Update contact card","description":"Update the personal contact card (Name & Photo) for the specified phone number. All fields are optional — only provided fields are updated.\n\n⚠️ **Plan requirement:** Setting the `first_name`, `last_name`, or `avatar` is only available on **Dedicated Commercial** and **Dedicated Enterprise** plans. Numbers on other plans receive a `403`.","operationId":"updateMyContactCard","parameters":[{"name":"number","in":"path","required":true,"description":"E.164 phone number (URL-encoded, e.g., %2B15551234567)","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"first_name":{"type":"string","description":"First name"},"last_name":{"type":"string","description":"Last name"},"avatar":{"type":"string","description":"Profile photo as base64-encoded JPEG/PNG"},"sharing":{"type":"object","properties":{"enabled":{"type":"boolean","description":"Enable/disable Name & Photo sharing"},"audience":{"type":"integer","description":"0 = Contacts Only, 1 = Always Ask"},"name_format":{"type":"integer","description":"0 = First & Last, 1 = First Only"}}}}}}}},"responses":{"200":{"description":"Contact card updated","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","example":true},"phone_number":{"type":"string"},"first_name":{"type":"string","nullable":true},"last_name":{"type":"string","nullable":true}}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"description":"Phone number not accessible with this API key"},"404":{"$ref":"#/components/responses/NotFound"},"502":{"description":"Temporary communication error"}}}},"/me/numbers/{number}/call-forwarding":{"post":{"tags":["Numbers"],"summary":"Request call forwarding","description":"Open a request to forward calls from one of your numbers to another phone number.\n\nThis does **not** instantly reconfigure forwarding — it opens a support request that the Blooio team fulfils, and the change typically takes effect within one business day. The `{number}` path parameter is the source number to forward, and `forward_to` is the destination.\n\nOnly **dedicated** or **inbound** numbers owned by your organization can be forwarded; shared numbers cannot, because the underlying line is shared across organizations. Both numbers must be valid US numbers.","operationId":"requestCallForwarding","parameters":[{"name":"number","in":"path","required":true,"description":"Source E.164 phone number to forward (URL-encoded, e.g., %2B15551234567). Must be a dedicated or inbound number owned by your organization.","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["forward_to"],"properties":{"forward_to":{"type":"string","description":"Destination US phone number that calls should be forwarded to. E.164 format recommended (e.g., +15559876543).","example":"+15559876543"}}}}}},"responses":{"201":{"description":"Call forwarding request created","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","example":true},"ticket_id":{"type":"string","description":"Identifier of the support ticket tracking this request","example":"tkt_abc123"},"status":{"type":"string","description":"Ticket status","example":"open"},"number":{"type":"string","description":"Source number (E.164)","example":"+15551234567"},"forward_to":{"type":"string","description":"Destination number (E.164)","example":"+15559876543"}}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"description":"Ticket creation is disabled for your organization"}}}},"/contacts":{"get":{"tags":["Contacts"],"summary":"List contacts","description":"List all contacts for the organization with optional search and pagination.","operationId":"listContacts","parameters":[{"$ref":"#/components/parameters/LimitParam"},{"$ref":"#/components/parameters/OffsetParam"},{"name":"q","in":"query","description":"Search query (matches identifier or name)","schema":{"type":"string"}},{"name":"sort","in":"query","description":"Sort order","schema":{"type":"string","enum":["recent","oldest","name_asc","name_desc"],"default":"recent"}}],"responses":{"200":{"description":"List of contacts","content":{"application/json":{"schema":{"type":"object","properties":{"contacts":{"type":"array","items":{"$ref":"#/components/schemas/Contact"}},"pagination":{"$ref":"#/components/schemas/Pagination"}}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"}}},"post":{"tags":["Contacts"],"summary":"Create a contact","description":"Create a new contact with a phone number (E.164 format) or email address.","operationId":"createContact","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["identifier"],"properties":{"identifier":{"type":"string","description":"Phone number (E.164 format, e.g., +15551234567) or email address","example":"+15551234567"},"name":{"type":"string","description":"Display name for the contact","example":"John Doe"}}}}}},"responses":{"201":{"description":"Contact created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Contact"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"409":{"description":"Contact already exists","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/contacts/{contactId}":{"get":{"tags":["Contacts"],"summary":"Get a contact","description":"Get details for a specific contact by phone number or email.","operationId":"getContact","parameters":[{"$ref":"#/components/parameters/ContactIdParam"}],"responses":{"200":{"description":"Contact details","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Contact"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"}}},"patch":{"tags":["Contacts"],"summary":"Update a contact","description":"Update a contact's name.","operationId":"updateContact","parameters":[{"$ref":"#/components/parameters/ContactIdParam"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","nullable":true,"description":"New display name (null to clear)","example":"Jane Doe"}}}}}},"responses":{"200":{"description":"Contact updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Contact"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"}}},"delete":{"tags":["Contacts"],"summary":"Delete a contact","description":"Soft-delete a contact.","operationId":"deleteContact","parameters":[{"$ref":"#/components/parameters/ContactIdParam"}],"responses":{"200":{"description":"Contact deleted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeleteResponse"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"}}}},"/contacts/{contactId}/capabilities":{"get":{"tags":["Contacts"],"summary":"Check contact capabilities","description":"Check if a contact supports iMessage and/or SMS.","operationId":"getContactCapabilities","parameters":[{"$ref":"#/components/parameters/ContactIdParam"}],"responses":{"200":{"description":"Contact capabilities","content":{"application/json":{"schema":{"type":"object","properties":{"contact":{"type":"string","description":"Normalized contact identifier"},"type":{"type":"string","enum":["phone","email"]},"capabilities":{"type":"object","properties":{"imessage":{"type":"boolean","description":"Whether iMessage is available"},"sms":{"type":"boolean","description":"Whether SMS is available (phone only)"},"facetime":{"type":"boolean","description":"Whether FaceTime is available"}}},"last_checked":{"type":"integer","format":"int64","description":"Timestamp when capabilities were checked"}}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"},"503":{"description":"No active number available to check capabilities","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/contacts/{contactId}/tags":{"get":{"tags":["Contacts"],"summary":"List contact tags","description":"List all tags assigned to a contact.","operationId":"listContactTags","parameters":[{"$ref":"#/components/parameters/ContactIdParam"}],"responses":{"200":{"description":"List of tags","content":{"application/json":{"schema":{"type":"object","properties":{"tags":{"type":"array","items":{"type":"object","properties":{"tag":{"type":"string","description":"The tag value","example":"vip"},"created_at":{"type":"integer","format":"int64","description":"Timestamp when the tag was added (ms since epoch)"}}}}}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"}}},"post":{"tags":["Contacts"],"summary":"Add tags to a contact","description":"Add one or more tags to a contact. If a tag already exists on the contact, it is re-activated (idempotent). Tags are free-form strings.","operationId":"addContactTags","parameters":[{"$ref":"#/components/parameters/ContactIdParam"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["tags"],"properties":{"tags":{"type":"array","items":{"type":"string"},"description":"Tags to add","example":["vip","priority"]}}}}}},"responses":{"201":{"description":"Tags added","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","example":true},"tags_added":{"type":"array","items":{"type":"string"},"description":"Tags that were added","example":["vip","priority"]}}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"}}}},"/contacts/{contactId}/tags/{tag}":{"delete":{"tags":["Contacts"],"summary":"Remove a tag from a contact","description":"Remove a specific tag from a contact. The tag is soft-deleted and can be re-added later.","operationId":"removeContactTag","parameters":[{"$ref":"#/components/parameters/ContactIdParam"},{"name":"tag","in":"path","required":true,"description":"The tag to remove (URL-encode if it contains special characters)","schema":{"type":"string"},"example":"vip"}],"responses":{"200":{"description":"Tag removed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeleteResponse"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"}}}},"/location/contacts":{"get":{"tags":["Location"],"summary":"List contact locations","description":"Returns cached FindMy contact locations available through your blooio account. Each entry includes the contact's handle (phone/email), coordinates, and last update time.","operationId":"listLocationContacts","responses":{"200":{"description":"List of contact locations","content":{"application/json":{"schema":{"type":"object","properties":{"friends":{"type":"array","items":{"$ref":"#/components/schemas/ContactLocation"}}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"description":"No active number is available for this API key"}}}},"/location/contacts/{handle}":{"get":{"tags":["Location"],"summary":"Get contact location","description":"Returns the cached location for a specific contact identified by phone number or email.","operationId":"getLocationContact","parameters":[{"name":"handle","in":"path","required":true,"schema":{"type":"string"},"description":"Contact's phone number (E.164) or email address"}],"responses":{"200":{"description":"Contact location data","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContactLocation"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"description":"No location found for this contact"}}}},"/location/contacts/refresh":{"post":{"tags":["Location"],"summary":"Refresh contact locations","description":"Triggers a refresh of cached FindMy contact locations. Updated results may take 15-20 seconds to appear.","operationId":"refreshLocationContacts","responses":{"200":{"description":"Refresh triggered, returns updated locations","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"friends":{"type":"array","items":{"$ref":"#/components/schemas/ContactLocation"}}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"}}}},"/facetime/calls":{"post":{"tags":["FaceTime"],"summary":"Initiate a FaceTime call (Coming Soon)","description":"**Coming Soon** -- This endpoint is temporarily disabled while we stabilize the FaceTime call flow.\n\nInitiates a FaceTime call to the specified phone number or email address. Returns a shareable FaceTime link that anyone can use to join the call. The call will ring the contact and auto-admit the first person who joins via the link.","operationId":"callFaceTime","x-blooio-status":"planned","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["handle"],"properties":{"handle":{"type":"string","description":"Phone number (E.164) or email address to call","example":"+15551234567"}}}}}},"responses":{"501":{"$ref":"#/components/responses/NotImplemented"}}}},"/groups":{"get":{"tags":["Groups"],"summary":"List groups","description":"List all groups for the organization with optional search and pagination.","operationId":"listGroups","parameters":[{"$ref":"#/components/parameters/LimitParam"},{"$ref":"#/components/parameters/OffsetParam"},{"name":"q","in":"query","description":"Search query (matches group name)","schema":{"type":"string"}},{"name":"sort","in":"query","description":"Sort order","schema":{"type":"string","enum":["recent","oldest","name_asc","name_desc"],"default":"recent"}}],"responses":{"200":{"description":"List of groups","content":{"application/json":{"schema":{"type":"object","properties":{"groups":{"type":"array","items":{"$ref":"#/components/schemas/Group"}},"pagination":{"$ref":"#/components/schemas/Pagination"}}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"}}},"post":{"tags":["Groups"],"summary":"Create a group","description":"Create a new group. No iMessage conversation exists yet: the first message you send to the group opens it.","operationId":"createGroup","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["name"],"properties":{"name":{"type":"string","description":"Group name (max 255 characters)","example":"Sales Team"},"members":{"type":"array","items":{"type":"string"},"description":"Phone numbers or emails of contacts in the group.","example":["+15551234567","+15559876543"]}}}}}},"responses":{"201":{"description":"Group created","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/Group"},{"type":"object","properties":{"added_members":{"type":"array","items":{"type":"string"},"description":"List of member identifiers that were added to the group"},"created_contacts":{"type":"array","items":{"type":"string"},"description":"List of contacts that were auto-created"}}}]}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"409":{"description":"Conflict. A group with the same participants already exists in another organization that shares this number.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/groups/{groupId}":{"get":{"tags":["Groups"],"summary":"Get a group","description":"Get details for a specific group.","operationId":"getGroup","parameters":[{"$ref":"#/components/parameters/GroupIdParam"}],"responses":{"200":{"description":"Group details","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Group"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"}}},"patch":{"tags":["Groups"],"summary":"Update a group","description":"Update a group's name. If the group already has an iMessage conversation, the conversation is renamed too.","operationId":"updateGroup","parameters":[{"$ref":"#/components/parameters/GroupIdParam"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","description":"New group name","example":"Marketing Team"}}}}}},"responses":{"200":{"description":"Group updated successfully.","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/Group"},{"type":"object","properties":{"device_sync":{"$ref":"#/components/schemas/DeviceSyncResult"}}}]}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"}}},"delete":{"tags":["Groups"],"summary":"Delete a group","description":"Soft-delete a group. Members are automatically removed. If the group is linked to an existing iMessage chat, the number also leaves that chat.","operationId":"deleteGroup","parameters":[{"$ref":"#/components/parameters/GroupIdParam"}],"responses":{"200":{"description":"Group deleted","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"deleted_at":{"type":"integer","format":"int64"}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"},"502":{"description":"Failed to leave linked iMessage chat","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"No active number available to leave group chat","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/groups/{groupId}/members":{"get":{"tags":["Group Members"],"summary":"List group members","description":"List all members of a group.","operationId":"listGroupMembers","parameters":[{"$ref":"#/components/parameters/GroupIdParam"},{"$ref":"#/components/parameters/LimitParam"},{"$ref":"#/components/parameters/OffsetParam"}],"responses":{"200":{"description":"List of group members","content":{"application/json":{"schema":{"type":"object","properties":{"group_id":{"type":"string","description":"The group ID"},"group_name":{"type":"string","nullable":true,"description":"The group name"},"icon_url":{"type":"string","nullable":true,"description":"URL of the group icon/photo"},"members":{"type":"array","items":{"$ref":"#/components/schemas/GroupMember"}},"pagination":{"$ref":"#/components/schemas/Pagination"}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"}}},"post":{"tags":["Group Members"],"summary":"Add a member to a group (Coming Soon)","description":"⚠️ **COMING SOON** - This endpoint is temporarily disabled while we stabilize this feature.\n\nAdd an existing contact to a group. If the group is linked to an existing iMessage chat, also adds the participant to that chat.","operationId":"addGroupMember","x-blooio-status":"planned","parameters":[{"$ref":"#/components/parameters/GroupIdParam"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["contact_id"],"properties":{"contact_id":{"type":"string","description":"Contact identifier (phone number or email)","example":"+15551234567"}}}}}},"responses":{"501":{"$ref":"#/components/responses/NotImplemented"}}}},"/groups/{groupId}/members/{contactId}":{"delete":{"tags":["Group Members"],"summary":"Remove a member from a group (Coming Soon)","description":"⚠️ **COMING SOON** - This endpoint is temporarily disabled while we stabilize this feature.\n\nRemove a contact from a group. If the group is linked to an existing iMessage chat, also removes the participant from that chat. If the contact being removed is the organization's own phone number, leaves the group chat instead.","operationId":"removeGroupMember","x-blooio-status":"planned","parameters":[{"$ref":"#/components/parameters/GroupIdParam"},{"$ref":"#/components/parameters/ContactIdParam"}],"responses":{"501":{"$ref":"#/components/responses/NotImplemented"}}}},"/groups/{groupId}/icon":{"post":{"tags":["Groups"],"summary":"Set group icon","description":"Set the group icon/photo. Requires the group to have an iMessage conversation, so send it a message first. Uses multipart/form-data.\n\nThe uploaded image is stored in Blooio storage and synced to the group's iMessage conversation before the request returns.","operationId":"setGroupIcon","parameters":[{"$ref":"#/components/parameters/GroupIdParam"}],"requestBody":{"required":true,"content":{"multipart/form-data":{"schema":{"type":"object","required":["icon"],"properties":{"icon":{"type":"string","format":"binary","description":"The icon image file to set as the group photo"}}}}}},"responses":{"200":{"description":"Group icon set successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GroupIconResponse"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"},"502":{"description":"Failed to update the linked iMessage chat","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"No active number available","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"tags":["Groups"],"summary":"Remove group icon","description":"Remove the group icon/photo. Requires the group to have an iMessage conversation.\n\nThe icon is removed from both Blooio storage and the group's iMessage conversation before the request returns.","operationId":"removeGroupIcon","parameters":[{"$ref":"#/components/parameters/GroupIdParam"}],"responses":{"200":{"description":"Group icon removed successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GroupIconResponse"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"},"502":{"description":"Failed to update the linked iMessage chat","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"No active number available","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/webhooks":{"get":{"tags":["Webhooks"],"summary":"List webhooks","description":"List all webhooks for the organization.","operationId":"listWebhooks","responses":{"200":{"description":"List of webhooks","content":{"application/json":{"schema":{"type":"object","properties":{"webhooks":{"type":"array","items":{"$ref":"#/components/schemas/Webhook"}}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"}}},"post":{"tags":["Webhooks"],"summary":"Create a webhook (closed)","description":"Registration through this endpoint is closed and returns 410. Use POST /v4/webhooks to create new subscriptions. Existing webhooks keep working and can still be listed, updated, and deleted here. Re-posting the URL of a webhook that already exists still returns 200 with that webhook, so idempotent provisioning scripts continue to work unchanged.","operationId":"createWebhook","deprecated":true,"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["webhook_url"],"properties":{"webhook_url":{"type":"string","format":"uri","description":"URL of an existing webhook, for the idempotent 200 response. A URL that does not already exist returns 410.","example":"https://example.com/webhook"},"valid_until":{"type":"integer","format":"int64","description":"Ignored. Retained so existing request bodies stay valid.","default":-1}}}}}},"responses":{"200":{"description":"Webhook already exists (idempotent)","content":{"application/json":{"schema":{"type":"object","properties":{"webhook_id":{"type":"string"},"webhook_url":{"type":"string"},"scope":{"type":"string","enum":["api_key","organization"]},"message":{"type":"string"}}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"409":{"description":"Webhook limit reached (max 64 per organization)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"410":{"description":"Registration through this endpoint is closed. Use POST /v4/webhooks.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"}}}}}}}}},"/webhooks/{webhookId}":{"get":{"tags":["Webhooks"],"summary":"Get a webhook","description":"Get details for a specific webhook.","operationId":"getWebhook","parameters":[{"$ref":"#/components/parameters/WebhookIdParam"}],"responses":{"200":{"description":"Webhook details","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Webhook"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"}}},"patch":{"tags":["Webhooks"],"summary":"Update a webhook","description":"Update a webhook's configuration.","operationId":"updateWebhook","parameters":[{"$ref":"#/components/parameters/WebhookIdParam"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"webhook_type":{"type":"string","enum":["message","status","all"],"description":"Type of events to receive"},"valid_until":{"type":"integer","format":"int64","description":"Expiration timestamp. Use -1 or null for no expiration."},"deprecate":{"type":"boolean","description":"Set to true to deprecate, false to undeprecate"}}}}}},"responses":{"200":{"description":"Webhook updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Webhook"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"}}},"delete":{"tags":["Webhooks"],"summary":"Delete a webhook","description":"Permanently delete a webhook.","operationId":"deleteWebhook","parameters":[{"$ref":"#/components/parameters/WebhookIdParam"}],"responses":{"200":{"description":"Webhook deleted","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"message":{"type":"string","example":"Webhook deleted"}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"}}}},"/webhooks/{webhookId}/secret/rotate":{"post":{"tags":["Webhooks"],"summary":"Rotate webhook signing secret","description":"Generate a new signing secret for the webhook. The new secret is returned only once in this response - store it securely. The old secret becomes invalid immediately.","operationId":"rotateWebhookSecret","parameters":[{"$ref":"#/components/parameters/WebhookIdParam"}],"responses":{"200":{"description":"Secret rotated successfully. The new secret is shown only once.","content":{"application/json":{"schema":{"type":"object","properties":{"webhook_id":{"type":"string"},"signing_secret":{"type":"string","description":"The new signing secret. Store this securely - it will not be shown again."},"rotated_at":{"type":"integer","format":"int64","description":"Timestamp when the secret was rotated"},"rotated_by":{"type":"string","description":"Identifier of who rotated the secret"},"rotation_count":{"type":"integer","description":"Total number of times this secret has been rotated"}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"}}}},"/webhooks/{webhookId}/logs":{"get":{"tags":["Webhook Logs"],"summary":"List webhook logs","description":"List delivery logs for a specific webhook.","operationId":"listWebhookLogs","parameters":[{"$ref":"#/components/parameters/WebhookIdParam"},{"$ref":"#/components/parameters/LimitParam"},{"$ref":"#/components/parameters/OffsetParam"},{"name":"sort","in":"query","description":"Sort order by attempted time","schema":{"type":"string","enum":["asc","desc"],"default":"desc"}},{"name":"status","in":"query","description":"Filter by exact HTTP status code","schema":{"type":"integer"}},{"name":"min_status","in":"query","description":"Minimum HTTP status code","schema":{"type":"integer"}},{"name":"max_status","in":"query","description":"Maximum HTTP status code","schema":{"type":"integer"}}],"responses":{"200":{"description":"List of webhook logs","content":{"application/json":{"schema":{"type":"object","properties":{"logs":{"type":"array","items":{"$ref":"#/components/schemas/WebhookLog"}},"pagination":{"type":"object","properties":{"total":{"type":"integer","description":"Total number of matching logs"},"limit":{"type":"integer"},"offset":{"type":"integer"},"returned":{"type":"integer","description":"Number of logs returned in this response"},"has_more":{"type":"boolean","description":"Whether there are more logs to fetch"}}}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"}}}},"/webhooks/{webhookId}/logs/{eventId}/replay":{"post":{"tags":["Webhook Logs"],"summary":"Replay a webhook event","description":"Re-send a webhook event to the configured URL.","operationId":"replayWebhookEvent","parameters":[{"$ref":"#/components/parameters/WebhookIdParam"},{"name":"eventId","in":"path","required":true,"description":"Event ID to replay","schema":{"type":"string"}}],"responses":{"200":{"description":"Event replayed","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","description":"Whether the replay received a 2xx response"},"replay_event_id":{"type":"string","description":"New event ID for this replay attempt"},"original_event_id":{"type":"string","description":"The original event ID that was replayed"},"webhook_id":{"type":"string"},"webhook_url":{"type":"string"},"response_status":{"type":"integer","description":"HTTP status code from replay attempt"},"duration_ms":{"type":"integer","description":"Time taken for the replay request in milliseconds"},"response_data":{"type":"object","description":"Response details from the replay attempt","properties":{"body":{"description":"Response body (if parseable)"},"headers":{"type":"object"},"size":{"type":"integer"},"contentType":{"type":"string"},"duration":{"type":"integer"},"error":{"type":"string","nullable":true},"errorType":{"type":"string","nullable":true}}}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"}}}},"/chats":{"get":{"tags":["Chats"],"summary":"List chats","description":"List all unique conversations for the organization, sorted by most recent message.","operationId":"listChats","parameters":[{"$ref":"#/components/parameters/LimitParam"},{"$ref":"#/components/parameters/OffsetParam"},{"name":"q","in":"query","description":"Search query (matches phone/email or contact name)","schema":{"type":"string"}},{"name":"sort","in":"query","description":"Sort order","schema":{"type":"string","enum":["recent","oldest"],"default":"recent"}}],"responses":{"200":{"description":"List of chats","content":{"application/json":{"schema":{"type":"object","properties":{"chats":{"type":"array","items":{"$ref":"#/components/schemas/Chat"}},"pagination":{"$ref":"#/components/schemas/Pagination"}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"}}}},"/chats/{chatId}":{"get":{"tags":["Chats"],"summary":"Get a chat","description":"Get details for a specific conversation.","operationId":"getChat","parameters":[{"$ref":"#/components/parameters/ChatIdParam"}],"responses":{"200":{"description":"Chat details","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChatDetail"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/ChatNotFound"}}}},"/chats/{chatId}/messages":{"get":{"tags":["Messages"],"summary":"List messages in a chat","description":"List all messages in a conversation with optional filtering.\n\nA conversation must already exist: this returns `404` for an address the organization has never exchanged a message with, rather than an empty list. Use `GET /chats` to enumerate the conversations that do exist.","operationId":"listChatMessages","parameters":[{"$ref":"#/components/parameters/ChatIdParam"},{"$ref":"#/components/parameters/LimitParam"},{"$ref":"#/components/parameters/OffsetParam"},{"name":"sort","in":"query","description":"Sort order by time","schema":{"type":"string","enum":["asc","desc"],"default":"desc"}},{"name":"direction","in":"query","description":"Filter by message direction","schema":{"type":"string","enum":["inbound","outbound"]}},{"name":"since","in":"query","description":"Only messages sent after this timestamp (ms)","schema":{"type":"integer","format":"int64"}},{"name":"until","in":"query","description":"Only messages sent before this timestamp (ms)","schema":{"type":"integer","format":"int64"}}],"responses":{"200":{"description":"List of messages","content":{"application/json":{"schema":{"type":"object","properties":{"chat_id":{"type":"string"},"messages":{"type":"array","items":{"$ref":"#/components/schemas/Message"}},"pagination":{"$ref":"#/components/schemas/Pagination"}}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/ChatNotFound"}}},"post":{"tags":["Messages"],"summary":"Send a message","description":"Send a message to a chat. The chatId can be: (1) E.164 phone number, (2) email address, (3) group ID (grp_xxxx), or (4) comma-separated list of phone/email for multi-recipient chats. For multi-recipient, an unnamed group is automatically created or reused if the exact participant combination already exists. For explicit groups, the group must be linked to an existing iMessage chat.\n\n**iMessage send-with-effect:** set the optional `effect` field to attach an Apple expressive send (slam, loud, gentle, invisible-ink) or screen effect (echo, spotlight, balloons, confetti, love, lasers, fireworks, celebration). Effects are an iMessage-only feature — when the recipient is on SMS/RCS the message is delivered without the animation. Effects are not supported in multipart (`parts`) mode.\n\n**Threaded replies (iMessage inline reply):** set the optional `reply_to` field to send the outgoing message as a reply to a specific earlier message. Two shapes are accepted: `{ \"message_id\": \"msg_…\" }` references a Blooio-minted message in the same chat (most common — the message_id returned by an earlier send or surfaced on a `message.received` webhook), or `{ \"guid\": \"…\", \"part_index\": 0 }` references the raw iMessage GUID for the rare case where the parent wasn't recorded by Blooio. The reply must target the same chat and the same from-number as the new send, and the parent must be no older than 30 days (the iMessage on-device retention horizon). Reply support is iMessage-only and is rejected on Twilio and dashboard-Twilio send paths; it's also rejected on multi-message fan-outs (`text` array or per-part URL-balloon batch). See the `400` responses for the full set of `reply_target_*` error codes.","operationId":"sendMessage","parameters":[{"$ref":"#/components/parameters/ChatIdParam"},{"name":"Idempotency-Key","in":"header","description":"Unique key to prevent duplicate message sends. If the same key is used again, the original message_id and status are returned.","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SendMessageRequest"}}}},"responses":{"200":{"description":"Duplicate request (idempotency key matched)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SendMessageResponse"}}}},"202":{"description":"Message accepted for sending","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SendMessageResponse"}}}},"400":{"description":"Bad request. Threaded-reply failures use the response body's `code` field:\n- `reply_target_invalid` — `reply_to` was supplied but missing both `message_id` and `guid`, or the resolved parent has no provider GUID.\n- `reply_target_chat_mismatch` — the parent message lives in a different chat than the new send.\n- `reply_target_device_mismatch` — the parent was sent or received on a different line (allocation). Switch the from-number to match.\n- `reply_target_expired` — the parent is older than the 30-day iMessage on-device retention window and may have been purged from the device.\n- `reply_target_not_supported` — `reply_to` was used on a path that doesn't support inline replies (Twilio or multi-message fan-out).\n- Other validation failures (missing content, invalid recipient, etc.) — no `code` field.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"ApiError","message":"You can only reply to messages from the last 30 days","status":400,"code":"reply_target_expired"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"description":"Forbidden. The response body's `code` field disambiguates the specific failure:\n- `inbound_only_no_prior_inbound` — the sender is on the Inbound plan and the recipient has never messaged this number first. Inbound numbers are reply-only. Body also includes `allocation_id` and `external_id`.\n- `conversation_content_restricted` — messaging safety: links, media, and attachments are not allowed before the recipient's first written reply (or in a re-engagement of an inactive conversation). An emoji reaction does not unlock them. Send plain text first.\n- `safety_new_conversations_paused` — messaging safety: brand-new conversations from this number are temporarily paused; replies to existing conversations are unaffected.\n- `safety_reply_only` — messaging safety: outbound from this number is restricted to conversations with prior inbound.\n- `safety_account_review` — messaging safety: the number is blocked pending account review.\n- Emergency number\n- Integration-assigned number that can't be sent from manually\n\nNumber-level safety actions (`safety_*`) clear automatically as the underlying sending pattern ages out.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"ApiError","message":"Inbound-only plan: outbound is restricted to contacts who messaged this number first.","status":403,"code":"inbound_only_no_prior_inbound","allocation_id":"alloc_...","external_id":"+15555550199"}}}},"404":{"description":"Not found. Threaded-reply failures use the response body's `code` field:\n- `reply_target_not_found` — `reply_to.message_id` did not match any message in this organization.\n- Other 404s (e.g., chat not found) have no `code`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"ApiError","message":"Reply target message not found","status":404,"code":"reply_target_not_found"}}}},"429":{"description":"Too many requests. Possible `code`s on this endpoint:\n- `outbound_limit_reached` — org-level new-contact cap (configured in Settings) tripped. Body includes `limit`, `current`, `mode`, and on per-number mode `allocation_id` + `sender_number`.\n- `new_conversation_limit_reached` — shared plan's daily new-conversation cap reached. Body includes `plan_id`, `cap`, `current`. Existing conversations continue to send.\n- `conversation_awaiting_reply` — messaging safety: up to 3 messages may be sent to a new recipient before they respond. Body includes `pre_reply_outbound_count` and `limit`.\n- `conversation_streak_limit` — messaging safety: consecutive-message cap since the recipient's last response was reached. Body includes `current_streak` and `limit`.\n- `conversation_inactive_paused` — messaging safety: no response in 14+ days and the single re-engagement message was already sent. Body includes `retry_after` (seconds), also sent as the `Retry-After` header: retry after the recipient replies. It is a polling interval, not a timer — the pause does not lift on its own.\n\nConversation-state limits lift as soon as the recipient responds, and an emoji reaction counts: a tapback clears the consecutive-message counter and keeps a thread from going inactive. Only writing back raises the cap and unlocks links, media, and attachments.","headers":{"Retry-After":{"description":"Sent with `conversation_inactive_paused`: seconds to wait before checking again. The pause lifts when the recipient replies, not when this elapses.","schema":{"type":"integer"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"No active number available","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/chats/{chatId}/messages/{messageId}":{"get":{"tags":["Messages"],"summary":"Get a message","description":"Get details for a specific message.","operationId":"getMessage","parameters":[{"$ref":"#/components/parameters/ChatIdParam"},{"$ref":"#/components/parameters/MessageIdParam"}],"responses":{"200":{"description":"Message details","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessageDetail"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"}}}},"/chats/{chatId}/messages/{messageId}/status":{"get":{"tags":["Messages"],"summary":"Get message status","description":"Get delivery status for a specific message.","operationId":"getMessageStatus","parameters":[{"$ref":"#/components/parameters/ChatIdParam"},{"$ref":"#/components/parameters/MessageIdParam"}],"responses":{"200":{"description":"Message status","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessageStatus"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"}}}},"/chats/{chatId}/messages/{messageId}/reactions":{"post":{"tags":["Reactions"],"summary":"Add or remove a reaction","description":"Add or remove a reaction to a message. Supports classic iMessage tapbacks (love, like, dislike, laugh, emphasize, question) and emoji reactions (e.g. +😂, -😂).\n\nThe messageId can be an explicit message ID (e.g., msg_xxx) or a relative index (-1 for last message, -2 for second-to-last, etc.). When using relative indices, you can optionally filter by message direction (inbound/outbound only).","operationId":"addReaction","parameters":[{"$ref":"#/components/parameters/ChatIdParam"},{"name":"messageId","in":"path","required":true,"description":"Message ID (e.g., msg_xxx) or relative index (-1, -2, etc.)","schema":{"type":"string"},"examples":{"explicit":{"value":"msg_abc123def456","summary":"Explicit message ID"},"lastMessage":{"value":"-1","summary":"Last message in chat"},"secondToLast":{"value":"-2","summary":"Second-to-last message"}}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReactionRequest"}}}},"responses":{"200":{"description":"Reaction added or removed successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReactionResponse"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"},"502":{"description":"Temporary communication error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Device not available","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/chats/{chatId}/polls":{"post":{"tags":["Polls"],"summary":"Send a poll","description":"Send a native iMessage poll to a chat. The poll appears as an interactive ballot that recipients can vote on.","operationId":"sendPoll","parameters":[{"$ref":"#/components/parameters/ChatIdParam"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["options"],"properties":{"title":{"type":"string","description":"Poll question or title (optional)"},"options":{"type":"array","description":"Array of 2-10 option strings for the poll","items":{"type":"string"},"minItems":2,"maxItems":10}}}}}},"responses":{"200":{"description":"Poll sent successfully","content":{"application/json":{"schema":{"type":"object","properties":{"poll_id":{"type":"string","description":"Unique identifier for the poll"},"chat_id":{"type":"string"},"poll":{"type":"object","properties":{"title":{"type":"string"},"options":{"type":"array","items":{"type":"string"}}}},"sent_at":{"type":"number"}}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"502":{"description":"Device unreachable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"No active device available","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/chats/{chatId}/polls/{pollId}":{"get":{"tags":["Polls"],"summary":"Get poll results","description":"Retrieve a poll's definition and aggregated vote counts. The pollId is the poll_id returned in the poll.received or poll.created webhook event.","operationId":"getPollResults","parameters":[{"$ref":"#/components/parameters/ChatIdParam"},{"name":"pollId","in":"path","required":true,"description":"The poll ID","schema":{"type":"string"}}],"responses":{"200":{"description":"Poll results","content":{"application/json":{"schema":{"type":"object","properties":{"poll_id":{"type":"string"},"chat_id":{"type":"string"},"title":{"type":"string"},"options":{"type":"array","items":{"type":"object","properties":{"text":{"type":"string"},"votes":{"type":"integer"}}}},"total_votes":{"type":"integer"}}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"}}}},"/chats/{chatId}/typing":{"post":{"tags":["Typing Indicators"],"summary":"Start typing indicator","description":"Start the typing indicator for a chat. The indicator shows the recipient that you are typing. Works for both 1:1 chats (pass a phone number or email as `chatId`) and group chats (pass the group ID, e.g. `grp_...`); in a group every participant sees the indicator.\n\n**RCS limitation:** typing indicators are only delivered for iMessage chats — the RCS protocol does not carry composing state. Calls against RCS-routed chats return 200 with a `warning` field and have no visible effect on the recipient.","operationId":"startTyping","parameters":[{"$ref":"#/components/parameters/ChatIdParam"}],"responses":{"200":{"description":"Typing indicator started","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TypingResponse"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"502":{"description":"Temporary communication error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"No active number available","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"tags":["Typing Indicators"],"summary":"Stop typing indicator","description":"Stop the typing indicator for a chat. Works for both 1:1 chats (pass a phone number or email as `chatId`) and group chats (pass the group ID, e.g. `grp_...`).\n\n**RCS limitation:** typing indicators are only delivered for iMessage chats — the RCS protocol does not carry composing state. Calls against RCS-routed chats return 200 with a `warning` field and have no visible effect on the recipient.","operationId":"stopTyping","parameters":[{"$ref":"#/components/parameters/ChatIdParam"}],"responses":{"200":{"description":"Typing indicator stopped","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TypingResponse"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"502":{"description":"Temporary communication error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"No active number available","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/chats/{chatId}/read":{"post":{"tags":["Read Receipts"],"summary":"Mark chat as read","description":"Mark all messages in a chat as read. This sends a read receipt to the sender.","operationId":"markChatRead","parameters":[{"$ref":"#/components/parameters/ChatIdParam"}],"responses":{"200":{"description":"Chat marked as read","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReadResponse"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"},"502":{"description":"Temporary communication error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/chats/{chatId}/contact-card":{"post":{"tags":["Contact Card"],"summary":"Share contact card","description":"Stage the contact card (Name & Photo) for sharing in a chat. The contact card will be piggybacked onto the next outgoing message (text or attachment) sent to this chat. This is idempotent — calling it multiple times is harmless.\n\n⚠️ **Plan requirement:** Contact card sharing is only available on **Dedicated Commercial** and **Dedicated Enterprise** plans. Numbers on other plans receive a `403`.","operationId":"shareContactCard","parameters":[{"$ref":"#/components/parameters/ChatIdParam"}],"responses":{"200":{"description":"Contact card staged for sharing","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","example":true},"chat_id":{"type":"string","description":"Normalized chat identifier"},"message":{"type":"string","example":"Contact card staged. It will be sent with the next outgoing message in this chat."}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"502":{"description":"Temporary communication error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"No active number available","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/chats/{chatId}/background":{"get":{"tags":["Chats"],"summary":"Get chat background","description":"Get the current background image metadata for a conversation. Works for both 1-on-1 and group chats.","operationId":"getChatBackground","parameters":[{"$ref":"#/components/parameters/ChatIdParam"}],"responses":{"200":{"description":"Chat background details","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChatBackgroundResponse"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"502":{"description":"Temporary communication error with device","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"No active number available","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"put":{"tags":["Chats"],"summary":"Set chat background","description":"Set or update the background image for a conversation. Works for both 1-on-1 and group chats.\n\nThe request body must be `multipart/form-data` with a single `background` field containing the **raw image file bytes** (not a URL or base64 string). Supported formats: JPEG, PNG, GIF, WebP, HEIC/HEIF. Maximum file size: 10 MB.\n\n**Example with curl** — note the `@` prefix that tells curl to read the file from disk:\n\n```bash\ncurl -X PUT \"https://api.blooio.com/v2/api/chats/%2B15551234567/background\" \\\n  -H \"Authorization: Bearer YOUR_API_KEY\" \\\n  -F \"background=@/path/to/image.jpg;type=image/jpeg\"\n```\n\nWhen the chat id is a phone number, percent-encode the leading `+` as `%2B` in the URL path.","operationId":"setChatBackground","parameters":[{"$ref":"#/components/parameters/ChatIdParam"}],"requestBody":{"required":true,"content":{"multipart/form-data":{"schema":{"type":"object","required":["background"],"properties":{"background":{"type":"string","format":"binary","description":"Binary image file upload (JPEG, PNG, GIF, WebP, HEIC/HEIF, max 10 MB). Send as a file field in `multipart/form-data` — e.g. `-F \"background=@/path/to/image.jpg\"` with curl, or a `File`/`Blob` appended to `FormData` in JavaScript. Do NOT send a URL or base64 string."}}}}}},"responses":{"200":{"description":"Chat background set successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChatBackgroundResponse"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"502":{"description":"Failed to set background on device","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"No active number available","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"tags":["Chats"],"summary":"Remove chat background","description":"Remove the background image from a conversation, reverting to the default appearance.","operationId":"removeChatBackground","parameters":[{"$ref":"#/components/parameters/ChatIdParam"}],"responses":{"200":{"description":"Chat background removed successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChatBackgroundResponse"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"502":{"description":"Failed to remove background on device","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"No active number available","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/phone-numbers/lookup":{"get":{"tags":["Phone Numbers"],"summary":"Look up a phone number","description":"Returns detailed information about a phone number including validation, formatting (E.164, national, international), number type, and NANPA geocoding (city, state/province) for North American numbers. The geocoding data is sourced from different database with 240,000+ NPA-NXX entries.\n\n**Requires an Enterprise plan** (Dedicated Enterprise). Returns 403 if your organization does not have an active enterprise subscription.","operationId":"lookupPhoneNumber","parameters":[{"name":"number","in":"query","required":true,"description":"Phone number to look up. Can be E.164 format (+12125551234), national format (2125551234), or with formatting ((212) 555-1234).","schema":{"type":"string","example":"+12125551234"}}],"responses":{"200":{"description":"Phone number information","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PhoneNumberLookupResult"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"description":"Enterprise plan required. Upgrade to Dedicated Enterprise to access this endpoint.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["Phone Numbers"],"summary":"Look up a phone number","description":"Same as the GET endpoint, but accepts the phone number in the request body. Useful when the number contains characters that are difficult to URL-encode.\n\n**Requires an Enterprise plan** (Dedicated Enterprise).","operationId":"lookupPhoneNumberPost","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["number"],"properties":{"number":{"type":"string","description":"Phone number to look up","example":"+12125551234"}}}}}},"responses":{"200":{"description":"Phone number information","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PhoneNumberLookupResult"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"description":"Enterprise plan required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/phone-numbers/batch":{"post":{"tags":["Phone Numbers"],"summary":"Batch look up phone numbers","description":"Look up multiple phone numbers in a single request. Returns the same detailed information as the single lookup endpoint for each number. Maximum 100 numbers per request.\n\n**Requires an Enterprise plan** (Dedicated Enterprise).","operationId":"batchLookupPhoneNumbers","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["numbers"],"properties":{"numbers":{"type":"array","items":{"type":"string"},"minItems":1,"maxItems":100,"description":"Array of phone numbers to look up","example":["+12125551234","+14155551234","+18582849901"]}}}}}},"responses":{"200":{"description":"Batch lookup results","content":{"application/json":{"schema":{"type":"object","properties":{"results":{"type":"array","items":{"$ref":"#/components/schemas/PhoneNumberLookupResult"}}}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"description":"Enterprise plan required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/analytics/risk-tolerance":{"get":{"tags":["Analytics"],"summary":"Get risk-tolerance report","description":"Returns the per-number risk-tolerance report for every dedicated and inbound number in the organization over a bounded time window. Numbers are returned sorted by descending risk score (riskiest first).\n\nEach entry carries a `risk_score` (0-100), a `risk_level` (`low`/`medium`/`high`), a `line_type` indicating which scoring profile was applied, the raw `metrics` used to derive it, the ten scored `risk_factors` (value + points + status per factor), and a `daily_data` time series of new inbound/outbound conversations for charting.\n\n**Scope** — Org-scoped: any API key in the organization returns the full scorable fleet, regardless of which numbers the key is attached to.\n\n**Eligibility** — Requires at least one dedicated number (Dedicated Commercial or Dedicated Enterprise) or inbound number (Inbound Basic). Organizations with only shared or trial numbers receive `403 dedicated_plan_required`. Inbound numbers are scored with the reply-only factor profile described on the Analytics tag.\n\n**Computation** — Real-time; recomputed from Postgres on every request (no cache). Definitions used across the metrics: a *conversation* is keyed by contact (or group); a *new conversation* is one whose all-time first message falls inside the window; a *reply* is a conversation that received 3 or more inbound messages; *bursts* are the peak count in any single UTC hour of the window. The expensive message-similarity (SimHash) metric is included automatically for fleets of 5 numbers or fewer, and otherwise only when `compute=true` (larger fleets return `message_similarity_percentage: null` unless requested).","operationId":"getRiskTolerance","parameters":[{"$ref":"#/components/parameters/RiskDaysParam"},{"$ref":"#/components/parameters/RiskFromParam"},{"$ref":"#/components/parameters/RiskToParam"},{"$ref":"#/components/parameters/RiskComputeParam"}],"responses":{"200":{"description":"Risk report for the organization's dedicated and inbound numbers","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RiskToleranceReport"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"description":"Organization has no dedicated or inbound numbers (`dedicated_plan_required`)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/analytics/risk-tolerance/summary":{"get":{"tags":["Analytics"],"summary":"Get risk-tolerance summary","description":"Returns a lightweight cached rollup of the organization's most recent risk scores (highest score/level and the count of high-risk numbers). Read from a cache populated by the full report; returns zeros with `computed_at: null` when the organization has never been scored. This endpoint never recomputes, so it is cheap to poll on load.","operationId":"getRiskSummary","responses":{"200":{"description":"Cached risk summary","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RiskToleranceSummary"}}}},"401":{"$ref":"#/components/responses/Unauthorized"}}}},"/analytics/risk-tolerance/{number}":{"get":{"tags":["Analytics"],"summary":"Get risk-tolerance report for a number","description":"Returns the risk-tolerance report for a single number in the organization: its `risk_score`, `risk_level`, `line_type`, `metrics`, `risk_factors`, and `daily_data` time series, computed over the requested window.\n\n**Scope** — Org-scoped: any API key in the organization can query any of the organization's numbers.\n\n**Eligibility** — Requires the number to be on a dedicated plan (Dedicated Commercial or Dedicated Enterprise) or an inbound plan (Inbound Basic). Shared, trial, and unplanned numbers return `403 dedicated_plan_required`. A number that isn't assigned to the organization returns `404`, and a non-E.164 `number` returns `400`. Inbound numbers are scored with the reply-only factor profile described on the Analytics tag.\n\n**Computation** — Same real-time compute and metric definitions as the org-wide report (a *reply* is a conversation with 3+ inbound messages; *bursts* are the peak in any single UTC hour; a *new conversation* is one whose first-ever message falls in the window). SimHash message similarity is included automatically for this single number unless the org is large and `compute=true` is omitted.","operationId":"getNumberRiskTolerance","parameters":[{"name":"number","in":"path","required":true,"description":"E.164 phone number (URL-encoded, e.g. %2B15551234567)","schema":{"type":"string"},"example":"%2B15551234567"},{"$ref":"#/components/parameters/RiskDaysParam"},{"$ref":"#/components/parameters/RiskFromParam"},{"$ref":"#/components/parameters/RiskToParam"},{"$ref":"#/components/parameters/RiskComputeParam"}],"responses":{"200":{"description":"Risk report for the number","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RiskToleranceNumberReport"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"description":"Number is not on a dedicated or inbound plan (`dedicated_plan_required`)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"$ref":"#/components/responses/NotFound"}}}}},"components":{"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","description":"API key authentication. Use your API key as the bearer token."}},"parameters":{"LimitParam":{"name":"limit","in":"query","description":"Maximum number of items to return in a single response. Must be between 1 and 200; defaults to 50. Use together with `offset` to page through large result sets.","schema":{"type":"integer","minimum":1,"maximum":200,"default":50}},"OffsetParam":{"name":"offset","in":"query","description":"Number of items to skip before returning results. Combine with `limit` for page-based pagination (e.g. `offset=50&limit=50` returns the second page). Defaults to 0.","schema":{"type":"integer","minimum":0,"default":0}},"ContactIdParam":{"name":"contactId","in":"path","required":true,"description":"Contact identifier (phone number in E.164 format or email, URL-encoded)","schema":{"type":"string"},"example":"%2B15551234567"},"GroupIdParam":{"name":"groupId","in":"path","required":true,"description":"Unique identifier of the group chat, prefixed with `grp_` (e.g. `grp_abc123def456`). Returned by the create-group and list-groups endpoints.","schema":{"type":"string","pattern":"^grp_[a-zA-Z0-9]+$"},"example":"grp_abc123def456"},"WebhookIdParam":{"name":"webhookId","in":"path","required":true,"description":"Unique identifier of the webhook subscription, prefixed with `wh_` (e.g. `wh_abc123def456`). Returned when you create or list webhooks.","schema":{"type":"string","pattern":"^wh_[a-zA-Z0-9]+$"},"example":"wh_abc123def456"},"ChatIdParam":{"name":"chatId","in":"path","required":true,"description":"Chat identifier. Can be: (1) phone number in E.164 format (e.g., +15551234567), (2) email address, (3) group ID (grp_xxxx), or (4) comma-separated list of phone numbers/emails for multi-recipient group chats (e.g., +15551234567,+15559876543). All values should be URL-encoded.","schema":{"type":"string"},"examples":{"phone":{"value":"%2B15551234567","summary":"Phone number (URL-encoded)"},"email":{"value":"user%40example.com","summary":"Email address (URL-encoded)"},"group":{"value":"grp_abc123def456","summary":"Group ID"},"multi":{"value":"%2B15551234567%2C%2B15559876543","summary":"Multiple recipients (comma-separated, URL-encoded)"}}},"MessageIdParam":{"name":"messageId","in":"path","required":true,"description":"Unique identifier of the message, prefixed with `msg_` (e.g. `msg_abc123def456`). Returned in the response when you send a message and in inbound message webhooks.","schema":{"type":"string"},"example":"msg_abc123def456"},"RiskDaysParam":{"name":"days","in":"query","description":"Length of the reporting window in days, ending now. Between 1 and 365; defaults to 30. Ignored when `from`/`to` are supplied.","schema":{"type":"integer","minimum":1,"maximum":365,"default":30}},"RiskFromParam":{"name":"from","in":"query","description":"Window start as a Unix epoch timestamp in milliseconds. When supplied, overrides `days`.","schema":{"type":"integer","format":"int64"}},"RiskToParam":{"name":"to","in":"query","description":"Window end as a Unix epoch timestamp in milliseconds. Defaults to now.","schema":{"type":"integer","format":"int64"}},"RiskComputeParam":{"name":"compute","in":"query","description":"Set to `true` to force the expensive message-similarity metric. Small fleets (<= 5 numbers) always compute it; larger fleets omit it unless this flag is set, so `message_similarity_percentage` may be `null` otherwise.","schema":{"type":"boolean","default":false}}},"responses":{"Unauthorized":{"description":"Authentication required or invalid","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"BadRequest":{"description":"Invalid request parameters","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"NotFound":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"ChatNotFound":{"description":"No conversation exists for this chatId (`code: chat_not_found`; the requested address is echoed as `chat_id`). A chat comes into existence with the first message sent to or received from an address, so a valid but never-messaged address returns this rather than an empty result. Sending with `POST /chats/{chatId}/messages` creates it.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"NotImplemented":{"description":"Endpoint is documented but not available yet","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"schemas":{"RiskWindow":{"type":"object","description":"The concrete time window the report was computed over.","properties":{"from":{"type":"integer","format":"int64","description":"Window start (Unix epoch ms)."},"to":{"type":"integer","format":"int64","description":"Window end (Unix epoch ms)."},"is_default":{"type":"boolean","description":"True when the caller supplied no window params (default 30 days)."}}},"RiskFactor":{"type":"object","description":"A single scored risk signal. Positive scores raise risk; negative scores (bonuses) lower it.","properties":{"value":{"type":"number","nullable":true,"description":"The measured value for this factor (units depend on the factor)."},"score":{"type":"number","description":"Points this factor contributed to the total risk score."},"status":{"type":"string","enum":["ok","bonus","warning","high","insufficient_data","not_applicable"],"description":"Qualitative status for display. `not_applicable` means the factor doesn't apply to this line type (e.g. outbound-initiation factors on a reply-only inbound number) and contributed 0 points."},"impact":{"type":"string","enum":["low","medium","high","very_high"],"description":"Relative weight of this factor in the overall score."},"sampleSize":{"type":"integer","description":"Sample size backing the value, when the factor guards on a minimum sample."},"peak_at":{"type":"string","nullable":true,"description":"Burst factors only (`newConversationBursts`, `messageBursts`). UTC date (`YYYY-MM-DD`) on which the window reported in `value` began."},"scored_value":{"type":"number","description":"Burst factors only. The window count the `score` was actually taken from. Because each daily candidate is aged before comparison, the costliest burst is not always the biggest one: a month-old 639/h can score less than a 240/h from yesterday. Equals `value` whenever the peak is also the scored window."},"scored_at":{"type":"string","nullable":true,"description":"Burst factors only. UTC date (`YYYY-MM-DD`) of the window described by `scored_value`."},"decay_weight":{"type":"number","description":"Burst factors only. Recency multiplier applied to the base band score, `0.5 ^ (age_days / 21)` with a floor of `0.25`. A burst is evidence that ages: without this, one two-minute event held a number at high risk for the entire window. Only the burst factors decay; every other factor is already a window average."}}},"RiskFactors":{"type":"object","description":"The ten additive risk factors that sum (clamped to 0-100) into `risk_score`. Each factor reports its measured `value`, the `score` (points) it contributed, a `status`, and its `impact` weight. Positive scores raise risk; negative scores are bonuses. Some factors only score once a minimum sample is reached (otherwise `status: insufficient_data`, `score: 0`). The scoring described below is for `dedicated` lines; where an inbound (reply-only) line differs, the difference is noted on the factor.","properties":{"outboundConversations":{"allOf":[{"$ref":"#/components/schemas/RiskFactor"}],"description":"Avg outbound-initiated conversations/day. Scoring: >50 = +30, 40-50 = +20, 30-40 = +8, else 0. Cold-outreach volume. **Inbound lines:** `not_applicable`, always 0 — a reply-only line cannot open cold threads."},"inboundConversations":{"allOf":[{"$ref":"#/components/schemas/RiskFactor"}],"description":"Avg inbound-initiated conversations/day (bonus). Scoring: >=100 = -20, 50-100 = -15, 30-50 = -10, 15-30 = -5, else 0. Organic demand lowers risk. **Inbound lines:** the value is still reported but earns no bonus, since inbound volume is the product working as sold rather than evidence of earned trust."},"inboundPercentage":{"allOf":[{"$ref":"#/components/schemas/RiskFactor"}],"description":"Percentage of new conversations the customer started (gradient). Scoring ranges from -15 (>=90% inbound) up to +20 (<20% inbound). Requires >= 5 new conversations to score. **Inbound lines:** `not_applicable`, always 0 — a reply-only line sits at ~100% by construction."},"totalContacts":{"allOf":[{"$ref":"#/components/schemas/RiskFactor"}],"description":"Distinct contacts messaged in the window. Scoring: >2000 = +15, 1500-2000 = +8, else 0."},"replyRate":{"allOf":[{"$ref":"#/components/schemas/RiskFactor"}],"description":"Percentage of conversations with 3+ inbound messages. Scoring: <20% = +35, 20-30% = +20, 30-40% = +8, >=50% = -5. Requires >= 10 conversations to score. Highest-weight (very_high) factor."},"inboundMsgCount":{"allOf":[{"$ref":"#/components/schemas/RiskFactor"}],"description":"Avg inbound messages per conversation. Scoring: <3 = +25 (with >= 3 conversations), else 0. **Inbound lines:** relaxed to <1.5 = +10, because a customer asking one question and getting an answer is the expected shape of an inbound thread."},"inboundOutboundRatio":{"allOf":[{"$ref":"#/components/schemas/RiskFactor"}],"description":"Inbound share of all messages. Scoring: <=10% = +20, 11-29% = +10, >=30% = 0. Requires >= 10 messages to score. Detects one-way traffic."},"newConversationBursts":{"allOf":[{"$ref":"#/components/schemas/RiskFactor"}],"description":"Peak new conversations the number itself opened in any sliding 60-minute window; conversations the customer started are excluded on every line type, so a rush of inbound demand is never mistaken for a blast. Base scoring: >60 = +40, 40-60 = +30, 25-40 = +20, 15-25 = +10, else 0. The base score is then multiplied by `decay_weight` (see `RiskFactor`), so an old burst costs less than the same burst today. Very-high weight; hallmark of mass-outreach automation."},"messageBursts":{"allOf":[{"$ref":"#/components/schemas/RiskFactor"}],"description":"Peak outbound messages in any sliding 60-minute window. Base scoring: >200 = +30, 150-200 = +20, 100-150 = +10, else 0, then multiplied by `decay_weight`."},"messageSimilarity":{"allOf":[{"$ref":"#/components/schemas/RiskFactor"}],"description":"Largest near-identical outbound cluster (SimHash) as a percentage of qualifying messages (>= 50 chars). Scoring: >70% = +15, 50-70% = +8, <30% = -2. Only evaluated with >= 20 qualifying messages and when the expensive metric was computed; otherwise `value: null`, `score: 0`."}}},"RiskMetrics":{"type":"object","description":"Raw and derived usage metrics for a number over the window. A *conversation* is keyed by contact (1:1) or group; a *new conversation* is one whose all-time first message falls inside the window; a *reply* is a conversation that received 3 or more inbound messages. Averages divide by the days the number could actually send in -- the window length capped to the number's own tenure -- not by the days that happened to have activity. So a line that was quiet for half the period still reads as low volume, while one that only existed for the last 9 days of a 30-day window reports its real pace instead of a third of it.","properties":{"avg_outbound_conversations_per_day":{"type":"number","description":"New outbound-initiated conversations started in the window, divided by days active (see the schema description). High values indicate cold-outreach volume (risk-raising)."},"avg_inbound_conversations_per_day":{"type":"number","description":"New inbound-initiated conversations (customer messaged first) in the window, divided by days active. High values indicate organic demand (risk-lowering)."},"inbound_initiated_percentage":{"type":"number","description":"Share of new conversations that the customer started, as a percentage: `inbound_initiated / (inbound_initiated + outbound_initiated) * 100`. Higher is healthier. Only scored once there are >= 5 new conversations."},"total_contacts":{"type":"integer","description":"Distinct contacts (conversation keys) messaged in the window. Large lists suggest broadcast/spam usage."},"reply_rate":{"type":"number","description":"Percentage of conversations that received a meaningful reply, defined as 3 or more inbound messages: `conversations_with_3plus_inbound / total_conversations * 100`. One of the strongest spam signals; only scored once there are >= 10 conversations."},"avg_inbound_messages_per_conversation":{"type":"number","description":"Mean inbound messages per conversation in the window. Below 3 (with >= 3 conversations) indicates shallow, low-engagement outreach."},"inbound_outbound_message_ratio":{"type":"number","description":"Inbound messages as a percentage of all messages: `total_inbound_messages / total_messages * 100`. Low values mean one-way (monologuing) traffic. Only scored once there are >= 10 messages."},"max_new_conversations_per_hour":{"type":"integer","description":"Peak number of NEW conversations the number itself opened in any sliding 60-minute window (burst detection). The window slides rather than snapping to clock hours, so a blast straddling :59 is reported at its real rate instead of being split across two buckets. Conversations the customer started are excluded, on every line type. A human pace is roughly <= 15/hour; sustained higher rates signal automation."},"max_messages_per_hour":{"type":"integer","description":"Peak outbound messages sent in any sliding 60-minute window (burst detection). Sustained rates above ~100/hour signal automation."},"message_similarity_percentage":{"type":"number","nullable":true,"description":"Templated-content signal: the largest cluster of near-identical outbound messages (by SimHash) as a percentage of qualifying messages. Only outbound messages with >= 50 characters count, and a valid ratio needs >= 20 qualifying messages. `null` when not computed (large fleet without `compute=true`) or below the minimum sample."},"inbound_initiated":{"type":"integer","description":"Count of new conversations the customer started in the window."},"outbound_initiated":{"type":"integer","description":"Count of new conversations this number started in the window."},"total_conversations":{"type":"integer","description":"Conversations with any message activity in the window."},"total_messages":{"type":"integer","description":"Inbound + outbound messages in the window (excludes deleted)."},"total_inbound_messages":{"type":"integer","description":"Inbound message count in the window."},"total_outbound_messages":{"type":"integer","description":"Outbound message count in the window."},"avg_messages_per_day":{"type":"number","description":"`total_messages` divided by days active."},"avg_conversation_depth":{"type":"number","description":"`total_messages / total_conversations` (0 when there are no conversations)."}}},"RiskDailySeriesPoint":{"type":"object","properties":{"date":{"type":"string","description":"UTC calendar day (YYYY-MM-DD).","example":"2026-07-01"},"count":{"type":"integer"}}},"RiskDailyData":{"type":"object","properties":{"outbound_conversations":{"type":"array","items":{"$ref":"#/components/schemas/RiskDailySeriesPoint"}},"inbound_conversations":{"type":"array","items":{"$ref":"#/components/schemas/RiskDailySeriesPoint"}}}},"RiskPhoneReport":{"type":"object","description":"Per-number risk report.","properties":{"phone_number":{"type":"string","example":"+15551234567"},"allocation_id":{"type":"string"},"line_type":{"type":"string","nullable":true,"enum":["dedicated","inbound","2fa",null],"description":"The line's allocation type, which determines the scoring profile applied. `inbound` lines are reply-only and use the reduced factor profile described on the Analytics tag; everything else is scored on the full dedicated profile."},"risk_score":{"type":"number","description":"Overall risk score, 0 (lowest) to 100 (highest). Clamped sum of the ten `risk_factors`."},"risk_level":{"type":"string","enum":["low","medium","high"],"description":"Banding of `risk_score`: `low` = 0-29 (healthy), `medium` = 30-59 (monitor), `high` = 60-100 (likely to be filtered/suspended by carriers)."},"has_activity":{"type":"boolean","description":"Whether the number sent, received, or reached anyone in the window. Every factor guards on a minimum sample, so a number with no traffic sums to `risk_score: 0` -- the same score a well-behaved line earns. Treat `false` as \"nothing to score yet\" rather than \"lowest risk\": don't present the score, and exclude the number from fleet averages."},"metrics":{"$ref":"#/components/schemas/RiskMetrics"},"risk_factors":{"$ref":"#/components/schemas/RiskFactors"},"daily_data":{"$ref":"#/components/schemas/RiskDailyData"}}},"RiskToleranceReport":{"type":"object","description":"Organization-wide risk report for all dedicated and inbound numbers.","properties":{"phone_numbers":{"type":"array","items":{"$ref":"#/components/schemas/RiskPhoneReport"},"description":"Per-number reports, sorted by descending risk score."},"period_days":{"type":"integer"},"window":{"$ref":"#/components/schemas/RiskWindow"},"calculated_at":{"type":"integer","format":"int64","description":"When the report was computed (Unix epoch ms)."},"computed_with_expensive_metrics":{"type":"boolean","description":"Whether the message-similarity metric was included."}}},"RiskToleranceNumberReport":{"allOf":[{"$ref":"#/components/schemas/RiskPhoneReport"},{"type":"object","properties":{"period_days":{"type":"integer"},"window":{"$ref":"#/components/schemas/RiskWindow"},"calculated_at":{"type":"integer","format":"int64"},"computed_with_expensive_metrics":{"type":"boolean"}}}]},"RiskToleranceSummary":{"type":"object","description":"Cached rollup of the organization's most recent risk scores.","properties":{"high_risk_count":{"type":"integer"},"max_risk_level":{"type":"string","enum":["low","medium","high"]},"max_risk_score":{"type":"number"},"phone_count":{"type":"integer"},"high_risk_phones":{"type":"array","items":{"type":"object","properties":{"phone_number":{"type":"string"},"risk_score":{"type":"number"},"risk_level":{"type":"string","enum":["low","medium","high"]}}}},"computed_at":{"type":"integer","format":"int64","nullable":true,"description":"When the cached summary was last computed (Unix epoch ms), or null if never."}}},"PhoneNumberLookupResult":{"type":"object","properties":{"input":{"type":"string","description":"The original input string","example":"+12125551234"},"valid":{"type":"boolean","description":"Whether the phone number is valid"},"possible":{"type":"boolean","description":"Whether the phone number is a possible number (less strict than valid)"},"e164":{"type":"string","description":"E.164 formatted number","example":"+12125551234"},"national":{"type":"string","description":"National formatted number","example":"(212) 555-1234"},"international":{"type":"string","description":"International formatted number","example":"+1 212 555 1234"},"country_calling_code":{"type":"string","description":"Country calling code without +","example":"1"},"country":{"type":"string","nullable":true,"description":"ISO 3166-1 alpha-2 country code","example":"US"},"national_number":{"type":"string","description":"National number without country code","example":"2125551234"},"type":{"type":"string","nullable":true,"description":"Number type detected by libphonenumber","enum":["FIXED_LINE","MOBILE","FIXED_LINE_OR_MOBILE","TOLL_FREE","PREMIUM_RATE","SHARED_COST","VOIP","PERSONAL_NUMBER","PAGER","UAN","VOICEMAIL"],"example":"FIXED_LINE_OR_MOBILE"},"location":{"type":"object","nullable":true,"description":"NANPA geocoding location (only for North American numbers with country code 1)","properties":{"city":{"type":"string","nullable":true,"description":"City name","example":"New York"},"region":{"type":"string","nullable":true,"description":"State/province abbreviation","example":"NY"},"region_name":{"type":"string","nullable":true,"description":"Full state/province name","example":"New York"}}},"area_code":{"type":"string","description":"NPA area code (first 3 digits of national number, only for NANP numbers)","example":"212"},"exchange":{"type":"string","description":"NXX exchange code (digits 4-6 of national number, only for NANP numbers)","example":"555"},"area_code_region":{"type":"string","description":"General region for the area code (most common city, only for NANP numbers)","example":"New York, NY"}}},"ContactLocation":{"type":"object","properties":{"handle":{"type":"string","description":"Contact's phone number or email"},"coordinates":{"type":"array","items":{"type":"number"},"description":"GPS coordinates [latitude, longitude]"},"status":{"type":"string","description":"Location status (e.g., 'live', 'shallow', 'legacy')"},"last_updated":{"type":"integer","format":"int64","description":"Timestamp of last location update (epoch ms)"}}},"Error":{"type":"object","properties":{"error":{"type":"string","description":"Error class identifier (typically `ApiError`)."},"message":{"type":"string","description":"Human-readable explanation of the failure."},"status":{"type":"integer","description":"HTTP status code"},"code":{"type":"string","description":"Machine-readable error code for programmatic handling (e.g. `inbound_only_no_prior_inbound`, `outbound_limit_reached`, `attachment_first_message_not_allowed`). Switch on `code`, not on `message`. Present on all known/structured error cases."}}},"Pagination":{"type":"object","properties":{"limit":{"type":"integer"},"offset":{"type":"integer"},"total":{"type":"integer"}}},"DeleteResponse":{"type":"object","properties":{"success":{"type":"boolean"},"deleted_at":{"type":"integer","format":"int64"}}},"MeResponse":{"type":"object","description":"Response depends on auth_type. For 'api_key': includes full API key details. For 'dashboard': includes user_id and organization info only.","properties":{"auth_type":{"type":"string","enum":["api_key","dashboard"],"description":"Type of authentication used"},"valid":{"type":"boolean","description":"Whether the API key is valid (only for api_key auth)"},"user_id":{"type":"string","nullable":true,"description":"User ID (only for dashboard auth)"},"api_key":{"type":"string","description":"The API key (only for api_key auth)"},"organization_id":{"type":"string","description":"Organization ID (only for api_key auth)"},"organization":{"type":"object","properties":{"organization_id":{"type":"string"},"name":{"type":"string"},"country_code":{"type":"string","nullable":true},"created_at":{"type":"integer","format":"int64"}}},"metadata":{"type":"object","description":"API key metadata (only for api_key auth)"},"integration_details":{"type":"object","nullable":true,"description":"Integration details if the API key is associated with an integration (only for api_key auth)"},"devices":{"type":"array","description":"List of devices associated with this API key (only for api_key auth)","items":{"type":"object","properties":{"phone_number":{"type":"string","nullable":true,"description":"Phone number assigned to this device (E.164 format)"},"is_active":{"type":"boolean","description":"False when the line is banned, suspended, or the underlying account is blocked."},"banned":{"type":"boolean","description":"True when the phone number is banned. Same meaning as `/me/numbers`."},"suspended":{"type":"boolean","description":"True when the phone number is suspended. Same meaning as `/me/numbers`."},"status":{"type":"string","enum":["active","suspended","banned"],"description":"`banned` if the number is banned, otherwise `suspended` if it is suspended, otherwise `active`. Mirrors `/me/numbers`."},"last_active":{"type":"integer","format":"int64","nullable":true},"plan_kind":{"type":"string","nullable":true,"enum":["shared","dedicated","inbound","trial","2fa",null],"description":"Plan type the underlying allocation runs on. `inbound` numbers are reply-only — see `/me/numbers` for details."}}}},"usage":{"type":"object","description":"Usage statistics (only for api_key auth)","properties":{"inbound_messages":{"type":"integer"},"outbound_messages":{"type":"integer"},"last_message_sent":{"type":"integer","format":"int64","nullable":true}}}}},"Contact":{"type":"object","properties":{"id":{"type":"string","description":"Contact identifier (phone or email)"},"contact_id":{"type":"string","description":"Internal contact ID"},"identifier":{"type":"string","description":"Phone number (E.164) or email"},"name":{"type":"string","nullable":true},"type":{"type":"string","enum":["phone","email"]},"created_at":{"type":"integer","format":"int64"},"last_message_time":{"type":"integer","format":"int64","nullable":true},"tags":{"type":"array","items":{"type":"string"}}}},"Group":{"type":"object","properties":{"group_id":{"type":"string"},"name":{"type":"string","nullable":true,"description":"Group name. Null for unnamed groups."},"chat_guid":{"type":"string","nullable":true,"deprecated":true,"description":"Deprecated. An identifier for the group's iMessage conversation, kept for existing integrations. Null until the group has one. Use `group_id` to identify the group."},"icon_url":{"type":"string","nullable":true,"description":"URL of the group icon/photo"},"member_count":{"type":"integer"},"message_count":{"type":"integer","description":"Total number of messages in this group"},"last_message_text":{"type":"string","nullable":true,"description":"Text of the most recent message in the group"},"last_message_time":{"type":"integer","format":"int64","nullable":true,"description":"Timestamp of the most recent message"},"last_message_direction":{"type":"string","enum":["inbound","outbound"],"nullable":true,"description":"Direction of the most recent message"},"created_at":{"type":"integer","format":"int64"}}},"GroupMember":{"type":"object","properties":{"id":{"type":"string","description":"Contact identifier (phone or email)"},"contact_id":{"type":"string"},"identifier":{"type":"string"},"name":{"type":"string","nullable":true},"added_at":{"type":"integer","format":"int64"}}},"GroupIconResponse":{"type":"object","description":"Response for group icon operations","properties":{"success":{"type":"boolean"},"group_id":{"type":"string"},"chat_guid":{"type":"string","deprecated":true,"description":"Deprecated. An identifier for the group's iMessage conversation, kept for existing integrations. Use `group_id` to identify the group."},"icon_url":{"type":"string","description":"URL of the uploaded icon (only present on set)"},"device_sync":{"type":"object","description":"Linked chat sync status","properties":{"chat_guid":{"type":"string","deprecated":true,"description":"Deprecated. The same value as the top-level `chat_guid`."},"synced":{"type":"boolean","description":"Whether the icon change was synced to the linked iMessage chat. This will be true on successful set/remove operations."},"message":{"type":"string","description":"Status message about linked chat sync"}}},"message":{"type":"string"}}},"ChatBackgroundResponse":{"type":"object","description":"Response for chat background operations","properties":{"chat_id":{"type":"string","description":"Normalized chat identifier (phone number, email, or group ID)"},"has_background":{"type":"boolean","description":"Whether the chat currently has a background set"},"background_id":{"type":"string","nullable":true,"description":"Unique identifier for the current background, or null if none"},"background_url":{"type":"string","format":"uri","nullable":true,"description":"Public URL of the persisted background image stored in R2. Returned after a successful PUT and on GET when a background has been set through the API. May be null if persistence failed or the background was set outside of the API."},"background_version":{"type":"integer","nullable":true,"description":"Version number of the background (for cache invalidation)"},"changed":{"type":"boolean","description":"Whether the background was changed by this operation (only present on PUT)"}}},"DeviceSyncResult":{"type":"object","description":"Result of syncing the operation to a linked iMessage chat","properties":{"action":{"type":"string","enum":["add_participant","remove_participant","leave"],"description":"The action that was performed for the linked chat"},"synced":{"type":"boolean","description":"Whether the sync was successful"},"error":{"type":"string","nullable":true,"description":"Error message if sync failed"}}},"Webhook":{"type":"object","properties":{"webhook_id":{"type":"string"},"webhook_url":{"type":"string","format":"uri"},"webhook_type":{"type":"string","enum":["message","status","all"]},"scope":{"type":"string","enum":["api_key","organization","integration"]},"api_key_name":{"type":"string","nullable":true,"description":"Name of the API key (if scope is api_key)"},"integration_name":{"type":"string","nullable":true,"description":"Name of the integration (if scope is integration)"},"created_at":{"type":"integer","format":"int64"},"deprecated_at":{"type":"integer","format":"int64","nullable":true},"valid_until":{"type":"integer","format":"int64","description":"-1 means no expiration"},"last_triggered":{"type":"integer","format":"int64","nullable":true},"failure_count":{"type":"integer"},"is_active":{"type":"boolean","description":"Whether the webhook is active (not deprecated)"}}},"WebhookLog":{"type":"object","properties":{"event_id":{"type":"string"},"scope":{"type":"string","enum":["api","integration","org"]},"attempted_time":{"type":"integer","format":"int64"},"response_received_at":{"type":"integer","format":"int64","nullable":true},"webhook_url":{"type":"string"},"event_body":{"$ref":"#/components/schemas/WebhookEventPayload"},"response_status":{"type":"integer","nullable":true,"description":"HTTP status code received from the webhook endpoint"},"response_json":{"type":"object","nullable":true,"description":"Response body from the webhook endpoint (if JSON)"},"metadata":{"type":"object","description":"Additional metadata about the webhook delivery","properties":{"organization_id":{"type":"string"},"event_name":{"type":"string"},"message_id":{"type":"string"},"is_replay":{"type":"boolean"},"original_event_id":{"type":"string"},"duration_ms":{"type":"integer"}}}}},"WebhookEventPayload":{"type":"object","description":"Webhook event payload. Structure varies by event type. All message events include group information when applicable.","properties":{"event":{"type":"string","description":"Event type (e.g., message.received, message.sent, message.delivered, message.failed, message.read)","example":"message.sent"},"message_id":{"type":"string","description":"Unique message identifier"},"external_id":{"type":"string","description":"Recipient identifier (phone number, email, or group ID)"},"status":{"type":"string","description":"Message status carried by the event. `queued` / `pending` = accepted, not yet handed off; `sent` = handed to Apple/the carrier; `delivered` = a delivery receipt was received; `read` = a read receipt was received (iMessage, when the recipient has read receipts on); `failed` = delivery failed (see `error_code` / `error_message`); `received` = an inbound message arrived.","enum":["queued","pending","sent","delivered","failed","read","received"]},"protocol":{"type":"string","description":"Transport used to carry the message; never null. `pending` = accepted and dispatched, wire service not resolved yet (settles within seconds of send); `imessage` = delivered over iMessage (blue bubble); `rcs` = delivered over RCS; `sms` = fell back to SMS/MMS (green bubble); `unknown` = accepted by the carrier but the wire service could not be resolved before the tracking window closed (see `error`).","enum":["pending","unknown","imessage","sms","rcs"]},"timestamp":{"type":"integer","format":"int64","description":"Event timestamp in milliseconds"},"internal_id":{"type":"string","nullable":true,"description":"Phone number that sent/received the message"},"text":{"type":"string","nullable":true,"description":"Message text content"},"formatted_text":{"type":"string","description":"Markdown for a rich-text (bold/italic/underline/strikethrough) message. Omitted entirely when the message carries no styling, so its presence is how you detect rich text.\n\nPresent in both directions: on an outbound send made with `format: \"markdown\"`, and on an inbound iMessage whose sender styled their text — so styling a customer applied in Messages arrives here even though your integration never asked for it.\n\nAlways a normalized re-serialization of the message's actual styling rather than an echo of the source string: bold is spelled `**`, italic `*`, underline `++`, strikethrough `~~`, and any character that would otherwise read as a delimiter is backslash-escaped. Re-sending this value verbatim with `format: \"markdown\"` reproduces the same styled message. Blooio iMessage only. This is the SAME field delivered on the message webhooks, so a message reads identically via REST or webhook."},"attachments":{"type":"array","nullable":true,"description":"Array of attachment objects","items":{"type":"object","properties":{"url":{"type":"string"},"name":{"type":"string","nullable":true}}}},"pending_attachment_count":{"type":"integer","description":"`message.received` only: how many attachments the sender sent that haven't finished downloading yet; `attachments` then lists only the ones already stored. Omitted when nothing is pending. Once they land, a `message.updated` event with the same `message_id` carries the complete `attachments`, for a webhook subscribed to `message.updated`."},"is_group":{"type":"boolean","description":"Whether this message is from/to a group chat. Always present."},"group_id":{"type":"string","nullable":true,"description":"Group ID (only present when is_group=true)"},"group_name":{"type":"string","nullable":true,"description":"Group display name (only present when is_group=true)"},"participants":{"type":"array","nullable":true,"description":"Array of group participants (only present when is_group=true). One entry per person: a participant appears once even if Blooio holds more than one identity for their number.","items":{"type":"object","properties":{"contact_id":{"type":"string"},"identifier":{"type":"string"},"name":{"type":"string","nullable":true}}}},"chat_guid":{"type":"string","nullable":true,"deprecated":true,"description":"Deprecated, kept for existing integrations. An identifier for the iMessage conversation this message arrived in (only on `message.received` when is_group=true). Matches the `chat_guid` on GET /groups/{groupId}. Use `group_id` to identify the group.","example":"iMessage;+;chat123456789"},"chat_name":{"type":"string","nullable":true,"description":"The name the device reports for the conversation (only on `message.received` when is_group=true). May differ from `group_name`, or be present when `group_name` is null.","example":"Sales Team"},"sender":{"type":"string","nullable":true,"description":"Sender identifier (for inbound messages)"},"sent_at":{"type":"integer","format":"int64","nullable":true,"description":"Timestamp when message was sent (for message.sent events)"},"delivered_at":{"type":"integer","format":"int64","nullable":true,"description":"Timestamp when message was delivered (for message.delivered events)"},"read_at":{"type":"integer","format":"int64","nullable":true,"description":"Timestamp when message was read (for message.read events)"},"error_code":{"type":"string","nullable":true,"description":"Error code (for message.failed events)"},"error_message":{"type":"string","nullable":true,"description":"Error description (for message.failed events)"}}},"Chat":{"type":"object","properties":{"id":{"type":"string","description":"Chat identifier (phone number, email, or group ID)"},"type":{"type":"string","enum":["phone","email","group"]},"is_group":{"type":"boolean","description":"Whether this is a group chat"},"group_id":{"type":"string","nullable":true,"description":"Group ID (only for group chats)"},"group_name":{"type":"string","nullable":true,"description":"Group name (only for group chats)"},"member_count":{"type":"integer","description":"Number of members (only for group chats)"},"contact":{"type":"object","nullable":true,"description":"Contact info (only for non-group chats)","properties":{"contact_id":{"type":"string"},"name":{"type":"string","nullable":true},"identifier":{"type":"string"}}},"message_count":{"type":"integer"},"inbound_count":{"type":"integer"},"outbound_count":{"type":"integer"},"background_url":{"type":"string","format":"uri","nullable":true,"description":"Public URL of the chat background image (if one has been set via the API)"},"background_id":{"type":"string","nullable":true,"description":"Identifier for the active chat background"},"last_message_time":{"type":"integer","format":"int64"},"last_inbound_time":{"type":"integer","format":"int64","nullable":true},"last_outbound_time":{"type":"integer","format":"int64","nullable":true},"last_message":{"$ref":"#/components/schemas/LastMessage"}}},"ChatDetail":{"type":"object","properties":{"id":{"type":"string","description":"Chat identifier (phone number, email, or group ID)"},"type":{"type":"string","enum":["phone","email","group"]},"is_group":{"type":"boolean","description":"Whether this is a group chat"},"group_id":{"type":"string","nullable":true,"description":"Group ID (only for group chats)"},"group_name":{"type":"string","nullable":true,"description":"Group name (only for group chats)"},"member_count":{"type":"integer","description":"Number of members (only for group chats)"},"contact":{"type":"object","nullable":true,"description":"Contact info (only for non-group chats)","properties":{"contact_id":{"type":"string"},"name":{"type":"string","nullable":true},"identifier":{"type":"string"}}},"message_count":{"type":"integer"},"inbound_count":{"type":"integer"},"outbound_count":{"type":"integer"},"background_url":{"type":"string","format":"uri","nullable":true,"description":"Public URL of the chat background image (if one has been set via the API)"},"background_id":{"type":"string","nullable":true,"description":"Identifier for the active chat background"},"first_message_time":{"type":"integer","format":"int64"},"last_message_time":{"type":"integer","format":"int64"},"last_inbound_time":{"type":"integer","format":"int64","nullable":true},"last_outbound_time":{"type":"integer","format":"int64","nullable":true},"last_message":{"$ref":"#/components/schemas/LastMessage"}}},"LastMessage":{"type":"object","properties":{"message_id":{"type":"string"},"text":{"type":"string","nullable":true},"direction":{"type":"string","enum":["inbound","outbound"]},"time_sent":{"type":"integer","format":"int64"}}},"Message":{"type":"object","properties":{"message_id":{"type":"string"},"direction":{"type":"string","enum":["inbound","outbound"]},"external_id":{"type":"string","description":"Phone number or email of the contact, or group ID for group messages"},"internal_id":{"type":"string","nullable":true,"description":"Organization phone number (from-number) used for this message"},"text":{"type":"string","nullable":true},"formatted_text":{"type":"string","description":"Markdown for a rich-text (bold/italic/underline/strikethrough) message. Omitted entirely when the message carries no styling, so its presence is how you detect rich text.\n\nPresent in both directions: on an outbound send made with `format: \"markdown\"`, and on an inbound iMessage whose sender styled their text — so styling a customer applied in Messages arrives here even though your integration never asked for it.\n\nAlways a normalized re-serialization of the message's actual styling rather than an echo of the source string: bold is spelled `**`, italic `*`, underline `++`, strikethrough `~~`, and any character that would otherwise read as a delimiter is backslash-escaped. Re-sending this value verbatim with `format: \"markdown\"` reproduces the same styled message. Blooio iMessage only. This is the SAME field delivered on the message webhooks, so a message reads identically via REST or webhook."},"attachments":{"type":"array","items":{"type":"object"}},"sender":{"type":"string","nullable":true,"description":"Sender's phone number or email for inbound group messages. Null for outbound messages and 1-1 chats."},"reactions":{"type":"array","description":"Reactions on this message (tapbacks and emoji reactions)","items":{"$ref":"#/components/schemas/Reaction"}},"time_sent":{"type":"integer","format":"int64"},"time_delivered":{"type":"integer","format":"int64","nullable":true},"status":{"type":"string","description":"Delivery lifecycle state. `pending` = persisted and being prepared for dispatch; `queued` = accepted and waiting to be handed to Apple/the carrier; `sent` = handed off to Apple/the carrier (protocol resolution happens around here); `delivered` = a delivery receipt was received; `failed` = could not be delivered (see `error`); `cancellation_requested` = a cancel was requested for a still-queued message (best-effort); `cancelled` = cancelled before dispatch. Inbound messages are surfaced via webhooks with `received`; read receipts arrive as a `read` event.","enum":["pending","queued","sent","delivered","failed","cancellation_requested","cancelled"],"nullable":true},"protocol":{"type":"string","description":"Transport used to carry the message; never null. `pending` = accepted and dispatched, wire service not resolved yet (settles within seconds of send); `imessage` = delivered over iMessage (blue bubble); `rcs` = delivered over RCS; `sms` = fell back to SMS/MMS (green bubble); `unknown` = accepted by the carrier but the wire service could not be resolved before the tracking window closed (see `error`).","enum":["pending","unknown","imessage","sms","rcs"]},"error":{"type":"string","nullable":true},"reply_to":{"allOf":[{"$ref":"#/components/schemas/ReplyToInfo"}],"nullable":true,"description":"Present only on inline-reply messages. Omitted entirely for top-level messages."}}},"MessageDetail":{"type":"object","properties":{"message_id":{"type":"string"},"chat_id":{"type":"string"},"direction":{"type":"string","enum":["inbound","outbound"]},"internal_id":{"type":"string","nullable":true,"description":"Organization phone number (from-number) used for this message"},"contact":{"type":"object","nullable":true,"properties":{"contact_id":{"type":"string"},"name":{"type":"string","nullable":true},"identifier":{"type":"string","description":"The contact's phone number or email"}}},"sender":{"type":"string","nullable":true,"description":"Sender's phone number or email for inbound group messages. Null for outbound messages and 1-1 chats."},"text":{"type":"string","nullable":true},"formatted_text":{"type":"string","description":"Markdown for a rich-text (bold/italic/underline/strikethrough) message. Omitted entirely when the message carries no styling, so its presence is how you detect rich text.\n\nPresent in both directions: on an outbound send made with `format: \"markdown\"`, and on an inbound iMessage whose sender styled their text — so styling a customer applied in Messages arrives here even though your integration never asked for it.\n\nAlways a normalized re-serialization of the message's actual styling rather than an echo of the source string: bold is spelled `**`, italic `*`, underline `++`, strikethrough `~~`, and any character that would otherwise read as a delimiter is backslash-escaped. Re-sending this value verbatim with `format: \"markdown\"` reproduces the same styled message. Blooio iMessage only. This is the SAME field delivered on the message webhooks, so a message reads identically via REST or webhook."},"attachments":{"type":"array","items":{"type":"object"}},"reactions":{"type":"array","description":"Reactions on this message (tapbacks and emoji reactions)","items":{"$ref":"#/components/schemas/Reaction"}},"time_sent":{"type":"integer","format":"int64"},"time_delivered":{"type":"integer","format":"int64","nullable":true},"status":{"type":"string","description":"Delivery lifecycle state. `pending` = persisted and being prepared for dispatch; `queued` = accepted and waiting to be handed to Apple/the carrier; `sent` = handed off to Apple/the carrier (protocol resolution happens around here); `delivered` = a delivery receipt was received; `failed` = could not be delivered (see `error`); `cancellation_requested` = a cancel was requested for a still-queued message (best-effort); `cancelled` = cancelled before dispatch. Inbound messages are surfaced via webhooks with `received`; read receipts arrive as a `read` event.","enum":["pending","queued","sent","delivered","failed","cancellation_requested","cancelled"],"nullable":true},"protocol":{"type":"string","description":"Transport used to carry the message; never null. `pending` = accepted and dispatched, wire service not resolved yet (settles within seconds of send); `imessage` = delivered over iMessage (blue bubble); `rcs` = delivered over RCS; `sms` = fell back to SMS/MMS (green bubble); `unknown` = accepted by the carrier but the wire service could not be resolved before the tracking window closed (see `error`).","enum":["pending","unknown","imessage","sms","rcs"]},"error":{"type":"string","nullable":true},"reply_to":{"allOf":[{"$ref":"#/components/schemas/ReplyToInfo"}],"nullable":true,"description":"Present only on inline-reply messages. Omitted entirely for top-level messages."}}},"ReplyToInfo":{"type":"object","description":"Inline-reply parent reference. Identical shape on `message.received` webhooks and on every GET endpoint that returns a single message or a list of messages.","required":["message_id","guid","part_index"],"properties":{"message_id":{"type":"string","nullable":true,"description":"The Blooio `message_id` of the parent message. NULL when the parent isn't in our `messages` table (e.g., the original was sent from outside Blooio's pipeline)."},"guid":{"type":"string","nullable":true,"description":"The raw iMessage GUID of the parent. Always populated on real inline replies; the on-device record-of-truth identifier that survives even when `message_id` cannot be resolved."},"part_index":{"type":"integer","minimum":0,"default":0,"description":"Which part of the parent was replied to. 0 for the common single-part case."}}},"ReplyToRequest":{"type":"object","description":"Inline-reply target on `POST /chats/{chatId}/messages`. Pass either `message_id` (preferred — references a Blooio-minted message) or `guid` (raw iMessage GUID, useful for replying to messages received before the row was minted in Blooio). The new send is dispatched to Lava with the resolved `selectedMessageGuid` + `partIndex`, which iMessage renders as an inline reply on the recipient's device.","properties":{"message_id":{"type":"string","description":"Blooio `message_id` of the parent. Must belong to the same chat, same from-number, and be no older than 30 days. Returns 404 `reply_target_not_found` if unknown."},"guid":{"type":"string","description":"Raw iMessage GUID of the parent. When supplied without a `message_id`, Blooio attempts to look up the parent via `provider_message_guid`; if the parent isn't in our table the send still proceeds (Lava will thread on the device when possible) and the response carries `parent_unresolved: true`."},"part_index":{"type":"integer","minimum":0,"default":0,"description":"Which part of the parent to reply to. Defaults to 0 (covers the 99% case of replying to a single-part text message)."}}},"Reaction":{"type":"object","properties":{"reaction":{"type":"string","description":"The reaction value. Classic tapbacks: love, like, dislike, laugh, emphasize, question. Emoji reactions: the emoji character (e.g. 😂, 👍)."},"is_added":{"type":"boolean","description":"Whether the reaction is currently active (true) or was removed (false)"},"time_sent":{"type":"integer","format":"int64","description":"Timestamp when the reaction was sent (ms)"},"sender":{"type":"string","nullable":true,"description":"Phone number or email of who sent the reaction. Null when the reaction was sent by you (outbound)."}}},"SendMessageRequest":{"type":"object","description":"Request body for sending a message","properties":{"text":{"oneOf":[{"type":"string"},{"type":"array","items":{"type":"string"}}],"description":"Message text. Can be a single string or array of strings (each becomes a separate message)"},"format":{"type":"string","enum":["plain","markdown"],"default":"plain","description":"How to interpret `text` (and each `parts[].text`). Defaults to `plain`, which sends the string exactly as given.\n\nWith `markdown`, four constructs are parsed and delivered as real iMessage rich text — the recipient sees styled text, not delimiters:\n\n| Construct | Syntax |\n| --- | --- |\n| Bold | `**bold**` or `__bold__` |\n| Italic | `*italic*` or `_italic_` |\n| Underline | `++underline++` |\n| Strikethrough | `~~strike~~` |\n\nThey nest freely (`**bold and _italic_**`). Everything else Markdown can express — headings, lists, links, code spans, blockquotes, images — is NOT styling iMessage can carry, so it is passed through as literal characters: `[Blooio](https://blooio.com)` is delivered with its brackets and URL intact, and `# Heading` keeps its `#`. Escape a delimiter with a backslash (`\\*not italic\\*`) to send it literally.\n\nThe styling travels in the message's attributed body, so the stored `text` and the `text` returned on reads and webhooks is always the plain string the recipient sees, with the delimiters removed. The Markdown itself comes back as `formatted_text`, re-serialized into a normalized spelling rather than echoed verbatim (`__bold__` returns as `**bold**`).\n\nOnly valid on Blooio iMessage channels — `400 format_unsupported_for_channel_type` on any other channel type, since no other channel type has a rich-text equivalent and would otherwise deliver your delimiters as literal text. Rich text also requires the message to be delivered over iMessage: a Blooio send that falls back to SMS arrives as unstyled plain text (the `text` string), because SMS cannot carry styling.\n\nApplies to a text send and to `parts`. Rejected with `400 invalid_content` when combined with `attachments` — a media caption is not a styled bubble, so send the media and the styled text as two messages — when set without `text` or `parts`, when the Markdown source exceeds 20000 characters, or when it compiles to more than 256 distinct formatting ranges."},"attachments":{"type":"array","items":{"oneOf":[{"type":"string","description":"URL to the attachment"},{"type":"object","properties":{"url":{"type":"string"},"name":{"type":"string"}},"required":["url"]}]},"description":"Array of attachment URLs or objects with url/name.\n\n**Voice memos:** a single audio file (`.mp3`, `.m4a`, `.wav`, `.aac`, `.opus`, `.ogg`) is automatically sent as a voice memo (the native waveform/scrubber bubble), not a plain audio-file attachment — no extra field is needed. A voice memo is a standalone bubble, so it cannot be combined with `text` or any other attachment; send the voice memo and the text as two separate messages."},"use_typing_indicator":{"type":"boolean","description":"Whether to show typing indicator before sending. Defaults to org preference."},"from_number":{"type":"string","description":"E.164 phone number to send from. For Twilio API keys, this is optional — if omitted, the first assigned Twilio number is auto-selected. For Blooio (iMessage) API keys, this selects a specific number from your pool. Must be a number assigned to your API key."},"share_contact":{"type":"boolean","description":"If true, the contact card (Name & Photo) will be shared with this message. The contact card is piggybacked onto the outgoing message. Defaults to false. ⚠️ Only available on **Dedicated Commercial** and **Dedicated Enterprise** plans — other plans receive a `403`.","default":false},"parts":{"type":"array","description":"Ordered array of message parts. Two modes:\n\n  1. **Multipart mode** — parts sent as a single unified iMessage bubble (mix of text and attachment parts). This is the default.\n  2. **URL-balloon batch mode** — triggered when any part has a `link_preview` object. Each part becomes its own rich-link-preview iMessage; parts are sent sequentially in array order. In batch mode every part must be text-only with `text` being a single http(s) URL. Response contains `message_ids[]` + `count` instead of `message_id`.","items":{"type":"object","properties":{"text":{"type":"string","description":"Text content for this part. Mutually exclusive with 'url'."},"mention":{"type":"string","description":"Participant phone number or email to @-mention. Only valid with 'text'. The entire text of the part is rendered as the mention."},"url":{"type":"string","description":"URL to an attachment for this part. Mutually exclusive with 'text'."},"name":{"type":"string","description":"Filename for the attachment. Only valid with 'url'."},"link_preview":{"nullable":true,"description":"Optional. Per-part rich-link-preview override. When any part carries this, every part must be a text-only single-URL part (URL-balloon batch mode).","allOf":[{"$ref":"#/components/schemas/LinkPreview"}]}}}},"link_preview":{"nullable":true,"description":"Optional. Override the rich-link-preview image and/or title on URL messages. See the LinkPreview schema. When omitted, Blooio auto-generates the preview from the page's Open Graph tags.","allOf":[{"$ref":"#/components/schemas/LinkPreview"}]},"effect":{"type":"string","nullable":true,"enum":["slam","loud","gentle","invisible-ink","echo","spotlight","balloons","confetti","love","lasers","fireworks","celebration","none"],"description":"Optional. Attach an iMessage send-with-effect to the outgoing message.\n\n**Bubble effects** (apply to a single text bubble):\n- `slam` — Slam\n- `loud` — Loud\n- `gentle` — Gentle\n- `invisible-ink` — Invisible Ink\n\n**Screen effects** (full-screen animation in the recipient's chat):\n- `echo` — Echo\n- `spotlight` — Spotlight\n- `balloons` — Balloons\n- `confetti` — Confetti\n- `love` — Love (heart)\n- `lasers` — Lasers\n- `fireworks` — Fireworks\n- `celebration` — Celebration (sparkles)\n\nValues are case-insensitive and accept either dashes or spaces (`\"Invisible Ink\"` and `\"invisible-ink\"` both work). Pass `\"none\"` or omit the field to send without an effect.\n\n**Limitations:**\n- iMessage-only — when the chat is delivered as SMS or RCS the message is sent without an animation.\n- Not supported alongside the `parts` array (multipart bubbles cannot carry an effect). Use the top-level `text` field instead.\n- When `text` is an array, every message in the array is sent with the same effect."},"reply_to":{"allOf":[{"$ref":"#/components/schemas/ReplyToRequest"}],"nullable":true,"description":"Optional. Send this message as an iMessage inline reply targeting a specific earlier message. iMessage-only — rejected on Twilio and multi-message fan-outs (`text` array or URL-balloon batch)."}}},"LinkPreview":{"type":"object","description":"Rich-link-preview overrides for URL messages (iMessage URL balloon). All fields are optional. Only applies when the message text (or the concatenated part text) is exactly a single http(s) URL. If omitted but the text is a URL, Blooio auto-fetches the page's Open Graph metadata to generate a preview. If the image download fails, the send still succeeds — Blooio silently falls back to the auto-generated preview.","properties":{"image_url":{"type":"string","format":"uri","description":"HTTPS URL to an image (png, jpg, webp, gif). Blooio downloads the image server-side and attaches it as the rich-link hero. Max 16 MB. If the download fails or returns a non-image MIME, the send falls back to auto-fetched OG metadata."},"title":{"type":"string","maxLength":200,"description":"Bold title line rendered in the iMessage bubble. Overrides the page's `<meta property=\"og:title\">`."}}},"SendMessageResponse":{"type":"object","description":"Response after sending a message","properties":{"message_id":{"type":"string","description":"ID of the sent message (single-message sends)"},"message_ids":{"type":"array","items":{"type":"string"},"description":"IDs of sent messages. Present when `text` is an array or when `parts` uses per-part `link_preview` (URL-balloon batch mode)."},"count":{"type":"integer","description":"Number of messages sent. Only present in URL-balloon batch mode."},"status":{"type":"string","enum":["queued","failed"],"description":"Initial status of the message(s). `queued` = accepted for delivery (the normal 202 result); `failed` = rejected before dispatch. Subsequent transitions (`sent` → `delivered`, or `failed`) are reported via the status endpoint and `message.status` webhooks."},"group_id":{"type":"string","description":"Group ID when sending to multi-recipient (new or existing)"},"group_created":{"type":"boolean","description":"True if a new unnamed group was created for this multi-recipient message"},"participants":{"type":"array","items":{"type":"string"},"description":"List of participants (present for multi-recipient)"},"parent_unresolved":{"type":"boolean","description":"Present (and `true`) only when `reply_to.guid` was supplied without a `message_id` and the GUID didn't map to any Blooio-minted row. The send still proceeds and the device may still thread it; this flag signals that Blooio couldn't link the new message to a known parent."}}},"MessageStatus":{"type":"object","properties":{"message_id":{"type":"string"},"chat_id":{"type":"string"},"direction":{"type":"string","enum":["inbound","outbound"]},"status":{"type":"string","description":"Delivery lifecycle state. `pending` = persisted and being prepared for dispatch; `queued` = accepted and waiting to be handed to Apple/the carrier; `sent` = handed off to Apple/the carrier (protocol resolution happens around here); `delivered` = a delivery receipt was received; `failed` = could not be delivered (see `error`); `cancellation_requested` = a cancel was requested for a still-queued message (best-effort); `cancelled` = cancelled before dispatch. Inbound messages are surfaced via webhooks with `received`; read receipts arrive as a `read` event.","enum":["pending","queued","sent","delivered","failed","cancellation_requested","cancelled"],"nullable":true},"protocol":{"type":"string","description":"Transport used to carry the message; never null. `pending` = accepted and dispatched, wire service not resolved yet (settles within seconds of send); `imessage` = delivered over iMessage (blue bubble); `rcs` = delivered over RCS; `sms` = fell back to SMS/MMS (green bubble); `unknown` = accepted by the carrier but the wire service could not be resolved before the tracking window closed (see `error`).","enum":["pending","unknown","imessage","sms","rcs"]},"time_sent":{"type":"integer","format":"int64"},"time_delivered":{"type":"integer","format":"int64","nullable":true},"error":{"type":"string","nullable":true}}},"TypingResponse":{"type":"object","properties":{"chat_id":{"type":"string","description":"Chat identifier"},"typing":{"type":"boolean","description":"Whether typing indicator is active"},"started_at":{"type":"integer","format":"int64","description":"Timestamp when typing started (only for start)"},"stopped_at":{"type":"integer","format":"int64","description":"Timestamp when typing stopped (only for stop)"},"warning":{"type":"string","description":"Present when the request was accepted but the indicator could not be delivered. The most common reason is that the chat last routed via RCS, which does not carry composing state.","example":"RCS chats do not support composing indicators"}}},"ReadResponse":{"type":"object","properties":{"chat_id":{"type":"string","description":"Chat identifier"},"status":{"type":"string","enum":["read"],"description":"Read status"},"marked_at":{"type":"integer","format":"int64","description":"Timestamp when marked as read"}}},"ReactionRequest":{"type":"object","required":["reaction"],"properties":{"reaction":{"type":"string","description":"The reaction to add or remove. Must be prefixed with `+` to add or `-` to remove.\n\n**Classic tapbacks:** `+love`, `-love`, `+like`, `-like`, `+dislike`, `-dislike`, `+laugh`, `-laugh`, `+emphasize`, `-emphasize`, `+question`, `-question`\n\n**Emoji reactions:** Any emoji prefixed with `+` or `-` (e.g. `+😂`, `-😂`, `+👍`, `-🔥`).","examples":["+love","-like","+😂","-🔥"]},"direction":{"type":"string","enum":["inbound","outbound"],"description":"Filter by message direction (only used when messageId is a relative index like -1, -2)"}}},"ReactionResponse":{"type":"object","properties":{"success":{"type":"boolean","description":"Whether the reaction was sent successfully"},"message_id":{"type":"string","description":"The ID of the message that was reacted to"},"reaction":{"type":"string","description":"The reaction that was added or removed. For classic tapbacks: love, like, dislike, laugh, emphasize, question. For emoji reactions: the emoji character (e.g. 😂, 👍, 🔥).","examples":["love","like","😂","👍"]},"action":{"type":"string","enum":["add","remove"],"description":"The action that was performed"}}}}}}