# Business Portfolio Canonical: https://docs.bluehola.com/docs/assets-phone-numbers/business-portfolios OpenAPI: https://docs.bluehola.com/openapi.yaml # Business Portfolio A Business Portfolio belongs to a [customer entity](customer-entities.md) and contains WABAs and phone numbers. For [Customer Onboarding](../guides/customer-onboarding.md), first create the local record, then use its `bm_...` ID for an invitation or a direct authorization submission. A customer Key can create its own record; `metaBmId` is bound after Meta authorization. | Endpoint | Purpose | | --- | --- | | [List Portfolios](get-v1-business-portfolios.md) | The Portfolios within the current API Key's authorization scope. | | [Create Portfolio](post-v1-business-portfolios.md) | Create the local onboarding record and obtain `portfolioId`. | | [Portfolio Details](get-v1-business-portfolios-id.md) | Details and ownership relationships for a single Portfolio. | To rename, reassign or delete a Portfolio, or to link a Meta Pixel to it, contact BlueMedia support. --- # Customer Entities Canonical: https://docs.bluehola.com/docs/assets-phone-numbers/customer-entities OpenAPI: https://docs.bluehola.com/openapi.yaml # Customer Entities A customer entity groups one or more Business Portfolios within a business unit (BU). It is also the authorization boundary for newly issued customer API Keys, which can operate across the entity’s current Business Portfolios. The ownership chain is **customer entity → Business Portfolio → WABA → phone number**. | Endpoint | Purpose | | --- | --- | | [Customer Entity Details](get-v1-customer-entities-id.md) | Read your own customer entity. | A customer API Key's customer entity is already assigned: use the `customerEntityId` from `GET /whoami`. Use it to filter [Portfolios](get-v1-business-portfolios.md), [WABAs](get-v1-wabas.md) and [phone numbers](get-v1-phone-numbers.md). You can [create your own Portfolio](post-v1-business-portfolios.md) with only `name` and continue onboarding without creating another customer entity. --- # Portfolio Details Canonical: https://docs.bluehola.com/docs/assets-phone-numbers/get-v1-business-portfolios-id OpenAPI: https://docs.bluehola.com/openapi.yaml
GET/v1/business-portfolios/{id}
Get Portfolio details. :::note[Authentication] Send `Authorization: Bearer ` in the request headers. Which resources an API Key can reach is determined by its current authorization scope. ::: ## Request Base URL: `https://api.bluehola.com` ### Parameters | Name | In | Required | Type / constraints | Description | | --- | --- | --- | --- | --- | | `id` | path | Yes | string | The platform's Business Portfolio ID, `bm_...` | ## Response | Status | Description | | --- | --- | | `200` | OK | | `4xx` | Client error | ### 200 response schema ```json { "$ref": "#/components/schemas/BusinessPortfolio" } ``` For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md). ## Notes There is no cross-account visibility — queries are scoped to the current credential's tenant context only (enforced by RLS). A lookup that cannot find the resource always returns 404, without distinguishing "this id does not exist at all" from "this id exists but belongs to another account", so that error-code differences cannot be used to probe whether someone else owns a given resource id. --- # List Portfolios Canonical: https://docs.bluehola.com/docs/assets-phone-numbers/get-v1-business-portfolios OpenAPI: https://docs.bluehola.com/openapi.yaml
GET/v1/business-portfolios
List the Business Portfolios the current API Key can access. :::note[Authentication] Send `Authorization: Bearer ` in the request headers. Which resources an API Key can reach is determined by its current authorization scope. ::: ## Request Base URL: `https://api.bluehola.com` ### Parameters | Name | In | Required | Type / constraints | Description | | --- | --- | --- | --- | --- | | `customerEntityId` | query | For customer Keys | string | Use your own `cust_...` from `GET /whoami`; optional for other API Keys. | ## Response | Status | Description | | --- | --- | | `200` | OK | | `4xx` | Client error | ### 200 response schema ```json { "type": "array", "items": { "$ref": "#/components/schemas/BusinessPortfolio" } } ``` For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md). ## Notes Only returns Business Portfolios within the current API Key's authorization scope. The caller cannot widen visibility through query parameters; resources it cannot access, or that do not exist, are never revealed through this endpoint. For a customer Key, `customerEntityId` is required and must equal the value returned by `GET /whoami`; omitting it or using another customer returns `403`. HTTP 200 with `[]` is normal before the first onboarding. [Create a Portfolio](post-v1-business-portfolios.md) with only `name`, then follow [Customer Onboarding](../guides/customer-onboarding.md). --- # Customer Entity Details Canonical: https://docs.bluehola.com/docs/assets-phone-numbers/get-v1-customer-entities-id OpenAPI: https://docs.bluehola.com/openapi.yaml
GET/v1/customer-entities/{id}
Read one customer entity. :::note[Authentication] Send `Authorization: Bearer `. Access is limited to the current API Key authorization scope. ::: ## Request Base URL: `https://api.bluehola.com` ### Parameters | Name | In | Required | Description | | --- | --- | --- | --- | | `id` | path | Yes | The customer entity platform ID, `cust_...`. | ## Response | Status | Description | | --- | --- | | `200` | OK | | `4xx` | Client error | ```json { "$ref": "#/components/schemas/CustomerEntity" } ``` For the common error envelope, see [Error Codes](../guides/error-codes.md). ## Notes A missing entity and an entity outside the current BU both return 404. --- # Get Registration Status Canonical: https://docs.bluehola.com/docs/assets-phone-numbers/get-v1-phone-numbers-id-registration-status OpenAPI: https://docs.bluehola.com/openapi.yaml
GET/v1/phone-numbers/{id}/registration-status
Get the Meta registration, name, quality and two-step verification status. :::note[Authentication] Send `Authorization: Bearer ` in the request headers, with the required scope `phone_numbers:read`. Which resources an API Key can reach is determined by its current authorization scope. ::: ## Request Base URL: `https://api.bluehola.com` ### Parameters | Name | In | Required | Type / constraints | Description | | --- | --- | --- | --- | --- | | `id` | path | Yes | string | Platform-scoped phone number ID, `pn_...` | ## Response | Status | Description | | --- | --- | | `200` | OK | | `4xx` | Client error | For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md). ## Notes Calls the Meta Graph API live to read this number's fields. Returns 409 if the Business Portfolio this number belongs to has not completed Meta authorization, or that authorization has expired. --- # Phone Number Details Canonical: https://docs.bluehola.com/docs/assets-phone-numbers/get-v1-phone-numbers-id OpenAPI: https://docs.bluehola.com/openapi.yaml
GET/v1/phone-numbers/{id}
Get phone number details. :::note[Authentication] Send `Authorization: Bearer ` in the request headers. Which resources an API Key can reach is determined by its current authorization scope. ::: ## Request Base URL: `https://api.bluehola.com` ### Parameters | Name | In | Required | Type / constraints | Description | | --- | --- | --- | --- | --- | | `id` | path | Yes | string | Platform-scoped phone number ID, `pn_...` | ## Response | Status | Description | | --- | --- | | `200` | OK | | `4xx` | Client error | ### 200 response schema ```json { "$ref": "#/components/schemas/PhoneNumber" } ``` For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md). ## Notes As above: reads the local snapshot, does not query Meta live. --- # List Phone Numbers Canonical: https://docs.bluehola.com/docs/assets-phone-numbers/get-v1-phone-numbers OpenAPI: https://docs.bluehola.com/openapi.yaml
GET/v1/phone-numbers
List phone numbers, optionally filtered by WABA, Business Portfolio or customer entity. :::note[Authentication] Send `Authorization: Bearer ` in the request headers. Which resources an API Key can reach is determined by its current authorization scope. ::: ## Request Base URL: `https://api.bluehola.com` ### Parameters | Name | In | Required | Type / constraints | Description | | --- | --- | --- | --- | --- | | `wabaId` | query | No | string | Filter by WABA (`waba_...`). | | `portfolioId` | query | No | string | Filter by Business Portfolio (`bm_...`). | | `customerEntityId` | query | No | string | Filter by customer entity (`cust_...`). | ## Response | Status | Description | | --- | --- | | `200` | OK | | `4xx` | Client error | ### 200 response schema ```json { "type": "array", "items": { "$ref": "#/components/schemas/PhoneNumber" } } ``` For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md). ## Notes This is a local snapshot; use registration-status for live Meta status. All three filters are optional, and an empty string means no filter. Multiple filters intersect. Business Portfolio and customer entity filters follow the number’s WABA’s current ownership, so reassignment changes the results. --- # Get WABA Usage Analytics Canonical: https://docs.bluehola.com/docs/assets-phone-numbers/get-v1-wabas-id-analytics OpenAPI: https://docs.bluehola.com/openapi.yaml
GET/v1/wabas/{id}/analytics
Query this WABA's usage/cost analytics directly from Meta, as a cross-check against the local ledger usage view. The messaging and pricing fields are requested and reported independently: the response is { messaging: {ok, data|error}, pricing: {ok, data|error} }, so if one is rejected by Meta the other still returns data, with Meta's raw code/subcode in the error. Note that pricing's COST is not returned for WABAs sharing a Solution Partner credit line. :::note[Authentication] Send `Authorization: Bearer ` in the request headers, with the required scope `billing:read`. Which resources an API Key can reach is determined by its current authorization scope. ::: ## Request Base URL: `https://api.bluehola.com` ### Parameters | Name | In | Required | Type / constraints | Description | | --- | --- | --- | --- | --- | | `id` | path | Yes | string | The platform WABA ID, `waba_...` | | `start` | query | Yes | unix timestamp | Start of the reporting period (seconds). **Required**; returns `400 VALIDATION_FAILED` if it cannot be parsed as a number | | `end` | query | Yes | unix timestamp | End of the reporting period (seconds). **Required**; returns `400 VALIDATION_FAILED` if it cannot be parsed as a number | | `granularity` | query | No | `HALF_HOUR` \| `DAY` \| `MONTH` | Defaults to `DAY`; other values do not error, they are always treated as `DAY` | | `phoneNumbers` | query | No | string | A comma-separated list of **Meta phone number ids** (digits only, 1–32 characters per segment), to filter by number. Returns `400 VALIDATION_FAILED` if it contains any non-digit characters | ## Response | Status | Description | | --- | --- | | `200` | OK | | `4xx` | Client error | For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md). ## Notes #### Parameter validation - `start`/`end`: must parse to a finite unix timestamp; parsing failure is a straight 400. - `granularity`: only `HALF_HOUR` and `MONTH` are strictly accepted as non-default values — any other value (including omitting it) **silently falls back to `DAY`**. The endpoint will not correct a typo for you; you need to confirm the value yourself. - `phoneNumbers`: strictly validated as digits only (each number id up to 32 characters). These values are interpolated directly into the field-filter expression sent to the Meta Graph API (of the form `.phone_numbers(id1,id2)`); unsanitised input could in principle use `)` or `.` to break out of the filter and rewrite the whole expression — this validation is not an optional robustness check, it is an injection gate. #### Meta authorization state The service automatically selects whichever saved, usable Meta authorization it has. If that Business Portfolio has not completed Meta authorization, or its authorization has expired, this returns **409 rather than 404** — the problem is not "this WABA doesn't exist", it is that the platform currently cannot query Meta on the customer's behalf. --- # Get WABA Details Canonical: https://docs.bluehola.com/docs/assets-phone-numbers/get-v1-wabas-id OpenAPI: https://docs.bluehola.com/openapi.yaml
GET/v1/wabas/{id}
Get WABA details. :::note[Authentication] Send `Authorization: Bearer ` in the request headers. Which resources an API Key can reach is determined by its current authorization scope. ::: ## Request Base URL: `https://api.bluehola.com` ### Parameters | Name | In | Required | Type / constraints | Description | | --- | --- | --- | --- | --- | | `id` | path | Yes | string | The platform WABA ID, `waba_...` | ## Response | Status | Description | | --- | --- | | `200` | OK | | `4xx` | Client error | ### 200 response schema ```json { "$ref": "#/components/schemas/Waba" } ``` For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md). ## Notes Queries are scoped strictly to the current account context (RLS plus an explicit filter, doubly enforced); anything that does not exist or does not belong to the current account returns 404, without revealing whether that id actually exists under a different account. This returns the local record. --- # List WABAs Canonical: https://docs.bluehola.com/docs/assets-phone-numbers/get-v1-wabas OpenAPI: https://docs.bluehola.com/openapi.yaml
GET/v1/wabas
List WABAs, optionally filtered by Business Portfolio or customer entity. :::note[Authentication] Send `Authorization: Bearer ` in the request headers. Which resources an API Key can reach is determined by its current authorization scope. ::: ## Request Base URL: `https://api.bluehola.com` ### Parameters | Name | In | Required | Type / constraints | Description | | --- | --- | --- | --- | --- | | `portfolioId` | query | No | string | Filter by Business Portfolio (`bm_...`). | | `customerEntityId` | query | No | string | Filter by customer entity (`cust_...`). | ## Response | Status | Description | | --- | --- | | `200` | OK | | `4xx` | Client error | ### 200 response schema ```json { "type": "array", "items": { "$ref": "#/components/schemas/Waba" } } ``` For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md). ## Notes Both filters are optional. An empty string has the same effect as omitting a filter. When both are supplied, the results must match both. `customerEntityId` follows the WABA’s Business Portfolio’s current customer entity, so reassignment changes the results. --- # Phone Number Records Canonical: https://docs.bluehola.com/docs/assets-phone-numbers/phone-numbers OpenAPI: https://docs.bluehola.com/openapi.yaml # Phone Number Records Reading a phone number's local record on the platform side. Two data sources need to be kept distinct: | Endpoint | Data source | | --- | --- | | `GET /v1/phone-numbers` / `{id}` | **Local snapshot** (from the last sync), does not reach Meta, and may lag. | | Endpoints under [Registration & Verification](phone-registration.md) | Call the Meta Graph API live. | | Endpoint | Purpose | | --- | --- | | [List Phone Numbers](get-v1-phone-numbers.md) | Numbers within the current authorization scope. | | [Phone Number Details](get-v1-phone-numbers-id.md) | The local snapshot for a single number. | To add, remove or deactivate a phone number, contact BlueMedia support. For the full lifecycle, see [Phone Number Registration & Lifecycle](../guides/phone-numbers.md). --- # Registration & Verification Canonical: https://docs.bluehola.com/docs/assets-phone-numbers/phone-registration OpenAPI: https://docs.bluehola.com/openapi.yaml # Registration & Verification This group of endpoints calls the Meta Graph API live. | Endpoint | Purpose | | --- | --- | | [Get Registration Status](get-v1-phone-numbers-id-registration-status.md) | Read Meta-side registration status, name review, quality rating and two-step verification state live. | | [Register Phone Number](post-v1-phone-numbers-id-register.md) | Register with the Cloud API using a 6-digit PIN. | Ownership verification, deregistration, two-step verification PIN changes and display name changes are handled by BlueMedia; contact BlueMedia support when you need one of them. :::warning **At most 10 register/deregister requests in 72 hours** (a Meta-side rule). Exceeding it makes Meta return error code 133016 and blocks that number's registration capability for 72 hours. Do not register the same number over and over while debugging your onboarding flow. ::: Two things that catch people out: `register`'s `pin` carries two meanings (on first registration it "sets the PIN"; once two-step verification is enabled it is the "existing PIN" — Meta does not distinguish the two); once a display name review passes you **must call register again within 14 days** for the new name to actually sync to WhatsApp's servers. See [Phone Number Registration & Lifecycle](../guides/phone-numbers.md) for details. --- # Create Portfolio Canonical: https://docs.bluehola.com/docs/assets-phone-numbers/post-v1-business-portfolios OpenAPI: https://docs.bluehola.com/openapi.yaml
POST/v1/business-portfolios
Create a BlueHola onboarding record; a customer Key automatically assigns it to its own customer entity. :::note[Authentication] Send `Authorization: Bearer `. A customer Key needs `onboarding:write` to create a record for its own customer entity. ::: ## Request Base URL: `https://api.bluehola.com` ### Request body fields | Field | Type | Required | Description | | --- | --- | --- | --- | | `customerEntityId` | string | Conditional | Customer Keys may omit it; when supplied, it must be their own `cust_...`. Other API Keys must supply an accessible customer entity. | | `name` | string | Yes | Business Portfolio name. | | `metaBmId` | string | No | Numeric Meta Business Portfolio ID. Customer Keys must omit this field; authorization binds it later. | ```bash curl -X POST "https://api.bluehola.com/v1/business-portfolios" \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "name": "Example Company" }' ``` ## Response ```json title="201 Created (excerpt)" { "id": "bm_01923abc", "name": "Example Company", "customerEntityId": "cust_01923abc", "metaBmId": null } ``` Use `id` as `portfolioId` when [creating an invitation](../onboarding/post-v1-onboarding-invitations.md) or [submitting a Meta authorization result](../onboarding/post-v1-onboarding-embedded-signup.md). These routes require an existing local record; neither creates it implicitly. ## Ownership and Meta binding A customer Key cannot choose another customer (`403 TENANT_FORBIDDEN`) or prefill `metaBmId` (`400 VALIDATION_FAILED`). The record starts with `metaBmId: null`. After Meta authorization, the backend verifies the WABA grant and binds the owner ID read from Meta. The internal `bm_...` ID and numeric Meta ID are different fields; creating this record alone does not create or authorize Meta assets. For other API Keys, `customerEntityId` is required and must belong to the current authorization scope; `metaBmId` remains optional. See [Customer Onboarding](../guides/customer-onboarding.md) for the complete self-service flow and [Error Codes](../guides/error-codes.md) for common errors. --- # Register Phone Number with a 6-Digit PIN Canonical: https://docs.bluehola.com/docs/assets-phone-numbers/post-v1-phone-numbers-id-register OpenAPI: https://docs.bluehola.com/openapi.yaml
POST/v1/phone-numbers/{id}/register
Register the phone number using a 6-digit PIN. :::note[Authentication] Send `Authorization: Bearer ` in the request headers, with the required scope `phone_numbers:manage`. Which resources an API Key can reach is determined by its current authorization scope. ::: ## Request Base URL: `https://api.bluehola.com` ### Parameters | Name | In | Required | Type / constraints | Description | | --- | --- | --- | --- | --- | | `id` | path | Yes | string | Platform-scoped phone number ID, `pn_...` | ### Request body A request body is required. ### Request body fields | Field | Type | Required | Description | | --- | --- | --- | --- | | `pin` | string | Yes | 6 digits | Content-Type: `application/json` Schema: ```json { "type": "object", "properties": { "pin": { "type": "string", "description": "string · required — 6 digits" } }, "required": [ "pin" ] } ``` ## Response | Status | Description | | --- | --- | | `200` | OK | | `4xx` | Client error | For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md). ## Notes `pin` carries a dual meaning: it is both "the two-step verification PIN being set on first registration" and "the existing PIN when the number already has two-step verification enabled" — Meta does not distinguish the two cases. #### Preconditions This endpoint does **not** check whether request-code/verify-code have been completed: - A number already verified in WhatsApp Manager → can be registered directly. - Calling register directly on a number with unverified ownership → rejected by Meta (go through request-code/verify-code first). #### Rate limit At most 10 registration requests in 72 hours (a Meta-side rule); exceeding it blocks that number's registration capability for 72 hours. On success the local state is hard-coded to connected, without parsing Meta's response body for confirmation. #### Registering again after a display name is approved After a new display name is approved, you must call this endpoint for the new name to reach WhatsApp users — within 14 days of approval, or the name has to be submitted for review again. Once registration succeeds, the platform refreshes the number from Meta automatically, so `GET /v1/phone-numbers/{id}` returns the new name right away. If that refresh fails, the registration result is unaffected. #### Customer Keys Customer Keys can call this endpoint, but only for phone numbers their customer entity currently owns; any other number returns `403`. The rest of the lifecycle group — deregister, request-code, verify-code and two-step-pin — is not open to customer Keys. --- # WhatsApp Business Account (WABA) Canonical: https://docs.bluehola.com/docs/assets-phone-numbers/wabas OpenAPI: https://docs.bluehola.com/openapi.yaml # WhatsApp Business Account (WABA) A WABA sits under a Business Portfolio, and phone numbers sit under a WABA. | Endpoint | Purpose | | --- | --- | | [List WABAs](get-v1-wabas.md) | WABAs within the current authorization scope. | | [WABA Details](get-v1-wabas-id.md) | Details of a single WABA. | Marketing templates use Meta’s Marketing Messages API. The WABA response includes `marketingMessagesStatus` and `marketingMessagesCheckedAt`; the status is informational and does not control the send route. Credit line authorization, Marketing Messages onboarding, renaming and deleting a WABA are handled by BlueMedia; contact BlueMedia support when you need one of them. For how messages are charged, see [Billing & Credit Line](../guides/billing.md). --- # Verify API Key Canonical: https://docs.bluehola.com/docs/authentication/get-whoami OpenAPI: https://docs.bluehola.com/openapi.yaml
GET/whoami
Verify an API Key and return the current account identifier and API service version. :::note[Authentication] Send `Authorization: Bearer ` in the request headers. Which resources an API Key can reach is determined by its current authorization scope. ::: ## Request Base URL: `https://api.bluehola.com` ## Response | Status | Description | | --- | --- | | `200` | OK | | `4xx` | Client error | ### 200 response schema ```json { "type": "object", "additionalProperties": true, "required": [ "tenantId", "customerEntityId", "platformVersion" ], "properties": { "tenantId": { "type": "string", "description": "The account identifier this API Key belongs to" }, "customerEntityId": { "type": ["string", "null"], "description": "The customer entity ID bound to a customer API Key; null for other credentials. Use it to filter Business Portfolio, WABA and phone number lists." }, "platformVersion": { "type": "string", "description": "The API process version that handled this request" } } } ``` For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md). ## Notes This is a side-effect-free credential check. `tenantId` confirms which account the current API Key belongs to, and `platformVersion` indicates only the current API process version. The response may carry additional diagnostic fields; customer integrations should not rely on them to make authorization decisions. For customer Keys, `customerEntityId` identifies the customer entity to pass when listing Business Portfolios, WABAs or phone numbers. It is `null` for other credentials. --- # OAuth Token Endpoint Canonical: https://docs.bluehola.com/docs/authentication/post-oauth-token OpenAPI: https://docs.bluehola.com/openapi.yaml
POST/oauth/token
The OAuth token endpoint, supporting authorization_code and refresh_token. :::note[Authentication] This endpoint does not require an API Key. ::: ## Request Base URL: `https://api.bluehola.com` ### Request body A request body is required. ### Request body fields | Field | Type | Required | Description | | --- | --- | --- | --- | | `grant_type` | string | Yes | `authorization_code` or `refresh_token` | | `client_id` | string | Yes | | | `client_secret` | string | Yes | This *is* the client authentication method — which is why this endpoint carries **no API Key auth** | | `code` | string | No | Required when grant_type=authorization_code | | `redirect_uri` | string | No | Required when grant_type=authorization_code, and must match the one used at issue time **character for character** (RFC 6749 §4.1.3) | | `code_verifier` | string | No | **Required** if a code_challenge was sent during authorization, otherwise 400 — allowing it to be omitted would let anyone who intercepts a code bypass the whole of PKCE simply by not sending it | | `refresh_token` | string | No | Required when grant_type=refresh_token | Content-Type: `application/json` Schema: ```json { "type": "object", "properties": { "grant_type": { "type": "string", "description": "string · required — `authorization_code` or `refresh_token`" }, "client_id": { "type": "string", "description": "string · required — " }, "client_secret": { "type": "string", "description": "string · required — This *is* the client authentication method — which is why this endpoint carries **no API Key auth**" }, "code": { "type": "string", "description": "string · optional — Required when grant_type=authorization_code" }, "redirect_uri": { "type": "string", "description": "string · optional — Required when grant_type=authorization_code, and must match the one used at issue time **character for character** (RFC 6749 §4.1.3)" }, "code_verifier": { "type": "string", "description": "string · optional — **Required** if a code_challenge was sent during authorization, otherwise 400 — allowing it to be omitted would let anyone who intercepts a code bypass the whole of PKCE simply by not sending it" }, "refresh_token": { "type": "string", "description": "string · optional — Required when grant_type=refresh_token" } }, "required": [ "grant_type", "client_id", "client_secret" ] } ``` ## Response | Status | Description | | --- | --- | | `200` | OK | | `4xx` | Client error | ### 200 response schema ```json { "$ref": "#/components/schemas/OAuthTokenResponse" } ``` For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md). ## Notes #### Response `access_token`, `refresh_token`, `token_type: Bearer`, `expires_in` (seconds), `scope`, `account_id`, `project_id`, `connection_id`. #### Lifetimes and rotation Access tokens last **1 hour**, refresh tokens **30 days**. Every refresh **rotates** them: the old pair is revoked immediately and a brand-new pair is issued. This is not for convenience — if a refresh token leaks, rotation means only one of the attacker and the real client can keep using it, and the other one's next refresh failing is your signal that something is wrong. Renewing the same row in place would leave the leaked copy usable forever, with no trace. #### Failure semantics An authorization code that does not exist, has already been used, or has expired returns **the same message** in all three cases, deliberately undifferentiated — distinguishing them would turn this endpoint into a probe for code state. The code is consumed with a single conditional UPDATE (`WHERE used_at IS NULL AND expires_at > now()`, judged by the database clock) rather than a read followed by a write: two concurrent requests would both pass the read and each obtain a token, and authorization code replay is the most classic OAuth attack there is. #### Calling business endpoints with an access token `Authorization: Bearer oat_...`, using the same header as an API Key. An access token's reach is fixed to the Business Portfolio chosen at authorization time; it cannot be widened through request parameters, and it cannot reach another customer's assets. --- # Pipeline Backlog Check Canonical: https://docs.bluehola.com/docs/billing-status/get-health-pipeline OpenAPI: https://docs.bluehola.com/openapi.yaml
GET/health/pipeline
Checks whether the sending pipeline is actually moving, by reading the age of the oldest backlog from the database. Meant for external probing. :::note[Authentication] This endpoint does not require an API Key. ::: ## Request Base URL: `https://api.bluehola.com` ## Response | Status | Description | | --- | --- | | `200` | OK — `status` is `ok` and every backlog item is inside its threshold. | | `503` | A backlog item is past its threshold (`status` is `degraded`, with the same response shape as `200`), or the check could not query the database. | | `4xx` | Client error | For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md). ### Response fields For `200` responses and `503` responses caused by a threshold breach, `status`, `checkedAt` and `checks` are required. `checks` requires `outbox`, `accepted` and `sending`; each of those objects requires `ok`, `oldestSeconds`, `pending` and `thresholdSeconds`. | Field | Type | Meaning | | --- | --- | --- | | `status` | string: `ok` or `degraded` | Always `ok` on `200`; `degraded` when any item is past its threshold. | | `checkedAt` | string (`date-time`) | When the check ran (ISO 8601). | | `checks` | object | The three backlog checks. | | `checks.outbox` / `checks.accepted` / `checks.sending` | object | One object per backlog item. | | `checks.*.ok` | boolean | Whether this item is inside its threshold. | | `checks.*.oldestSeconds` | number | Age of the oldest item in that state, in seconds; 0 when there is none. | | `checks.*.pending` | integer | How many items are in that state. | | `checks.*.thresholdSeconds` | number | The threshold this item is compared against. | ### 200 example ```json { "status": "ok", "checkedAt": "2026-11-18T08:00:00.000Z", "checks": { "outbox": { "ok": true, "oldestSeconds": 12, "pending": 2, "thresholdSeconds": 120 }, "accepted": { "ok": true, "oldestSeconds": 30, "pending": 4, "thresholdSeconds": 300 }, "sending": { "ok": true, "oldestSeconds": 45, "pending": 3, "thresholdSeconds": 600 } } } ``` ### 503 example (threshold exceeded) A threshold-related `503` returns the same fields as a `200`. `status` is `degraded`, and `ok` is `false` for each check that exceeded its threshold. ```json { "status": "degraded", "checkedAt": "2026-11-18T08:00:00.000Z", "checks": { "outbox": { "ok": false, "oldestSeconds": 185, "pending": 2, "thresholdSeconds": 120 }, "accepted": { "ok": true, "oldestSeconds": 30, "pending": 4, "thresholdSeconds": 300 }, "sending": { "ok": true, "oldestSeconds": 45, "pending": 3, "thresholdSeconds": 600 } } } ``` ## Notes This reads three ages from the database: the oldest unpublished `outbox` event, the oldest message still in `accepted`, and the oldest message still in `sending`. If any of them is past its threshold it returns **503** with each item's details; otherwise **200**. The defaults are 120s for the oldest unpublished outbox event, 300s for the oldest `accepted` message and 600s for the oldest `sending` message. Adjust them with `PIPELINE_OUTBOX_MAX_SECONDS`, `PIPELINE_ACCEPTED_MAX_SECONDS` and `PIPELINE_SENDING_MAX_SECONDS`. This is the probe to watch from outside, and to alert on when it returns 503. The readiness check only shows that the API itself can reach PostgreSQL and Redis: when the scheduler is stuck or the message worker stops consuming, `/ready` still returns 200 while customer messages sit in `accepted`. Measuring the backlog in the database is the only way to see that from outside. It is deliberately **not** folded into `/ready`. The deploy script uses `/ready` to decide whether a new API instance can take traffic; backlog is a worker or scheduler problem, and a new API instance should not be judged unhealthy — and its release failed — because of it. If the check itself cannot query the database, it returns **503** with `status` `error` and no `checks`. Treat that the same way: the pipeline state is unknown, so alarm on it. Only messages created in the last 6 hours are counted when looking at `accepted` and `sending` ages; older ones are handled by the send-outcome audit and reservation reconciliation tasks. The result is cached for 10 seconds, so a frequent probe does not query the database every time. --- # Liveness Check Canonical: https://docs.bluehola.com/docs/billing-status/get-live OpenAPI: https://docs.bluehola.com/openapi.yaml
GET/live
Process liveness check. :::note[Authentication] This endpoint does not require an API Key. ::: ## Request Base URL: `https://api.bluehola.com` ## Response | Status | Description | | --- | --- | | `200` | OK | | `4xx` | Client error | For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md). ## Notes This only checks that the process is alive; it always returns success and never reaches the database or Redis, so it cannot signal "the service can actually handle requests" — it only tells you whether the process is still running (used by container probes). --- # Readiness Check Canonical: https://docs.bluehola.com/docs/billing-status/get-ready OpenAPI: https://docs.bluehola.com/openapi.yaml
GET/ready
Readiness check for PostgreSQL and Redis. :::note[Authentication] This endpoint does not require an API Key. ::: ## Request Base URL: `https://api.bluehola.com` ## Response | Status | Description | | --- | --- | | `200` | OK | | `4xx` | Client error | For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md). ## Notes This checks both Postgres and Redis health in parallel and returns 503 if either is unhealthy; it is better suited than /live for deciding whether to admit traffic. --- # Message Usage & Prices Canonical: https://docs.bluehola.com/docs/billing-status/get-v1-usage-messages OpenAPI: https://docs.bluehola.com/openapi.yaml
GET/v1/usage/messages
Returns your own message volume over a recent window, grouped by message type, billing category, destination country and unit price. This is the customer-side finance view: it answers "how many messages went where, and what did each one cost". :::note[Authentication] Send `Authorization: Bearer ` in the request headers, with scope `messages:read`. This endpoint requires a **customer-level** API Key: the customer entity in scope comes from the Key, never from a request field. BU and platform-level API Keys receive `403`. ::: ## Request Base URL: `https://api.bluehola.com` ### Query parameters | Parameter | Type | Required | Description | | --- | --- | --- | --- | | `days` | `7` \| `30` \| `90` | No | Window length; defaults to `30`. Any other value returns `400`. | ```bash curl "https://api.bluehola.com/v1/usage/messages?days=30" \ -H "Authorization: Bearer " ``` ## Response | Status | Description | | --- | --- | | `200` | OK | | `403` | The Key is not a customer-level Key, or it has no customer entity binding | | `4xx` | Client error | For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md). ```json title="200 OK (example)" { "generatedAt": "2026-11-23T03:00:00.000Z", "windowDays": 30, "rows": [ { "type": "template", "category": "MARKETING", "country": "Brazil", "market": "Brazil", "currency": "USD", "unitPrice": "0.0625", "unitPriceMicros": 62500, "messageCount": 1200 }, { "type": "template", "category": "UTILITY", "country": "India", "market": "India", "currency": "USD", "unitPrice": "0.0014", "unitPriceMicros": 1400, "messageCount": 8400 } ] } ``` | Field | Type | Meaning | | --- | --- | --- | | `generatedAt` | string (`date-time`) | When the summary was generated. | | `windowDays` | integer: `7`, `30` or `90` | The window actually used. | | `rows` | array | One row per message type, billing category, destination country and unit price. | | `rows[].type` | string | Message type: `text`, `template`, `image`, and so on. | | `rows[].category` | string or `null` | Billing category (`MARKETING`, `UTILITY`, `AUTHENTICATION`, …). `null` for non-template messages. | | `rows[].country` | string or `null` | Destination country resolved from the recipient number. `null` when it cannot be resolved. | | `rows[].market` | string or `null` | The Meta billing market used for pricing. Some markets are regions, such as `Rest of Western Europe`, so this may differ from `country`. | | `rows[].currency` | string | Pricing currency, for example `USD`. | | `rows[].unitPrice` | string or `null` | The unit price charged for this message, as a decimal string. `"0"` for messages that were free. | | `rows[].unitPriceMicros` | integer or `null` | The same price in micros (1 unit = 1,000,000 micros). | | `rows[].messageCount` | integer | Number of messages in this group during the window. | ## Notes #### What is counted Only messages that have a pricing record are counted. A free message has no charge on the ledger, so counting from the ledger would silently drop entire categories of traffic; this view therefore counts priced messages, including those priced at `0`. #### Why the same country and type can appear more than once Volume-tier pricing can charge a different unit price for messages in the same country and category. Rows are grouped by the **actual unit price charged**, so merging them would produce an average that no message was actually billed at. Sum `messageCount` across rows if you only need the total volume. #### Ownership The customer entity is taken from the API Key. A customer Key sees only its own customer entity's messages, and a BU-level view is intentionally not available here — use the console for BU-wide reporting. --- # Service Health Probes Canonical: https://docs.bluehola.com/docs/billing-status/health OpenAPI: https://docs.bluehola.com/openapi.yaml # Service Health Probes Three probes for load balancers, container orchestration and monitoring systems. | Endpoint | Purpose | | --- | --- | | [Liveness Check](get-live.md) | Returns success as long as the process is alive; does not check dependencies. | | [Readiness Check](get-ready.md) | Additionally checks whether PostgreSQL and Redis are ready. | | [Pipeline Backlog Check](get-health-pipeline.md) | Reads from the database whether the sending pipeline is moving; returns 503 once the oldest unpublished outbox event, the oldest `accepted` message or the oldest `sending` message is past its threshold. | Use the readiness check to decide whether traffic can be admitted: passing the liveness check does not mean the dependencies are available. Use the pipeline backlog check to decide whether the platform is actually delivering: the readiness check still returns 200 when the scheduler is stuck or the message worker stops consuming, while every customer message sits in `accepted`. It is the one external probing should alert on, and it is deliberately kept out of the readiness check so a worker backlog never fails an API release. --- # Diagnose Customer Token Scopes Canonical: https://docs.bluehola.com/docs/business-verification/get-v1-business-portfolios-id-token-scopes OpenAPI: https://docs.bluehola.com/openapi.yaml
GET/v1/business-portfolios/{id}/token-scopes
Diagnose which scopes Meta granted to this Portfolio's customer Embedded Signup token (via debug_token). Used to determine whether an analytics/WABA status permission error is because the token is missing whatsapp_business_management or the platform's App is missing Advanced Access. Does not echo back the token itself. :::note[Authentication] Send `Authorization: Bearer ` in the request headers, with scope: `onboarding:read`. Which resources an API Key can reach is determined by its current authorization scope. ::: ## Request Base URL: `https://api.bluehola.com` ### Parameters | Name | In | Required | Type / constraints | Description | | --- | --- | --- | --- | --- | | `id` | path | Yes | string | The platform's Business Portfolio ID, `bm_...` | ## Response | Status | Description | | --- | --- | | `200` | OK | | `4xx` | Client error | For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md). ## Notes This depends on the platform's own App ID + App Secret being fully configured before it can call Meta's `debug_token` endpoint; when they are not configured, this diagnostic capability itself is unavailable and it returns 500 rather than an empty result meaning "this token has no scopes at all" — the two have entirely different meanings, and confusing them leads to misdiagnosing it as a customer authorization problem. Besides the top-level `scopes` array, the response also echoes `granularScopes` (which includes the specific `targetIds` each permission is bound to), because a permission such as `whatsapp_business_management` may on Meta's side be scoped to a specific range of WABA/business ids — looking only at the top-level scope list would miss the more subtle failure case of "this token does genuinely have this permission, but it does not cover the specific asset you are operating on". --- # Authentication & Scopes Canonical: https://docs.bluehola.com/docs/guides/authentication OpenAPI: https://docs.bluehola.com/openapi.yaml Except for the public endpoints (Meta callbacks and health checks), every request must carry `Authorization: Bearer `. Treat your API Key like a password: keep it out of front-end code, URLs, logs and ticket screenshots. ## What an API Key's authorization scope covers A customer API Key is bound to one customer entity and can access that entity’s current Business Portfolios, WABAs and phone numbers. One Key can therefore operate across multiple Business Portfolios owned by the same customer. Previously issued single-Portfolio Keys remain valid, but new single-Portfolio Keys are no longer issued. - Reaching for a resource outside the authorization scope returns `403` or `404`, without revealing whether the resource exists. - For `GET /v1/business-portfolios`, `GET /v1/wabas` and `GET /v1/phone-numbers`, a customer Key must explicitly pass its `customerEntityId` query parameter. Get this ID from `GET /whoami`. Other list endpoints that a customer Key must filter are marked in [Endpoints a customer Key can call](#customer-key-endpoints); every filter value must stay inside the current authorization scope. - An API Key's authorization scope is maintained server-side and cannot be widened through request parameters. - To change the authorization scope, add phone numbers or have a Key reissued, contact BlueMedia support. ## Endpoints a customer Key can call {#customer-key-endpoints} A customer Key can call only the endpoints below. Any other endpoint — for example the `GET /v1/messages` list, `/v1/credit-account/*`, credit-line authorization and `/v1/api-keys` — returns `403 TENANT_FORBIDDEN` (`customer-level keys cannot call …`) before the request is validated, whatever scopes the Key carries. The scope each endpoint requires still applies on top. | Area | Endpoints | Ownership is checked against | | --- | --- | --- | | Identity | `GET /whoami` | — | | Customer entity and assets | `GET /v1/customer-entities/{id}`; `GET /v1/business-portfolios`, `GET /v1/wabas`, `GET /v1/phone-numbers` (each requires `customerEntityId`); `GET /v1/business-portfolios/{id}` and `/token-scopes`; `GET /v1/wabas/{id}`; `GET /v1/phone-numbers/{id}` and `/registration-status`; `POST /v1/phone-numbers/{id}/register` | The ID in the path, or `customerEntityId` | | Self-service onboarding | `POST /v1/business-portfolios`; `GET /v1/onboarding/config`; `POST /v1/onboarding/embedded-signup`, `/es-events` and `/invitations`; `GET /v1/onboarding/embedded-signup` and `/invitations`; `GET /v1/onboarding/embedded-signup/{operationId}`; `POST /v1/onboarding/embedded-signup/{operationId}/retry`; `DELETE /v1/onboarding/invitations/{id}` | The Key’s customer entity, the submitted `portfolioId`, or the operation/invitation’s Portfolio; lists are filtered automatically | | Messages and media | `POST /v1/messages`, `POST /v1/messages/read`, `GET /v1/messages/{id}`, `POST /v1/media`, `GET /v1/media/{id}` and `/content` | `phoneNumberId`, the message's phone number, or the media's phone number (the uploading number, or the number that received an inbound media message) | | Templates and Flows | `GET /v1/templates` (requires `wabaId`), `POST /v1/templates`, `GET` / `PATCH` / `DELETE /v1/templates/{id}`, `POST /v1/templates/media`, `POST /v1/templates/sync`, `GET /v1/templates/analytics`, `POST /v1/templates/analytics/enable`, `GET /v1/flows` (requires `wabaId`), `GET /v1/flows/{id}` (requires `wabaId`) | `wabaId`, or the template's WABA | | Broadcasts | `POST /v1/broadcasts`, `GET /v1/broadcasts` (requires `phoneNumberId`), `GET /v1/broadcasts/{id}` and `/recipients`, `POST /v1/broadcasts/{id}/pause` / `resume` / `cancel` | `phoneNumberId`, or the campaign's sending number | | Inbox | `GET /v1/conversations` (requires `phoneNumberId`), `GET /v1/conversations/{id}`, `POST /v1/conversations/{id}/read` | `phoneNumberId`, or the conversation's business number | | Webhooks | `POST /v1/webhook-endpoints` (requires `customerId`), `GET /v1/webhook-endpoints` (requires `customerId`), `GET` / `PATCH` / `DELETE /v1/webhook-endpoints/{id}`, `POST /v1/webhook-endpoints/{id}/rotate-secret` / `enable` / `verify` / `test`, `GET /v1/webhook-endpoints/{id}/deliveries`, `POST /v1/webhook-endpoints/{id}/deliveries/{deliveryId}/redeliver` | `customerId` (must equal the Key's own customer entity), or the customer entity the endpoint belongs to | Every resource must belong to a Business Portfolio the customer entity currently owns; otherwise the call returns `403`. A customer Key creates webhook endpoints bound to its own customer entity: pass `customerId` with the `customerEntityId` from `GET /whoami`. One such endpoint receives events for **every** Business Portfolio the customer entity currently owns, including Portfolios added later, so there is no need for one endpoint per Portfolio. A customer Key cannot create account-level endpoints (no binding) or endpoints bound to a single Portfolio (`projectId`). Endpoints a customer Key created earlier with `projectId` keep receiving that Portfolio's events and can still be managed by ID, but `GET /v1/webhook-endpoints?customerId=` does not list them; to move to the customer-level binding, create an endpoint with `customerId` and then delete the old one, or the same events are delivered twice. ## Scopes (fine-grained permissions) An API Key may additionally carry fine-grained scopes. The scope each endpoint requires is stated in the "Authentication" note at the top of that endpoint's page; without it you get a `403`. You cannot widen your own scopes — contact BlueMedia support for changes. Every value, and the endpoints that **actually check** it: | scope | Endpoints that check it | | ----- | ------------ | | `messages:send` | `POST /v1/messages`, `POST /v1/messages/read`, `POST /v1/broadcasts` and its pause/resume/cancel | | `messages:read` | `GET /v1/conversations`, `GET /v1/conversations/{id}`, `POST /v1/conversations/{id}/read`, the `GET /v1/broadcasts` family | | `templates:manage` | Creating/editing/deleting/syncing templates, template analytics and enabling it, uploading template media headers | | `media:write` | `POST /v1/media` | | `phone_numbers:manage` | `POST /v1/phone-numbers/{id}/register` | | `phone_numbers:read` | `GET /v1/phone-numbers/{id}/registration-status` | | `onboarding:read` | The `GET /v1/onboarding/embedded-signup` family, `GET /v1/onboarding/invitations`, `GET /v1/business-portfolios/{id}/token-scopes` | | `onboarding:write` | Creating/retrying onboarding operations, creating and revoking invitations, reporting ES events; creating a Portfolio with a customer Key | Two things are easy to misread: - **An endpoint that lists no scope under "Authentication" checks no additional scope** — a Key can call it when that operation and resource are within its authorization scope. Most **read** endpoints for assets and messages (`GET /v1/messages/{id}`, `GET /v1/phone-numbers`, `GET /v1/templates`) fall into this category. They are still confined by the API Key's authorization scope; they simply do not demand an extra scope on top. - Some Keys have a scope of `*` (unrestricted) or an empty one (broad Keys issued historically). Both **pass every** scope check. ## Per-number restrictions An API Key may be further restricted to specific phone numbers. If a number that belongs to the current customer entity still returns `403`, check whether it has been added to the current Key's authorization scope. ## A portal account is not API authentication The developer console uses a browser session. Always use `Authorization: Bearer` with an API Key for server-side integrations — do not copy browser session data and use it as a long-lived credential. ## Confirming which account a credential belongs to Calling `GET /whoami` confirms an API Key and returns the account identifier, service version and `customerEntityId` for customer Keys (`null` for other Keys). It does not return the full secret, the phone number allowlist, or any other sensitive authorization detail. For first-time onboarding, create your own Portfolio with only `name`, then generate an invitation or submit a Meta authorization result. See [Customer Onboarding](customer-onboarding.md). Customer Keys cannot prefill `metaBmId`, change Portfolio ownership, or call the separate Alipay configuration endpoint; an Alipay invitation remains available through `mode: alipay`. --- # Billing & Credit Line Canonical: https://docs.bluehola.com/docs/guides/billing OpenAPI: https://docs.bluehola.com/openapi.yaml Airtime for each customer account is managed with a credit account plus an append-only ledger: an amount is reserved before sending, settled once Meta accepts, and reversed automatically if delivery fails. ## The credit account Each account has one credit balance, opened and adjusted by BlueMedia. To check or adjust your account's credit line, contact BlueMedia support. ## Account credit versus customer budgets An account has exactly one overall balance; BlueMedia can set an independent **budget cap** for each customer entity on top of it, shared by every Business Portfolio under that customer, but that cap is not a second wallet. Adjusting a customer budget does not change the account's overall balance. To change your budget, contact BlueMedia support. :::warning When a customer's budget is exhausted, sending fails with `402 CUSTOMER_BUDGET_EXCEEDED`; when the account's overall balance is short, it returns `INSUFFICIENT_FUNDS`. They mean different things, so use the error code to tell BlueMedia whether the customer budget or the account credit needs adjusting. Historical messages can still show `BM_BUDGET_EXCEEDED`, which means the same as `CUSTOMER_BUDGET_EXCEEDED`. Broadcasts are costed in full **at creation time** and rejected up front, so they never stop halfway through. ::: ## Reservation → settlement → reversal | When | What happens | | ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------ | | Message submitted (accepted) | A `reserved` amount is locked and a reservation record created. The amount is the message's price from your rate card at the highest rate that can apply (a flat fallback estimate only when it cannot be priced), so settlement only ever releases the difference. An insufficient account balance gives `402 INSUFFICIENT_FUNDS` outright, and an exhausted customer budget gives `402 CUSTOMER_BUDGET_EXCEEDED`. | | Meta accepts (returns a wamid) | Settlement: the reservation becomes an actual charge and a ledger entry is written. | | `failed` status callback | The charge is reversed automatically (idempotency key `reverse:`, so repeated callbacks do not reverse twice). | The ledger is append-only (ledger\_entries — inserts, never updates), and a given idempotency key is posted at most once, so retries and duplicate callbacks cannot produce a double charge. ```mermaid sequenceDiagram autonumber participant C as Caller participant P as BlueMedia participant M as Meta C->>P: POST /v1/messages P->>P: Lock the reserved amount, create a reservation record Note over P: Insufficient balance → 402 INSUFFICIENT_FUNDS
Customer budget exhausted → 402 CUSTOMER_BUDGET_EXCEEDED P-->>C: 202 accepted P->>M: Submit the message M-->>P: Accepted, returns a wamid P->>P: Settle: reservation becomes a charge, ledger entry written M-->>P: failed status callback P->>P: Automatic reversal (idempotency key derived from messageId, no double reversal) ``` ## Service-message pricing from 2026-10-01 Meta began charging per message for non-template service replies sent on or after **2026-10-01**, including replies inside an open 24-hour customer service window. Utility templates sent inside that window also became chargeable on that date. The open window still determines whether a non-template reply is allowed; it no longer makes the reply free. Messages sent before the change keep the pricing rule for their send date. Service-message rates vary by recipient market and match Meta's utility and authentication rates, without volume tiers for service messages. Check your applicable rate card for the amount. A later `failed` status still reverses the charge as described above; Meta's pricing information in a status callback can also identify a message as non-billable. ## Meta credit line sharing Before a customer can use a credit line to send template messages, BlueMedia must authorize the line and attach it to a WABA. Meta first shares the line with the customer's Business Portfolio and then attaches it to a specific WABA — which is why other WABAs under the same Business Portfolio share that authorization. Once authorized, BlueMedia settles the WhatsApp spend with Meta. Sending from a Business Portfolio whose credit line is not ready fails with `CREDIT_LINE_NOT_READY`; contact BlueMedia support to have it authorized. --- # Ad Attribution & Conversion Reporting Canonical: https://docs.bluehola.com/docs/guides/ctwa-attribution OpenAPI: https://docs.bluehola.com/openapi.yaml The first message a user sends after clicking a Click to WhatsApp (CTWA) ad carries the **id of that ad click**. Reporting it back to Meta alongside the resulting sale or lead is what lets the ads dashboard work out how many conversions the ad actually produced. This data appears only in that one webhook and cannot be retrieved afterwards from Meta's Graph API, so the platform stores it for you. ## Prerequisites | Requirement | Notes | | ------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- | | The customer is running CTWA ads | Only conversations that started from an ad have an attributable click id. Ordinary conversations do not. | | The Business Portfolio has a Pixel linked | Conversion events must be reported to the customer's own Meta Pixel (dataset). The link comes from the Pixel the customer chose during Embedded Signup; to add it later, contact BlueMedia support. | ## 1\. Find the conversations an ad produced Both the inbox list and the conversation detail carry the ad attribution fields: ```json title="One record from GET /v1/conversations (excerpt)" { "id": "conv_...", "contactWaId": "8613800138000", "contactName": "Zhang San", "ctwaClid": "Aff-n8ZTODiE79d22KtAwQKj9e_mIEOOj...", "adSourceId": "120210000000000000", "adSourceUrl": "https://fb.me/xxxxx", "adSourceType": "ad", "attributedAt": "2026-08-21T09:12:00.000Z" } ``` `adSourceId` is the ad id and answers "which ad brought this customer in"; `ctwaClid` is the only identifier Meta accepts when reporting a conversion. Attribution uses **first touch**: if the same person later clicks a different ad and comes back, that does not overwrite the conversation's original source (the full per-message `referral` is still kept on the message records). :::warning **`ctwaClid` can be empty while `adSourceId` has a value.** The WhatsApp Status ad placement does not emit a click id (established Meta behaviour). You can tell which ad such a conversation came from, but you **cannot report conversions** for it. ::: ## 2\. Report conversions Conversion events are reported to Meta through BlueMedia. To report the sales or leads your own systems confirm, contact BlueMedia support; customer API Keys cannot submit conversion events directly. Conversions Meta recognises automatically (below) need no action from you. ## Conversions Meta recognises automatically A customer can authorize Meta to analyse ad-driven conversations automatically, letting Meta decide that an order or lead occurred and push that conclusion to the platform — which queues and reports it for you, with **no API call on your part**. To enable it, the customer ticks "automatically recognise order and lead events" on the assets page of the Embedded Signup flow, or turns on the corresponding switch afterwards under Meta Business Suite → Settings → WhatsApp accounts → Privacy and data sharing. :::note **Not available to customers in the EU, the UK or Japan** (a Meta restriction). Also note that these are *inferred* results and may not agree exactly with the sales you confirm yourself — the two are recorded separately and never overwrite each other. ::: --- # Customer Onboarding Canonical: https://docs.bluehola.com/docs/guides/customer-onboarding OpenAPI: https://docs.bluehola.com/openapi.yaml With a customer API Key you can onboard your own WhatsApp assets. Identify the ownership target by **exactly one** of `customerEntityId` (recommended — no Business Portfolio is needed in advance) or `portfolioId` (an existing BlueHola Business Portfolio record); then choose the hosted invitation page or submit the result from your own Meta SDK authorization page. Both routes use the same onboarding state machine. Creating invitations and onboarding operations requires `onboarding:write`; reading invitations and operations requires `onboarding:read`. Every target must remain inside the Key’s current authorization scope. All credentials and links below are placeholders. ## 1. Confirm your identity and check existing records ```bash curl "https://api.bluehola.com/whoami" \ -H "Authorization: Bearer " ``` Read `customerEntityId` from the response and pass it when listing assets. A customer Key must include its own customer entity filter on the Portfolio, WABA and phone number lists; omitting it returns `403`. ```bash curl "https://api.bluehola.com/v1/business-portfolios?customerEntityId=cust_01923abc" \ -H "Authorization: Bearer " ``` An HTTP 200 with `[]` means no Portfolio is registered for this customer yet. If you plan to identify onboarding by `portfolioId`, create a record in the next step; with `customerEntityId`, records are created automatically after authorization. ## 2. (Optional) Create an internal onboarding record Skip this step when you identify onboarding by `customerEntityId`. ```bash curl -X POST "https://api.bluehola.com/v1/business-portfolios" \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "name": "Example Company" }' ``` ```json title="201 Created (excerpt)" { "id": "bm_01923abc", "name": "Example Company", "customerEntityId": "cust_01923abc", "metaBmId": null } ``` Save the returned `id` and use it as `portfolioId`. With a customer Key, ownership is derived from the Key: `customerEntityId` may be omitted, and specifying another customer returns `403`. Omit `metaBmId`; supplying it with a customer Key returns `400`. This creates a local onboarding record, without creating or authorizing any Meta asset. See [Create Portfolio](../assets-phone-numbers/post-v1-business-portfolios.md). | Identifier | Meaning | | --- | --- | | `customerEntityId`, such as `cust_01923abc` | Your customer entity, read from `GET /whoami`. Passing it to an onboarding or invitation call needs no Portfolio in advance. | | `portfolioId`, such as `bm_01923abc` | BlueHola’s internal Business Portfolio record ID. It identifies one specific record and is not required when you use `customerEntityId`. | | `metaBmId`, such as `1234567890123456` | The numeric Meta Business Portfolio ID, determined by Meta from the authorized WABA. It cannot replace `portfolioId`. | ## 3. Choose an authorization route | Route | When to use it | | --- | --- | | Hosted invitation page | You want a ready-made page for the customer to complete Meta authorization. | | Your own Meta SDK page | You already run an authorization page and can submit Meta’s result from your backend. | ### A. Generate a hosted invitation link ```bash curl -X POST "https://api.bluehola.com/v1/onboarding/invitations" \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "customerEntityId": "cust_01923abc" }' ``` Pass exactly one of `customerEntityId` or `portfolioId`; both or neither returns 400. With `customerEntityId`, the response’s `portfolioName` is empty because the Portfolio does not exist until the customer authorizes. The HTTP 201 response contains `url`, `expiresAt` and an initial `status: pending`. Save the URL when it is returned: the plaintext link appears only once. The link expires after 1800 seconds (30 minutes) by default; `expiresInSeconds` accepts 300–86400. Open the returned URL on the customer’s device. A person with access to the intended Meta Business Portfolio signs in to Meta and selects the business, WABA and, when applicable, phone number. The page submits the authorization result automatically using its invitation token; it needs no API Key from the person opening it. You do not separately call `POST /v1/onboarding/embedded-signup` for this route. `mode` can be `splbv` (default), `alipay` or `standard`. Alipay verification requires the legal representative’s participation. See [Create Onboarding Link](../onboarding/post-v1-onboarding-invitations.md) for verification options. ### B. Submit the result from your own SDK page Read the non-confidential SDK settings from [`GET /v1/onboarding/config`](../onboarding/get-v1-onboarding-config.md). After your page completes Meta authorization, submit the returned code and asset IDs from your backend: ```bash curl -X POST "https://api.bluehola.com/v1/onboarding/embedded-signup" \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "customerEntityId": "cust_01923abc", "code": "", "wabaId": "", "phoneNumberId": "", "esVersion": "v4" }' ``` Use Meta’s actual return values. Pass exactly one of `customerEntityId` or `portfolioId`. `phoneNumberId` is optional for a WABA-only completion; also forward `sessionInfo` from the ES message event when available. `POST /v1/onboarding/embedded-signup` consumes a completed authorization result and returns an operation; it does not generate an authorization URL. An empty `{}` body is invalid. See [Complete Onboarding](../onboarding/post-v1-onboarding-embedded-signup.md). ## 4. Confirm the binding and operation status The backend exchanges the code, checks the grant against the submitted WABA and phone number, and reads the WABA owner from Meta before binding `metaBmId`. Merely creating a record or holding a numeric Meta BM ID does not establish that binding. When you passed `customerEntityId`, the Portfolio is found from the WABA owner and reused or created at this point, and the operation’s `portfolioId` is backfilled. If that Meta BM already belongs to another customer or another BU, the operation fails with `lastErrorCode: ONBOARDING_META_BM_ALREADY_CONNECTED` and `requiredInput: null`: the binding is not reassigned and retrying cannot fix it — start a new onboarding for the Business Portfolio that already holds that Meta BM. A customer entity that does not exist returns 404 before the authorization code is used. When you passed `portfolioId`, an existing `metaBmId` that disagrees with the authorized WABA owner is rejected with `403`. ```bash curl "https://api.bluehola.com/v1/onboarding/embedded-signup?limit=20" \ -H "Authorization: Bearer " ``` The list returns `{ "data": [...] }`, automatically filtered to your customer’s current Portfolios. `GET /v1/onboarding/invitations?limit=20` has the same customer filtering. Neither list requires `customerEntityId`. Use the operation’s `id` (`onb_...`) with `GET /v1/onboarding/embedded-signup/{operationId}` for detailed progress. Check `status: completed`; HTTP 201 from the direct endpoint or HTTP 202 from an invitation completion alone does not mean onboarding succeeded. On failure, use the matching retry endpoint for the existing operation. You can read the resulting Meta binding with `GET /v1/business-portfolios/{id}`. ## The five orchestration stages An onboarding run is a **persisted, resumable** state machine. The `steps` array returned by a single-operation query always contains these five steps, each with a status of `pending`, `running`, `completed`, `failed` or `skipped`: | Step id | What it does | | ---------------- | --------------------------------------------------------------------------------------------------------------------- | | `exchange_token` | Exchanges the Meta OAuth code for the credential needed to reach that customer's Meta resources later, and stores it encrypted with AES-256-GCM. | | `subscribe_app` | Subscribes the app with Meta so that WABA message and status callbacks flow into the platform's webhook pipeline. | | `register_phone` | Registers the number with the Cloud API. When no phone registration was requested, the whole step is marked `skipped`; the registration PIN is generated by the platform and stored encrypted, so the customer does not need to supply one. | | `sync_resources` | Pulls the latest WABA and phone number details from Meta (display name, quality rating and so on). | | `persist_assets` | Persists the assets and ownership relationships (WABA, phone number, cross-account reverse index). | A failure in any step halts the whole run: `currentStep` and `lastError*` stop at the point of failure and the status becomes `failed`. At that point call `POST .../embedded-signup/{operationId}/retry` to **resume from where it stopped**, rather than POSTing to the create endpoint again — that would create a brand-new operation. The `code` parameter on retry is optional: omit it if the old token is still valid (it simply resumes), and only have the customer re-authorize for a fresh code once the token has expired. An operation that completed without registering a phone number at the time can also use retry to run just that registration step later. ```mermaid flowchart TB S([triggered by complete or retry]) --> T1["exchange_token
exchange for credentials, store AES-256-GCM encrypted"] T1 --> T2["subscribe_app
subscribe the app, open the webhook pipeline"] T2 --> T3["register_phone
register the number with the Cloud API"] T3 --> T4["sync_resources
pull the latest WABA / phone number details"] T4 --> T5["persist_assets
persist assets and ownership"] T5 --> OK([completed]) T3 -. whole step skipped if no registration was requested .-> T4 T1 -. any step fails .-> F T2 -. fails .-> F T3 -. fails .-> F T4 -. fails .-> F T5 -. fails .-> F F["failed
currentStep and lastError stop at the failure"] -->|"POST .../retry resumes from there"| S ``` ## Customer-side endpoints (no authentication) The group of endpoints beginning `/v1/onboarding/invitations/{token}` deliberately carries **no API Key auth** — the token in the link is itself the credential (rate-limited per source IP). | Endpoint | Purpose | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `GET .../{token}` | Landing page initialization: returns non-confidential information such as the customer name and the Meta appId/configId. Invalid, expired and revoked all resolve to the same "invitation is no longer valid" outcome, without revealing which. | | `POST .../{token}/complete` | Submits the Meta authorization result (code + wabaId + phoneNumberId) and triggers the orchestration. It claims the invitation atomically (pending and unexpired) before executing, so a double-click on submit cannot produce two sets of assets. A 202 only means it was accepted — you must poll status. | | `POST .../{token}/retry` | After a first failure, resumes the same operation with a **fresh code**. Only the code may change — wabaId and phoneNumberId were bound on first submission, and pointing at different target assets on retry is rejected. | | `GET .../{token}/status` | Polls progress. Before complete has been called it returns a placeholder structure (with empty steps) rather than an error; once started it returns the same redacted step view that complete/retry produce. | The `requiredInput` field in a failure response tells the customer what to do next: `authorization_code` means they need to go through Meta authorization again for a fresh code; `null` means they cannot recover on their own and should contact their account manager. **Onboarding success and credit line sharing are two independent states** — a credit line that has not synced will not cause onboarding to be reported as failed. --- # Error Codes Canonical: https://docs.bluehola.com/docs/guides/error-codes OpenAPI: https://docs.bluehola.com/openapi.yaml ## The HTTP error envelope Every API error uses the same envelope and returns the same request trace ID in a response header: ```http HTTP/1.1 429 Too Many Requests X-Request-Id: req_01923abc Content-Type: application/json { "error": { "code": "RATE_LIMITED", "message": "rate limit exceeded", "retryable": true, "httpStatus": 429, "requestId": "req_01923abc" } } ``` Write `requestId` into your own logs; when you need a human to investigate, supply it along with the request time and the endpoint path. `details` and `upstream` appear only on the relevant errors — for the complete structure see [OpenAPI & Agent Access](../reference/openapi.md). ## Error codes | code | httpStatus | retryable | Description | | --- | --- | --- | --- | | UNAUTHENTICATED | 401 | No | Missing or invalid Bearer token | | FORBIDDEN | 403 | No | The request was refused | | TENANT_FORBIDDEN | 403 | No | Insufficient account, role or scope | | VALIDATION_FAILED | 400 / 409 | No | Invalid parameters or a state conflict | | NOT_FOUND | 404 | No | The resource does not exist, or does not belong to the current account | | IDEMPOTENCY_CONFLICT | 409 | No | The same Idempotency-Key was used with different request content | | INSUFFICIENT_FUNDS | 402 | No | The credit account's available balance is too low; top up or adjust the credit line | | BM_BUDGET_EXCEEDED | 402 | No | The account balance is fine, but the Business Portfolio this message belongs to has exhausted its budget; raise that Portfolio's budget cap. `details` carries portfolioId / remainingMinor | | CUSTOMER_BUDGET_EXCEEDED | 402 | No | The account balance is fine, but the customer entity this message belongs to has exhausted its budget; raise that customer entity's budget cap | | WHATSAPP_24H_WINDOW_EXPIRED | 409 | No | More than 24 hours have passed since the customer last replied, so only template messages can be sent; `details.customerAction` gives the next step | | RATE_LIMITED | 429 | Yes | Back off and retry | | PRICE_IMPORT_INVALID | 400 / 409 | No | The rate table CSV failed validation, or the current state does not permit this operation (for example publishing an already-published import). `details.issues` lists each problem with its **line number**; when high-severity warnings exist, `details.warnings` gives the list needing confirmation | | PRICING_UNAVAILABLE | 409 | No | No rate found for the market + category combination (or that currency has no published version for the day). **It will not silently fall back to charging 0** — a missing price is a fault and someone needs to fill the rate table in | | ENGAGEMENT_COOLDOWN | 429 | No | This recipient recently tripped Meta's per-person engagement ceiling (131049) from this number, and the platform refuses further templates locally during a 24h cooldown — retrying within those 24h extends Meta's block (and not only for marketing). Wait or switch recipients; do **not** treat this as a back-off-and-retry case | | MARKETING_OPT_OUT | 403 | No | This recipient has turned off marketing messages from this business inside WhatsApp (the `stop` from the `user_preferences` webhook). The opt-out is recorded against both the phone number and the BSUID Meta reports, and a send matching either `to` or `toUserId` is blocked. **There is no expiry** — only the user turning it back on lifts it, so remove the number from your marketing lists. Forcing it through means Meta accepts the message and then rules 131050 at delivery, burning a reservation and leaving a failed mark against the number's quality rating | | UPSTREAM_META_ERROR | 502 | Depends on the response | Meta returned an error. **`message` is Meta's own wording, passed through unchanged**; `upstream` holds the entire native envelope: `code` (Meta's numeric code — the official advice is to drive error handling from it), `details` (`error_data.details`, the other officially recommended basis), `userTitle` / `userMsg` (Meta often writes "how to fix it" only here), `type`, `traceId` (`fbtrace_id`, the only credential you can attach when opening a Direct Support ticket) and `subcode` (officially no longer returned as of v16.0+ — do **not** write logic against it) | | INTERNAL | 500 | Usually | Record the request details, then retry or alert | `BM_BUDGET_EXCEEDED` is no longer returned for new requests: budgets are now set per customer entity, and an exhausted budget returns `CUSTOMER_BUDGET_EXCEEDED`. The old code stays listed because historical message records can still carry it; handle the two the same way. ## Message failure codes (`error.code` from `GET /v1/messages/{id}`) These are a **separate system** from the HTTP error codes above: the codes here describe why a message that was already accepted ultimately failed to arrive. They are returned through the message detail endpoint and the status webhooks, not as the `error.code` of an HTTP response. **When the failure comes from Meta, `error.code` is the number in the "Meta code" column below** (so it maps straight onto Meta's official error code table), `error.message` is Meta's own wording, and `error.meta` is the entire native envelope (including `details` and `fbtrace_id`). For locally determined message failures, such as insufficient account balance, an exhausted customer budget, and exhausted retries, `error.code` is the platform classification in the left-hand column. `ENGAGEMENT_COOLDOWN` is different: the request is rejected with HTTP 429 before a message record is created. The "Description" column is our categorisation, not Meta's wording. `retryable` / `customerAction` / `stage` are **the platform's judgement**, not fields Meta supplies: retrying a code marked `retryable: false` gets you an identical result, and `customerAction` says who has to fix it (`fix_template_params` is something the caller can correct in five seconds; `contact_platform_admin` is on us). | Platform classification | Meta code | Stage | Retryable | customerAction | Description | | --- | --- | --- | --- | --- | --- | | BM_BUDGET_EXCEEDED | — | Submission | No | raise_bm_budget | This Business Portfolio has exhausted its budget; raise its budget cap and retry. | | BSUID_NOT_SUPPORTED_FOR_MESSAGE | 131062 | Submission | No | check_recipient | This message cannot be delivered by BSUID: Max Price templates and one-tap/zero-tap/copy-code authentication templates require the recipient phone number. Pass the phone number in `to` instead. | | CUSTOMER_BUDGET_EXCEEDED | — | Submission | No | raise_customer_budget | This customer entity has exhausted its budget; raise its budget cap and retry. | | CREDIT_LINE_NOT_READY | 131042 | Delivery | No | authorize_credit_line | This WABA's payment method or BlueMedia credit line is unavailable. If the credit line is already attached, check whether the **allocation shared to that Business Portfolio is 0** — the allocation must be set under "Billing & payments → Credit lines" in Meta Business Suite (the API cannot set it). | | DISPLAY_NAME_NOT_APPROVED | 131037, 2388103 | Submission | No | approve_display_name | This 555 test number's display name has not passed review; change it in the Meta console and wait for approval. | | FLOW_BLOCKED | 132068 | Submission | No | fix_flow | This Flow is blocked and must be corrected first. | | FLOW_THROTTLED | 132069 | Submission | No | fix_flow | This Flow is throttled (10 messages using it have already gone out in the last hour); the Flow must be corrected first. | | INSUFFICIENT_FUNDS | — | Submission | No | contact_platform_admin | The local credit account balance is too low; top up or adjust the credit line first. | | INTERNAL | — | Submission | Yes (platform retries automatically) | contact_platform_admin | An internal platform error, currently being retried automatically; if it keeps failing, contact BlueMedia support with the message ID. | | MARKETING_DISABLED_ON_CLOUD_API | 131063 | Submission | No | use_marketing_messages_api | This WABA has marketing messages disabled on the Cloud API (disable_marketing_messages_on_cloud_api=true). BlueMedia routes marketing templates through the Marketing Messages API automatically; if this error still occurs, check the WABA's Meta configuration and share the message ID with support. You do not need to change the BlueMedia request endpoint. | | MARKETING_EXPERIMENT_EXCLUDED | 130472 | Delivery | No | none | The message was not sent because of a marketing message experiment grouping (Meta-side control group behaviour); this is not a configuration problem. | | MARKETING_OPT_OUT | 131050 | Delivery | No | stop_marketing_to_recipient | The recipient has turned off marketing messages from this business inside WhatsApp. Do not resend (it will not arrive either); remove the number from your marketing lists. If they turn it back on, Meta notifies you through the user_preferences webhook. | | MAX_PRICE_REQUIRES_MM_API | 131061 | Submission | No | use_marketing_messages_api | This template has a Max Price and must be sent through the Marketing Messages API, not the Cloud API. BlueMedia routes marketing templates automatically; if this error still occurs, share the message ID with support. | | MAX_PRICE_UNSUPPORTED_COUNTRY | 131065 | Submission | No | check_recipient | Max Price delivery is not supported in this country. Use a template without a bid (rate-card billing), or choose a recipient in a supported country. | | MEDIA_DOWNLOAD_FAILED | 131052 | Delivery | No | check_media | The media file the user sent could not be downloaded; see error.meta.details for the reason, and consider asking the user to send the file another way. | | MEDIA_UPLOAD_FAILED | 131053 | Submission | No | check_media | The media file in the message could not be uploaded (commonly an unsupported format); see error.meta.details for the reason. | | MESSAGE_TYPE_UNSUPPORTED | 131051 | Submission | No | fix_request_params | Unsupported message type; use a supported one. | | MESSAGE_UNDELIVERABLE | 131026 | Delivery | No | check_recipient | The message cannot be delivered: the recipient number may not be a WhatsApp user, or may not have accepted the latest terms of service. | | META_ENGAGEMENT_LIMIT | 131049 | Delivery | No | wait_24h | Meta did not deliver the message in order to protect ecosystem engagement quality; wait at least 24 hours before trying the same user again. | | META_PERMISSION_DENIED | 10, 200 | Submission | No | fix_app_credentials | Meta denied permission for this request; check the App permissions and the token's authorization scope. | | META_RATE_LIMIT | 4, 80007 | Submission | Yes (platform retries automatically) | retry_automatically | Meta API rate limit; the platform backs off and retries automatically. | | META_SERVICE_UNAVAILABLE | 131016, 133004 | Submission | Yes (platform retries automatically) | retry_automatically | Meta's service is temporarily unavailable; the platform backs off and retries automatically. | | META_THROUGHPUT_LIMIT | 130429 | Submission | Yes (platform retries automatically) | retry_automatically | The Cloud API throughput ceiling has been reached; the platform backs off and retries automatically. | | META_TOKEN_INVALID | 190 | Submission | No | fix_app_credentials | The Meta access token is invalid or expired; re-authorize. | | PAIR_RATE_LIMIT | 131056 | Submission | Yes (platform retries automatically) | retry_automatically | Too many messages in a short period from one sending number to one recipient; the platform backs off and retries automatically. | | PAYMENTS_TOS_PENDING | 134011 | Submission | No | contact_platform_admin | This WABA has not accepted the WhatsApp Payments terms of service; accept them via the link in the error message before sending. | | PHONE_NOT_REGISTERED | 131045, 133010 | Submission | No | register_phone_number | Something is wrong with the sending number's registration; complete its registration on the WhatsApp Business Platform first. | | PHONE_NOT_VERIFIED | 133006 | Submission | No | register_phone_number | This number must be verified before it can be registered and used. | | PHONE_SEND_RESTRICTED | 131048 | Submission | Yes (platform retries automatically) | retry_automatically | This number's send volume is restricted (earlier messages were blocked or marked as spam in large numbers). The platform backs off and retries; if it keeps failing, check the number's quality rating in WhatsApp Manager. | | RECIPIENT_BLOCKED_BY_BUSINESS | 130403 | Delivery | No | unblock_recipient | The business has blocked this user on WhatsApp; unblock them before messaging again. | | RECIPIENT_IS_SENDER | 131021 | Submission | No | fix_request_params | The recipient number is the same as the sending number; send to a different number. | | REQUEST_PARAM_INVALID | 131009, 135000 | Submission | No | fix_request_params | One or more parameters in the request have an invalid value; check the permitted ranges against the endpoint documentation. | | REQUEST_PARAM_MISSING | 131008 | Submission | No | fix_request_params | The request is missing a required parameter; add it per the endpoint documentation. | | RETRIES_EXHAUSTED | — | Submission | No | contact_platform_admin | Still unsuccessful after repeated retries; check the last failure reason. | | TEMPLATE_CLASSIFICATION_LIMIT | 131064 | Submission | No | contact_platform_admin | This account has hit a sending cap due to template classification violations (both template and direct messages are restricted). Check that your template categories are correct; the restriction lifts automatically once the enforcement period ends. | | TEMPLATE_DISABLED | 132016 | Submission | No | fix_template | This template has been permanently disabled after repeated pauses; create a new template with different content. | | TEMPLATE_NOT_FOUND | 132001 | Submission | No | sync_template | The template does not exist or is out of sync with Meta; sync templates first and confirm the name and language. | | TEMPLATE_PARAM_FORMAT_INVALID | 132012 | Submission | No | fix_template_params | A template parameter's format does not match the template definition (for example a malformed structured parameter such as a date or currency). | | TEMPLATE_PARAM_MISMATCH | 132000 | Submission | No | fix_template_params | The number of template parameters does not match the template definition; send components matching the declared placeholders in count and order. | | TEMPLATE_PAUSED | 132015 | Submission | No | fix_template | This template is paused because its quality rating is too low; change its content and resubmit for review. | | TEMPLATE_POLICY_VIOLATION | 132007 | Submission | No | fix_template | The template content violates WhatsApp policy; change it and resubmit for review. | | TEMPLATE_TEXT_TOO_LONG | 132005 | Submission | No | fix_template | The template translation is too long; shorten the template content in WhatsApp Manager. | | UPSTREAM_META_ERROR | — | Submission | Yes (platform retries automatically) | retry_automatically | Upstream is temporarily unavailable; the platform retries automatically. | | WABA_MAINTENANCE_MODE | 131057 | Submission | Yes (platform retries automatically) | retry_automatically | This WABA is in maintenance mode (for example a throughput upgrade); the platform backs off and retries automatically. | | WABA_RESTRICTED | 131031 | Submission | No | contact_platform_admin | The WABA is restricted for policy violations or unverifiable data; BlueMedia support needs to handle it in the Meta console. | | WHATSAPP_24H_WINDOW_EXPIRED | 131047 | Submission | No | use_template_or_wait_for_reply | More than 24 hours have passed since the customer last replied; send an approved template message, or wait for the customer to write first. | ### What the 24-hour guidance for `131049` means The 24 hours is the **minimum wait after a `131049` failure before retrying**. It is not a promise that a marketing message will be deliverable once 24 hours have passed since this business last messaged the recipient. Meta applies an adaptive per-user marketing limit based on factors including the recipient's recent marketing-message read rate, overall inbox activity, and marketing messages received from **any business** during a period determined by Meta. Therefore, a recipient can still receive `131049` even when this business's previous successful delivery was several days ago. Meta does not expose the recipient's current cap or its exact reset time. Meta does explicitly state that every delivered marketing template outside an open customer-service window counts toward the limit, while marketing messages sent after the user replies and within that 24-hour window do not count. What Meta does **not** publish is a fixed number of messages, a fixed calculation period, a remaining-quota query, or an exact reset time. The threshold varies by user and changes with engagement, so it cannot be predicted from this business's send history alone. When the failure record has `stage: delivery`, a Meta `wamid`, and `error.code: 131049`, the platform successfully submitted the message and Meta rejected it during delivery under this recipient-level policy. Do not retry automatically. Wait at least 24 hours from the failed attempt; the adaptive limit may remain in effect for longer. --- # Sending Messages & Tracking Status Canonical: https://docs.bluehola.com/docs/guides/messaging OpenAPI: https://docs.bluehola.com/openapi.yaml The `202 Accepted` from `POST /v1/messages` only means the platform has accepted the request — not that it was delivered, and not even that it was submitted to Meta. To track the real status you must poll `GET /v1/messages/{id}` or receive the status webhooks. ## How statuses progress | Status | Meaning | | ----------- | -------------------------------------------------------------------------------------------------------------------------------- | | `accepted` | The platform has accepted the request; nothing has been submitted to Meta yet. | | `sending` | Being submitted to the appropriate Meta messaging endpoint. | | `submitted` | Meta accepted it and returned a `wamid`, but no status callback has arrived yet. **This is not the same as "sent"** — in Meta's documentation `sent` is a separate status callback. | | `sent` | A Meta status callback confirms it reached the carrier network the user's device is on. | | `delivered` | Delivered to the user's device. | | `read` | The user has read it. **This can arrive without a preceding `delivered`** — when the user happens to be sitting in the chat window, Meta omits the delivered callback. Do not assume the statuses always arrive as a complete sequence. | | `failed` | Terminal. Check the `error` field returned by `GET /v1/messages/{id}` (see the message failure code table on the [Error Codes](error-codes.md) page). | Statuses only move forward — a late or duplicate callback will never push one backwards (a message already at `delivered` will not revert to `sent`). ```mermaid stateDiagram-v2 [*] --> accepted : POST /v1/messages returns 202 accepted --> sending : platform starts submitting sending --> submitted : Meta accepts and returns a wamid submitted --> sent : Meta status callback sent --> delivered : delivered to the user's device delivered --> read : the user reads it sent --> read : Meta omits delivered when the user is in the chat window sending --> failed : failure during submission submitted --> failed : failure during delivery read --> [*] failed --> [*] ``` The `sent --> read` edge in this diagram is the branch that gets missed most often: **do not assume the statuses always arrive as a complete sequence**. ## Idempotency and rate limits Generate one stable `Idempotency-Key` (≤200 characters) per business event: within the current authorization scope, a repeated key returns **the original** message rather than sending another one, which makes it the only safe way to retry after a network timeout. By default each API Key's account is limited to 600 messages per minute; exceeding that returns `429 RATE_LIMITED`, and you simply back off and retry. ## The 24-hour customer service window More than 24 hours after the customer last messaged you, only approved **template messages** may be sent — free-form content is no longer allowed. The platform makes a local determination before persisting anything: free-form messages it is certain are outside the window return `409 WHATSAPP_24H_WINDOW_EXPIRED` immediately (with `details.customerAction` giving the next step), without wasting a credit reservation. But that local check only covers the "definitely closed" case — a message the platform believes is inside the window when it has actually closed can still be rejected by Meta, in which case it falls through to the normal message failure code path. ## Binding parameters in template messages The `parameters` inside `components` must match the placeholders declared when the template was created **exactly** in count and order, or Meta returns a parameter mismatch error. Before sending a template, the platform verifies it has been approved (APPROVED). Template messages are not bound by the 24-hour window, and are the only message type available once it has closed. ## Marketing template delivery For a template whose category is `MARKETING`, BlueMedia submits to Meta’s Marketing Messages API. This applies regardless of the WABA’s recorded onboarding status. Meta uses Marketing Messages delivery for an onboarded WABA and automatically falls back to Cloud API for a WABA that has not signed the terms (`product_policy: CLOUD_API_FALLBACK`). Other message types and template categories keep their normal Cloud API route. The request to BlueMedia remains `POST /v1/messages`. See [WABA status and onboarding](../assets-phone-numbers/wabas.md). ## Supported message types `POST /v1/messages` accepts 11 values for `type`, with the content carried in a field of the same name: | type | Purpose | | ---- | ---- | | `text` | Plain text (turn on `preview_url` for link previews). **Used when `type` is omitted.** | | `template` | An approved template message. The only type available once the 24-hour window has closed. | | `image` / `video` / `audio` / `document` / `sticker` | Media messages. | | `interactive` | Buttons, lists, CTA URLs, Flows, location requests, address collection, contact information requests — the whole `interactive` object is passed through to Meta verbatim, so every subtype Meta supports can be sent. `request_contact_info` is checked locally first: it needs a non-blank `body.text` and `action: { name: "request_contact_info" }`. | | `location` | Send a geographic location (`latitude` / `longitude` required). | | `contacts` | Send contact cards — at most 257 in one message. | | `reaction` | React to an existing message with an emoji (`message_id` must start with `wamid.`). | For the required and optional fields of each type, see [Submit Outbound Message](../messaging/post-v1-messages.md). A misshapen request returns `400` **before anything is persisted** and never enters the asynchronous send queue. ## Media messages There are two ways to reference media, and you must give **exactly one**: - `id`: upload first via `POST /v1/media?phoneNumberId=pn_...` to obtain a Meta media id. **The upload endpoint checks size per media type**, matching Meta's own limits (roughly 5 MB images, 16 MB audio/video/documents — the platform caps documents stricter than Meta's own 100 MB — and 100 KB static / 500 KB animated WebP stickers); a file over its type's limit returns `400` before it ever reaches Meta. - `link`: a URL Meta can reach publicly, which Meta fetches itself. **Documents over 16 MB have to go this way** (Meta allows up to 100 MB only through `link`); so does anything else this upload endpoint rejects for size. Giving both or neither is a `400` (`provide exactly one of \`id\` or \`link\``). Size for media sent by `id` is already checked at upload time (see above). Format is never pre-checked, and neither size nor format is pre-checked for media sent by `link` — both are enforced by **Meta at delivery time**; the send endpoint itself does not pre-check them, so an oversized or malformed message gets a 202 first and only later turns failed via a status callback. Meta media ids typically expire after a few days, so do not treat one id as a long-term asset library; temporary download URLs expire after 5 minutes, so use the `GET /v1/media/{id}/content` proxy download for long-term storage. ## Read receipts and typing indicators `POST /v1/messages/read` marks an inbound message as read, optionally accompanied by a "typing" indicator (valid for about 25 seconds, or until the other party receives your next message). It talks directly to Meta's real-time endpoint, incurs no charge and consumes no send quota. Note that it is entirely separate from the inbox's `POST /v1/conversations/{id}/read`, which only clears the platform's local unread count; the two are not linked. ## Conversations that start from an ad When a customer arrives by clicking a "Click to WhatsApp" ad, their first message carries the ad click id, which the platform stores. To make Meta's ads dashboard attribute conversions to that ad, you need to report the conversion events back — see [Ad Attribution & Conversion Reporting](ctwa-attribution.md). ## When billing happens Meta charges on **delivery**, but the platform settles as soon as Meta accepts the message and returns a `wamid`. If a later status callback confirms `failed`, the platform automatically reverses that charge against the credit account (idempotently — it will not reverse twice). So a message that was accepted but failed to deliver ends up costing nothing, with no manual work. See [Billing & Credit Line](billing.md) for details. --- # Phone Number Registration & Lifecycle Canonical: https://docs.bluehola.com/docs/guides/phone-numbers OpenAPI: https://docs.bluehola.com/openapi.yaml Adding a phone number on the Meta side and verifying its ownership must be done in WhatsApp Manager; with the BlueMedia API you read your numbers, check their live registration status and register them with the Cloud API. ## Local snapshot versus live Meta state | Endpoint | Data source | | ------------------------------------------------ | --------------------------------------------------------------------- | | `GET /v1/phone-numbers` / `{id}` | The local snapshot (from the last sync). Does not reach Meta and may lag. | | `GET /v1/phone-numbers/{id}/registration-status` | A live call to the Meta Graph API: registration status, name review, quality rating, two-step verification state. | ## Registering a number `POST /v1/phone-numbers/{id}/register` registers the number with the Cloud API using a 6-digit PIN. On success, the local state is marked connected immediately. :::note The number's ownership must already be verified in WhatsApp Manager. The platform does not check this first: calling register on an unverified number is rejected by Meta, and you decide the next step from the error returned. ::: The `pin` parameter on `register` carries two meanings: on first registration it is "the two-step verification PIN being set for this number"; when the number already has two-step verification enabled it is "the existing PIN". Meta does not distinguish the two cases. ## After a display name change A new display name goes into Meta's review and does not take effect immediately. Once the review passes, you **must call register again within 14 days** for the new name to actually sync to WhatsApp's servers; calling register before the review passes has no effect. If the 14 days pass without registering, the name has to be submitted again. ## Registration rate limit :::warning **At most 10 register/deregister requests in 72 hours** (a Meta-side rule). Exceeding it makes Meta return error code 133016 and blocks that number's registration capability for 72 hours. Be careful not to register the same number over and over while debugging your onboarding flow. ::: ## Other lifecycle operations Ownership verification, two-step verification PIN changes, display name changes, deregistration and deleting a number are handled by BlueMedia. Contact BlueMedia support when you need one of them. --- # Quickstart Canonical: https://docs.bluehola.com/docs/guides/quickstart OpenAPI: https://docs.bluehola.com/openapi.yaml From receiving your API Key to sending your first WhatsApp message, in 4 steps. ## Base URL The base address for every `/v1/*` endpoint is: ``` https://api.bluehola.com ``` ## 1\. Get an API Key Email us at [senpeng.zheng1@bluefocus.com](mailto:senpeng.zheng1@bluefocus.com) to obtain an API Key. BlueMedia configures the Key's authorization scope; you do not need to choose or understand the internal permission hierarchy. :::warning **The secret is returned in plaintext exactly once, at creation.** Save it immediately — the platform stores only a hash, and a lost key can only be reissued. ::: ## 2\. Verify the token Call `GET /whoami` with `Authorization: Bearer ` to confirm the token works and read `tenantId` and `customerEntityId`. The latter is set for customer Keys and is `null` for other Keys. ```bash curl https://api.bluehola.com/whoami \ -H "Authorization: Bearer " ``` ```json { "tenantId": "tenant_01923abc...", "customerEntityId": "cust_01923abc...", "platformVersion": "1.0.302" } ``` `platformVersion` is the version of the API process that handled this request — useful when checking whether a given fix has shipped. The response may carry other diagnostic fields; do **not** use them to make authorization decisions. ## 3\. List your available phone numbers Before sending anything, check which registered numbers you have. For a customer Key, pass the `customerEntityId` returned by `/whoami`; a customer Key cannot list numbers without this filter: ```bash curl "https://api.bluehola.com/v1/phone-numbers?customerEntityId=cust_01923abc..." \ -H "Authorization: Bearer " ``` Take an `id` (in `pn_...` form) from the returned list for the next step — do not reuse the placeholder from these docs, it is not a real phone number ID. ## 4\. Send your first message ```bash curl -X POST https://api.bluehola.com/v1/messages \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -H "Idempotency-Key: order-8821-notify" \ -d '{ "phoneNumberId": "pn_01923abc", "to": "8613800138000", "type": "text", "text": { "body": "Hi, your order has shipped." } }' ``` The response is `202 Accepted`, carrying the message id and an initial status of `accepted`. **That does not mean it was delivered** — track what happens next with `GET /v1/messages/{id}` or webhooks (see [Sending Messages & Tracking Status](messaging.md)). :::note **Idempotency:** send an `Idempotency-Key` (≤200 characters). Reusing the same key within the current authorization scope returns *the original* message rather than sending a second one — always include it when retrying a request that timed out. ::: Next, read [Authentication & Scopes](authentication.md) to understand authorization scopes, and [Webhook Integration](webhook-integration.md) to learn how to receive status callbacks and user replies. If your asset lists are empty, follow [Customer Onboarding](customer-onboarding.md): create a Portfolio with only `name`, then generate a hosted invitation or submit the authorization result from your own SDK page. A customer Key can complete these steps for its own customer; do not substitute a numeric Meta Business Portfolio ID for `portfolioId`. --- # Webhook Integration Canonical: https://docs.bluehola.com/docs/guides/webhook-integration OpenAPI: https://docs.bluehola.com/openapi.yaml Create a callback endpoint to receive user messages, status updates and asset changes such as phone numbers and templates, without polling. ## Creating an endpoint ```bash curl -X POST https://api.bluehola.com/v1/webhook-endpoints \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "url": "https://your-server.example.com/whatsapp-webhook", "events": ["message", "status"] }' ``` `events` is optional; the permitted values are in the "Event types" table below, and leaving it out saves `*` (receive everything, including types added later). `secret` is optional; if you supply your own it must be **at least 16 characters**, and if you do not the platform generates a random value prefixed `whsec_`. **The secret is returned only once, in the creation response** — it is what verifies signatures, so save it immediately; the platform will never show it in plaintext again. Optional fields narrow the scope and select the protocol: | Field | Purpose | | ---- | ---- | | `customerId` | Receive events for every Business Portfolio the customer entity (`cust_...`) currently owns, including Portfolios it adds later. Recommended when one receiver serves one customer. A customer Key must pass its own customer entity here. | | `projectId` | Receive events only for that single Business Portfolio (`bm_...`). Mutually exclusive with `customerId`; customer Keys cannot use it. | With neither `customerId` nor `projectId` the endpoint is account-level and receives every event under the account. **An endpoint with a binding never receives events outside it**; when an event's ownership cannot be resolved it is not delivered there either (better to miss a delivery than to send it to the wrong party). | Field | Purpose | | ---- | ---- | | `connectionId` | Use the **connection protocol**: the newer signature scheme described below, with the endpoint starting out `pending` and delivering nothing until ownership verification passes. It can also be written as `metadata.connection_id`; the two forms are equivalent. | `metadata` accepts arbitrary JSON, which the platform stores verbatim and returns when you read the endpoint. ## Endpoint states | How it was created | Initial status | Notes | | -------- | ----------- | ---- | | Without `connectionId` / `metadata.connection_id` | `active` | **Delivery starts immediately**; no further action needed. | | With `connectionId` | `pending` | It only becomes `active` after `POST /v1/webhook-endpoints/{id}/verify` passes ownership verification; nothing is delivered before that. | `DELETE /v1/webhook-endpoints/{id}` is a **soft disable** (status becomes `disabled`, delivery stops, history is retained), and the response body is the disabled endpoint object rather than an empty body. To restore it use `POST /v1/webhook-endpoints/{id}/enable`: a verified endpoint returns to `active`; an unverified connection-protocol endpoint returns to `pending` (it must pass verification again — this is not something the caller can override). :::note **Read this before rotating a secret.** `POST .../rotate-secret` takes effect immediately with no overlap period: the very next delivery is signed with the new secret, so any delivery that arrives before you have stored the new value will fail verification and — being a 4xx — is treated as a **permanent failure and not retried**. The safe approach is to rotate during a quiet period, or to `DELETE` (disable) → rotate → store the value → `POST .../enable`. ::: ## URL restrictions Endpoint URLs are checked on both creation and update, and a failure returns `400 VALIDATION_FAILED`: - production URLs **must be https**; - the hostname cannot be an internal name such as `localhost` or `metadata.google.internal`; - the resolved address must not fall in a private, loopback, link-local (including the cloud metadata address `169.254.169.254`) or CGNAT reserved range — and **resolution is repeated before every delivery**, so repointing the domain at an internal address afterwards is blocked too. ## Ownership verification and testing `POST .../verify` and `POST .../test` use the **same mechanism** (what a test needs to answer is exactly "can this address receive, and can it verify signatures" — a separate path would allow tests to pass while real deliveries fail): 1. The platform synchronously POSTs a `webhook.verification` event to your URL, with `data.challenge` holding a random value prefixed `ch_`; 2. Your endpoint verifies the signature first, then echoes that value back in the response body — either as top-level `{"challenge":"..."}` or as `{"data":{"challenge":"..."}}`; 3. The platform compares it with a constant-time comparison, and on success the endpoint becomes `active`. The challenge request times out after **5 seconds** (shorter than a regular delivery, because the caller is waiting for the result), and at most 4 KB of the response body is read. Failure does **not** change the status — the endpoint stays `pending`, so fix the receiving side and call again; the reason is in the response's `reason` field. The challenge is **signed exactly the way real events are**, so passing verification means real events will verify too. ```mermaid sequenceDiagram autonumber participant C as Caller participant P as BlueMedia participant E as Your endpoint C->>P: POST /v1/webhook-endpoints/{id}/verify P->>E: POST webhook.verification (data.challenge = ch_...) Note over P,E: 5 second timeout, at most 4 KB of the body read E->>E: Verify the signature, then read the challenge E-->>P: Echo {"challenge":"ch_..."} P->>P: Constant-time comparison P-->>C: Success → active. Failure → stays pending (see reason) ``` ## Verifying signatures There are two signature schemes, **chosen by whether the endpoint was created with the connection protocol**. When reading an endpoint, an `apiVersion` of `null` means the first scheme below. ### Default scheme (`apiVersion: null`) Every callback carries `X-Webhook-Signature-256: sha256=`, which is an HMAC-SHA256 over the **raw request body bytes** using the endpoint secret. You must verify it before parsing the JSON — compute the same value yourself and compare against the header: ```js const crypto = require('node:crypto'); function verify(rawBody, signatureHeader, secret) { if (typeof signatureHeader !== 'string') return false; // header missing const expected = Buffer.from('sha256=' + crypto .createHmac('sha256', secret) .update(rawBody) // must be the raw bytes, not the result of parsing and re-stringifying .digest('hex')); const provided = Buffer.from(signatureHeader); // timingSafeEqual throws when the lengths differ — check first, or a malformed header becomes a 500 instead of a rejection if (provided.length !== expected.length) return false; return crypto.timingSafeEqual(expected, provided); } ``` The other headers: `X-Webhook-Event` (this event's type, see below) and `X-Delivery-Id` (the unique id of this delivery, for reconciliation and de-duplication). ### Connection protocol scheme (`apiVersion` non-null) Endpoints created with a `connectionId` use four different headers, and **none of the three above appear**: | Header | Meaning | | ------ | ---- | | `Webhook-Id` | The event id, for idempotent de-duplication. Platform events use `evt_...`; the fan-out of Meta inbound events uses the delivery id (`wd_...`) | | `Webhook-Endpoint-Id` | The endpoint id (`whe_...`) | | `Webhook-Timestamp` | The unix seconds at signing time | | `Webhook-Signature` | `v1,` | `` is `HMAC_SHA256(secret, ".")`. **The timestamp is part of the signature** rather than just a header, so it cannot be tampered with, and the receiver can reject replays outside a tolerance window on that basis: ```js const crypto = require('node:crypto'); function verifyV1(rawBody, timestampHeader, signatureHeader, secret) { const [version, provided] = String(signatureHeader).split(',', 2); if (version !== 'v1' || !provided) return false; const expected = crypto .createHmac('sha256', secret) .update(`${timestampHeader}.${rawBody}`) // again, must be the raw bytes .digest('hex'); const a = Buffer.from(expected); const b = Buffer.from(provided); if (a.length !== b.length) return false; // compare byte lengths: a non-ASCII header has more bytes than characters return crypto.timingSafeEqual(a, b); } ``` ### Ownership headers (both schemes) Every delivery, under either signature scheme, also carries ownership headers so the receiver can tell which account, Business Portfolio and customer entity an event belongs to — Meta inbound events are forwarded as-is and their body has no `account_id`: | Header | Meaning | | ------ | ---- | | `X-Account-Id` | The account the event belongs to (the same value as `account_id` in the platform event envelope) | | `X-Project-Id` | The Business Portfolio (`bm_...`) | | `X-Customer-Id` | The customer entity (`cust_...`) | `X-Project-Id` and `X-Customer-Id` are **omitted** — not sent empty — when that ownership cannot be resolved (for example the WABA has not finished onboarding, or the Portfolio has no customer entity). Use them for attribution, reporting and troubleshooting; to route Meta inbound events, key on `metadata.phone_number_id` in the payload, which is always present. These headers are not part of the signature, so existing signature verification is unaffected. ## Event types The values of `X-Webhook-Event` (or `type` in the connection protocol's event envelope) fall into two groups, **listed together in the same `events` array when subscribing**: Meta inbound events: | kind | When it fires | | --------- | ---------------------------------------------------------------------------------- | | `message` | The user sent a new message (of any type, including images, documents and locations). | | `status` | A status change on a message you sent: `sent` / `delivered` / `read` / `failed`. | | `change` | Other asset changes (phone numbers, template review outcomes and so on) — everything that is not one of the two above. | | `probe` | The fallback classification for a Meta callback whose body **cannot be parsed as any known event** (a Meta connectivity probe, or a new payload shape we do not recognise yet). The raw body is in `value`. It is **not** the console's "Test" button, which sends `webhook.verification`. | Platform events: | kind | When it fires | | --------------------- | -------------------------------------------------------------- | | `job.completed` | A platform-side asynchronous job completed. | | `job.failed` | A platform-side asynchronous job failed. | | `usage.updated` | Usage data changed. | | `webhook.verification` | The challenge event for ownership verification and testing (see the previous section). | | `contact.identity_changed` | A user's BSUID changed, or Meta sent an identity-change system message. See Normalized events below. | | `contact.info_shared` | A user shared contact details. See Normalized events below. | | `marketing.preference_updated` | A user stopped or resumed marketing messages. See Normalized events below. | | `phone_number.username_updated` | A business username's status changed. See Normalized events below. | `*` means receive everything, **including types added in future** — make sure an endpoint subscribed to `*` ignores or logs types it does not recognize rather than failing. Prefix wildcards such as `job.*` are not supported — only exact values and `*`. ## Delivery and retries A `2xx` from your endpoint counts as a successful delivery. `5xx`, `429` and network-level failures are treated as transient and retried; any other `4xx` (for example you deliberately rejecting after a failed signature check) is a terminal failure and is **not** retried — so make sure your endpoint returns 5xx rather than 4xx for transient faults. Each request times out after 10 seconds. The retry schedule is a **fixed table**, not exponential backoff. After the first delivery there are at most 7 retries, for **8 attempts in total**: | Retry # | Since previous failure | | ---------- | ------------ | | 1 | immediately | | 2 | 1 minute | | 3 | 5 minutes | | 4 | 30 minutes | | 5 | 2 hours | | 6 | 12 hours | | 7 | 24 hours | The early "immediately + 1 minute" steps cover the vast majority of transient faults; stretching the later ones out to hours gives the receiving side's operators time to fix things. **The whole retry window is about 38.6 hours**; after 8 attempts it gives up rather than retrying forever. An event your endpoint missed after that can be found with [List Deliveries](../webhooks/get-v1-webhook-endpoints-id-deliveries.md) (`status=failed`) and sent again with [Redeliver a Delivery](../webhooks/post-v1-webhook-endpoints-id-deliveries-deliveryid-redeliver.md). Because retries exist, delivery is **at-least-once**: de-duplicate on the event id (`X-Delivery-Id` under the default scheme, `Webhook-Id` under the connection protocol). A manual redelivery keeps the original `Webhook-Id` under the connection protocol, but gets a new `X-Delivery-Id` under the default scheme — if you redeliver an event your endpoint may already have processed, de-duplicate on the event content (for example the message `id` / `wamid`). `GET /v1/webhook-endpoints` returns each endpoint's **most recent** delivery result (`lastDelivery`: status, response code, attempt count, latest error, timestamp), or `null` if nothing has ever been delivered. Counts of delivered/failed/pending are deliberately not provided — that kind of aggregate gets slower as message volume grows, and "did the last one succeed" is the signal you actually need. For individual delivery records, use [List Deliveries](../webhooks/get-v1-webhook-endpoints-id-deliveries.md). ## Payload structure There are two shapes, paired with the two signature schemes. Every event type has a standalone schema suitable for Ajv, a JSON Schema validator or a code generator; the entry point is [OpenAPI & Agent Access](../reference/openapi.md). The `webhooks` section of the OpenAPI 3.1 document references the same contracts. ### Meta inbound events (fan-out, paired with the default signature scheme) The callback body takes the shape `{ kind, ...context fields, message / status / value }`, with the fields varying by `kind`: ```json title="Example status event" { "kind": "status", "wabaId": "waba_...", "phoneNumberId": "pn_...", "status": { "id": "wamid.HBg...", "status": "delivered", "timestamp": "1735000000", "recipient_id": "8613800138000", "pricing": { "billable": true, "pricing_model": "PMP", "category": "marketing_lite_dynamic", "type": "regular", "cost": { "amount": 0.035, "currency": "USD" } } } } ``` For a Max Price template, `delivered` and `read` status events use `pricing.category: "marketing_lite_dynamic"` and may include `pricing.cost`. `cost.amount` is a number in the currency's base unit (for example dollars for USD), and `cost.currency` is the ISO currency. This is Meta's **estimated** charge; the Meta invoice is the source of truth for final pricing. Other pricing fields are forwarded unchanged. ### The platform event envelope (paired with the connection protocol signature scheme) Events the platform publishes itself (`job.*`, `usage.updated`, `webhook.verification` and the normalized events below) use a fixed envelope with the business content in `data`: ```json title="Example webhook.verification" { "id": "evt_...", "type": "webhook.verification", "api_version": "2026-01-01", "created_at": "2026-09-20T10:00:00.000Z", "account_id": "tenant_...", "project_id": "bm_...", "data": { "challenge": "ch_..." } } ``` `project_id` is `null` on account-level endpoints. `created_at` is always UTC with millisecond precision. ## Normalized events For a few kinds of Meta notification, the platform publishes an **additional** event in the platform envelope so you do not have to parse Meta's nested shapes. The original `message` / `change` event is still forwarded; the two carry the same content in different shapes, so subscribe to whichever you want to handle. Fields are snake_case. A field Meta did not provide is `null` — the platform never infers or fills it in (for example, it never substitutes a BSUID for a missing phone number). Most of these events carry `meta_phone_number_id` and `meta_waba_id` (the Meta-side IDs of the number and WABA), and `occurred_at` (Meta's event time, `null` if it could not be parsed). ### `contact.identity_changed` | Field | Meaning | | --- | --- | | `source` | `user_id_update` (Meta's structured BSUID change) or `system_message` (an identity-change system message). | | `user_id` | `{ previous, current }`. For `system_message`, `previous` is `null`: Meta puts the old BSUID only in human-readable text, which is not a contract. | | `parent_user_id` | `{ previous, current }` or `null`. | | `wa_id` | The user's phone number, or `null`. | | `detail` | Meta's `detail`, for `user_id_update`. | | `conversations_remapped` | For `user_id_update`: how many conversations in this account were moved to the new BSUID. | | `system_type` / `wamid` / `from` | For `system_message`: `user_changed_user_id` or `user_changed_number`, the system message ID and its sender. | ### `contact.info_shared` | Field | Meaning | | --- | --- | | `wamid` / `from` / `from_user_id` | The `contacts` message ID, the sender's phone number and BSUID. | | `context_wamid` | The message this one replied to, if any. | | `contacts[]` | `origin`, `has_vcard` and `phones[]` (`phone`, `wa_id`, `type`). The vCard itself is in the original `message` event. | `origin` is `contact_request` when the user tapped a [contact information request](../messaging/post-v1-messages.md) and shared their own details, `other` when they sent a contact card directly (which may be someone else's), and `null` when Meta did not say. The two cases need opposite handling, so **do not treat `null` as `contact_request`**. ### `marketing.preference_updated` | Field | Meaning | | --- | --- | | `value` | `stop` or `resume`. Other values are not forwarded. | | `wa_id` / `user_id` / `parent_user_id` | The user's phone number and BSUIDs. `wa_id` may be `null` with only `user_id` present; at least one of `wa_id` and `user_id` is set. | | `applies_to_meta_phone_number_id` | The sending number this preference applies to. It is not extended to the whole business or to other numbers. | | `category` | The preference category, `marketing_messages` by default. | | `detail` | Meta's `detail`. | The platform blocks marketing sends to an opted-out user whichever identifier you send to; see `MARKETING_OPT_OUT` in [Error Codes](error-codes.md). ### `phone_number.username_updated` | Field | Meaning | | --- | --- | | `display_phone_number` | The phone number, digits only. | | `username` / `status` | The business username and its status (`approved`, `reserved` or `deleted`). | | `applied` | `false` means this was a late, older event and the platform did not use it to overwrite a newer value — do not use it to overwrite yours either. | This event carries `meta_waba_id` but no `meta_phone_number_id`. --- # Conversation Thread Canonical: https://docs.bluehola.com/docs/inbox-conversations/get-v1-conversations-id OpenAPI: https://docs.bluehola.com/openapi.yaml
GET/v1/conversations/{id}
A single conversation thread: conversation info plus recent inbound/outbound messages merged together. :::note[Authentication] Send `Authorization: Bearer ` in the request headers, with scope: `messages:read`. Which resources an API Key can reach is determined by its current authorization scope. ::: ## Request Base URL: `https://api.bluehola.com` ### Parameters | Name | In | Required | Type / constraints | Description | | --- | --- | --- | --- | --- | | `id` | path | Yes | string | The conversation ID, `conv_...` | | `limit` | query | No | integer 1..200 | Number of messages to return, default 50. Out-of-range values are clamped; ignored if unparseable | ## Response | Status | Description | | --- | --- | | `200` | OK | | `4xx` | Client error | For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md). ## Notes The returned merged message list combines two sources — inbound (persisted from webhooks) and outbound (persisted at send time) — into a single thread ordered by time; `limit` is likewise clamped to 1–200, and requesting a conversation outside the caller's account returns 404 (rather than 403), to avoid revealing whether the resource exists. Outbound messages carry `status`/`errorCode`/`errorMessage`, and a failed outbound message additionally carries the same `stage` and structured `error` (policy code, metaCode, retryable, customerAction) as `GET /v1/messages/{id}`; these fields are always null on inbound messages. --- # Inbox List Canonical: https://docs.bluehola.com/docs/inbox-conversations/get-v1-conversations OpenAPI: https://docs.bluehola.com/openapi.yaml
GET/v1/conversations
The inbox list, sorted by most recent activity; before (an ISO timestamp) provides cursor-based pagination. :::note[Authentication] Send `Authorization: Bearer ` in the request headers, with scope: `messages:read`. Which resources an API Key can reach is determined by its current authorization scope. ::: ## Request Base URL: `https://api.bluehola.com` ### Parameters | Name | In | Required | Type / constraints | Description | | --- | --- | --- | --- | --- | | `limit` | query | No | integer 1..200 | Default 50. Out-of-range values are **clamped** rather than erroring; ignored if unparseable as a number | | `before` | query | No | ISO 8601 date-time | A keyset cursor: returns only conversations with activity earlier than this, taken from the last row's time on the previous page. Ignored if unparseable (same as omitting it) | | `phoneNumberId` | query | Required for customer Keys | string | Return only the conversations of this business number (`pn_...`). A customer Key must pass a number its customer entity owns, otherwise `403` | ## Response | Status | Description | | --- | --- | | `200` | OK | | `4xx` | Client error | For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md). ## Notes `limit` is clamped to between 1 and 200 (out-of-range values are silently corrected, not rejected); `before` is a cursor rather than an offset, paging in descending order of most recent activity, to avoid the misalignment that new messages arriving mid-pagination would otherwise cause. `phoneNumberId` limits the list to one business number; without it a BU Key sees the inbox of every number in the account. --- # Reset Unread Count Canonical: https://docs.bluehola.com/docs/inbox-conversations/post-v1-conversations-id-read OpenAPI: https://docs.bluehola.com/openapi.yaml
POST/v1/conversations/{id}/read
Reset the unread count; this does not send a read receipt to WhatsApp (that requires POST /v1/messages/read). :::note[Authentication] Send `Authorization: Bearer ` in the request headers, with scope: `messages:read`. Which resources an API Key can reach is determined by its current authorization scope. ::: ## Request Base URL: `https://api.bluehola.com` ### Parameters | Name | In | Required | Type / constraints | Description | | --- | --- | --- | --- | --- | | `id` | path | Yes | string | The conversation ID, `conv_...` | ## Response | Status | Description | | --- | --- | | `200` | OK | | `4xx` | Client error | For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md). ## Notes This only resets the platform's local unread count; it is a purely local operation and produces no outbound request. If you need WhatsApp to show a "read" receipt to the other user, you must separately call POST /v1/messages/read — the two are not linked and must be called independently by the client. --- # BlueMedia API Canonical: https://docs.bluehola.com/docs/ OpenAPI: https://docs.bluehola.com/openapi.yaml # BlueMedia API Integrate the WhatsApp Business Platform through the BlueMedia API: customer onboarding, phone number management, templates and message sending, webhook callbacks and billing queries. :::info Before you start, have the **API Key** supplied by BlueMedia to hand. Except for the public endpoints that are explicitly marked as such, every request must carry `Authorization: Bearer `. ::: **API Base URL** ```text https://api.bluehola.com ``` ## Start here > 此处为网页卡片导航;请使用本文件顶部的 canonical URL 继续浏览。 ## Recommended integration order 1. Read the [Quickstart](guides/quickstart.md) and verify your API Key. 2. Follow [Customer Onboarding](guides/customer-onboarding.md) to get the Business Portfolio, WABA and phone number in place. 3. Configure [webhooks](guides/webhook-integration.md) so you can receive asynchronous statuses and inbound messages. 4. Follow [Sending Messages & Tracking Status](guides/messaging.md) to send a test message and confirm its final status. The left-hand navigation lists every endpoint, grouped by business domain. Each endpoint is its own Markdown page, so it can be maintained, reviewed and change-tracked independently. --- # Broadcasts Canonical: https://docs.bluehola.com/docs/messaging/broadcasts OpenAPI: https://docs.bluehola.com/openapi.yaml # Broadcasts Dispatch one template message to a batch of recipients, and pause, resume or cancel it while it's in progress. Recipients can use a phone (`to`) or BSUID (`toUserId`), with phone taking precedence. De-duplicate your audience by Contact before submission: server-side deduplication is by the identity actually used, not by `reference` or an inferred phone/BSUID link. Authentication templates cannot target BSUIDs; a BSUID must match the sending phone's Business Portfolio scope. See [Create Broadcast](post-v1-broadcasts.md) for validation, pricing and scope-failure handling; [Recipient Details](get-v1-broadcasts-id-recipients.md) returns the identity actually used. A broadcast is costed against the total in full **at creation time**: if the account balance or the customer budget can't cover it, the whole campaign is rejected outright — it never sends half the list and then stops. | Endpoint | Purpose | | --- | --- | | [Create Broadcast](post-v1-broadcasts.md) | Submit a template, recipient list and parameters to create a campaign. | | [List Broadcast Campaigns](get-v1-broadcasts.md) | The current account's campaigns and their statuses; find a campaign by its `Idempotency-Key`. | | [Campaign Details](get-v1-broadcasts-id.md) | Progress and summary counts for a single campaign. | | [Recipient Details](get-v1-broadcasts-id-recipients.md) | Per-recipient dispatch status, delivery status and failure reasons, with your own `reference`. | | [Pause Delivery](post-v1-broadcasts-id-pause.md) | Stop further dispatch; messages already submitted are unaffected. | | [Resume Campaign](post-v1-broadcasts-id-resume.md) | Let a paused campaign continue dispatching. | | [Cancel Campaign](post-v1-broadcasts-id-cancel.md) | Terminate a campaign; remaining recipients are never dispatched to. | Send an `Idempotency-Key` header when creating a campaign so that a retried request cannot create a second campaign — see [Create Broadcast](post-v1-broadcasts.md). Broadcasts can only send approved template messages, so they are not bound by the 24-hour customer service window. Reservation and reversal rules are the same as for a single message — see [Billing & Credit Line](../guides/billing.md). --- # Recipient Details Canonical: https://docs.bluehola.com/docs/messaging/get-v1-broadcasts-id-recipients OpenAPI: https://docs.bluehola.com/openapi.yaml
GET/v1/broadcasts/{id}/recipients
Recipient details, with each row's delivery facts in `delivery`. `status` filters by dispatch status and `deliveryStatus` by delivery status. :::note[Authentication] Send `Authorization: Bearer ` in the request headers, with scope `messages:read`. Which resources an API Key can reach is determined by its current authorization scope. ::: ## Request Base URL: `https://api.bluehola.com` ### Parameters | Name | In | Required | Type / constraints | Description | | --- | --- | --- | --- | --- | | `id` | path | Yes | string | The broadcast campaign ID, `bc_...` | | `status` | query | No | string | Filter by **dispatch** status: `pending` / `dispatching` / `queued` / `failed` / `skipped` / `canceled`. Any other value returns `400 VALIDATION_FAILED` | | `deliveryStatus` | query | No | string | Filter by **delivery** status: `accepted` / `sending` / `submitted` / `sent` / `delivered` / `read` / `failed`. Any other value returns `400 VALIDATION_FAILED` | | `after` | query | No | string | Pagination: pass the `id` of the last row on the previous page | | `limit` | query | No | integer 1..1000 | Defaults to **200** (unlike other list endpoints). Out-of-range values are clamped | ## Response | Status | Description | | --- | --- | | `200` | OK | | `4xx` | Client error | For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md). ## Notes `status` filters by **dispatch** status (pending / dispatching / queued / failed / skipped / canceled, the same keys as the dispatch counts); `deliveryStatus` filters by **delivery** status (accepted / sending / submitted / sent / delivered / read / failed). Any other value returns 400. They are different sets: `status=failed` means the platform could not dispatch to that recipient, while `deliveryStatus=failed` means the message was dispatched and Meta refused to deliver it. For a complete list of failures, pull both — do not add the two counts together. Each row has `id`, `toNumber` / `toUserId` (the phone or BSUID actually used, with the other `null`; phone wins when both were supplied), `reference` (your identifier, returned verbatim and not used for deduplication), `status`, `errorCode` / `errorMessage` (why dispatch failed), `messageId`, `dispatchedAt`, and `delivery`: `{ status, wamid, errorCode, errorMessage, updatedAt }` (`null` until the recipient has been dispatched; when the failure comes from Meta, `errorCode` is Meta's numeric code). For the full message record, `messageId` still points at GET /v1/messages/{id}. Historical phone-only rows return `toUserId: null`. A BSUID's Business Portfolio scope cannot be validated locally; Meta rejects a mismatched scope, with no phone fallback or sender switch. `202` / `dryRun` does not guarantee delivery. Inspect dispatch or delivery errors here and GET /v1/messages/{messageId} for the full native Meta error. Pagination: rows are sorted by `id` ascending; pass the `id` of the last row on the previous page as `after`. Fewer rows than `limit` means you have reached the end. `limit` defaults to 200 and is clamped between 1 and 1000. The total is `dispatch.total` from GET /v1/broadcasts/{id}. --- # Campaign Details Canonical: https://docs.bluehola.com/docs/messaging/get-v1-broadcasts-id OpenAPI: https://docs.bluehola.com/openapi.yaml
GET/v1/broadcasts/{id}
A single campaign: status, estimated cost, dispatch progress and delivery results. :::note[Authentication] Send `Authorization: Bearer ` in the request headers, with scope `messages:read`. Which resources an API Key can reach is determined by its current authorization scope. ::: ## Request Base URL: `https://api.bluehola.com` ### Parameters | Name | In | Required | Type / constraints | Description | | --- | --- | --- | --- | --- | | `id` | path | Yes | string | The broadcast campaign ID, `bc_...` | ## Response | Status | Description | | --- | --- | | `200` | OK | | `4xx` | Client error | For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md). ## Notes #### Dispatch and delivery are two different measures `dispatch` is **dispatch** progress (pending / dispatching / queued / failed / skipped / canceled) — "did we hand this message off". `delivery` is the **delivery** outcome, aggregated from messages.status (accepted / sending / sent / delivered / read / failed) — "what happened on the WhatsApp side". `dispatch.failed` means dispatch itself failed (for example the number was deactivated); `delivery.failed` means Meta rejected it or delivery failed. The two are not equal and should not be added together. #### status = completed does not mean everything arrived completed only means "every recipient has been handed to the send pipeline". Delivery outcomes come back asynchronously — check the `delivery` counts. Failed messages are reversed automatically under the usual rules. --- # List the current account's broadcast campaigns Canonical: https://docs.bluehola.com/docs/messaging/get-v1-broadcasts OpenAPI: https://docs.bluehola.com/openapi.yaml
GET/v1/broadcasts
List the current account's broadcast campaigns, with dispatch progress and delivery result counts. :::note[Authentication] Send `Authorization: Bearer ` in the request headers, with scope `messages:read`. Which resources an API Key can reach is determined by its current authorization scope. ::: ## Request Base URL: `https://api.bluehola.com` ### Parameters | Name | In | Required | Type / constraints | Description | | --- | --- | --- | --- | --- | | `limit` | query | No | integer 1..200 | Defaults to 50. Values above 200 are treated as 200; non-positive or unparseable values are treated as 50 | | `before` | query | No | ISO 8601 | Pagination: pass the `broadcast.createdAt` of the last entry on the previous page. An unparseable value returns `400 VALIDATION_FAILED` | | `idempotencyKey` | query | No | string | Find the campaign created with this `Idempotency-Key` (0 or 1 entries) | | `phoneNumberId` | query | Required for customer Keys | string | Return only campaigns sent from this number (`pn_...`). A customer Key must pass a number its customer entity owns, otherwise `403` | ## Response | Status | Description | | --- | --- | | `200` | OK | | `4xx` | Client error | For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md). ## Notes `limit` defaults to 50 with a ceiling of 200; entries are sorted by creation time, newest first. Page with `before` (an ISO timestamp: the `broadcast.createdAt` of the last entry on the previous page). `idempotencyKey` finds a campaign by the `Idempotency-Key` used when creating it (0 or 1 entries) — use it to check whether a create request whose outcome is unknown actually created the campaign. `phoneNumberId` limits the list to one sending number and combines with the other filters. Each entry carries two separate sets of counts, `dispatch` (dispatch progress) and `delivery` (delivery outcome), which mean different things — see GET /v1/broadcasts/{id}. --- # Get the final status, wamid and failure reason Canonical: https://docs.bluehola.com/docs/messaging/get-v1-messages-id OpenAPI: https://docs.bluehola.com/openapi.yaml
GET/v1/messages/{id}
Get the final status, wamid and failure reason. :::note[Authentication] Send `Authorization: Bearer ` in the request headers. Which resources an API Key can reach is determined by its current authorization scope. ::: ## Request Base URL: `https://api.bluehola.com` ### Parameters | Name | In | Required | Type / constraints | Description | | --- | --- | --- | --- | --- | | `id` | path | Yes | string | The platform's message ID, `msg_...` | ## Response | Status | Description | | --- | --- | | `200` | `MessageDetails`, including the status and a structured failure reason | | `401` | API Key missing or invalid | | `403` | The current credential cannot access this resource | | `404` | The message does not exist, or does not belong to the current account | | `500` | Internal platform error | For the complete response structure, see `MessageDetails` in [OpenAPI & Agent Access](../reference/openapi.md). For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md). ## Notes Status progression: `accepted` → `sending` → `submitted` → `sent` → `delivered` → `read`, with any step able to turn `failed`. **`submitted` only means Meta accepted the request and returned a wamid — it does not mean the message was sent**; `sent` is a separate status callback, and `delivered` is when it actually reaches the device. On failure, `error.code` coming from Meta is Meta's own numeric code (which maps directly onto their official error code table); only failures determined locally — insufficient account balance, an exhausted customer budget, the local 131049 cooldown, or exhausted retries — use one of our own error codes. `error.message` is Meta's own wording, passed through unchanged; `error.meta` is the entire native envelope (`details` / `userMsg` / `type` / `fbtrace_id`, the last of which is the credential you need when opening a Meta Direct Support ticket). `retryable` / `customerAction` / `stage` are BlueMedia's own judgement, not fields Meta supplies (submit means it was rejected before ever being delivered; delivery means Meta accepted it and it failed afterwards); the same failure status can hide failures of completely different natures, so do not decide whether to retry from the status alone. If the Meta response is lost after submission, a message may remain in `sending` while the platform reconciles its outcome. Poll this endpoint later. Reusing the same `Idempotency-Key` returns the same platform message; do not submit a new message for the same business event. --- # Messages Canonical: https://docs.bluehola.com/docs/messaging/messages OpenAPI: https://docs.bluehola.com/openapi.yaml # Messages Submit outbound messages, check message status, and mark inbound messages as read. The `202 Accepted` returned by `POST /v1/messages` only means the **platform has accepted it** — not that it was delivered, and not even that it was submitted to Meta. There are only two ways to get the real outcome: poll `GET /v1/messages/{id}`, or receive the status webhooks. | Endpoint | Purpose | | --- | --- | | [Submit Outbound Message](post-v1-messages.md) | Send any of 11 message types (text, template, media, interactive, and more). Sending an `Idempotency-Key` is recommended. | | [Get Message Status](get-v1-messages-id.md) | The final status, `wamid` and failure reason for a single message. | | [Mark as Read](post-v1-messages-read.md) | Mark an inbound message as read, optionally with a "typing" indicator. No charge and no send quota consumed. | :::info `POST /v1/messages/read` and the inbox's `POST /v1/conversations/{id}/read` are two independent things: the former talks directly to Meta's read receipt, while the latter only clears the platform's local unread count — the two are not linked. ::: For the state machine, the 24-hour customer service window, media reference rules (`id` and `link` must have exactly one), and when billing happens, see [Sending Messages & Tracking Status](../guides/messaging.md). For the failure code table, see [Error Codes](../guides/error-codes.md). --- # Cancel Campaign Canonical: https://docs.bluehola.com/docs/messaging/post-v1-broadcasts-id-cancel OpenAPI: https://docs.bluehola.com/openapi.yaml
POST/v1/broadcasts/{id}/cancel
Cancel a campaign and void every recipient not yet dispatched to, all at once. Cannot be undone. :::note[Authentication] Send `Authorization: Bearer ` in the request headers, with scope `messages:send`. Which resources an API Key can reach is determined by its current authorization scope. ::: ## Request Base URL: `https://api.bluehola.com` ### Parameters | Name | In | Required | Type / constraints | Description | | --- | --- | --- | --- | --- | | `id` | path | Yes | string | The broadcast campaign ID, `bc_...` | ## Response | Status | Description | | --- | --- | | `200` | OK | | `4xx` | Client error | For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md). ## Notes Returns `canceledRecipients` (the number of pending recipients voided at that moment). Messages already dispatched cannot be recalled — WhatsApp has no unsend endpoint, so those messages are still delivered as scheduled and are still charged. Cancellation takes effect before the dispatcher's **next** message: the dispatcher re-reads the campaign status before sending each message, so recipients claimed in the current round but not yet sent are voided right away (they will not receive anything after the cancel). The only window is the one message being handed to the send pipeline at the moment of cancellation. So besides `canceledRecipients`, a very small number of recipients in `dispatching` may turn `canceled` over the next few seconds; rely on the `dispatch` counts from GET /v1/broadcasts/{id}. Cancellation is final and cannot be resumed; to send to the remaining recipients, create a new campaign. --- # Pause Delivery Canonical: https://docs.bluehola.com/docs/messaging/post-v1-broadcasts-id-pause OpenAPI: https://docs.bluehola.com/openapi.yaml
POST/v1/broadcasts/{id}/pause
Pause dispatch. Messages already handed off to WhatsApp cannot be recalled. :::note[Authentication] Send `Authorization: Bearer ` in the request headers, with scope `messages:send`. Which resources an API Key can reach is determined by its current authorization scope. ::: ## Request Base URL: `https://api.bluehola.com` ### Parameters | Name | In | Required | Type / constraints | Description | | --- | --- | --- | --- | --- | | `id` | path | Yes | string | The broadcast campaign ID, `bc_...` | ### Request body A request body is required. ### Request body fields | Field | Type | Required | Description | | --- | --- | --- | --- | | `reason` | string | No | The reason for pausing, written into the campaign's pauseReason | Content-Type: `application/json` Schema: ```json { "type": "object", "properties": { "reason": { "type": "string", "description": "string · optional — the reason for pausing, written into the campaign's pauseReason" } } } ``` ## Response | Status | Description | | --- | --- | | `200` | OK | | `4xx` | Client error | For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md). ## Notes Only valid for scheduled / running campaigns; other states return 409, with the current state given in details.status. When the balance runs out the platform **automatically** pauses the campaign and sets pauseReason to insufficient credit — after topping up, just call resume to continue sending to the remaining recipients; there is no need to recreate the campaign. Pausing takes effect before the dispatcher's next message, and recipients claimed in the current round but not yet sent go back to `pending`. Resume only continues with `pending` recipients; it does **not** resend to recipients whose dispatch failed (`status=failed`). --- # Resume a paused campaign Canonical: https://docs.bluehola.com/docs/messaging/post-v1-broadcasts-id-resume OpenAPI: https://docs.bluehola.com/openapi.yaml
POST/v1/broadcasts/{id}/resume
Resume a paused campaign, continuing with the remaining recipients. :::note[Authentication] Send `Authorization: Bearer ` in the request headers, with scope `messages:send`. Which resources an API Key can reach is determined by its current authorization scope. ::: ## Request Base URL: `https://api.bluehola.com` ### Parameters | Name | In | Required | Type / constraints | Description | | --- | --- | --- | --- | --- | | `id` | path | Yes | string | The broadcast campaign ID, `bc_...` | ## Response | Status | Description | | --- | --- | | `200` | OK | | `4xx` | Client error | For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md). ## Notes Only valid when paused. Resuming clears pauseReason; recipients already marked failed are not resent (to resend, create a new campaign for that batch of numbers). --- # Create Broadcast Canonical: https://docs.bluehola.com/docs/messaging/post-v1-broadcasts OpenAPI: https://docs.bluehola.com/openapi.yaml
POST/v1/broadcasts
Create a broadcast (bulk template send). Returns 202 — by the time the response comes back, nothing has been sent yet: the platform advances the actual sending one message at a time, throttled to its send rate. :::note[Authentication] Send `Authorization: Bearer ` in the request headers, with scope `messages:send`. Which resources an API Key can reach is determined by its current authorization scope. ::: ## Request Base URL: `https://api.bluehola.com` ### Parameters | Name | In | Required | Type / constraints | Description | | --- | --- | --- | --- | --- | | `Idempotency-Key` | header | No | string, ≤200 characters | Campaign-level idempotency key. The same key with the same request body returns the original campaign (`replayed: true`); the same key with a different request body returns `409 IDEMPOTENCY_CONFLICT`; ignored when `dryRun` is set. A longer key returns `400 VALIDATION_FAILED` | ### Request body A request body is required. ### Request body fields | Field | Type | Required | Description | | --- | --- | --- | --- | | `name` | string | Yes | A human-readable campaign name, e.g. "Singles' Day Warm-up" | | `phoneNumberId` | string | Yes | The sending number, pn_... | | `template` | object | Yes | { name, language: { code }, components? }; a campaign sends exactly one template | | `recipients` | array | Yes | [{ to?, toUserId?, variables?, reference? }], at most 20000 entries; provide a phone (`to`) or BSUID (`toUserId`), with phone taking precedence; variables override template.components; `reference` is correlation data (1–200 characters), not a deduplication key, returned in [Recipient Details](get-v1-broadcasts-id-recipients.md) | | `scheduledAt` | ISO 8601 | No | Dispatch starts only once this time is reached; omit it to start immediately | | `dryRun` | boolean | No | true validates and estimates cost only, without persisting anything | Content-Type: `application/json` Example: ```json { "name": "Singles' Day Warm-up", "phoneNumberId": "", "template": { "name": "promo_v1", "language": { "code": "zh_CN" } }, "recipients": [ { "to": "8613800138000", "reference": "crm-10001" }, { "toUserId": "US.13491208655302741918", "reference": "crm-10002", "variables": [ { "type": "body", "parameters": [ { "type": "text", "text": "Zhang San" } ] } ] } ] } ``` Schema: ```json { "type": "object", "properties": { "name": { "type": "string", "description": "string · required — a human-readable campaign name, e.g. \"Singles' Day Warm-up\"" }, "phoneNumberId": { "type": "string", "description": "string · required — the sending number, pn_..." }, "template": { "type": "string", "description": "object · required — { name, language: { code }, components? }; a campaign sends exactly one template" }, "recipients": { "type": "array", "minItems": 1, "maxItems": 20000, "description": "Provide to (phone) or toUserId (BSUID); phone wins when both are supplied.", "items": { "type": "object", "additionalProperties": false, "anyOf": [{ "required": ["to"] }, { "required": ["toUserId"] }], "properties": { "to": { "type": "string", "minLength": 1 }, "toUserId": { "type": "string", "minLength": 1 }, "variables": { "type": "array", "items": { "type": "object" } }, "reference": { "type": "string", "minLength": 1, "maxLength": 200 } } } }, "scheduledAt": { "type": "string", "description": "ISO 8601 · optional — dispatch starts only once this time is reached; omit it to start immediately" }, "dryRun": { "type": "string", "description": "boolean · optional — true validates and estimates cost only, without persisting anything" } }, "required": [ "name", "phoneNumberId", "template", "recipients" ], "example": { "name": "Singles' Day Warm-up", "phoneNumberId": "", "template": { "name": "promo_v1", "language": { "code": "zh_CN" } }, "recipients": [ { "to": "8613800138000", "reference": "crm-10001" }, { "toUserId": "US.13491208655302741918", "reference": "crm-10002", "variables": [ { "type": "body", "parameters": [ { "type": "text", "text": "Zhang San" } ] } ] } ] } } ``` ## Response | Status | Description | | --- | --- | | `202` | Accepted | | `4xx` | Client error | For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md). ## Notes #### How this differs from looping your own calls to POST /v1/messages Throttling, de-duplication, resuming after a mid-run outage, and cost pre-checks all happen on the platform side. The Cloud API defaults to 80 msg/s per number (1000 after an upgrade; only 20 for numbers that coexist with the WhatsApp Business app), returning 130429 if you exceed it; the platform paces itself at "N messages per round, one round per second", roughly 50 msg/s by default. #### Four things that happen at creation - **The template is validated exactly once**: not yet approved, or not present under the WABA that owns this number → an immediate 404/409, rather than turning into tens of thousands of failed recipients. - **Effective identities are de-duplicated**: normalize phone numbers (`+86 133…`, `86133…`, spaces and hyphens), or compare full BSUID strings exactly. Keep the first entry's variables and `reference`. The response's `submitted` / `accepted` / `duplicates` are the submitted, persisted and duplicate counts. When both identities are supplied, only the phone is used; the ignored BSUID is not treated as an alias. The platform cannot infer that separate phone-only and BSUID-only entries are the same Contact: de-duplicate by Contact in your audience before submitting. `reference` is not a deduplication key. - **Invalid identities each get a reason**: phone entries use `{ to, reason }` (empty / not_a_number / length_out_of_range); BSUID entries use `{ toUserId, reason: "invalid_bsuid" }`. If no valid recipients remain, creation returns `400 VALIDATION_FAILED`. Format validation does not check WhatsApp registration, and an invalid supplied phone never falls back to BSUID. - **Cost is pre-checked**: each de-duplicated recipient is priced from your rate card by market, at the highest rate that can apply — so the estimate is an upper bound on what the campaign will actually cost. Recipients that cannot be priced (for example a market missing from the rate card) are counted at a flat fallback estimate. The same estimate is returned as `estimatedCostMinor` with `dryRun: true`, and is what each message reserves when it is sent. If the account balance can't cover the whole campaign, it returns `402 INSUFFICIENT_FUNDS` right away, rather than sending half of it and stopping; if the customer budget can't, it returns `402 CUSTOMER_BUDGET_EXCEEDED`. The `INSUFFICIENT_FUNDS` details are `requiredMinor` / `availableMinor`, the authoritative `requiredMicros` / `availableMicros`, `currency`, `recipients`, and `pricedRecipients` / `fallbackRecipients` / `fallbackEstimateMinor`. **If `fallbackRecipients` is not 0, check the rate card before topping up**: those recipients were counted at the fallback estimate, which is usually far higher than the real price. #### BSUID restrictions and Business Portfolio scope Provide `to` or `toUserId` on each recipient. When both are present, the phone wins and only the identity actually used is persisted (`toNumber` or `toUserId` in recipient details, with the other `null`). Use the full BSUID, including its country prefix and periods; do not put it in `to`. One-tap / zero-tap / copy-code authentication templates and templates with Max Price cannot target BSUIDs. If any accepted recipient actually uses a BSUID, creation rejects the entire campaign with `400 VALIDATION_FAILED`, including `dryRun`, before storing the campaign or recipients. Supplying a phone as well uses the phone and is not blocked by this rule. A regular BSUID is scoped to one **Business Portfolio**: select a sending phone owned by that Portfolio. Parent BSUIDs (`CC.ENT.id`) work only across the Portfolios Meta enrolled in that parent scope. Scope cannot be verified from the BSUID string locally; **`dryRun` and `202` acceptance do not guarantee deliverability**. Meta rejects a mismatched scope; the platform never switches sending numbers or falls back to a phone. Inspect dispatch `errorCode` / `errorMessage` or `delivery.errorCode` / `delivery.errorMessage` in [Recipient Details](get-v1-broadcasts-id-recipients.md), and [Message Details](get-v1-messages-id.md) for the full native Meta error. No fixed numeric scope-mismatch error code is promised. BSUID-only recipients have no phone for market pricing and use the existing unpriced-recipient fallback estimate for the pre-check and reservation; the BSUID country prefix is not a phone pricing market. Existing authorization, opt-out, cooldown, pacing, balance, customer budget and idempotency rules still apply. #### Warnings are worth reading `warnings` does not block creation, but each one genuinely affects the delivery outcome: - The recipient count exceeds the **Business Portfolio**'s message cap for the number used (a new combination gets only 250 unique users/24h, shared across every number under that combination); the excess will be rejected by Meta; - The platform doesn't know the current limit tier locally (it hasn't been synced) — ask BlueMedia support to refresh the number from Meta; - A MARKETING template sent to a +1 number: WhatsApp does not deliver marketing templates to US numbers (Canada is also +1 and the platform cannot tell them apart locally, so it only warns rather than silently dropping them); - MARKETING templates are subject to a **per-person frequency cap**; recipients over the limit fail with 131049 and cannot be retried within 24 hours (the platform does not automatically retry this kind of failure); - Sending large volumes of marketing messages while a number's quality rating is YELLOW/RED will push the rating down further and may trigger a lower limit. #### Idempotency - **Campaign level**: with an `Idempotency-Key` header, one key creates at most one campaign. Repeating the POST (same key, same request body) returns the original campaign with `replayed: true` in the response, and `submitted` / `accepted` / `warnings` and the other counts are the results of **the original** request. The same key with a different request body returns `409 IDEMPOTENCY_CONFLICT`. Replay happens before the balance and template checks, so a retry does not get a `402` even after the original campaign has spent the balance. Concurrent requests with the same key persist only one campaign. Without this header, repeating the POST creates two campaigns. - **When the outcome is unknown**: if the create request timed out and you do not know whether the campaign was created, query `GET /v1/broadcasts?idempotencyKey=`. Do not guess by name or time, and do not create it again with a new key. - **Recipient level**: each recipient's message uses a fixed idempotency key, `bcast:`, so a restart of the dispatch process cannot send the same person a duplicate. --- # Mark an inbound message as read Canonical: https://docs.bluehola.com/docs/messaging/post-v1-messages-read OpenAPI: https://docs.bluehola.com/openapi.yaml
POST/v1/messages/read
Mark an inbound message as read (optionally with a typing indicator); takes effect in real time, incurs no charge, and is not a send. :::note[Authentication] Send `Authorization: Bearer ` in the request headers, with scope `messages:send`. Which resources an API Key can reach is determined by its current authorization scope. ::: ## Request Base URL: `https://api.bluehola.com` ### Request body A request body is required. ### Request body fields | Field | Type | Required | Description | | --- | --- | --- | --- | | `phoneNumberId` | string | Yes | The platform's phone number ID, pn_... | | `messageId` | string | Yes | The inbound message's wamid.* | | `typing` | boolean | No | true attaches a "typing" indicator | Content-Type: `application/json` Schema: ```json { "type": "object", "properties": { "phoneNumberId": { "type": "string", "description": "string · required — the platform's phone number ID, pn_..." }, "messageId": { "type": "string", "description": "string · required — the inbound message's wamid.*" }, "typing": { "type": "string", "description": "boolean · optional — true attaches a \"typing\" indicator" } }, "required": [ "phoneNumberId", "messageId" ] } ``` ## Response | Status | Description | | --- | --- | | `200` | OK | | `4xx` | Client error | For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md). ## Notes This talks directly to Meta's real-time endpoint, bypassing the Transactional Outbox, and consumes no send quota or rate limit; the typing indicator attached with typing=true is only active for a short time (about 25 seconds, or until your next message), and only succeeds while the original inbound message that messageId refers to is still within its window (Meta recommends marking it within 30 days). --- # Submit Outbound Message Canonical: https://docs.bluehola.com/docs/messaging/post-v1-messages OpenAPI: https://docs.bluehola.com/openapi.yaml
POST/v1/messages
Submit an outbound message, returning 202 with status accepted. Sending a business-unique Idempotency-Key (up to 200 characters) is recommended; a repeated key within the current authorization scope returns the same message; the default rate limit is 600 per minute. :::note[Authentication] Send `Authorization: Bearer ` in the request headers, with scope `messages:send`. Which resources an API Key can reach is determined by its current authorization scope. ::: ## Request Base URL: `https://api.bluehola.com` ### Parameters | Name | In | Required | Type / constraints | Description | | --- | --- | --- | --- | --- | | `Idempotency-Key` | header | No | string · up to 200 | A business-unique key, up to 200 characters; a repeated key within the current authorization scope returns the same message rather than sending it again | ### Request body A request body is required. ### Request body fields | Field | Type | Required | Description | | --- | --- | --- | --- | | `phoneNumberId` | string | Yes | The platform's phone number ID, pn_...; get the numbers actually held in the current authorization scope from GET /v1/phone-numbers rather than reusing the placeholder from these examples | | `to` | string | No | The recipient's number in E.164 form, without the +. At least one of this and `toUserId` **must be given** | | `toUserId` | string | No | The recipient's BSUID (called `recipient` in Meta's request body), for example `US.13491208655302741918` | | `type` | string | No | `text` / `template` / `image` / `video` / `audio` / `document` / `sticker` / `interactive` / `location` / `contacts` / `reaction`. **Treated as `text` when omitted** (for backwards compatibility); any other unrecognised value returns `400 VALIDATION_FAILED` | | `` | object \| object[] | Yes | The content object with the same name as `type`, required depending on the type (`contacts` is an array, the rest are objects). See "Request body shape by type" below for each type's fields | Content-Type: `application/json` Example: ```json { "phoneNumberId": "", "to": "8613800138000", "type": "text", "text": { "body": "Hello", "preview_url": false } } ``` For the complete request contract, see `MessageRequest` in [OpenAPI & Agent Access](../reference/openapi.md). It uses `oneOf` + `discriminator` to describe the 11 message shapes, rather than mis-describing the dynamic `` as a plain string: ```yaml MessageRequest: oneOf: - $ref: '#/components/schemas/TextMessageRequest' - $ref: '#/components/schemas/TemplateMessageRequest' - $ref: '#/components/schemas/ImageMessageRequest' - $ref: '#/components/schemas/VideoMessageRequest' # remaining types are in the OpenAPI document discriminator: propertyName: type ``` The schema also validates that at least one of `to` / `toUserId` is present, and that exactly one of the media `id` / `link` is given. Omitting `type` is backwards-compatibility behaviour for text only; new code should send `type` explicitly. ## Response | Status | Description | | --- | --- | | `202` | Accepted, returns the full `MessageRecord`; does not mean it was delivered | | `400` | Malformed request body, recipient, or idempotency key | | `401` | API Key missing or invalid | | `403` | Insufficient scope, or the recipient has opted out of marketing messages | | `404` | The sending number does not exist, or is outside the current authorization scope | | `409` | An idempotency conflict, or the 24-hour customer service window has closed | | `429` | Rate limited, or Meta's per-person engagement cooldown | | `500` | Internal platform error | Example success response: ```json { "id": "msg_01923abc", "tenantId": "tenant_01923abc", "phoneNumberId": "pn_01923abc", "metaPhoneNumberId": "1234567890", "toNumber": "8613800138000", "toUserId": null, "type": "text", "content": {"body": "Hello", "preview_url": false}, "category": null, "status": "accepted", "wamid": null, "errorCode": null, "errorMessage": null, "metaError": null, "idempotencyKey": "order-8821-notify", "createdAt": "2026-09-22T10:00:00.000Z", "updatedAt": "2026-09-22T10:00:00.000Z" } ``` Every error response carries an `X-Request-Id` response header, matching `error.requestId` in the body. For the complete field definitions, see `ErrorResponse` in [OpenAPI & Agent Access](../reference/openapi.md). For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md). ## Notes #### Request body shape by type `type` determines the shape of the content object with the same name; validation happens before anything is persisted — a malformed shape returns `400 VALIDATION_FAILED` and never enters the asynchronous send queue. | type | Field of the same name | Required fields | Optional fields | | --- | --- | --- | --- | | `text` | `text` (object) | `body` | `preview_url` (boolean) | | `template` | `template` (object) | `name`, `language.code` | `components` (object[]) | | `image` | `image` (object) | `id` **or** `link` (**exactly one**) | `caption` | | `video` | `video` (object) | `id` **or** `link` (exactly one) | `caption` | | `audio` | `audio` (object) | `id` **or** `link` (exactly one) | — | | `sticker` | `sticker` (object) | `id` **or** `link` (exactly one) | — | | `document` | `document` (object) | `id` **or** `link` (exactly one) | `caption`, `filename` | | `interactive` | `interactive` (object) | `type`; for `request_contact_info`, also a non-blank `body.text` and `action.name: "request_contact_info"` | Every other field is passed through to Meta as-is (`flow` / `button` / `list` / `cta_url` / `location_request_message` / `address_message` / `request_contact_info` are all supported, with no platform changes needed) | | `location` | `location` (object) | `latitude` (-90..90), `longitude` (-180..180); either may be a number or a string | `name`, `address` | | `contacts` | `contacts` (**array**, 1–257 entries) | `name.formatted_name` on each entry | `addresses`, `emails`, `org`, `phones`, `urls`, `birthday` (`YYYY-MM-DD`) | | `reaction` | `reaction` (object) | `message_id` (must start with `wamid.`), `emoji` | — | For media types, `id` and `link` **must have exactly one given** — supplying both or neither is a `400` (with the message `provide exactly one of \`id\` or \`link\``): - `id` is a Meta media id obtained by uploading via `POST /v1/media` first — the upload endpoint checks size per media type (roughly 5 MB images, 16 MB audio/video/documents, 100 KB-500 KB WebP stickers; see [Media](../templates-flows-media/media.md)); - `link` is a URL Meta can reach publicly, which Meta fetches itself — **documents over 16 MB have to go this way** (Meta allows up to 100 MB only through `link`), as does anything else the upload endpoint rejects for size. #### Requesting contact information `interactive.type: "request_contact_info"` asks the user to share their phone number. Its shape is fixed — `body.text` plus `action: { name: "request_contact_info" }` — and the platform checks it locally: a missing `action.name` or blank `body.text` returns `400 VALIDATION_FAILED` instead of an unhelpful rejection from Meta. ```json title="Example interactive object" { "type": "request_contact_info", "body": { "text": "Share your phone number so we can follow up on your order." }, "action": { "name": "request_contact_info" } } ``` A `202` only means the request was accepted, **not** that the user shared anything. If they share, it arrives as a `message` webhook of type `contacts` with `origin: contact_request`, plus a normalized `contact.info_shared` event — see [Webhook Integration](../guides/webhook-integration.md). If the conversation so far only had the user's BSUID (`contactWaId` empty), the platform fills `contactWaId` on `GET /v1/conversations` with the shared `wa_id`, so you can send to that number from then on. Only a share with `origin: contact_request` is used, never a contact card the user sent directly (`origin: other`, which may be someone else's), and an existing `contactWaId` is never overwritten. #### Marketing template delivery Marketing-category templates are submitted through Meta’s Marketing Messages API. The platform sets `product_policy: CLOUD_API_FALLBACK`, so Meta falls back to Cloud API when the WABA has not signed the Marketing Messages terms. The caller still uses this same endpoint; the WABA’s stored `marketingMessagesStatus` does not select the route. Templates with Max Price use this same request endpoint and routing. #### Binding parameters in template messages The `parameters` inside `components` must match the placeholders declared when the template was created **exactly** in count and order, or Meta returns a parameter mismatch error. Template messages are not bound by the 24-hour customer service window and can be sent at any time. #### Local pre-check for the 24-hour window A free-form message (not a template) sent outside the window is determined locally **before anything is persisted** and returns `409 WHATSAPP_24H_WINDOW_EXPIRED` immediately, without reaching Meta and wasting a credit reservation. But this local check only catches the "definitely closed" case — a message the platform believes is inside the window when it has actually closed can still be rejected by Meta, which then falls through to the normal message failure code path (see the message failure code table on the "Error Codes" page). An open window permits a non-template service reply but does not make it free: Meta charges for service replies and in-window utility templates sent on or after 2026-10-01. See [Billing & Credit Line](../guides/billing.md). #### Media message limits Format is never pre-checked by this endpoint — it is enforced by **Meta at delivery time** for both `id` and `link`, so a malformed message gets a 202 accepted first and only later fails via a status callback. Size for `link` is likewise only checked by Meta at delivery (roughly 5 MB images, 16 MB audio and video, 100 MB documents). Size for `id` was already checked when the file was uploaded: `POST /v1/media` enforces a per-type limit (roughly 5 MB images, 16 MB audio/video/documents, 100 KB-500 KB WebP stickers) and returns `400` before the file ever reaches Meta — so an asset that was small enough to upload is small enough to send. #### A recipient can be a phone number or a BSUID At least one of `to` (phone number) and `toUserId` (BSUID) **must be given**; if both are given, the **phone number takes priority** (matching Meta's own precedence). BSUID is a user identifier Meta has included on every inbound message since April 2026 (in the form `US.13491208655302741918`, unique per business combination), obtainable from `contactUserId` on `GET /v1/conversations`. **It is the only usable recipient identifier for some conversations** — once a user enables a WhatsApp username, Meta stops sending the phone number unless you've interacted with them in the last 30 days. Three restrictions: - **Templates with Max Price cannot be sent to a BSUID** (Meta error `131062`). Pass the recipient phone number in `to`; if both identifiers are present, the phone takes priority. - **One-tap / zero-tap / copy-code authentication templates cannot be sent to a BSUID** (Meta requires a phone number for these). The platform rejects this locally before sending and explains why, rather than leaving you with an opaque `131062` — these templates are usually login codes, and a failure means the user cannot log in. - BSUID is **unique per Business Portfolio**: using customer A's BSUID with customer B's number will fail. Marketing opt-outs are checked against both identifiers: an opt-out Meta reported with only a BSUID also blocks sending to that user by phone number, and the reverse (see `MARKETING_OPT_OUT` in [Error Codes](../guides/error-codes.md)). --- # Revoke an Unused Invitation on the Current Account Canonical: https://docs.bluehola.com/docs/onboarding/delete-v1-onboarding-invitations-id OpenAPI: https://docs.bluehola.com/openapi.yaml
DELETE/v1/onboarding/invitations/{id}
Revoke an unused invitation on the current account; a completed invitation cannot be revoked (returns 409). :::note[Authentication] Send `Authorization: Bearer ` in the request headers, with scope `onboarding:write`. Which resources an API Key can reach is determined by its current authorization scope. ::: ## Request Base URL: `https://api.bluehola.com` ### Parameters | Name | In | Required | Type / constraints | Description | | --- | --- | --- | --- | --- | | `id` | path | Yes | string | The invitation record ID, `inv_...` (not the token in the link) | ## Response | Status | Description | | --- | --- | | `200` | OK | | `4xx` | Client error | For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md). ## Notes Revocation is implemented as a conditional update, `WHERE status='pending'`; when it fails to claim the row, the two possible reasons are distinguished precisely: "the id does not exist" returns 404, while "the id exists but is no longer pending" returns 409, with the actual current status (one of completed/failed/expired/revoked) included in the error message — so support or operations staff can tell at a glance whether the link "has already been used" or "has already expired", rather than being told only that revocation failed. --- # Get Embedded Signup SDK Configuration Canonical: https://docs.bluehola.com/docs/onboarding/get-v1-onboarding-config OpenAPI: https://docs.bluehola.com/openapi.yaml
GET/v1/onboarding/config
Read the non-confidential settings for your own Meta SDK authorization page. :::note[Authentication] Send `Authorization: Bearer `. Customer Keys support this endpoint; no additional scope is required. ::: ## Request ```bash curl "https://api.bluehola.com/v1/onboarding/config" \ -H "Authorization: Bearer " ``` ## Response ```json title="200 OK (example)" { "appId": "", "configId": "", "sdkVersion": "v26.0", "sessionInfoVersion": "3", "esVersion": "v4", "features": [ { "name": "will_be_partner_certified" } ] } ``` `appId` and `configId` are `null` when not configured. The response contains no App Secret or access token. Use `sdkVersion`, `sessionInfoVersion`, `esVersion` and `features` as returned when initializing the SDK flow; pass the features through unchanged. After Meta authorization completes, submit its result from your backend through [Complete Onboarding](post-v1-onboarding-embedded-signup.md), identifying the ownership target with exactly one of `customerEntityId` or `portfolioId`. For a ready-made page, [create an invitation](post-v1-onboarding-invitations.md) instead. The invitation supplies its own mode-specific configuration, including `mode: alipay` when selected; this endpoint keeps its default SPLBV configuration. See [Customer Onboarding](../guides/customer-onboarding.md). --- # Query Steps, Errors and Provisioned Assets Canonical: https://docs.bluehola.com/docs/onboarding/get-v1-onboarding-embedded-signup-operationid OpenAPI: https://docs.bluehola.com/openapi.yaml
GET/v1/onboarding/embedded-signup/{operationId}
Query steps, errors and provisioned assets; the ID is onb_.... :::note[Authentication] Send `Authorization: Bearer ` in the request headers, with scope `onboarding:read`. Which resources an API Key can reach is determined by its current authorization scope. ::: ## Request Base URL: `https://api.bluehola.com` ### Parameters | Name | In | Required | Type / constraints | Description | | --- | --- | --- | --- | --- | | `operationId` | path | Yes | string | The onboarding operation ID, `onb_...` | ## Response | Status | Description | | --- | --- | | `200` | OK | | `4xx` | Client error | For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md). ## Notes Returns the full steps array (each step's id and status, for rendering a progress bar) along with fields such as lastError/lastErrorCode — the most direct way to diagnose "which step is it stuck on". An `operationId` that does not match the expected format (`onb_` prefix plus a UUIDv7) returns 400 immediately; the request never reaches the database layer, so a made-up id cannot be used to probe the system. --- # List Recent Operations Canonical: https://docs.bluehola.com/docs/onboarding/get-v1-onboarding-embedded-signup OpenAPI: https://docs.bluehola.com/openapi.yaml
GET/v1/onboarding/embedded-signup
List recent operations; limit ranges from 1 to 50. :::note[Authentication] Send `Authorization: Bearer ` in the request headers, with scope `onboarding:read`. Which resources an API Key can reach is determined by its current authorization scope. ::: ## Request Base URL: `https://api.bluehola.com` ### Parameters | Name | In | Required | Type / constraints | Description | | --- | --- | --- | --- | --- | | `limit` | query | No | integer 1..50 | Defaults to 20. **Out-of-range values return `400 VALIDATION_FAILED`**, they are not clamped | ## Response | Status | Description | | --- | --- | | `200` | OK | | `4xx` | Client error | For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md). ## Notes Returns `{ "data": [...] }` in reverse creation order. `limit` defaults to 20 and must be an integer from 1 to 50; an out-of-range value returns `400 VALIDATION_FAILED`. A customer Key sees only records associated with its own currently owned Portfolios. The customer filter is derived from authentication; no `customerEntityId` query parameter is required. The summary list omits per-step detail; use `GET /v1/onboarding/embedded-signup/{operationId}` for the full operation. --- # Poll Onboarding Progress Canonical: https://docs.bluehola.com/docs/onboarding/get-v1-onboarding-invitations-token-status OpenAPI: https://docs.bluehola.com/openapi.yaml
GET/v1/onboarding/invitations/{token}/status
[Customer-side, unauthenticated] Poll onboarding progress. Returns only redacted steps and errors, with no token, code or account information. :::note[Authentication] This endpoint does not require an API Key. ::: ## Request Base URL: `https://api.bluehola.com` ### Parameters | Name | In | Required | Type / constraints | Description | | --- | --- | --- | --- | --- | | `token` | path | Yes | string | The one-time token from the invitation link | ## Response | Status | Description | | --- | --- | | `200` | OK | | `4xx` | Client error | For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md). ## Notes If complete has not been called successfully yet for this invitation (no operationId bound), this returns a placeholder structure (currentStep null, steps an empty array, result null) rather than an error, and the landing page uses that to show its initial "waiting for the customer to submit" state. Once an operation is bound, this endpoint forwards that operation's redacted step/error view directly, sharing the same underlying data source as the complete and retry endpoints — so all three always describe "how far this onboarding run has gotten" identically, and a poll result can never contradict a submission result. Separately, onboarding succeeding and credit line sharing succeeding are two entirely independent states — a credit line that has not synced will not cause this endpoint to report the whole run as failed, which would otherwise mislead the customer into thinking onboarding was incomplete. --- # Get the Non-Confidential Information the Invitation Landing Page Needs Canonical: https://docs.bluehola.com/docs/onboarding/get-v1-onboarding-invitations-token OpenAPI: https://docs.bluehola.com/openapi.yaml
GET/v1/onboarding/invitations/{token}
[Customer-side, unauthenticated] Get the non-confidential information the invitation landing page needs (customer name, Meta appId/configId). :::note[Authentication] This endpoint does not require an API Key. ::: ## Request Base URL: `https://api.bluehola.com` ### Parameters | Name | In | Required | Type / constraints | Description | | --- | --- | --- | --- | --- | | `token` | path | Yes | string | The one-time token from the invitation link (43 characters of base64url). It is itself the credential, so this endpoint needs no API Key | ## Response | Status | Description | | --- | --- | | `200` | OK | | `4xx` | Client error | For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md). ## Notes An invalid, expired or revoked token all resolve to the same "invitation is no longer valid" response (the response body's status field distinguishes which one, but the page copy does not explain the reason) — deliberately withholding information such as "does this token even exist, and why is it invalid" from anyone probing without a valid link. The token must be a syntactically valid 43-character base64url string; a malformed shape returns 400 immediately, without even a hash comparison or a database query, so malformed input cannot be used to run up a real query's cost. The response includes `mode` (`splbv`, `alipay` or `standard`) and its server-supplied `features`. The invitation record determines both; the client must not choose them. Branch on `mode` directly, since an empty `features` array is valid for `standard`. --- # List Invitations Issued by the Current Account and Their Status Canonical: https://docs.bluehola.com/docs/onboarding/get-v1-onboarding-invitations OpenAPI: https://docs.bluehola.com/openapi.yaml
GET/v1/onboarding/invitations
List invitations issued by the current account and their status; the token itself is never echoed back. :::note[Authentication] Send `Authorization: Bearer ` in the request headers, with scope `onboarding:read`. Which resources an API Key can reach is determined by its current authorization scope. ::: ## Request Base URL: `https://api.bluehola.com` ### Parameters | Name | In | Required | Type / constraints | Description | | --- | --- | --- | --- | --- | | `limit` | query | No | integer 1..100 | Defaults to 20. **Out-of-range values return `400 VALIDATION_FAILED`**, they are not clamped | ## Response | Status | Description | | --- | --- | | `200` | OK | | `4xx` | Client error | For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md). ## Notes Returns `{ "data": [...] }` in reverse creation order. `limit` defaults to 20 and must be an integer from 1 to 100; an out-of-range value returns `400 VALIDATION_FAILED`. A customer Key sees only records associated with its own currently owned Portfolios. The customer filter is derived from authentication; no `customerEntityId` query parameter is required. Neither plaintext invitation tokens nor token hashes are returned; a usable invitation URL cannot be reconstructed from this list. --- # Customer Invitation Page (Public) Canonical: https://docs.bluehola.com/docs/onboarding/invitation-public OpenAPI: https://docs.bluehola.com/openapi.yaml # Customer Invitation Page (Public) The endpoints under `/v1/onboarding/invitations/{token}` deliberately carry **no API Key auth** — the token in the link is itself the credential (rate-limited per source IP). They are called from the standalone landing page the customer sees, outside the developer console. | Endpoint | Purpose | | --- | --- | | [Get Invitation](get-v1-onboarding-invitations-token.md) | Landing page initialization: the customer name, the Meta appId/configId and other non-confidential information. | | [Submit Meta Authorization Result](post-v1-onboarding-invitations-token-complete.md) | Submit code + wabaId + phoneNumberId and trigger the orchestration. A double-click on submit cannot produce two sets of assets. | | [Retry Onboarding](post-v1-onboarding-invitations-token-retry.md) | After a first failure, resume the same operation with a fresh code. | | [Poll Onboarding Progress](get-v1-onboarding-invitations-token-status.md) | Returns a redacted step view, with no token, code or account information in it. | | [Report Drop-off & Self-Service Errors](post-v1-onboarding-invitations-token-es-events.md) | Reporting used when the customer abandons the flow or self-reports an error on the page. | Invalid, expired and revoked invitations all resolve to the same "invitation is no longer valid" outcome, without revealing which. The `requiredInput` field in a failure response tells the customer what to do next: `authorization_code` means they need to re-authorize for a fresh code; `null` means they cannot recover on their own and should contact their account manager. :::info On retry, only `code` may change — `wabaId` and `phoneNumberId` were bound on first submission, and pointing at different target assets is rejected. ::: --- # Invitation Management Canonical: https://docs.bluehola.com/docs/onboarding/invitations OpenAPI: https://docs.bluehola.com/openapi.yaml # Invitation Management Create a one-time invitation so the customer can complete Meta authorization on their own device. Your backend may use a customer API Key with `onboarding:write` to create links for that customer’s Portfolios. The person opening the page uses the invitation token and does not enter an API Key or App Secret. Pass either `customerEntityId` (recommended) or `portfolioId` — exactly one. With `customerEntityId`, no Portfolio has to exist in advance: after the customer authorizes through the link, the Business Portfolio is found or created from the WABA owner. Both creation and management are confined to the Key’s own customer; invitation lists are filtered automatically. | Endpoint | Purpose | | --- | --- | | [Create Onboarding Link](post-v1-onboarding-invitations.md) | Create an invitation for a given customer entity or Business Portfolio; returns a one-time link. | | [List Invitations](get-v1-onboarding-invitations.md) | Invitations the current account has issued and their status. | | [Revoke Invitation](delete-v1-onboarding-invitations-id.md) | Void an invitation that has not been used yet. | :::warning **The plaintext link appears exactly once, in the creation response.** The token is 43 characters of base64url and only its SHA-256 is stored, so a lost link can only be regenerated. `expiresInSeconds` defaults to 1800 seconds and can be set between 300 and 86400. ::: Once the customer opens the link, it calls the [customer-side invitation endpoints](invitation-public.md) (no authentication required). See [Customer Onboarding](../guides/customer-onboarding.md) for the full flow. --- # Resume from Failed Step Canonical: https://docs.bluehola.com/docs/onboarding/post-v1-onboarding-embedded-signup-operationid-retry OpenAPI: https://docs.bluehola.com/openapi.yaml
POST/v1/onboarding/embedded-signup/{operationId}/retry
Resume from a failed step; phone registration uses the platform's automatically generated, encrypted default PIN. :::note[Authentication] Send `Authorization: Bearer ` in the request headers, with scope `onboarding:write`. Which resources an API Key can reach is determined by its current authorization scope. ::: ## Request Base URL: `https://api.bluehola.com` ### Parameters | Name | In | Required | Type / constraints | Description | | --- | --- | --- | --- | --- | | `operationId` | path | Yes | string | The onboarding operation ID, `onb_...` | ### Request body A request body is required. ### Request body fields | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | No | Provide this if the OAuth code has expired | Content-Type: `application/json` Schema: ```json { "type": "object", "properties": { "code": { "type": "string", "description": "string · optional — provide this if the OAuth code has expired" } } } ``` ## Response | Status | Description | | --- | --- | | `201` | Created | | `4xx` | Client error | For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md). ## Notes Internally this first performs an atomic claim to switch the operation's state to "processing"; when the claim fails (for example it is already running, or another concurrent request claimed it first) it simply returns the current state rather than erroring or re-triggering the orchestration — which turns "a jittery finger clicking retry several times" into a safe operation instead of a source of concurrency bugs. #### When to send `code` - **Omit `code`**: reuses the encrypted customer token saved from the first authorization to keep going. Suited to cases where only the phone registration step failed and a fresh Meta OAuth authorization is not needed. - **Provide a new `code`**: use this once the old token has expired or been revoked, to re-authorize before resuming. - Neither a new `code` nor a saved token exists (for example it was never successfully authorized): this returns a clear error asking for re-authorization, rather than failing ambiguously. An operation that completed overall but did not request phone registration at the time can also use this endpoint to **run just the registration step**, without redoing the whole flow. --- # Complete Onboarding Canonical: https://docs.bluehola.com/docs/onboarding/post-v1-onboarding-embedded-signup OpenAPI: https://docs.bluehola.com/openapi.yaml
POST/v1/onboarding/embedded-signup
Complete onboarding, returning 201 and a trackable operation record. :::note[Authentication] Send `Authorization: Bearer ` in the request headers, with scope `onboarding:write`. Which resources an API Key can reach is determined by its current authorization scope. ::: ## Request Base URL: `https://api.bluehola.com` ### Request body A request body is required. ### Request body fields | Field | Type | Required | Description | | --- | --- | --- | --- | | `portfolioId` | string | No | The platform's Business Portfolio ID, bm_... Use **exactly one** of this and `customerEntityId` | | `customerEntityId` | string | No | Customer entity ID, cust_... Use **exactly one** of this and `portfolioId`. When starting for a customer, no Business Portfolio is needed in advance: after authorization, the Portfolio is found or created from the WABA owner | | `code` | string | Yes | A one-time Meta OAuth authorization code | | `wabaId` | string | Yes | The WABA ID returned by Meta | | `phoneNumberId` | string | No | The Phone Number ID returned by Meta. **May be absent**: as of ES v3, a customer can finish without a number and add one later | | `esVersion` | v2 \| v3 \| v4 | No | Version used by the authorization page, for diagnostics. New sessions use v4. | | `sessionInfo` | object | No | The raw session info from the ES `message` event, including the ids of assets the customer selected (`dataset_ids` is the Pixel/dataset) | Content-Type: `application/json` Example: ```json { "customerEntityId": "cust_x", "code": "", "wabaId": "", "phoneNumberId": "" } ``` Schema: ```json { "type": "object", "properties": { "portfolioId": { "type": "string", "description": "string · optional — the platform's Business Portfolio ID, bm_... Use exactly one of this and customerEntityId" }, "customerEntityId": { "type": "string", "description": "string · optional — customer entity ID, cust_... Use exactly one of this and portfolioId. When starting for a customer, no Business Portfolio is needed in advance: after authorization, the Portfolio is found or created from the WABA owner" }, "code": { "type": "string", "description": "string · required — a one-time Meta OAuth authorization code" }, "wabaId": { "type": "string", "description": "string · required — the WABA ID returned by Meta" }, "phoneNumberId": { "type": "string", "description": "string · optional — the Phone Number ID returned by Meta. **May be absent**: as of ES v3, a customer can finish without a number and add one later" }, "esVersion": { "type": "string", "description": "Version used by the authorization page, for diagnostics. New sessions use v4." }, "sessionInfo": { "type": "object", "additionalProperties": true, "description": "object · optional — the raw session info from the ES message event, including the ids of assets the customer selected (`dataset_ids` is the Pixel/dataset)" } }, "required": [ "code", "wabaId" ], "example": { "customerEntityId": "cust_x", "code": "", "wabaId": "", "phoneNumberId": "" } } ``` ## Response | Status | Description | | --- | --- | | `201` | Created | | `4xx` | Client error | For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md). ## Notes #### The five orchestration stages - Exchange `code` with Meta for that Portfolio's customer System User token, storing it encrypted (AES-256-GCM). - Verify that token actually carries asset authorization for the target WABA/phone number. - Subscribe the app with Meta (subscribeApp). - If this request carries phone registration intent, call registration (the PIN is lazily generated and stored encrypted). - Persist the final WABA/phone number details. #### What happens after a failure Progress is persisted and resumable: any step failing halts the whole run, with `currentStep`/`lastError*` stopping at the point of failure. After that you must call the retry endpoint to **resume from where it stopped** — POSTing to this endpoint again creates a brand-new operation rather than continuing the old one. #### Ownership: by Business Portfolio or by customer (exactly one) - Pass `portfolioId` (the existing route): the Portfolio must already exist under the current account and is not created implicitly. After authorization, the WABA owner must match that Portfolio's recorded Meta BM ID; otherwise the request returns 403. - Pass `customerEntityId` (recommended): no Portfolio is needed in advance. After authorization, the Business Portfolio is found from the WABA's `owner_business_info` and reused when the customer already has that Meta BM, or created (name taken from Meta) when it does not; the operation's `portfolioId` is then backfilled. If that Meta BM already belongs to **another customer or another BU**, the operation ends `status: failed` with `lastErrorCode: ONBOARDING_META_BM_ALREADY_CONNECTED` and `requiredInput: null` — the binding is never reassigned. Retrying cannot fix this; start a new onboarding for the existing Business Portfolio. Passing both fields or neither returns 400. A missing customer entity returns 404 **before** the one-time authorization code is used, so a bad `customerEntityId` does not burn a code. A customer Key may use only its own customer entity or its own Portfolios; anything else returns 403. The Meta BM ID is written only from the authorized WABA owner, never from caller input. --- # Report an Embedded Signup Session Event Canonical: https://docs.bluehola.com/docs/onboarding/post-v1-onboarding-es-events OpenAPI: https://docs.bluehola.com/openapi.yaml
POST/v1/onboarding/es-events
Report one Embedded Signup session event (which screen the customer abandoned on, or a customer self-reported error). Always 202. :::note[Authentication] Send `Authorization: Bearer ` in the request headers, with scope `onboarding:write`. Which resources an API Key can reach is determined by its current authorization scope. ::: ## Request Base URL: `https://api.bluehola.com` ### Request body A request body is required. ### Request body fields | Field | Type | Required | Description | | --- | --- | --- | --- | | `portfolioId` | string | No | The Business Portfolio this run is for, bm_... Use **exactly one** of this and `customerEntityId` | | `customerEntityId` | string | No | Customer entity ID, cust_... when onboarding was started for a customer; before authorization there is no Portfolio yet. Use **exactly one** of this and `portfolioId` | | `event` | string | Yes | The `event` value from the ES message event: FINISH* / CANCEL / ERROR | | `esVersion` | v2 \| v3 \| v4 | No | The ES version used when starting | | `currentStep` | string | No | The screen the customer was on when they abandoned, e.g. PHONE_NUMBER_SETUP | | `errorCode` | string | No | The error code Meta gave when the customer self-reported an error during the flow | | `errorMessage` | string | No | The corresponding error text shown to the customer | | `metaSessionId` | string | No | Meta's session_id — **required when contacting Meta support** | | `timestamp` | integer | No | The unix seconds Meta supplied (only present for error events) | Content-Type: `application/json` Example: ```json { "customerEntityId": "cust_x", "event": "CANCEL", "currentStep": "PHONE_NUMBER_SETUP", "esVersion": "v4" } ``` Schema: ```json { "type": "object", "properties": { "portfolioId": { "type": "string", "description": "string · optional — the Business Portfolio this run is for, bm_... Use exactly one of this and customerEntityId" }, "customerEntityId": { "type": "string", "description": "string · optional — customer entity ID, cust_... when onboarding was started for a customer; before authorization there is no Portfolio yet. Use exactly one of this and portfolioId" }, "event": { "type": "string", "description": "string · required — the event value from the ES message event: FINISH* / CANCEL / ERROR" }, "esVersion": { "type": "string", "description": "v2 | v3 | v4 · optional — the ES version used when starting" }, "currentStep": { "type": "string", "description": "string · optional — the screen the customer was on when they abandoned, e.g. PHONE_NUMBER_SETUP" }, "errorCode": { "type": "string", "description": "string · optional — the error code Meta gave when the customer self-reported an error during the flow" }, "errorMessage": { "type": "string", "description": "string · optional — the corresponding error text shown to the customer" }, "metaSessionId": { "type": "string", "description": "string · optional — Meta's session_id — required when contacting Meta support" }, "timestamp": { "type": "string", "description": "integer · optional — the unix seconds Meta supplied (only present for error events)" } }, "required": [ "event" ], "example": { "customerEntityId": "cust_x", "event": "CANCEL", "currentStep": "PHONE_NUMBER_SETUP", "esVersion": "v4" } } ``` ## Response | Status | Description | | --- | --- | | `202` | Accepted | | `4xx` | Client error | For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md). ## Notes #### Why this endpoint exists Embedded Signup's session info logging (on by default from ES v3) **appears only in a single browser `message` event** — it cannot be queried from the Graph API afterwards. Two things are gone for good if this is lost: which screen the customer abandoned on (the only funnel data for onboarding), and the `session_id` from a customer self-reported error (the credential needed for Meta support). #### This is diagnostic data, not a business write It always returns 202, does not validate business semantics, and a persistence failure is only logged. The front end should fire-and-forget: a failed report here must never surface as an error on the customer's screen. The request body is `.strict()`, so extra fields cause a 400 — **in particular, never pass `code` in here**, since that is a 30-second credential that does not belong in this table. --- # Submit the Meta Authorization Result Canonical: https://docs.bluehola.com/docs/onboarding/post-v1-onboarding-invitations-token-complete OpenAPI: https://docs.bluehola.com/openapi.yaml
POST/v1/onboarding/invitations/{token}/complete
[Customer-side, unauthenticated] Submit the Meta authorization result and trigger the onboarding orchestration. The account and Portfolio come only from the invitation record and cannot be overridden by the body; extra fields are rejected. A 202 does not mean onboarding succeeded — you must read status. :::note[Authentication] This endpoint does not require an API Key. ::: ## Request Base URL: `https://api.bluehola.com` ### Parameters | Name | In | Required | Type / constraints | Description | | --- | --- | --- | --- | --- | | `token` | path | Yes | string | The one-time token from the invitation link | ### Request body A request body is required. ### Request body fields | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | Yes | A one-time Meta OAuth authorization code | | `wabaId` | string | Yes | The WABA ID returned by Meta (numeric) | | `phoneNumberId` | string | No | The Phone Number ID returned by Meta (numeric). May be absent — as of ES v3 a customer can onboard just the WABA | | `esVersion` | v2 \| v3 \| v4 | No | The ES version this run used | | `sessionInfo` | object | No | The raw ES session info | Content-Type: `application/json` Example: ```json { "code": "", "wabaId": "", "phoneNumberId": "" } ``` Schema: ```json { "type": "object", "properties": { "code": { "type": "string", "description": "string · required — a one-time Meta OAuth authorization code" }, "wabaId": { "type": "string", "description": "string · required — the WABA ID returned by Meta (numeric)" }, "phoneNumberId": { "type": "string", "description": "string · optional — the Phone Number ID returned by Meta (numeric). May be absent — as of ES v3 a customer can onboard just the WABA" }, "esVersion": { "type": "string", "description": "v2 | v3 | v4 · optional — the ES version this run used" }, "sessionInfo": { "type": "string", "description": "object · optional — the raw ES session info" } }, "required": [ "code", "wabaId" ], "example": { "code": "", "wabaId": "", "phoneNumberId": "" } } ``` ## Response | Status | Description | | --- | --- | | `202` | Accepted | | `4xx` | Client error | For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md). ## Notes #### Concurrency safety The claim runs a single atomic `WHERE status='pending' AND expires_at>now()` conditional update first, and the orchestration only starts once that succeeds — so even if the customer's finger slips and they double-click submit on the landing page, Meta-side subscriptions and assets cannot be created twice concurrently. If the orchestration throws before an operation record is actually created (for example the target Portfolio was deleted by the platform after the link was generated), the invitation is automatically put back to `pending` so the customer can resubmit, rather than being permanently stuck in "processing". #### The response is a redacted projection It contains only status/currentStep/steps/requiredInput/error, and **never returns the operation id itself**. `requiredInput` in particular lets the landing page immediately tell which category a failure falls into: - the customer needs to **go through Meta authorization again** (retry with a fresh code) - the client side cannot fix it and **needs to contact an account manager** There is no need to wait for the next `/status` poll before updating the message shown. --- # Report When a Customer Abandons the Flow or Self-Reports an Error on the Invitation Page Canonical: https://docs.bluehola.com/docs/onboarding/post-v1-onboarding-invitations-token-es-events OpenAPI: https://docs.bluehola.com/openapi.yaml
POST/v1/onboarding/invitations/{token}/es-events
[Customer-side, unauthenticated] Report when a customer abandons the flow or self-reports an error on the invitation page. Always 202. :::note[Authentication] This endpoint does not require an API Key. ::: ## Request Base URL: `https://api.bluehola.com` ### Parameters | Name | In | Required | Type / constraints | Description | | --- | --- | --- | --- | --- | | `token` | path | Yes | string | The one-time token from the invitation link | ### Request body A request body is required. ### Request body fields | Field | Type | Required | Description | | --- | --- | --- | --- | | `event` | string | Yes | FINISH* / CANCEL / ERROR | | `currentStep` | string | No | The screen the customer was on when they abandoned | | `errorCode` | string | No | Meta's error code | | `errorMessage` | string | No | Meta's error text | | `metaSessionId` | string | No | Meta's session_id | | `timestamp` | integer | No | Unix seconds | Content-Type: `application/json` Schema: ```json { "type": "object", "properties": { "event": { "type": "string", "description": "string · required — FINISH* / CANCEL / ERROR" }, "currentStep": { "type": "string", "description": "string · optional — the screen the customer was on when they abandoned" }, "errorCode": { "type": "string", "description": "string · optional — Meta's error code" }, "errorMessage": { "type": "string", "description": "string · optional — Meta's error text" }, "metaSessionId": { "type": "string", "description": "string · optional — Meta's session_id" }, "timestamp": { "type": "string", "description": "integer · optional — unix seconds" } }, "required": [ "event" ] } ``` ## Response | Status | Description | | --- | --- | | `202` | Accepted | | `4xx` | Client error | For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md). ## Notes Ownership (account / Portfolio) is resolved only from the token in the link; the body cannot specify it — the same rule as `/complete`. **This also returns 202 for an invalid token**: this is diagnostic data, and returning an error would only turn this endpoint into a probe for "does this token exist". Like the other customer-side endpoints, it is rate-limited per source IP. --- # After the First Authorization Attempt Fails Canonical: https://docs.bluehola.com/docs/onboarding/post-v1-onboarding-invitations-token-retry OpenAPI: https://docs.bluehola.com/openapi.yaml
POST/v1/onboarding/invitations/{token}/retry
[Customer-side, unauthenticated] After the first authorization attempt fails, continue the **same** operation with a new Meta code (no new onboarding task is created). Only code is accepted: wabaId/phoneNumberId are already recorded on the operation, and pointing at different target assets on retry is not allowed. Only a failed, unexpired invitation can be retried; a completed one returns 409. :::note[Authentication] This endpoint does not require an API Key. ::: ## Request Base URL: `https://api.bluehola.com` ### Parameters | Name | In | Required | Type / constraints | Description | | --- | --- | --- | --- | --- | | `token` | path | Yes | string | The one-time token from the invitation link | ### Request body A request body is required. ### Request body fields | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | Yes | A new, one-time Meta OAuth authorization code | Content-Type: `application/json` Example: ```json { "code": "" } ``` Schema: ```json { "type": "object", "properties": { "code": { "type": "string", "description": "string · required — a new, one-time Meta OAuth authorization code" } }, "required": [ "code" ], "example": { "code": "" } } ``` ## Response | Status | Description | | --- | --- | | `202` | Accepted | | `4xx` | Client error | For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md). ## Notes #### Diagnostics when the claim fails The claim condition is stricter than for complete: it requires the invitation status to be exactly `failed`, the link to be unexpired, and an operationId to already be bound. When the claim fails, this does not return a generic error — it diagnoses the specific reason first and returns the matching message: - `completed` → "no retry needed" - `pending` (never successfully submitted) → "not submitted yet, please complete authorization first" - `running` (currently processing) → "processing, please wait", marked with `retryable:true` for the landing page to poll on - `failed` but the link has expired → equivalent to "the invitation is no longer valid" #### Resume semantics Under the hood this reuses retryEmbeddedSignup, **resuming from the step that last failed** — subscription or phone registration steps that already succeeded are not re-run. If this retry throws again, the invitation is put back to `failed` (rather than `pending`, as a failure inside complete would be) — deliberately preserving the "already submitted once" semantics, so the next attempt still goes through this endpoint rather than mistakenly falling back to the first-submission complete endpoint. --- # Generate a Customer Onboarding Link Canonical: https://docs.bluehola.com/docs/onboarding/post-v1-onboarding-invitations OpenAPI: https://docs.bluehola.com/openapi.yaml
POST/v1/onboarding/invitations
Generate a one-time onboarding link for a given customer and Business Portfolio. The plaintext URL is returned exactly once in this response (only a hash is stored) — send it to the customer right away. :::note[Authentication] Send `Authorization: Bearer ` in the request headers, with scope `onboarding:write`. Which resources an API Key can reach is determined by its current authorization scope. ::: ## Request Base URL: `https://api.bluehola.com` ### Request body A request body is required. ### Request body fields | Field | Type | Required | Description | | --- | --- | --- | --- | | `tenantId` | string | No | An internal ownership field; omit it when the customer calls this | | `portfolioId` | string | No | BlueHola internal ID (`bm_...`); a customer Key may use only its own customer’s Portfolio. Use **exactly one** of this and `customerEntityId` | | `customerEntityId` | string | No | Customer entity ID, cust_.... Use **exactly one** of this and `portfolioId`. When starting for a customer, no Business Portfolio is needed in advance: after the customer authorizes through the link, the Portfolio is found or created from the WABA owner; `portfolioName` is then empty in the response and on the landing page | | `expiresInSeconds` | number | No | 300 to 86400, defaults to 1800 | | `mode` | string | No | `splbv`, `alipay` or `standard`; defaults to `splbv` | Content-Type: `application/json` Example: ```json { "customerEntityId": "cust_x", "expiresInSeconds": 1800 } ``` Schema: ```json { "type": "object", "properties": { "tenantId": { "type": "string", "description": "string · optional — an internal ownership field; omit it when the customer calls this" }, "portfolioId": { "type": "string", "description": "BlueHola internal ID (bm_...); customer Keys may use only their own customer’s Portfolio. Use exactly one of this and customerEntityId" }, "customerEntityId": { "type": "string", "description": "string · optional — customer entity ID, cust_.... Use exactly one of this and portfolioId. When starting for a customer, no Business Portfolio is needed in advance: after the customer authorizes through the link, the Portfolio is found or created from the WABA owner; portfolioName is then empty in the response and on the landing page" }, "expiresInSeconds": { "type": "integer", "minimum": 300, "maximum": 86400, "default": 1800, "description": "number · optional — 300 to 86400, defaults to 1800" }, "mode": { "type": "string", "description": "splbv | alipay | standard; default splbv" } }, "required": [], "example": { "customerEntityId": "cust_x", "expiresInSeconds": 1800 } } ``` ## Response | Status | Description | | --- | --- | | `201` | Created | | `4xx` | Client error | For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md). ## Notes Pass **exactly one** of `customerEntityId` or `portfolioId`; passing both or neither returns 400. `customerEntityId` is recommended: no Portfolio needs to exist beforehand. After the customer authorizes through the link, the Business Portfolio is found from the WABA's `owner_business_info` and reused or created, and `portfolioName` is empty in the creation response and on the landing page. The token itself is a base64url encoding of 32 random bytes (43 characters); only its SHA-256 hash is stored, and the plaintext appears exactly once, in this creation response — a lost token can only be regenerated. This is the same security model used for API Keys. The creator field is for audit purposes only and does not affect the customer-side flow. `mode` chooses the verification flow: `splbv` (default), `alipay`, or `standard`. Alipay verification needs the company registration code, legal representative’s name and the representative’s own face verification, so use a customer self-service invitation. The server supplies the matching `features` for this invitation; pass them through unchanged. An omitted `alipay_business_verification` feature can silently skip that step. For Alipay, keep the default 30-minute link lifetime unless the customer needs a different window. Customer Keys support this endpoint with `onboarding:write`. They may use only their own customer entity or their own Portfolios; anything else returns 403, and an ownership target outside the current BU returns 404. Omit `tenantId`. You can still [create a Portfolio](../assets-phone-numbers/post-v1-business-portfolios.md) with only `name` and pass its returned `id` as `portfolioId` instead. The HTTP 201 response supplies `url`, `expiresAt` and `status: pending`; the hosted page submits the Meta result automatically. See [Customer Onboarding](../guides/customer-onboarding.md). --- # Direct SDK Onboarding Canonical: https://docs.bluehola.com/docs/onboarding/provider-onboarding OpenAPI: https://docs.bluehola.com/openapi.yaml # Direct SDK Onboarding Use this route when your own Meta SDK page has already obtained the customer’s authorization result. Read the SDK settings from [`GET /v1/onboarding/config`](get-v1-onboarding-config.md). Your backend may submit the result with a customer API Key and `onboarding:write`, identifying the ownership target by **exactly one** of `customerEntityId` (recommended) or `portfolioId`. An authorized portal session remains supported. Passing `customerEntityId` needs no Business Portfolio in advance: after authorization, the Portfolio is found or created from the WABA owner. To use that same ownership model on the hosted page, [create an invitation](post-v1-onboarding-invitations.md) with `customerEntityId`; that page submits the result automatically. An onboarding run is a **persisted, resumable** state machine with five fixed steps: `exchange_token` → `subscribe_app` → `register_phone` → `sync_resources` → `persist_assets`. | Endpoint | Purpose | | --- | --- | | [Complete Onboarding](post-v1-onboarding-embedded-signup.md) | Submit `customerEntityId` or `portfolioId` (exactly one), plus `code`, `wabaId` and optional `phoneNumberId`. Returns HTTP 201; inspect the operation status. | | [List Recent Operations](get-v1-onboarding-embedded-signup.md) | List recent onboarding operations and their status. | | [Operation Details](get-v1-onboarding-embedded-signup-operationid.md) | The five-step progress, errors and provisioned assets for a single operation. | | [Resume from Failed Step](post-v1-onboarding-embedded-signup-operationid-retry.md) | Resume from where it stopped. `code` is optional: omit it if the old credential is still valid. | | [Report ES Session Event](post-v1-onboarding-es-events.md) | Report a session event from inside the Embedded Signup popup, to help diagnose where a customer got stuck. | :::warning After a failure, call retry to **resume the same operation** — do not POST to the create endpoint again, which would create a brand-new operation. An operation that completed without registering a phone number at the time can also use retry to run just that registration step later. ::: For how to choose between the two onboarding routes and what each of the five steps does, see [Customer Onboarding](../guides/customer-onboarding.md). --- # API Changelog Canonical: https://docs.bluehola.com/docs/reference/changelog OpenAPI: https://docs.bluehola.com/openapi.yaml This page records API contract and documentation changes that affect callers. Machine-readable version: [`/changelog.json`](https://docs.bluehola.com/changelog.json). :::note Every entry is classified as `Added`, `Changed`, `Deprecated`, `Removed`, `Fixed` or `Breaking`; anything involving a deprecation must state a sunset date and a migration path. The history here starts from 2026-09-22; earlier API changes have not been fully reconstructed. ::: ## 2026-11-23 ### Added - Customers can read their own message volume and unit prices with `GET /v1/usage/messages` (`messages:read`; customer-level API Keys only). The response groups messages by message type, billing category, destination country and the actual unit price charged, with `messageCount` per row. Only messages with a pricing record are counted — free messages have no ledger row, so a ledger-based count would drop them. Tiered pricing can produce several rows for the same country and category; sum `messageCount` across them for total volume. Country comes from the recipient number and is `null` when it cannot be resolved; `market` is the Meta billing market, which may be a region. See [Message Usage & Prices](../billing-status/get-v1-usage-messages.md). - Onboarding can now start from a customer entity, not only from an existing Business Portfolio. [Complete Onboarding](../onboarding/post-v1-onboarding-embedded-signup.md), [Create Onboarding Link](../onboarding/post-v1-onboarding-invitations.md) and [Report an Embedded Signup Session Event](../onboarding/post-v1-onboarding-es-events.md) accept **exactly one** of `customerEntityId` (`cust_...`) or `portfolioId` (`bm_...`); passing both or neither returns `400`. With `customerEntityId`, no Portfolio needs to exist in advance: after the customer authorizes, the Business Portfolio is found from the WABA's Meta owner and reused when that customer already has the same Meta BM, or created otherwise, and the operation's `portfolioId` is backfilled. If the Meta BM already belongs to another customer or another BU, the operation ends `failed` with `lastErrorCode: ONBOARDING_META_BM_ALREADY_CONNECTED` and `requiredInput: null`; the binding is not reassigned and retrying cannot fix it. A missing customer entity returns `404` before the one-time authorization code is used. The existing `portfolioId` route is unchanged. See [Customer Onboarding](../guides/customer-onboarding.md). ### Changed - An invitation created with `customerEntityId` returns an empty `portfolioName` in its `201` response, and the landing page shows an empty Portfolio name, because the Portfolio is created only after the customer authorizes. Invitations created with `portfolioId` are unchanged. ## 2026-11-19 ### Removed - The API reference now covers only the endpoints a customer API Key can call, plus the public health and invitation endpoints. Pages, OpenAPI operations and guide sections for endpoints that customer Keys cannot call have been removed: BU and platform-level asset management (customer entity lists and edits, creating, updating and deleting Business Portfolios, WABAs and phone numbers, delete previews, Meta account details, business profile and message routing, Pixel linking), phone number lifecycle operations other than `register`, credit line authorization, Marketing Messages onboarding, Business Verification, Flow management, `DELETE /v1/media/{id}`, the `GET /v1/messages` list, conversion event reporting, overview counts, and the credit account, customer budget and pricing endpoints. `GET /v1/wabas/{id}/analytics` was also removed, because it requires the `billing:read` scope, which customer Keys are not issued. Calling these endpoints with a customer Key has always returned `403`; server behavior is unchanged. Contact BlueMedia support for operations that are no longer documented. ## 2026-11-18 ### Added - `MARKETING` templates accept optional `optimizationSpec` on [Create Template](../templates-flows-media/post-v1-templates.md) and [Edit Template](../templates-flows-media/patch-v1-templates-id.md), and template reads return its Max Price snapshot. `bidAmount` is the integer cap per 1,000 deliveries in the Messaging account currency's smallest unit; optional country multipliers support at most 240 entries. Bid-only edits retain the review status; omitting the spec preserves it, while two explicit nulls clear it. Max Price sends require a phone number rather than a BSUID-only recipient, including broadcasts and `dryRun`; failure codes now cover `131061`, `131062` and `131065`. Delivered/read webhooks expose `pricing.category: "marketing_lite_dynamic"` and estimated `pricing.cost`; the Meta invoice remains final. BlueMedia's rate-card, balance, reservation and customer-budget rules are unchanged. See [Templates](../templates-flows-media/templates.md) and [Webhook Integration](../guides/webhook-integration.md). ### Changed - When ownership verification fails on `POST /v1/webhook-endpoints/{id}/verify` and the receiving end's failure response carries a well-formed `CF-Ray` header (Cloudflare Ray ID), the failure reason recorded in `metadata.last_verification_error` now includes that value, so the receiver's administrators can locate the block record. The endpoint still stays `pending` on failure; no fields or statuses changed. See [Trigger Ownership Verification](../webhooks/post-v1-webhook-endpoints-id-verify.md). - The existing `GET /health/pipeline` endpoint now has an explicit OpenAPI schema for its `200` response. Top-level `status`, `checkedAt` and `checks` are required; `checks` requires `outbox`, `accepted` and `sending`, each with required boolean `ok`, number `oldestSeconds`, integer `pending` and number `thresholdSeconds`. `status` is `ok` on `200`; when any item exceeds its threshold, `503` returns the same response shape with `status: "degraded"`. This completes the machine-readable success contract; probing behavior is unchanged. See [Pipeline Backlog Check](../billing-status/get-health-pipeline.md). ## 2026-11-17 ### Added - Customer Keys can create their own onboarding record with `POST /v1/business-portfolios` (`name` only, `onboarding:write`), then generate an invitation or complete Embedded Signup for that Portfolio. Reading operations/invitations requires `onboarding:read`; lists are automatically limited to the customer’s current Portfolios, and detail/retry/revoke requests check the same ownership. `GET /v1/onboarding/config` supplies SDK settings. Cross-customer access remains denied. ### Fixed - Corrected the customer onboarding guide, authentication allowlist, API examples and OpenAPI: create the local record first; `portfolioId` is the returned `bm_...` ID, not the numeric Meta Business Portfolio ID. Customer Keys must omit `metaBmId` (supplying it returns 400); the backend binds it from the authorized WABA owner after Meta checks. An empty asset list is a normal starting state. Asset lists require the customer’s `customerEntityId`; onboarding lists derive it from authentication. `POST /v1/onboarding/embedded-signup` submits an authorization result and returns HTTP 201; it does not create a link or a Portfolio. Both onboarding lists reject out-of-range limits with 400. These documentation corrections describe the current behavior. See [Customer Onboarding](../guides/customer-onboarding.md). ## 2026-11-13 ### Added - `POST /v1/broadcasts` accepts `toUserId` (BSUID) for recipients without a phone. Provide `to` or `toUserId`; phone wins when both are present. Normalised phones and exact BSUIDs are de-duplicated separately (first entry wins); de-duplicate Contacts before submission because `reference` and inferred phone/BSUID links are not deduplication keys. Recipient details return the identity actually used in nullable `toNumber` / `toUserId`. One-tap / zero-tap / copy-code authentication templates targeting any BSUID are rejected at creation with `400 VALIDATION_FAILED`, including `dryRun`. A BSUID must match the sending phone's Business Portfolio scope; Meta rejects mismatches without phone fallback or sender switching, and `dryRun` / `202` does not guarantee scope validity. BSUID-only pricing uses the existing fallback estimate; budget, opt-out, cooldown and idempotency rules are unchanged. The OpenAPI contract now describes the nested recipient fields and nullable identity response. See [Create Broadcast](../messaging/post-v1-broadcasts.md) and [Recipient Details](../messaging/get-v1-broadcasts-id-recipients.md). ## 2026-11-11 ### Added - `GET /health/pipeline` reports whether the sending pipeline is actually moving, by reading three ages from the database: the oldest unpublished outbox event, the oldest message still in `accepted` and the oldest message still in `sending`. It returns `503` with each item's details once any of them is past its threshold (defaults 120s / 300s / 600s, adjustable with `PIPELINE_OUTBOX_MAX_SECONDS`, `PIPELINE_ACCEPTED_MAX_SECONDS` and `PIPELINE_SENDING_MAX_SECONDS`), and `200` otherwise. It needs no API Key. The readiness check still returns 200 when the scheduler is stuck or the message worker stops consuming — customer messages just sit in `accepted` — so this is the endpoint external probing should watch and alert on for 503. It is deliberately not folded into `/ready`, which the deploy script uses to decide whether a new API instance can take traffic. See [Pipeline Backlog Check](../billing-status/get-health-pipeline.md). ## 2026-11-09 ### Added - `GET /v1/messages` accepts `idempotencyKey` to look up the message created with that `Idempotency-Key` on `POST /v1/messages`. It returns an array of 0 or 1 items and ignores the other filters; use it when a send request timed out and you do not know whether the message was created. An optional `phoneNumberId` narrows the lookup to one sending number. A platform-level Key must pass `X-Tenant-Id`. Calls without `idempotencyKey` behave exactly as before. ## 2026-11-04 ### Added - `POST /v1/pricing/estimates` gives a read-only cost estimate for a broadcast's recipient list: numbers are grouped by pricing market and priced from your rate card, at the same customer price the real charge uses. It does not check the balance, reserve anything or store anything. Recipients that cannot be priced are listed in `unpriced` with a reason instead of being filled in with a fallback amount or reported as 0. Pass `authentication_international` explicitly when it applies; it is not inferred from the market. ## 2026-11-03 ### Added - Customer Keys can call `POST /v1/phone-numbers/{id}/register` for phone numbers their customer entity owns (other numbers return `403`), so they can register a number again themselves after a new display name is approved. deregister, request-code, verify-code and two-step-pin stay closed to customer Keys. See [Register Phone Number](../assets-phone-numbers/post-v1-phone-numbers-id-register.md). ### Changed - After a successful `POST /v1/phone-numbers/{id}/register`, the platform refreshes the number from Meta, so `GET /v1/phone-numbers/{id}` shows the new display name right away instead of the old one until the next refresh. ### Fixed - `GET /v1/phone-numbers/{id}/meta-status` reported `displayName.nextAction: await_review` after a number had been registered again with its approved name; it now reports `none`. ## 2026-11-02 ### Changed - The broadcast cost pre-check (`POST /v1/broadcasts`, including `dryRun`) and the amount reserved for each message are now priced from your rate card, at the highest rate that can apply, instead of a flat estimate per message. A small balance can now start a campaign it can actually afford. Recipients that cannot be priced are still counted at the flat fallback estimate. The `402 INSUFFICIENT_FUNDS` details add `requiredMicros`, `availableMicros`, `pricedRecipients`, `fallbackRecipients` and `fallbackEstimateMinor`; if `fallbackRecipients` is not 0, check the rate card before topping up. The customer budget pre-check uses the same estimate. See [Create Broadcast](../messaging/post-v1-broadcasts.md). ## 2026-11-01 ### Fixed - The signature verification samples in [Webhook Integration](../guides/webhook-integration.md) could throw instead of returning `false`. The default-scheme sample called `crypto.timingSafeEqual` without first checking that the header was present and the lengths matched, and the connection-protocol sample compared string lengths rather than byte lengths. A missing, truncated or non-ASCII signature header therefore raised an exception, which a receiver typically turns into a `500` instead of rejecting the request. Both samples now check presence and byte length first. Signing on our side is unchanged; if you copied either sample, add the same checks. ## 2026-10-31 ### Added - `GET /v1/webhook-endpoints/{id}/deliveries` lists an endpoint's delivery records, newest first: status, attempts, the receiver's response code and a response excerpt, the latest error and the next retry time, without the event payload. It accepts a `status` filter (`pending` / `queued` / `delivered` / `failed`) and `limit` (1–100, default 50), and pages with `before` = the previous `nextCursor`; invalid values return `400`. See [List Deliveries](../webhooks/get-v1-webhook-endpoints-id-deliveries.md). - `POST /v1/webhook-endpoints/{id}/deliveries/{deliveryId}/redeliver` sends a finished (`delivered` / `failed`) delivery again, to recover events missed after automatic retries stopped (about 38.6 hours). It returns `202` with a new delivery record whose `redeliveredFrom` is the original; the original is kept. It uses the endpoint's current URL and secret. Under the connection protocol the redelivery keeps the original `Webhook-Id`; under the default scheme `X-Delivery-Id` is new, so de-duplicate on event content. It returns `409` with `details.reason` `delivery_in_progress`, `endpoint_not_active` or `redelivery_in_progress`, and `404` when the delivery does not belong to the endpoint. See [Redeliver a Delivery](../webhooks/post-v1-webhook-endpoints-id-deliveries-deliveryid-redeliver.md). - Customer Keys can call both endpoints for endpoints that belong to their customer entity. ## 2026-10-30 ### Breaking - Customer Keys now bind webhook endpoints to their customer entity with `customerId` instead of to one Business Portfolio with `projectId`. This replaces the `projectId` rule announced earlier the same day: `POST /v1/webhook-endpoints` and `GET /v1/webhook-endpoints` from a customer Key must pass `customerId` equal to its own customer entity (the `customerEntityId` from `GET /whoami`), and a customer Key that passes only `projectId` gets `403`. One customer-bound endpoint receives events for every Portfolio the customer entity owns, including ones added later. Endpoints a customer Key already created with `projectId` keep receiving that Portfolio's events and can still be managed by ID, but `GET /v1/webhook-endpoints?customerId=` does not list them. To migrate, create one endpoint with `customerId`, then `DELETE` the Portfolio-bound ones so events are not delivered twice. See [Endpoints a customer Key can call](../guides/authentication.md#customer-key-endpoints). ### Added - Customer Keys can now manage templates, broadcasts, the inbox and webhook endpoints for the Business Portfolios their customer entity owns: `POST /v1/templates`, `GET` / `PATCH` / `DELETE /v1/templates/{id}`, `POST /v1/templates/media`, `POST /v1/templates/sync`, template analytics; the `/v1/broadcasts` family; the `/v1/conversations` family; and the `/v1/webhook-endpoints` family. Before this they returned `403 TENANT_FORBIDDEN` (`customer-level keys cannot call …`) for customer Keys. The full list is in [Endpoints a customer Key can call](../guides/authentication.md#customer-key-endpoints). - `GET /v1/conversations` and `GET /v1/broadcasts` accept `phoneNumberId` to limit the list to one phone number. It is optional for BU Keys; customer Keys must pass it. - `POST /v1/webhook-endpoints` accepts `customerId` (`cust_...`): the endpoint receives events for every Business Portfolio that customer entity currently owns, resolved per event. It is mutually exclusive with `projectId` (passing both returns `400`), and the customer entity must belong to the account and have `status: active` (otherwise `400`); while its status is not `active`, its endpoints receive no events. `GET /v1/webhook-endpoints` accepts `customerId` and `projectId` filters, each matching the binding exactly. See [Create Account Callback Endpoint](../webhooks/post-v1-webhook-endpoints.md). - Every webhook delivery, under both signature schemes, carries ownership headers `X-Account-Id`, `X-Project-Id` (Business Portfolio) and `X-Customer-Id` (customer entity). The last two are omitted when that ownership cannot be resolved. They are not part of the signature, so existing verification is unaffected. See [Webhook Integration](../guides/webhook-integration.md). - `DELETE /v1/phone-numbers/{id}/contact-book?bsuid=` deletes one user's entry from Meta's contact book, for personal data deletion requests (scope `phone_numbers:manage`). It returns `{ deleted }`; `deleted: false` means there was no entry and is also a success. Parent BSUIDs (`US.ENT.…`) are rejected with `400`. ### Changed - `PATCH /v1/business-portfolios/{id}` that changes `customerEntityId` returns `409 VALIDATION_FAILED` (`details.reason: "portfolio_bound_webhook_endpoints"`, with `details.endpointIds`) while webhook endpoints that are not disabled are bound directly to that Portfolio, because they would keep receiving its events after it belongs to another customer. Disable them first. - When a user who was known only by BSUID taps a contact information request and shares their own number (`origin: contact_request`), the conversation's empty `contactWaId` is filled with the shared `wa_id`, so you can send to that number afterwards. Contact cards sent directly (`origin: other`) are not used, and an existing `contactWaId` is not overwritten. ### Fixed - `GET /v1/media/{id}` and `GET /v1/media/{id}/content` returned `404` for media ids from inbound messages (images, stickers and other files users sent in), for every Key. Both now accept those ids as well as uploaded media, and customer Keys can call them; ownership is checked against the media's phone number. `DELETE /v1/media/{id}` still only accepts uploaded media and is not open to customer Keys. ## 2026-10-29 ### Fixed - [FAQ](faq.md) and [Rate Limits & Quotas](rate-limits.md) still described a single hard 5 MB limit on the upload endpoint and said audio, video and documents over 5 MB had to be sent by `link`. They now match the per-type check in place since 2026-10-09: 5 MB for images, 16 MB for audio, video and documents, and 100 KB / 500 KB for WebP stickers; only documents over 16 MB (up to Meta's 100 MB) need `link`. See [Upload Media](../templates-flows-media/post-v1-media.md). This corrects the documentation and does not announce an API change. ## 2026-10-23 ### Added - `GET /v1/phone-numbers/{id}/meta-status` returns a local, read-only projection of the number's Meta-side state: the display name in effect, the latest name request with `nextAction` and `reRegisterDeadline` (Meta requires registering again within 14 days of approval), Official Business Account status and business username. It does not call Meta; Refresh Status from Meta updates it. - Business profile on the Meta side: `GET /v1/phone-numbers/{id}/business-profile/meta` reads the profile Meta holds and overwrites the local copy; `POST /v1/phone-numbers/{id}/business-profile/meta` updates it on Meta and reads it back, reporting each field as `confirmed` / `mismatch` / `unknown` / `unverifiable`; `POST /v1/phone-numbers/{id}/profile-picture` uploads a JPG/PNG of at most 5 MB and returns a `handle` (valid for about 4 days) to pass as `profilePictureHandle`. The existing `GET` / `PUT /v1/phone-numbers/{id}/business-profile` still only read and write the local record. - `GET` / `POST /v1/wabas/{id}/meta-account` read the WABA name and time zone Meta holds, and rename the account on Meta with a read-back check (`confirmed`: `true` / `false` / `null`). Renaming requires `onboarding:write`. `GET` / `PATCH /v1/wabas/{id}` still only act on the local record. - `POST /v1/broadcasts` accepts an `Idempotency-Key` header (at most 200 characters): the same key and body return the original campaign with `replayed: true`, and a different body returns `409 IDEMPOTENCY_CONFLICT`. `GET /v1/broadcasts` adds `idempotencyKey` to find that campaign when a create request's outcome is unknown, and `before` for pagination by `createdAt`. Without the header, a repeated POST still creates a second campaign. - `GET /v1/broadcasts/{id}/recipients` rows now include `delivery` (`{ status, wamid, errorCode, errorMessage, updatedAt }`) and the `reference` you set per recipient at creation (`recipients[].reference`, at most 200 characters). It adds a `deliveryStatus` filter and an `after` cursor (rows sorted by `id` ascending). - Four normalized webhook events in the platform envelope, published in addition to the original Meta-shaped events: `contact.identity_changed`, `contact.info_shared`, `marketing.preference_updated` and `phone_number.username_updated`. They can be listed in `events`, and each has a standalone JSON Schema under `/schemas/webhooks/`. Endpoints subscribed to `*` (the default when `events` is omitted) receive them too, so make sure such a receiver ignores event types it does not recognize. See [Webhook Integration](../guides/webhook-integration.md). - The `POST /v1/phone-numbers/{id}/refresh` response adds `metaSync`: a per-field result (`updated` / `unchanged` / `not_returned`) and the outcome of the separate Official Business Account and business username reads in `sections.oba` / `sections.username`. ### Changed - `POST /v1/templates/sync` now follows Meta's pagination for up to 5 pages of 200 templates per call instead of only the first page. When `truncated` is `true` the response includes `nextCursor`; pass it as `after` to continue. `nextCursor` is `null` once everything has been read. - `GET /v1/broadcasts/{id}/recipients` returns `400 VALIDATION_FAILED` for a `status` or `deliveryStatus` value outside the documented set. - Cancelling or pausing a broadcast takes effect before the dispatcher's next message, so recipients claimed in the current round but not yet sent are voided or returned to `pending`. Resume continues only with `pending` recipients and does not resend recipients whose dispatch failed. - `POST /v1/messages` validates `interactive.type: request_contact_info` locally: it needs a non-blank `body.text` and `action.name: request_contact_info`, otherwise the request returns `400 VALIDATION_FAILED`. Other interactive subtypes are still passed through to Meta. ### Fixed - An opt-out Meta reported with only a BSUID (no `wa_id`) was previously dropped. It is now recorded, opt-outs are stored against both the phone number and the BSUID, and a marketing send is blocked with `MARKETING_OPT_OUT` when either `to` or `toUserId` matches. - The Recipient Details page now lists the `status` filter values correctly as `pending` / `dispatching` / `queued` / `failed` / `skipped` / `canceled`. This documents existing behaviour and does not announce an API change. ## 2026-10-21 ### Breaking - Budget caps moved from the Business Portfolio to the customer entity. `PUT` / `DELETE /v1/credit-account/allocations/{portfolioId}` are replaced by `PUT` / `DELETE /v1/credit-account/allocations/{customerEntityId}`. `GET /v1/credit-account/allocations` and `GET /v1/credit-account/allocations/audit` now return one row per customer entity, keyed by `customerEntityId`, with the customer's Portfolios in `items[].portfolios[]`, and add authoritative `*Micros` amounts. Existing caps were rolled up: a customer whose Portfolios all had caps in one currency now has their sum as its cap; any other customer has no limit, and `unlimitedReason` says why. A Portfolio frozen on its own with `0` is no longer frozen if a sibling Portfolio had a non-zero cap. To migrate, pass the customer entity ID, read the new list shape, and check each customer's `allocatedMinor`. The reference pages moved to Set Budget Cap and Remove Budget Cap; see Customer Budgets. - An exhausted budget now returns `402 CUSTOMER_BUDGET_EXCEEDED`, and a failed message records it with `customerAction: raise_customer_budget`. Its `details` carry `customerEntityId` instead of `portfolioId`. `BM_BUDGET_EXCEEDED` is no longer returned for new requests but can remain on historical messages; handle both codes the same way. ### Added - `GET /v1/credit-account/allocations/by-bm` returns read-only net spend per Business Portfolio. Portfolios no longer have a cap of their own. - The OpenAPI document declares `CustomerAction` as an enum schema. ### Changed - `DELETE /v1/customer-entities/{id}` returns 409 with `details.allocationCount` while the customer entity still has a budget cap. Remove the cap first with `DELETE /v1/credit-account/allocations/{customerEntityId}`. ### Fixed - The Delete Customer Entity page now also lists the existing `apiKeyCount` blocker: a customer entity that still has API Keys issued for it cannot be deleted. This documents existing behaviour and does not announce an API change. ## 2026-10-16 ### Breaking - The API base URL is now `https://api.bluehola.com`, documentation is served from `https://docs.bluehola.com`, and the portal — including invitation links (`https://portal.bluehola.com/invite/`) — is now at `https://portal.bluehola.com`. Update your configured API base URL and any saved documentation or portal links to the new domain. ## 2026-10-09 ### Changed - `POST /v1/media` and `POST /v1/templates/media` now check upload size per media type instead of a single 5 MB cap, matching Meta's own limits: 5 MB for `image/jpeg`/`image/png`, 16 MB for audio, video and documents (the platform caps documents stricter than Meta's own 100 MB, because the upload path buffers the whole file in memory), and 100 KB static / 500 KB animated for WebP stickers. Audio, video and documents up to 16 MB can now be uploaded directly; previously anything over 5 MB had to be sent by `link`. The generic multipart error message changed from `invalid multipart upload (max 5MB)` to `invalid multipart upload (max 16MB per file, 3 files)`; exceeding a type's limit now returns `400 VALIDATION_FAILED` with `details: { mimeType, sizeBytes, limitBytes }`. ## 2026-10-08 ### Changed - Customer API Keys now cover all current Business Portfolios under one customer entity. New single-Portfolio Keys are no longer issued; existing ones remain valid. Customer Keys must pass `customerEntityId` to list Portfolios, WABAs or phone numbers; `/whoami` now returns that ID. Migrate by issuing a customer Key and replacing the old credential. ### Fixed - Clarified Meta’s pricing policy effective 2026-10-01: non-template service replies and utility templates in an open 24-hour customer service window are chargeable by send date. The window still controls whether a non-template reply is allowed; it does not make the reply free. This documents the pricing rule and does not announce an API contract change. ## 2026-10-02 ### Fixed - Translated all 469 Chinese `description` occurrences in the downloadable OpenAPI JSON and YAML to English, including request and response fields, parameters, component schemas and error responses. The synchronization step now fails if a new untranslated description appears. ## 2026-10-01 ### Added - Documented the five customer entity operations under `GET/POST /v1/customer-entities` and `GET/PATCH/DELETE /v1/customer-entities/{id}`. A customer entity groups Business Portfolios within one BU; it is not a new authorization boundary. - Documented `POST /v1/wabas/{id}/marketing-messages/refresh` and `POST /v1/wabas/{id}/marketing-messages/onboarding-request`. The latter asks Meta to email the customer's Business Portfolio administrators to sign the Marketing Messages terms. ### Changed - Synchronized the downloadable OpenAPI 3.1 contract with ApiWorker `main`: 90 public paths and 41 schemas. The new pages and navigation are available in English, Simplified Chinese and Traditional Chinese. - Documented `customerEntityId` filters for Business Portfolios, WABAs and phone numbers, plus the `portfolioId` filter for phone numbers. Filters follow current ownership and intersect when combined. - Clarified billing usage: `effective*` is actual spend after reversals, `charged*` and `reversed*` are gross amounts, and ledger net values can be negative at a reporting window boundary. Reconciliation uses `*Micros`. - Documented invitation verification `mode` and server-provided `features`, the automatic Marketing Messages route for marketing templates, and how to query a message whose Meta submission outcome is uncertain. ## 2026-09-22 ### Added - Published the OpenAPI 3.1 download entry points: [`/openapi.yaml`](https://docs.bluehola.com/openapi.yaml) and [`/openapi.json`](https://docs.bluehola.com/openapi.json). - Published `llms.txt`, the full Markdown corpus and a standalone Markdown file per page, for coding agents to read directly. - Published standalone JSON Schemas for the 8 webhook event types, with a unified entry point under OpenAPI `webhooks`. - Added formal success response schemas and per-status error responses for `POST /v1/messages`, `GET /v1/messages` and `GET /v1/messages/{id}`. ### Fixed - Fixed the contradictory documentation about whether `type` is required on a message request: omitting it is backwards compatibility for text only, and new code should send it explicitly. - Fixed `` content being incorrectly described as a string; message requests now use `oneOf` + `discriminator` and express the combination constraints on recipients and media references. ### Changed - The OpenAPI query parameters for the message list now declare accurate types, ranges, date formats and the status enum. The server's existing behaviour — ignoring invalid values and returning an empty list — is unchanged. ## 2026-09-21 **The documentation site moved from GitBook to Docusaurus.** - Navigation became a three-level structure: business domain → resource group → endpoint. Collapsed, the sidebar went from 122 entries to 46. - Endpoint entries in the sidebar gained HTTP method badges (GET / POST / PUT / PATCH / DELETE). - Added 18 resource-group index pages, each giving that group's use cases, endpoint overview and common pitfalls. - Added this "Reference" section: [Glossary](glossary.md), [Rate Limits & Quotas](rate-limits.md), [Idempotency & Retries](idempotency.md), [FAQ](faq.md). - Added flowcharts to the guides: the message state machine, the five-step onboarding orchestration, billing reservation/settlement/reversal, phone number registration order, and webhook ownership verification. - Added site-wide full-text search (Chinese and English). - Fixed 7 code blocks whose incorrect language annotation broke highlighting. :::warning After the migration, **endpoint page URLs gained an extra segment** for the resource group, for example: ```text title="URL change" old /xiao-xi-fa-song-yu-zhuang-tai/post-v1-messages new /docs/messaging/messages/post-v1-messages ``` Old links will 404. If your internal documentation or ticket templates reference the old addresses, they need updating. ::: ## 2026-09-20 **Reorganised endpoint navigation by business domain.** - 121 endpoint pages moved from a flat list into business-domain groups. - Shortened over-long navigation entry names (for example "Read final status, wamid and failure reason" → "Get Message Status"). --- # FAQ Canonical: https://docs.bluehola.com/docs/reference/faq OpenAPI: https://docs.bluehola.com/openapi.yaml Ordered by how often they come up. Each entry is just the conclusion; the reasoning is on the linked page. ## Messaging ### Does a `202 Accepted` mean the message went out? No. `202` only means the **platform has accepted it** — neither that it was delivered nor that it was submitted to Meta. There are only two ways to get the real outcome: poll [`GET /v1/messages/{id}`](../messaging/get-v1-messages-id.md), or receive the status webhooks. See [Sending Messages & Tracking Status](../guides/messaging.md). ### Why is there no `delivered` status — it goes straight to `read`? When the user happens to be sitting in the chat window, Meta omits the `delivered` callback. **Do not assume the statuses always arrive as a complete sequence**, and do not treat a missing `delivered` as a fault. ### A message returns `TEMPLATE_NOT_FOUND`, but the template is clearly approved in the console Your local templates are out of sync with Meta. Call [Sync Templates from Meta](../templates-flows-media/post-v1-templates-sync.md) first, then confirm both the name and the language match. ### The 24-hour window has closed — what can I still send? Only **approved template messages**. The platform makes a local determination before persisting anything: free-form messages it is certain are outside the window return `409 WHATSAPP_24H_WINDOW_EXPIRED` immediately, without wasting a credit reservation. ### Uploading media returns 400 VALIDATION_FAILED The upload endpoint checks each file's size **by media type**: 5 MB for JPG/PNG images, 16 MB for audio, video and documents, and 100 KB static / 500 KB animated for WebP stickers. Over a type's limit, the error's `details` give `mimeType`, `sizeBytes` and `limitBytes`; any file over 16 MB is rejected with `invalid multipart upload (max 16MB per file, 3 files)`. Documents between 16 MB and Meta's 100 MB cap can use the `link` form instead: give Meta a publicly reachable URL and let it fetch the file itself. Images over 5 MB and audio or video over 16 MB are past Meta's own limits too (roughly the same numbers), so `link` does not get around them: an oversized `link` message gets a `202` first and only later turns `failed` via a status callback — compress or re-encode the file. See [Upload Media](../templates-flows-media/post-v1-media.md). ## Billing ### Sending returns 402 — should I adjust the budget or top up? Check the error code: `CUSTOMER_BUDGET_EXCEEDED` means that customer entity has exhausted its budget, so ask us to adjust its budget cap (historical messages may show `BM_BUDGET_EXCEEDED`, which means the same); `INSUFFICIENT_FUNDS` means the account's overall balance is short and you need to contact us to add credit. ### Are failed deliveries refunded? Yes, automatically. The platform settles when Meta accepts the message, and anything a later status callback confirms as `failed` is reversed automatically (idempotently — it will not reverse twice). No manual work required. ## Phone numbers and assets ### I changed the display name, so why does WhatsApp still show the old one? Once the review passes you **must call `register` again** for the new name to actually sync to WhatsApp's servers. Calling register repeatedly, or resubmitting, before the review passes has no effect. ### The credit line is attached but I still get `CREDIT_LINE_NOT_READY` Check whether the **allocation shared to that Business Portfolio is 0**. The allocation has to be set under "Billing & payments → Credit lines" in Meta Business Suite; the **API cannot set it**. ### My number got blocked for 72 hours while I was debugging onboarding A Meta-side rule: **at most 10 register/deregister calls in 72 hours**. Exceeding it returns `133016` and blocks that number's registration capability for 72 hours. Do not register the same number over and over while debugging. See [Rate Limits & Quotas](rate-limits.md). ## Onboarding ### Onboarding failed — can I just call the create endpoint again? No, that creates a brand-new operation. Call `retry` to **resume the same one from where it stopped**. The `code` parameter is optional: omit it if the old credential is still valid, and only have the customer re-authorize for a new code once it has expired. ### Can a lost invitation link be recovered? No. The plaintext link **appears exactly once, in the creation response**; only the token's SHA-256 is stored. If it is lost, generate a new one. ### Onboarding succeeded but the credit line did not sync — does that count as a failure? No. **Onboarding success and credit line sharing are two independent states**; a credit line that has not synced will not cause onboarding to be reported as failed. ## Webhooks ### Every signature check fails after I rotate the secret `rotate-secret` **takes effect immediately, with no overlap period**. The safe approach is to rotate during a quiet period, or to `DELETE` (soft disable) → rotate → store the new value → `POST .../enable`. ### Can an endpoint receive another customer's events? An endpoint bound with `customerId` only receives events for the Business Portfolios that customer entity owns, and one bound with `projectId` only receives events for that one Portfolio — **never** another customer's or Portfolio's; when an event's ownership cannot be resolved it is not delivered to either (better to miss a delivery than to send it to the wrong party). Omitting both is what makes an endpoint account-level, receiving every customer's events under the account. ### I received the same event twice That is expected. Delivery is **at-least-once**, so de-duplicate on `X-Delivery-Id` (default scheme) or `Webhook-Id` (connection protocol). See [Idempotency & Retries](idempotency.md). ### My endpoint was down — can I get the missed events back? Yes. Automatic retries stop after about 38.6 hours. Use [List Deliveries](../webhooks/get-v1-webhook-endpoints-id-deliveries.md) with `status=failed` to find the events your endpoint missed, then call [Redeliver a Delivery](../webhooks/post-v1-webhook-endpoints-id-deliveries-deliveryid-redeliver.md) for each one. The redelivery goes to the endpoint's current URL and is signed with its current secret. ### What does receiving a `probe` event mean? It is the fallback classification for a Meta callback whose body cannot be parsed as any known event — a connectivity probe, or a new payload shape not yet recognised — with the raw body in `value`. It is **not** the console's "Test" button, which sends `webhook.verification`. --- # Glossary Canonical: https://docs.bluehola.com/docs/reference/glossary OpenAPI: https://docs.bluehola.com/openapi.yaml Only terms you will actually meet in these docs are listed. The ID prefix column is the quickest way to tell which kind of resource an unfamiliar id belongs to. ## Assets and identity | Term | ID prefix | Meaning | | --- | --- | --- | | API Key | — | The single credential for a server-side integration, bound to one customer entity and its current Business Portfolios. Previously issued single-Portfolio Keys remain valid. The plaintext appears exactly once, at issue time; the platform stores only a hash. See [Authentication & Scopes](../guides/authentication.md). | | scope | — | A fine-grained permission on an API Key, such as `messages:send`. Whether an endpoint checks scopes is stated in the "Authentication" note on that endpoint's page; a Key whose value is `*` or empty passes every check. | | tenantId | `tenant_` | Account identifier. Call [`GET /whoami`](../authentication/get-whoami.md) to confirm which account the current Key belongs to. | | Business Portfolio | `bm_` | The outermost container for a customer's assets; WABAs and phone numbers both hang off it. These docs use this term consistently when referring to a customer. | | WABA | `waba_` | WhatsApp Business Account. Sits under a Business Portfolio and is what phone numbers and templates belong to. | | Business phone number | `pn_` | The platform's own record of a phone number. Note that read endpoints return a **local snapshot**; for live state on the Meta side, query the [registration status](../assets-phone-numbers/get-v1-phone-numbers-id-registration-status.md). | | platformVersion | — | The API process version that handled this request. Useful when checking whether a given fix has shipped. Do **not** base authorization decisions on it. | ## Messaging | Term | ID prefix | Meaning | | --- | --- | --- | | wamid | `wamid.` | Meta's message identifier, returned once Meta has accepted the message. | | Idempotency-Key | — | A request de-duplication key that you generate yourself, ≤200 characters. See [Idempotency & Retries](idempotency.md). | | 24-hour customer service window | — | For 24 hours after the customer last messaged you, you may send free-form content. Once the window closes, only approved templates can be sent. | | Template | — | A message template that requires Meta review. The only message type available once the 24-hour window has closed. | | Flow | — | A multi-step interactive form inside a conversation. It must be published before it can be referenced in an `interactive` message. | | Media id | — | Returned by Meta after uploading via `POST /v1/media`. It typically **expires after a few days** — do not treat it as a long-term asset library. | | CTWA | — | Click to WhatsApp advertising. The first message it produces carries the ad click id. | | Pixel / dataset | — | Meta's conversion dataset. Conversion events received while nothing is linked are stored as `skipped` and replayed automatically once a link exists. | ## Billing | Term | Meaning | | --- | --- | | minor units | An integer in the smallest currency unit. Every amount field in these docs (`*Minor`) uses this convention — not floating-point major units. | | Credit account | A single account-level wallet holding the currency, available balance and reserved balance. When no credit line has been opened, the balance endpoint returns **404** rather than all zeros. | | Reservation / settlement / reversal | Submitting a message locks a `reserved` amount; when Meta returns a wamid it becomes an actual charge; when a status callback reports `failed` it is reversed automatically. | | Budget cap | `allocatedMinor`: `null` means **no limit**, `0` means **frozen**. The two mean opposite things. | | Credit line | Meta-side credit sharing. It is shared to a Business Portfolio first, then attached to a specific WABA — which is why other WABAs under the same Portfolio share that authorization. | | Net charged vs. volume sent | `totalChargedCount` aggregates the ledger (+1 per charge, −1 per reversal); `totalMessages` counts rows in the message table (including uncharged and failed ones). **It is normal for the two to differ.** | ## Onboarding and webhooks | Term | ID prefix | Meaning | | --- | --- | --- | | Embedded Signup (ES) | — | Meta's customer authorization popup flow. The platform orchestrates it as a resumable five-step state machine. | | operationId | — | Identifies one onboarding orchestration. After a failure, use `retry` to **continue the same one** rather than creating a new one. | | Invitation token | — | A one-time credential inside an invitation link: 43 characters of base64url, stored only as SHA-256. The plaintext appears exactly once, in the creation response. | | PLBV | — | Meta's Business Verification status. | | Endpoint | `whe_` | A webhook receiving endpoint. `DELETE` is a soft disable; history is retained. | | Connection protocol | — | The newer signature scheme used by endpoints created with a `connectionId` (`Webhook-Signature: v1,`, with the timestamp included in the signature). Such endpoints start out `pending`. | | X-Delivery-Id / Webhook-Id | `wd_` / `evt_` | The unique id of a delivery or an event, for de-duplication on the receiving side. Delivery is **at-least-once**. | | probe event | — | The fallback classification Meta uses when a callback body cannot be parsed as a known event. This is **not** the console's "Test" button, which sends `webhook.verification`. | --- # Idempotency & Retries Canonical: https://docs.bluehola.com/docs/reference/idempotency OpenAPI: https://docs.bluehola.com/openapi.yaml This API guarantees idempotency in four places. Once you are clear on what each one's scope is, you will not end up with duplicate charges or duplicate assets. ## Request idempotency (Idempotency-Key) Send a stable `Idempotency-Key` (≤200 characters) with `POST /v1/messages`: ```bash title="Retrying a request that timed out" curl -X POST https://api.bluehola.com/v1/messages \ -H "Authorization: Bearer " \ -H "Idempotency-Key: order-8821-notify" \ -H "Content-Type: application/json" \ -d '{ "phoneNumberId": "pn_01923abc", "to": "8613800138000", "type": "text", "text": { "body": "Your order has shipped" } }' ``` - Reusing the same key **within the current authorization scope** returns *the original* message; nothing is sent twice. - The same key with **different request content** returns `409 IDEMPOTENCY_CONFLICT` — that is telling you your key generation logic is wrong. Do not work around it by changing the key. - If you do not know whether a request succeeded, retry with the **same** key: the original message is returned if it was created, and nothing is sent twice. `POST /v1/broadcasts` accepts the same header at **campaign level**: one key creates at most one campaign. A repeat with the same key and body returns the original campaign with `replayed: true`; the same key with a different body returns `409 IDEMPOTENCY_CONFLICT`. If you do not know whether a create request succeeded, look it up with `GET /v1/broadcasts?idempotencyKey=` rather than creating it again under a new key. See [Create Broadcast](../messaging/post-v1-broadcasts.md). :::tip Generate one key per **business event** (such as `order-8821-notify`), not one per HTTP call. When retrying after a network timeout, that is the only safe approach. ::: ## Ledger idempotency The ledger is append-only (inserts, never updates), and a given idempotency key is posted at most once: - Settlement happens when Meta returns a `wamid`. - A `failed` status callback triggers an automatic reversal, and the reversal record's idempotency key is derived from the message id, so **repeated callbacks do not reverse repeatedly**. The upshot is that a message which was accepted but failed to deliver ends up costing nothing, with no manual intervention. See [Billing & Credit Line](../guides/billing.md). ## Atomic claiming in onboarding orchestration The invitation link's `complete` endpoint performs an **atomic claim** (requiring the invitation to be pending and unexpired) before running the orchestration, so a customer double-clicking submit on the landing page **does not produce two sets of assets**. After a failure you must call `retry` to **continue the same operation**: ```mermaid flowchart LR A["POST .../complete"] --> B{"Claim succeeded?"} B -- No --> R([Rejected, no duplicate assets]) B -- Yes --> C[Run the five-step orchestration] C -- A step fails --> F["failed
currentStep stays at the failure"] F --> D["POST .../retry
resume the same operation from that point"] D --> C C -- All done --> OK([completed]) ``` :::danger `POST`ing to the create endpoint again after a failure **creates a brand-new operation** — it does not resume. On retry, only `code` may change: `wabaId` and `phoneNumberId` were bound on first submission, and pointing at different target assets is rejected. ::: Credit line authorization is idempotent in the same way: an already-authorized Business Portfolio is not authorized again, and an already-attached WABA does not trigger another call to Meta. ## At-least-once webhook delivery Because retries exist, delivery is **at-least-once**. De-duplicate by event id: | Signature scheme | Header to de-duplicate on | | --- | --- | | Default scheme (`apiVersion: null`) | `X-Delivery-Id` | | Connection protocol (`apiVersion` non-null) | `Webhook-Id` | A manual redelivery ([Redeliver a Delivery](../webhooks/post-v1-webhook-endpoints-id-deliveries-deliveryid-redeliver.md)) keeps the original `Webhook-Id` under the connection protocol, but gets a new `X-Delivery-Id` under the default scheme; in that case de-duplicate on the event content (for example the message `id` / `wamid`). The retry schedule is a **fixed table**, not exponential backoff. After the first delivery there are at most 7 retries, for 8 attempts in total: | Retry # | Since previous failure | Elapsed total | | --- | --- | --- | | 1 | immediately | ~0 | | 2 | 1 minute | 1 minute | | 3 | 5 minutes | 6 minutes | | 4 | 30 minutes | 36 minutes | | 5 | 2 hours | 2.6 hours | | 6 | 12 hours | 14.6 hours | | 7 | 24 hours | 38.6 hours | The early "immediately + 1 minute" steps cover the vast majority of transient faults; stretching the later ones out to hours leaves the receiving side's operators time to fix things. After 8 attempts it gives up — it will not retry forever. Events missed after that can be found with [List Deliveries](../webhooks/get-v1-webhook-endpoints-id-deliveries.md) and sent again with [Redeliver a Delivery](../webhooks/post-v1-webhook-endpoints-id-deliveries-deliveryid-redeliver.md). :::warning Only `5xx`, `429` and network-level failures are retried; **any other `4xx` is treated as a terminal failure and is not retried**. So make sure your endpoint returns 5xx rather than 4xx for transient faults — deliberately returning 4xx on a signature-verification failure means that event is not retried automatically, and can only be recovered by redelivering it manually. ::: For complete signature verification code, see [Webhook Integration](../guides/webhook-integration.md). --- # OpenAPI & Agent Access Canonical: https://docs.bluehola.com/docs/reference/openapi OpenAPI: https://docs.bluehola.com/openapi.yaml This page is the entry point for automated tools. The web pages explain business semantics; machines should read the OpenAPI spec and JSON Schemas first rather than inferring types from examples. ## Machine-readable surface | Resource | Location | Best for | | --- | --- | --- | | OpenAPI 3.1 (YAML) | [`/openapi.yaml`](https://docs.bluehola.com/openapi.yaml) | Code generation, IDE tooling, contract validation — the primary artifact | | OpenAPI 3.1 (JSON) | [`/openapi.json`](https://docs.bluehola.com/openapi.json) | Loading directly from a program instead of a generator CLI | | Agent index | [`/llms.txt`](https://docs.bluehola.com/llms.txt) | A short table of contents an agent can read first to decide what to fetch next | | Full Markdown corpus | [`/llms-full.txt`](https://docs.bluehola.com/llms-full.txt) | Every page concatenated — roughly 100K tokens, so only load it whole if your agent's context window can absorb that; otherwise prefer `llms.txt` plus individual pages | | Single-page Markdown | "View Markdown" at the top right of any page, or `/markdown/.md` | Loading just the one page you're working from, to keep context usage down | | Webhook JSON Schemas | see [below](#webhook-schemas) | Validating or generating types for inbound webhook payloads | API base URL: `https://api.bluehola.com`. ## Using this with an AI coding agent ### Quick start 1. Point your agent at `https://docs.bluehola.com/llms.txt` first — it is small (under 50 lines) and links to the guides and endpoint pages that actually matter, rather than dumping the whole corpus into context. 2. Have it fetch `https://docs.bluehola.com/openapi.yaml` before writing any request/response types. The spec is the source of truth for field names, required-ness and enums; the prose guides are the source of truth for asynchronous behaviour, retries and billing — neither one alone is complete (see [Contract precedence](#contract-precedence)). 3. For a single task against one part of the API, skip the full corpus and load only the relevant endpoint page's Markdown (the "View Markdown" link at the top of every page) plus the OpenAPI spec. That is usually enough context to implement one feature correctly. ### Example prompts These are meant to be copied into Claude Code, Codex, Cursor or similar tools more or less as-is. ```text title="Generate a typed client for sending messages" Read https://docs.bluehola.com/openapi.yaml and generate a TypeScript client for POST /v1/messages. Use the MessageRequest oneOf/discriminator on `type` to produce a discriminated union instead of one loose object type. Every call must accept an idempotencyKey and send it as the Idempotency-Key header (see https://docs.bluehola.com/markdown/reference/idempotency.md for why this is required, not optional). Do not invent fields that aren't in the schema. ``` ```text title="Implement a webhook receiver" Read https://docs.bluehola.com/markdown/guides/webhook-integration.md and implement an Express handler for our webhook endpoint. It must verify X-Webhook-Signature-256 as an HMAC-SHA256 of the *raw* request body before parsing JSON, reject on mismatch, and dispatch on X-Webhook-Event using the JSON Schemas at https://docs.bluehola.com/schemas/webhooks/ for each event's shape. De-duplicate on X-Delivery-Id, since delivery is at-least-once. ``` ```text title="Write a retry wrapper" Read https://docs.bluehola.com/markdown/guides/error-codes.md and write a fetch wrapper for our API client. Retry only when the response body's error.retryable is true, using exponential backoff with jitter. Do not retry on any other error, and do not reuse this logic for webhook delivery retries — the webhook retry schedule is fixed and controlled by the platform, not the caller (see https://docs.bluehola.com/markdown/reference/idempotency.md). ``` Each prompt links back to the guide it depends on deliberately: the OpenAPI spec alone tells an agent what a request *looks like*, not when to send it, when to retry it, or how billing settles — that context lives in the linked guides, and an agent that skips them tends to produce code that compiles but is subtly wrong (retrying non-retryable errors, missing the idempotency key, or double-handling webhook retries the platform already handles). ## Contract precedence When different materials appear to disagree, resolve it in this order: 1. OpenAPI / webhook JSON Schema: field types, required relationships, enums and response structures. 2. The relevant endpoint page: asynchronous behaviour, idempotency, state machines, billing and recovery. 3. Example code: for getting started only — never treat it as a complete schema. `POST /v1/messages` already uses `oneOf` and `discriminator` to describe each message type; relationships such as media `id` / `link` being mutually exclusive, and at least one of `to` / `toUserId` being required, are encoded in the schema too. `type` may be omitted and is treated as `text`, but new integrations should always send it explicitly. ## What the spec doesn't cover The OpenAPI document describes shapes, not behaviour. Before generating code against an endpoint, an agent should also have read whichever of these apply: | Concern | Where it's documented | | --- | --- | | Whether a `202` means delivered, and how to track the real outcome | [Sending Messages & Tracking Status](../guides/messaging.md) | | Which failures are safe to retry, and which aren't | [Error Codes](../guides/error-codes.md) | | Idempotency keys, at-least-once webhook delivery, the fixed webhook retry schedule | [Idempotency & Retries](idempotency.md) | | Request-rate and size limits, and what happens past each one | [Rate Limits & Quotas](rate-limits.md) | | When a charge is settled versus reversed | [Billing & Credit Line](../guides/billing.md) | None of this is encoded in the schema's types — it's business behaviour that only exists in prose, and skipping it is the most common way generated code ends up technically-correct but wrong in production. ## Webhook schemas Webhooks ship a separate JSON Schema per event type: - [`message`](https://docs.bluehola.com/schemas/webhooks/message.schema.json) - [`status`](https://docs.bluehola.com/schemas/webhooks/status.schema.json) - [`change`](https://docs.bluehola.com/schemas/webhooks/change.schema.json) - [`probe`](https://docs.bluehola.com/schemas/webhooks/probe.schema.json) - [`job.completed`](https://docs.bluehola.com/schemas/webhooks/job-completed.schema.json) - [`job.failed`](https://docs.bluehola.com/schemas/webhooks/job-failed.schema.json) - [`usage.updated`](https://docs.bluehola.com/schemas/webhooks/usage-updated.schema.json) - [`webhook.verification`](https://docs.bluehola.com/schemas/webhooks/webhook-verification.schema.json) - [`contact.identity_changed`](https://docs.bluehola.com/schemas/webhooks/contact-identity-changed.schema.json) - [`contact.info_shared`](https://docs.bluehola.com/schemas/webhooks/contact-info-shared.schema.json) - [`marketing.preference_updated`](https://docs.bluehola.com/schemas/webhooks/marketing-preference-updated.schema.json) - [`phone_number.username_updated`](https://docs.bluehola.com/schemas/webhooks/phone-number-username-updated.schema.json) The receiving side must still verify the raw request body's signature as described in [Webhook Integration](../guides/webhook-integration.md) before performing schema validation and event dispatch. ## Language of the specification Every `description` in `openapi.yaml` and `openapi.json` is translated to English during synchronization, including request and response fields, parameters, component schemas and error responses. An agent can use these descriptions for English code comments. Some upstream `summary` and `x-notes` text still appears in Chinese; use the English endpoint pages for behavioral guidance. Field names, types, enums and required relationships are unchanged. ## How this is kept up to date The public specification is synced from the API service's `/portal/openapi.json`; this docs repository only fills in precise schemas still missing from the outward-facing machine contract. After updating, maintainers run: ```bash npm run openapi:sync npm run build ``` The build generates `llms.txt`, the full Markdown corpus and a standalone Markdown file for every page; the docs check blocks any release that is missing a key message schema, a webhook schema or a download entry point. --- # Rate Limits & Quotas Canonical: https://docs.bluehola.com/docs/reference/rate-limits OpenAPI: https://docs.bluehola.com/openapi.yaml The limits scattered across the individual guides are collected here so you can work out "why was this rejected". Every row states **who imposes** the limit: you can talk to us about the platform-side ones, whereas the Meta-side ones leave you only waiting or changing your process. ## Request rate limits | Limit | Source | What you see | What to do | | --- | --- | --- | --- | | **600 requests/minute** per account (per API Key) | Platform | `429 RATE_LIMITED` | Back off and retry; `retryable: true` | | Customer-facing invitation page endpoints are limited **per source IP** | Platform | 429 | These endpoints carry no API Key — the token itself is the credential | | Meta API rate limit (codes `4` / `80007`) | Meta | Message failure code `META_RATE_LIMIT` | The platform backs off and retries automatically; no action needed | | Cloud API throughput ceiling (code `130429`) | Meta | `META_THROUGHPUT_LIMIT` | The platform retries automatically | | Too many messages in a short period from one sending number to one recipient (code `131056`) | Meta | `PAIR_RATE_LIMIT` | The platform retries automatically | `429` responses are **not guaranteed to carry `Retry-After`** today. Check `error.retryable` first: when it is `true`, use exponential backoff with jitter; when it is `false` (for example `ENGAGEMENT_COOLDOWN`), do not retry automatically. If the server later starts sending `Retry-After`, prefer the wait time given in the header. :::warning `ENGAGEMENT_COOLDOWN` (429) is **not** a rate limit you can back off and retry. That recipient tripped Meta's per-person engagement ceiling (131049), and the platform rejects further templates outright during a local 24-hour cooldown — **retrying within those 24 hours extends Meta's block**. Wait, or send to a different recipient. ::: ## Phone number lifecycle | Limit | Source | Notes | | --- | --- | --- | | **At most 10 register/deregister calls in 72 hours** | Meta | Exceeding it returns `133016` and blocks that number's registration capability for 72 hours. Do not register the same number over and over while debugging your onboarding flow. | | Display name: **at most 10 changes in 30 days** | Meta | Submission starts a review; once approved you **must register again** for it to actually sync. | | Verification codes are valid for about **10 minutes** and single-use | Meta | Repeated failures may trigger a temporary restriction. | | Two-step verification cannot be turned off via the API | Meta | It can only be disabled by hand in WhatsApp Manager; the endpoint can only set a new value. | ## Content and media | Limit | Source | Notes | | --- | --- | --- | | Upload size is checked **per media type**: 5 MB images, 16 MB audio, video and documents, 100 KB / 500 KB WebP stickers | Platform | Applies to `POST /v1/media` and `POST /v1/templates/media` (the latter accepts only JPG/PNG, MP4 and PDF). A file over its type's limit returns `400 VALIDATION_FAILED` before it reaches Meta (`details` gives `mimeType` / `sizeBytes` / `limitBytes`). Documents over 16 MB, up to Meta's 100 MB, must instead use the `link` form so Meta fetches them itself. See [Upload Media](../templates-flows-media/post-v1-media.md). | | ~5 MB images / ~16 MB audio and video / ~100 MB documents | Meta | Checked **at delivery time**; the send endpoint does not pre-check — an oversized message gets a `202` first and only later turns `failed` via a status callback. | | Meta media ids typically **expire after a few days** | Meta | Do not treat one id as a long-term asset library. | | Temporary media download URLs expire after **5 minutes** | Meta | For long-term storage use the [proxy download](../templates-flows-media/get-v1-media-id-content.md). | | At most **257 contacts** in one `contacts` message | Meta | — | | **10 messages per hour** per Flow | Meta | Exceeding it gives `FLOW_THROTTLED` (132069); fix the Flow first, resending will not help. | ## Webhooks | Limit | Source | Notes | | --- | --- | --- | | **10 second** timeout per regular delivery attempt | Platform | A `2xx` counts as success | | Verification/test challenges time out after **5 seconds**, with at most **4 KB** of the body read | Platform | Shorter than a regular delivery because the caller is waiting synchronously | | **7 retries, 8 attempts total**, over a window of about **38.6 hours** | Platform | A fixed table rather than exponential backoff; see [Idempotency & Retries](idempotency.md) | | Custom secrets must be **at least 16 characters** | Platform | Leave it blank and the platform generates a random value prefixed `whsec_` | | Endpoint URLs must be https and must not resolve to a private network | Platform | **Resolution is repeated before every delivery**, so repointing at a private address afterwards is blocked too | ## Other value constraints | Field | Constraint | | --- | --- | | `Idempotency-Key` | ≤200 characters | | Invitation `expiresInSeconds` | Defaults to 1800; configurable 300–86400 (24 hours maximum) | | Ledger `days` | Only 7 / 30 / 90 are accepted; any other value is treated as 30 | | Template message `components.parameters` | Count and order must match the template declaration **exactly** | ## Which failures the platform retries for you The following message failure codes are marked "platform retries automatically" — you do **not** need to resend them yourself: `INTERNAL`, `META_RATE_LIMIT`, `META_SERVICE_UNAVAILABLE`, `META_THROUGHPUT_LIMIT`, `PAIR_RATE_LIMIT`, `PHONE_SEND_RESTRICTED`, `UPSTREAM_META_ERROR`, `WABA_MAINTENANCE_MODE`. Every other code is `retryable: false` — retrying gets you an identical result, so act on `customerAction` instead. The full table is in [Error Codes](../guides/error-codes.md). --- # Delete Template Canonical: https://docs.bluehola.com/docs/templates-flows-media/delete-v1-templates-id OpenAPI: https://docs.bluehola.com/openapi.yaml
DELETE/v1/templates/{id}
Delete a template, returning 204. :::note[Authentication] Send `Authorization: Bearer ` in the request headers; required scope: `templates:manage`. Which resources an API Key can reach is determined by its current authorization scope. ::: ## Request Base URL: `https://api.bluehola.com` ### Parameters | Name | In | Required | Type / constraints | Description | | --- | --- | --- | --- | --- | | `id` | path | Yes | string | The platform's template ID, `tmpl_...` | ## Response | Status | Description | | --- | --- | | `204` | No Content | | `4xx` | Client error | For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md). ## Notes Deletion calls out to Meta first to delete the template by name (Meta's semantics delete every language version of that name under the WABA), and only removes the local row once that succeeds. If the call to Meta fails, the whole operation fails, so you never end up with an inconsistent state where the local row is gone but the Meta side still exists, or vice versa. --- # Flow Canonical: https://docs.bluehola.com/docs/templates-flows-media/flows OpenAPI: https://docs.bluehola.com/openapi.yaml # Flow A Flow is a multi-step interactive form presented inside a WhatsApp conversation. Once a Flow is published it can be referenced in an `interactive`-type message. | Endpoint | Purpose | | --- | --- | | [List Flows](get-v1-flows.md) | Read the list of Flows for a WABA. | | [Flow Details](get-v1-flows-id.md) | Read details after verifying WABA ownership. | To create, edit, publish or deprecate a Flow, contact BlueMedia support. :::warning Two send failure codes relate to Flows: `FLOW_BLOCKED` (the Flow is blocked and must be corrected first) and `FLOW_THROTTLED` (10 messages using this Flow have already gone out in the last hour). Both require fixing the Flow itself first — resending is no use. ::: --- # Get Flow Details After Verifying WABA Ownership Canonical: https://docs.bluehola.com/docs/templates-flows-media/get-v1-flows-id OpenAPI: https://docs.bluehola.com/openapi.yaml
GET/v1/flows/{id}
Verify WABA ownership, then read the Flow's details. :::note[Authentication] Send `Authorization: Bearer ` in the request headers. Which resources an API Key can reach is determined by its current authorization scope. ::: ## Request Base URL: `https://api.bluehola.com` ### Parameters | Name | In | Required | Type / constraints | Description | | --- | --- | --- | --- | --- | | `id` | path | Yes | string | The Flow id on Meta's side | | `wabaId` | query | Yes | string | The platform's internal WABA ID, `waba_...`. **Required** — Flows do not exist in the platform's own database, so this is the only way to verify ownership | ## Response | Status | Description | | --- | --- | | `200` | OK | | `4xx` | Client error | For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md). ## Notes The endpoint first pulls the list of Flow ids under that wabaId to check ownership, then reads the details separately; if the id exists but does not belong to the supplied wabaId, it returns 404 rather than leaking another WABA's Flow details. --- # List a WABA's Flows Canonical: https://docs.bluehola.com/docs/templates-flows-media/get-v1-flows OpenAPI: https://docs.bluehola.com/openapi.yaml
GET/v1/flows
List a WABA's Flows; wabaId is required. :::note[Authentication] Send `Authorization: Bearer ` in the request headers. Which resources an API Key can reach is determined by its current authorization scope. ::: ## Request Base URL: `https://api.bluehola.com` ### Parameters | Name | In | Required | Type / constraints | Description | | --- | --- | --- | --- | --- | | `wabaId` | query | Yes | string | The platform's internal WABA ID, `waba_...`. **Required**; missing or empty returns `400 VALIDATION_FAILED` | ## Response | Status | Description | | --- | --- | | `200` | OK | | `4xx` | Client error | For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md). ## Notes The platform does not store Flows locally — this reads the Flow list on Meta's side for that WABA; wabaId must be a WABA owned by the current account, otherwise 404. Sending a Flow message goes through `POST /v1/messages` with `type=interactive` and `action.flow`, using the id read here directly as that field's reference. --- # Proxy-download the raw media bytes Canonical: https://docs.bluehola.com/docs/templates-flows-media/get-v1-media-id-content OpenAPI: https://docs.bluehola.com/openapi.yaml
GET/v1/media/{id}/content
The platform proxies the download of the raw media bytes. :::note[Authentication] Send `Authorization: Bearer ` in the request headers. Which resources an API Key can reach is determined by its current authorization scope. ::: ## Request Base URL: `https://api.bluehola.com` ### Parameters | Name | In | Required | Type / constraints | Description | | --- | --- | --- | --- | --- | | `id` | path | Yes | string | The Meta media id | ## Response | Status | Description | | --- | --- | | `200` | OK | | `4xx` | Client error | For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md). ## Notes The platform proxies the download, so the caller does not need to obtain an access token and connect to Meta's temporary URL directly. It is subject to the same ownership check (both uploaded media and media in inbound messages can be downloaded, and customer Keys can call it), and under the hood it still uses that same URL with a 5-minute lifetime, so consecutive calls each trigger a fresh URL resolution. --- # Get media MIME type, size, hash and temporary URL Canonical: https://docs.bluehola.com/docs/templates-flows-media/get-v1-media-id OpenAPI: https://docs.bluehola.com/openapi.yaml
GET/v1/media/{id}
Read the media's MIME type, size, hash and a temporary URL. :::note[Authentication] Send `Authorization: Bearer ` in the request headers. Which resources an API Key can reach is determined by its current authorization scope. ::: ## Request Base URL: `https://api.bluehola.com` ### Parameters | Name | In | Required | Type / constraints | Description | | --- | --- | --- | --- | --- | | `id` | path | Yes | string | The Meta media id | ## Response | Status | Description | | --- | --- | | `200` | OK | | `4xx` | Client error | For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md). ## Notes Two kinds of media id can be looked up: media this account uploaded with `POST /v1/media`, and media in inbound messages users sent to this account's phone numbers (the `id` of an image, sticker, video, audio or document). Any other id returns 404, even if it genuinely exists on Meta's side. Customer Keys can call this endpoint; ownership is checked against the media's phone number (the uploading number, or the number that received the message), and a Key restricted to specific phone numbers is checked the same way. The download URL returned is a temporary link generated by Meta that **expires after 5 minutes**; once it expires, call this endpoint again for a new one rather than caching it long-term. --- # Template Analytics Canonical: https://docs.bluehola.com/docs/templates-flows-media/get-v1-templates-analytics OpenAPI: https://docs.bluehola.com/openapi.yaml
GET/v1/templates/analytics
Template analytics: sent / delivered / read / button clicks. :::note[Authentication] Send `Authorization: Bearer ` in the request headers; required scope: `templates:manage`. Which resources an API Key can reach is determined by its current authorization scope. ::: ## Request Base URL: `https://api.bluehola.com` ## Response | Status | Description | | --- | --- | | `200` | OK | | `4xx` | Client error | ### 200 response schema ```json { "$ref": "#/components/schemas/TemplateAnalyticsResult" } ``` For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md). ## Notes Query parameters: `wabaId`, `templateIds` (**local** template ids, comma-separated), `start`/`end` (unix seconds), `metricTypes` (optional, default `SENT,DELIVERED,READ,CLICKED`). #### You must enable it first Call `POST /v1/templates/analytics/enable` for this WABA once beforehand, or Meta returns an error directly. That is a one-time confirmation to Meta, and **once enabled it cannot be turned off**. #### Read the warnings in the response This endpoint carries several hard limits on Meta's side, and rather than swallowing them silently we write them into `warnings` honestly: - **At most 10 templates per call**; anything beyond that, only the first 10 are used; - **Read and button-click data are only kept for 7 days**; over a longer span, those two metrics will be 0 for the earlier part (not a bug); - **`COST` is never returned for a WABA on shared platform credit** (a Meta restriction, and that describes all of our customers). Ask BlueMedia for your spend figures; - A template id outside the current authorization scope, or one that has never been synced with a Meta id, is dropped and called out by name in `warnings`. Button-click data is only available for `MARKETING` / `UTILITY` category templates; WABAs in the EU and Japan are not supported (both Meta restrictions). --- # Get template details Canonical: https://docs.bluehola.com/docs/templates-flows-media/get-v1-templates-id OpenAPI: https://docs.bluehola.com/openapi.yaml
GET/v1/templates/{id}
Get a template's details. :::note[Authentication] Send `Authorization: Bearer ` in the request headers. Which resources an API Key can reach is determined by its current authorization scope. ::: ## Request Base URL: `https://api.bluehola.com` ### Parameters | Name | In | Required | Type / constraints | Description | | --- | --- | --- | --- | --- | | `id` | path | Yes | string | The platform's template ID, `tmpl_...` | ## Response | Status | Description | | --- | --- | | `200` | OK | | `4xx` | Client error | ### 200 response schema ```json { "$ref": "#/components/schemas/MessageTemplate" } ``` For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md). ## Notes A pure local read with no outbound call to Meta; use it to confirm status=APPROVED before sending. `POST /v1/messages` performs the same check before sending with a template of matching name and language, and rejects it if it has not passed review. --- # List templates and their latest review status Canonical: https://docs.bluehola.com/docs/templates-flows-media/get-v1-templates OpenAPI: https://docs.bluehola.com/openapi.yaml
GET/v1/templates
List templates and their latest review status. :::note[Authentication] Send `Authorization: Bearer ` in the request headers. Which resources an API Key can reach is determined by its current authorization scope. ::: ## Request Base URL: `https://api.bluehola.com` ### Parameters | Name | In | Required | Type / constraints | Description | | --- | --- | --- | --- | --- | | `wabaId` | query | No | string | Filter by WABA, `waba_...`. Omit or pass an empty string for no filter | ## Response | Status | Description | | --- | --- | | `200` | OK | | `4xx` | Client error | ### 200 response schema ```json { "type": "array", "items": { "$ref": "#/components/schemas/MessageTemplate" } } ``` For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md). ## Notes The `wabaId` query parameter restricts the results to a specific WABA, which must be within the current API Key's authorization scope. This returns the locally stored template records (including the most recently known review `status`), not a live query against Meta every time; if a Meta-side status has changed but the corresponding callback has not been processed yet, this can lag briefly. --- # Media Canonical: https://docs.bluehola.com/docs/templates-flows-media/media OpenAPI: https://docs.bluehola.com/openapi.yaml # Media There are two ways to reference media when sending a message, and you must give **exactly one**: `id` (uploaded to Meta beforehand) or `link` (a public URL Meta fetches itself). | Endpoint | Purpose | | --- | --- | | [Upload Media](post-v1-media.md) | Upload a multipart file to Meta and get back a media id. Requires `phoneNumberId`. | | [Media Details](get-v1-media-id.md) | Read the MIME type, size, hash and a temporary download URL. Works for uploaded media and for media users sent in. | | [Proxy Download](get-v1-media-id-content.md) | The platform proxies the download of the raw bytes. | :::warning **The upload endpoint checks size per media type**, matching Meta's own limits: roughly 5 MB for images, 16 MB for audio, video and documents (the platform caps documents stricter than Meta's own 100 MB), and 100 KB static / 500 KB animated for WebP stickers. A file over its type's limit returns `400` directly, before it ever reaches Meta. For documents over 16 MB, use the `link` form instead, for Meta to fetch itself. ::: Two timing issues to watch for: Meta media ids typically **expire after a few days**, so do not treat one id as a long-term asset library; the temporary download URL in the media details **expires after 5 minutes**, so use the proxy download if you need long-term storage. Size is pre-checked only on this upload path (see above); format is not — it still follows whatever Meta enforces **when the media message is actually sent**. For media referenced by `link`, the platform pre-checks neither size nor format; Meta applies both of its per-type limits at delivery, and an oversized or malformed message gets a `202` first and only later turns `failed` via a status callback. Uploading and deleting require the `media:write` scope; see [Sending Messages & Tracking Status](../guides/messaging.md) for details. --- # Edit Template Canonical: https://docs.bluehola.com/docs/templates-flows-media/patch-v1-templates-id OpenAPI: https://docs.bluehola.com/openapi.yaml
PATCH/v1/templates/{id}
Edit template content or Max Price. Content changes return to PENDING for review; bid-only changes retain the current status. :::note[Authentication] Send `Authorization: Bearer ` in the request headers; required scope: `templates:manage`. Which resources an API Key can reach is determined by its current authorization scope. ::: ## Request Base URL: `https://api.bluehola.com` ### Parameters | Name | In | Required | Type / constraints | Description | | --- | --- | --- | --- | --- | | `id` | path | Yes | string | The platform's template ID, `tmpl_...` | ### Request body A request body is required. ### Request body fields | Field | Type | Required | Description | | --- | --- | --- | --- | | `components` | array | No | The new component array (replaces the whole thing) | | `category` | MARKETING \| UTILITY \| AUTHENTICATION | No | The new category | | `parameterFormat` | positional \| named | No | The parameter placeholder style | | `allowCategoryChange` | boolean | No | Allow Meta to reclassify the category during review (avoids rejection over a category mismatch) | | `messageSendTtlSeconds` | integer | No | The TTL for messages sent with this template | | `optimizationSpec` | object | No | Set, change or clear Max Price; see below | Content-Type: `application/json` Schema: ```json { "type": "object", "properties": { "components": { "type": "string", "description": "array · optional — The new component array (replaces the whole thing)" }, "category": { "type": "string", "description": "MARKETING | UTILITY | AUTHENTICATION · optional — The new category" }, "parameterFormat": { "type": "string", "description": "positional | named · optional — The parameter placeholder style" }, "allowCategoryChange": { "type": "string", "description": "boolean · optional — Allow Meta to reclassify the category during review (avoids rejection over a category mismatch)" }, "messageSendTtlSeconds": { "type": "string", "description": "integer · optional — The TTL for messages sent with this template" }, "optimizationSpec": { "type": "string", "description": "object · optional — Max Price (MARKETING only): `{ bidAmount, bidStrategy: LOWEST_COST_WITH_BID_CAP, bidCountryMultiplierOverrides? }`. bidAmount is the maximum price per 1,000 deliveries in the smallest unit of the Messaging account currency ($0.05 per delivery = 5000). It may be below, equal to, or above the rate card; Meta charges no more than the effective bid. When editing, pass null for both bid fields to clear Max Price and return to rate-card billing." } } } ``` ## Response | Status | Description | | --- | --- | | `200` | OK | | `4xx` | Client error | ### 200 response schema ```json { "$ref": "#/components/schemas/MessageTemplate" } ``` For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md). ## Notes #### Only APPROVED / REJECTED templates can be edited A PENDING template is currently under review, and editing it would be rejected by Meta — the platform blocks it locally first and returns 409, so you see "wait for the review outcome" rather than an opaque upstream error. #### Content edits return to PENDING; bid-only edits do not Changing `components`, `category`, `parameterFormat` or `messageSendTtlSeconds` makes Meta review the template again, so the local status returns to `PENDING` and the previous rejection reason is cleared. The review outcome is filled in by the `message_template_status_update` webhook. Changing **only** `optimizationSpec` keeps the current status, so an `APPROVED` template does not become temporarily unsendable just because its bid changed. A new bid can take up to one hour to take effect. #### Updating or clearing Max Price - Omitting `optimizationSpec` leaves the bid unchanged. - To set or change it, provide both `bidAmount` and `bidStrategy`. Omitting `bidCountryMultiplierOverrides` preserves the existing country map; `{}` clears it; a non-empty map replaces it as a whole. - To return to rate-card billing, send exactly `{ "bidAmount": null, "bidStrategy": null }`. Do not include country overrides in a clear request. - A template with Max Price cannot be moved out of `MARKETING` directly; clear the bid first. #### No local content-difference check The platform does not compare the submitted fields with the currently stored template content. An empty request body is rejected with `400 nothing to update`; otherwise, the supplied fields are forwarded to Meta even if their values appear unchanged. If Meta accepts a content edit, the local status changes to `PENDING`; a bid-only edit follows the rule above. If Meta rejects the request, the API returns that error and the local template is not changed to `PENDING`. There is no separate "resubmit unchanged content" endpoint, so do not call this endpoint merely to force another review unless an actual edit is required. #### `name` and `language` cannot be changed Meta's edit endpoint has no fields for either — to change the name, create a new template instead. The request body is `.strict()`: sending them returns 400 rather than being silently ignored. A template with no Meta template id locally (never synced) returns 409; call `POST /v1/templates/sync` first. --- # Upload a multipart file to Meta Canonical: https://docs.bluehola.com/docs/templates-flows-media/post-v1-media OpenAPI: https://docs.bluehola.com/openapi.yaml
POST/v1/media
Upload a multipart file to Meta and get back a media ID. :::note[Authentication] Send `Authorization: Bearer ` in the request headers; required scope: `media:write`. Which resources an API Key can reach is determined by its current authorization scope. ::: ## Request Base URL: `https://api.bluehola.com` ### Parameters | Name | In | Required | Type / constraints | Description | | --- | --- | --- | --- | --- | | `phoneNumberId` | query | Yes | string | The platform's phone number ID, `pn_...`. **Required** — missing or empty returns `400 VALIDATION_FAILED`; it must also pass the API Key's phone number authorization check | ### Request body A request body is required. A single `file` part (at most 3 files per request); a file over **16 MB** returns `400 VALIDATION_FAILED` with the message `invalid multipart upload (max 16MB per file, 3 files)`. Each file is also checked against a per-type size limit — see **Upload size limits by media type** below — and exceeding that returns `400 VALIDATION_FAILED` with `details: { mimeType, sizeBytes, limitBytes }`. Content-Type: `multipart/form-data` Schema: ```json { "type": "object", "properties": { "file": { "type": "string", "format": "binary" } }, "required": [ "file" ] } ``` ## Response | Status | Description | | --- | --- | | `201` | Created | | `4xx` | Client error | For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md). ## Notes `phoneNumberId` must be the platform's own phone number ID (pn_...) and must belong to the current account; the server resolves the Meta-side phone number ID from it before forwarding the upload. The media itself is not persisted on the platform (only the filename, type and owning phone number are recorded — not the bytes), and Meta-side media IDs typically expire after a few days, so it is not advisable to depend on the same ID long-term. #### Upload size limits by media type The platform checks the uploaded file's size against a per-type table that mirrors Meta's own limits, instead of one flat cap: | Type | Limit | | --- | --- | | `image/jpeg`, `image/png` | 5 MB | | `audio/*` (aac, amr, mpeg, mp4, ogg), `video/3gpp`, `video/mp4` | 16 MB | | Documents (`text/plain`, `application/pdf`, Word/Excel/PowerPoint) | 16 MB — stricter than Meta's own 100 MB, because the upload path buffers the whole file in memory | | `image/webp` stickers | 100 KB static / 500 KB animated (read from the WebP container; a container the platform cannot recognize is treated as static, the stricter limit) | | Any other MIME type | 16 MB, deferred to Meta's own check | A file over its type's limit is rejected (`400 VALIDATION_FAILED`) before it ever reaches Meta. Audio, video and documents up to 16 MB can now go through this upload channel directly; use the `link` form on the message instead only for assets past these limits (or past Meta's own 100 MB cap for documents). The format allowlist and other per-type details still follow whatever Meta enforces **when the media message is actually sent**; the platform does not pre-check formats at this layer. --- # One-time confirmation to enable template analytics for this WABA Canonical: https://docs.bluehola.com/docs/templates-flows-media/post-v1-templates-analytics-enable OpenAPI: https://docs.bluehola.com/openapi.yaml
POST/v1/templates/analytics/enable
A one-time confirmation to enable template analytics for this WABA. **Once enabled it cannot be turned off.** :::note[Authentication] Send `Authorization: Bearer ` in the request headers; required scope: `templates:manage`. Which resources an API Key can reach is determined by its current authorization scope. ::: ## Request Base URL: `https://api.bluehola.com` ### Request body A request body is required. ### Request body fields | Field | Type | Required | Description | | --- | --- | --- | --- | | `wabaId` | string | Yes | The platform's WABA id (waba_...) | Content-Type: `application/json` Schema: ```json { "type": "object", "properties": { "wabaId": { "type": "string", "description": "string · required — The platform's WABA id (waba_...)" } }, "required": [ "wabaId" ] } ``` ## Response | Status | Description | | --- | --- | | `200` | OK | | `4xx` | Client error | ### 200 response schema ```json { "$ref": "#/components/schemas/TemplateInsightsEnabled" } ``` For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md). ## Notes This is a standalone endpoint rather than something turned on as a side effect of a read call: per Meta's own description, confirming enablement means authorizing Meta to collect and anonymize your and your customers' chat data and to track clicks on links inside templates, and **once enabled it cannot be turned off**. A decision like that needs someone to press the button deliberately. Meta only starts collecting template analytics data for this WABA after it is enabled — meaning **there is no historical data from before enablement**. --- # Upload a template media header asset Canonical: https://docs.bluehola.com/docs/templates-flows-media/post-v1-templates-media OpenAPI: https://docs.bluehola.com/openapi.yaml
POST/v1/templates/media
Upload a template media header asset (multipart) and get back the `handle` to put in components. :::note[Authentication] Send `Authorization: Bearer ` in the request headers; required scope: `templates:manage`. Which resources an API Key can reach is determined by its current authorization scope. ::: ## Request Base URL: `https://api.bluehola.com` ### Parameters | Name | In | Required | Type / constraints | Description | | --- | --- | --- | --- | --- | | `wabaId` | query | Yes | string | The platform's WABA ID, `waba_...`. **Required** — missing or empty returns `400 VALIDATION_FAILED` | ### Request body A request body is required. A single `file` part (at most 3 files per request); a file over **16 MB** returns `400 VALIDATION_FAILED`. Each file is also checked against the per-type limit listed under **Supported types and expiry** below, with the same error code. Content-Type: `multipart/form-data` Schema: ```json { "type": "object", "properties": { "file": { "type": "string", "format": "binary" } }, "required": [ "file" ] } ``` ## Response | Status | Description | | --- | --- | | `201` | Created | | `4xx` | Client error | For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md). ## Notes #### A template with an image/video/document header must come here first Meta requires a template's media header to be declared **only** via an asset handle, and a handle can only be obtained from the Resumable Upload API. First call `POST /v1/templates/media?wabaId=waba_...` (multipart, one `file` part) to get a `handle`, then put it into the template component: ```json { "type": "HEADER", "format": "IMAGE", "example": { "header_handle": [""] } } ``` #### It is not the same thing as `POST /v1/media` `POST /v1/media` produces a media id for **sending messages**; this endpoint produces a handle for **building templates**. The two are not interchangeable — putting a media id into `header_handle` is rejected by Meta. #### Supported types and expiry Only `image/jpeg`, `image/jpg`, `image/png`, `video/mp4` and `application/pdf` (Meta's allowlist, checked locally first, telling you the permitted list). Each type also has its own size limit: **5 MB** for `image/jpeg`/`image/png`, **16 MB** for `video/mp4` and `application/pdf` — the platform caps documents stricter than Meta's own 100 MB, because the upload path buffers the whole file in memory. **The handle expires after about 4 days** (the response's `expiresAt` is exactly that) — build the template as soon as you get it, and do not treat it as an asset library. --- # Sync Templates from Meta Canonical: https://docs.bluehola.com/docs/templates-flows-media/post-v1-templates-sync OpenAPI: https://docs.bluehola.com/openapi.yaml
POST/v1/templates/sync
Import/refresh into the local store whatever templates already exist on Meta's side for this WABA. :::note[Authentication] Send `Authorization: Bearer ` in the request headers; required scope: `templates:manage`. Which resources an API Key can reach is determined by its current authorization scope. ::: ## Request Base URL: `https://api.bluehola.com` ### Request body A request body is required. ### Request body fields | Field | Type | Required | Description | | --- | --- | --- | --- | | `wabaId` | string | Yes | The platform's WABA ID | | `after` | string | No | Continuation cursor: the `nextCursor` from the previous response (at most 512 characters). Omit it to start from the first page | Content-Type: `application/json` Schema: ```json { "type": "object", "properties": { "wabaId": { "type": "string", "description": "string · required — The platform's WABA ID" }, "after": { "type": "string", "description": "string · optional — continuation cursor: the nextCursor from the previous response; omit it to start from the first page" } }, "required": [ "wabaId" ] } ``` ## Response | Status | Description | | --- | --- | | `200` | OK | | `4xx` | Client error | ### 200 response schema ```json { "$ref": "#/components/schemas/TemplateSyncResult" } ``` For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md). ## Notes Onboarding (Embedded Signup) only creates the WABA and phone number — it never touches templates. But the send path requires a matching local template row, so any template the customer already built in WhatsApp Manager and had approved by Meta cannot be sent through this platform at all until it has been imported (you get 404 template not found for this phone number's WABA). The platform syncs automatically once onboarding completes; this endpoint is the entry point for doing it again manually. #### Idempotency and what it overwrites - Matched on (wabaId, name, language): an existing row is **updated**, a missing one is **inserted**. - Updates only overwrite the fields Meta is authoritative for: status / category / components / rejected_reason / metaTemplateId; `name` and `language` are left alone. - **It never deletes** local template rows that have no match. Deletion is destructive, and Meta's list is paginated — seeing only part of it and finding "extra" local rows is normal, not a reason to delete them. #### Pagination One call follows Meta's pagination cursor for at most 5 pages (200 templates per page). When everything has been read, the response has `truncated=false` and `nextCursor=null`; otherwise it has `truncated=true` and a `nextCursor` — call again with `after=` to continue from where it stopped, until `truncated=false`. Calling again without `after` starts over from the first page (idempotent, but it will not reach the later pages). #### Nothing is submitted to Meta This is a pure read plus a local write; it does not consume any of Meta's template review quota and can be called repeatedly and safely. --- # Create a template and submit it for Meta review Canonical: https://docs.bluehola.com/docs/templates-flows-media/post-v1-templates OpenAPI: https://docs.bluehola.com/openapi.yaml
POST/v1/templates
Create a template and submit it for Meta review. :::note[Authentication] Send `Authorization: Bearer ` in the request headers; required scope: `templates:manage`. Which resources an API Key can reach is determined by its current authorization scope. ::: ## Request Base URL: `https://api.bluehola.com` ### Request body A request body is required. ### Request body fields | Field | Type | Required | Description | | --- | --- | --- | --- | | `wabaId` | string | Yes | The platform's WABA ID | | `name` | string | Yes | Lowercase letters, digits and underscores | | `language` | string | Yes | For example en_US, zh_CN | | `category` | MARKETING \| UTILITY \| AUTHENTICATION | Yes | The template category | | `components` | object[] | Yes | Meta template components | | `parameterFormat` | positional \| named | No | The parameter format | | `optimizationSpec` | object | No | Max Price for MARKETING templates; see “Max Price” below | Content-Type: `application/json` Schema: ```json { "type": "object", "properties": { "wabaId": { "type": "string", "description": "string · required — The platform's WABA ID" }, "name": { "type": "string", "description": "string · required — Lowercase letters, digits and underscores" }, "language": { "type": "string", "description": "string · required — For example en_US, zh_CN" }, "category": { "type": "string", "description": "MARKETING | UTILITY | AUTHENTICATION · required — The template category" }, "components": { "type": "string", "description": "object[] · required — Meta template components" }, "parameterFormat": { "type": "string", "description": "positional | named · optional — The parameter format" }, "optimizationSpec": { "type": "string", "description": "object · optional — Max Price (MARKETING only): `{ bidAmount, bidStrategy: LOWEST_COST_WITH_BID_CAP, bidCountryMultiplierOverrides? }`. bidAmount is the maximum price per 1,000 deliveries in the smallest unit of the Messaging account currency ($0.05 per delivery = 5000). It may be below, equal to, or above the rate card; Meta charges no more than the effective bid. When editing, pass null for both bid fields to clear Max Price and return to rate-card billing." } }, "required": [ "wabaId", "name", "language", "category", "components" ] } ``` ## Response | Status | Description | | --- | --- | | `201` | Created | | `4xx` | Client error | For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md). ## Notes #### Max Price (optional) Set `optimizationSpec` only on a `MARKETING` template: ```json { "optimizationSpec": { "bidAmount": 5000, "bidStrategy": "LOWEST_COST_WITH_BID_CAP", "bidCountryMultiplierOverrides": { "IN": 1.2 } } } ``` - `bidAmount` is a positive integer: the maximum price **per 1,000 deliveries**, in the smallest unit of the Messaging account currency. For USD, `5000` means $0.05 per delivery. The platform passes this value to Meta unchanged; it does not multiply it by 1,000 or convert currency. - `bidStrategy` must be `LOWEST_COST_WITH_BID_CAP`. The bid may be below, equal to or above the rate card; the platform does not impose a rate-card-relative limit. Meta charges no more than the effective bid, but may reject an excessively low bid. - `bidCountryMultiplierOverrides` maps ISO 3166-1 alpha-2 country codes to multipliers greater than 0 and at most 10, with at most 240 entries. Unlisted countries use 1.0. Template reads return the normalized snapshot in this same map shape. - Omit `optimizationSpec` for ordinary rate-card billing. A new or changed bid can take up to one hour to take effect. Creation does a local pre-check for duplicates on name+language+wabaId, to avoid submitting the same thing to Meta twice; `components` is forwarded to Meta as-is with no secondary validation — a formatting mistake is rejected during Meta's review, not reported at creation time. The review outcome is not returned synchronously — the `status` in the creation response is only whatever initial value Meta happened to return at that moment (usually PENDING); the real APPROVED/REJECTED outcome is filled in asynchronously by the status update webhook. You need to poll `GET /v1/templates/{id}` or subscribe to the webhook to get the final state; review is usually completed within 24 hours. --- # Templates Canonical: https://docs.bluehola.com/docs/templates-flows-media/templates OpenAPI: https://docs.bluehola.com/openapi.yaml # Templates Template messages are the **only** message type available once the 24-hour customer service window has closed, so a template's review status directly determines whether it can be sent. | Endpoint | Purpose | | --- | --- | | [List Templates](get-v1-templates.md) | The template list with the latest review status. | | [Create Template](post-v1-templates.md) | Create a template and submit it for Meta review. | | [Template Details](get-v1-templates-id.md) | A single template's structure and status. | | [Edit Template](patch-v1-templates-id.md) | Change content or Max Price; content edits must be reviewed again. | | [Delete Template](delete-v1-templates-id.md) | Delete a template. | | [Sync Templates from Meta](post-v1-templates-sync.md) | Pull templates and review status from Meta, fixing any local drift. | | [Upload Template Media Header](post-v1-templates-media.md) | Upload the media asset a template's header needs. | | [Template Analytics](get-v1-templates-analytics.md) | A template's send and engagement data. | | [Enable Template Analytics](post-v1-templates-analytics-enable.md) | A one-time confirmation to turn on template analytics for a WABA. | :::info When sending, the `parameters` inside `components` must match the placeholders declared when the template was created **exactly in count and order**, or Meta returns a parameter mismatch (`TEMPLATE_PARAM_MISMATCH`). The platform verifies the template is `APPROVED` before sending. ::: ## Max Price for marketing templates Use the optional `optimizationSpec` on [Create Template](post-v1-templates.md) or [Edit Template](patch-v1-templates-id.md) to cap Meta's price per delivered marketing message. It is a **bid cap, not a campaign budget**: BlueMedia's rate-card, balance, credit-reservation and customer-budget rules remain unchanged. Send with the existing `POST /v1/messages` or broadcast endpoints. A Max Price template requires the recipient phone number in `to`; it cannot be sent to a BSUID-only recipient. A broadcast containing any effective BSUID-only recipient is rejected at creation, including `dryRun`. On `delivered` and `read` status webhooks, Max Price traffic uses `pricing.category: "marketing_lite_dynamic"` and may include `pricing.cost`. The cost is Meta's estimate in the currency's base unit; the Meta invoice is the source of truth for final charges. See [Webhook Integration](../guides/webhook-integration.md). For the related failure codes (`TEMPLATE_NOT_FOUND` needs a sync first, `TEMPLATE_PAUSED` means paused for low quality, `TEMPLATE_DISABLED` means permanently disabled and a new one must be created), see [Error Codes](../guides/error-codes.md). This group of endpoints requires the `templates:manage` scope — see [Authentication & Scopes](../guides/authentication.md). --- # Disable Endpoint (Keep History) Canonical: https://docs.bluehola.com/docs/webhooks/delete-v1-webhook-endpoints-id OpenAPI: https://docs.bluehola.com/openapi.yaml
DELETE/v1/webhook-endpoints/{id}
Disable an endpoint, keeping its history. :::note[Authentication] Send `Authorization: Bearer ` in the request headers. Which resources an API Key can reach is determined by its current authorization scope. ::: ## Request Base URL: `https://api.bluehola.com` ### Parameters | Name | In | Required | Type / constraints | Description | | --- | --- | --- | --- | --- | | `id` | path | Yes | string | The callback endpoint ID, `whe_...` | ## Response | Status | Description | | --- | --- | | `200` | OK | | `4xx` | Client error | For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md). ## Notes The semantics are disable, not a hard delete — past delivery records are retained, the endpoint's status changes but the row still exists, making it easy to audit or look back at what was delivered to that address when troubleshooting. --- # List Deliveries Canonical: https://docs.bluehola.com/docs/webhooks/get-v1-webhook-endpoints-id-deliveries OpenAPI: https://docs.bluehola.com/openapi.yaml
GET/v1/webhook-endpoints/{id}/deliveries
List an endpoint's delivery records, newest first, with cursor pagination. Event content is not included. :::note[Authentication] Send `Authorization: Bearer ` in the request headers. Which resources an API Key can reach is determined by its current authorization scope. ::: ## Request Base URL: `https://api.bluehola.com` ### Parameters | Name | In | Required | Type / constraints | Description | | --- | --- | --- | --- | --- | | `id` | path | Yes | string | The callback endpoint ID, `whe_...` | | `status` | query | No | `pending` / `queued` / `delivered` / `failed` | Return only deliveries in this status. Any other value returns `400` rather than being ignored | | `limit` | query | No | integer, 1–100 | Page size, default 50. Out of range returns `400` | | `before` | query | No | string | The `nextCursor` from the previous page | ```bash curl "https://api.bluehola.com/v1/webhook-endpoints/whe_123/deliveries?status=failed&limit=20" \ -H "Authorization: Bearer " ``` ## Response | Status | Description | | --- | --- | | `200` | OK | | `4xx` | Client error | ### 200 response schema ```json { "type": "object", "properties": { "items": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "string" }, "endpointId": { "type": "string" }, "eventId": { "type": [ "string", "null" ] }, "eventType": { "type": "string" }, "status": { "type": "string", "enum": [ "pending", "queued", "delivered", "failed" ] }, "attempts": { "type": "integer" }, "responseStatus": { "type": [ "integer", "null" ] }, "responseBodyPreview": { "type": [ "string", "null" ] }, "lastError": { "type": [ "string", "null" ] }, "nextRetryAt": { "type": [ "string", "null" ], "format": "date-time" }, "redeliveredFrom": { "type": [ "string", "null" ] }, "createdAt": { "type": "string", "format": "date-time" }, "completedAt": { "type": [ "string", "null" ], "format": "date-time" } } } }, "nextCursor": { "type": [ "string", "null" ] } } } ``` For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md). ### Response fields | Field | Meaning | | --- | --- | | `items[].id` | Delivery ID, `wd_...` | | `items[].endpointId` | The endpoint this delivery was sent to | | `items[].eventId` | The `evt_...` ID of a platform event; `null` for Meta-shaped events (`message` / `status` / `change`) | | `items[].eventType` | The event type, the same value as `X-Webhook-Event` | | `items[].status` | `pending` / `queued`: not finished yet, including deliveries waiting for their next retry. `delivered`: your endpoint returned `2xx`. `failed`: a final failure — a non-retryable `4xx`, or all 8 attempts used up | | `items[].attempts` | Attempts made so far | | `items[].responseStatus` | The HTTP status your endpoint returned on the last attempt; `null` if no response was received | | `items[].responseBodyPreview` | A truncated excerpt of your endpoint's response body | | `items[].lastError` | The latest error, such as a timeout or connection failure | | `items[].nextRetryAt` | When the next automatic retry is scheduled; `null` when none is | | `items[].redeliveredFrom` | For a [manual redelivery](post-v1-webhook-endpoints-id-deliveries-deliveryid-redeliver.md), the ID of the original delivery; otherwise `null` | | `items[].createdAt` / `completedAt` | When the delivery was created and when it finished (`null` while unfinished) | | `nextCursor` | Pass it as `before` for the next page; `null` means there are no more | ## Notes The list does **not** include the event payload. To get an event's content back, [redeliver](post-v1-webhook-endpoints-id-deliveries-deliveryid-redeliver.md) that delivery. This is the place to look when [List Endpoints](get-v1-webhook-endpoints.md) shows a failed `lastDelivery`: filter with `status=failed` to find the events your endpoint missed. A customer Key can only read the deliveries of endpoints that belong to its customer entity. --- # Get Endpoint Canonical: https://docs.bluehola.com/docs/webhooks/get-v1-webhook-endpoints-id OpenAPI: https://docs.bluehola.com/openapi.yaml
GET/v1/webhook-endpoints/{id}
Get a single endpoint. :::note[Authentication] Send `Authorization: Bearer ` in the request headers. Which resources an API Key can reach is determined by its current authorization scope. ::: ## Request Base URL: `https://api.bluehola.com` ### Parameters | Name | In | Required | Type / constraints | Description | | --- | --- | --- | --- | --- | | `id` | path | Yes | string | The callback endpoint ID, `whe_...` | ## Response | Status | Description | | --- | --- | | `200` | OK | | `4xx` | Client error | For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md). ## Notes Also does not return the secret; access from another account returns 404 rather than 403, to avoid revealing whether the resource exists. --- # List Endpoints Canonical: https://docs.bluehola.com/docs/webhooks/get-v1-webhook-endpoints OpenAPI: https://docs.bluehola.com/openapi.yaml
GET/v1/webhook-endpoints
List endpoints; secrets are not returned. Each endpoint carries `lastDelivery` (that endpoint's most recent delivery status / responseStatus / attempts / lastError / createdAt), or `null` if nothing has ever been delivered. Delivered/failed counts are deliberately not provided: that would be a COUNT aggregate that slows down linearly with message volume. :::note[Authentication] Send `Authorization: Bearer ` in the request headers. Which resources an API Key can reach is determined by its current authorization scope. ::: ## Request Base URL: `https://api.bluehola.com` ### Parameters | Name | In | Required | Type / constraints | Description | | --- | --- | --- | --- | --- | | `customerId` | query | Required for customer Keys | string | Return only endpoints bound to this customer entity (`cust_...`). A customer Key must pass its own customer entity, otherwise `403` | | `projectId` | query | No | string | Return only endpoints bound to this single Business Portfolio (`bm_...`) | ## Response | Status | Description | | --- | --- | | `200` | OK | | `4xx` | Client error | For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md). ## Notes Each endpoint's lastDelivery is obtained with a single LEFT JOIN LATERAL query rather than a per-endpoint query or a DISTINCT ON, relying on a migration-added (endpoint_id, created_at DESC) index to keep the cost constant. Each filter matches the binding exactly: `customerId` does not return endpoints bound to a single Portfolio or account-level endpoints, and `projectId` does not return customer-bound or account-level endpoints. Without either filter, every endpoint under this account is returned. --- # Patch Endpoint Canonical: https://docs.bluehola.com/docs/webhooks/patch-v1-webhook-endpoints-id OpenAPI: https://docs.bluehola.com/openapi.yaml
PATCH/v1/webhook-endpoints/{id}
Partially update an endpoint (url / events / metadata). :::note[Authentication] Send `Authorization: Bearer ` in the request headers. Which resources an API Key can reach is determined by its current authorization scope. ::: ## Request Base URL: `https://api.bluehola.com` ### Parameters | Name | In | Required | Type / constraints | Description | | --- | --- | --- | --- | --- | | `id` | path | Yes | string | The callback endpoint ID, `whe_...` | ### Request body A request body is required. ### Request body fields | Field | Type | Required | Description | | --- | --- | --- | --- | | `url` | string | No | The new callback address. **Goes through the same SSRF checks** — if that check only ran at creation time, a single url change would bypass the whole protection | | `events` | string[] | No | Replaces the subscription list (a full replacement, not an append). Same values as at creation: `message`, `status`, `change`, `probe`, `job.completed`, `job.failed`, `usage.updated`, `webhook.verification`, `contact.identity_changed`, `contact.info_shared`, `marketing.preference_updated`, `phone_number.username_updated`, `*` | | `metadata` | object | No | Caller-defined data | Content-Type: `application/json` Schema: ```json { "type": "object", "properties": { "url": { "type": "string", "description": "string · optional — the new callback address. **Goes through the same SSRF checks** — if that check only ran at creation time, a single url change would bypass the whole protection" }, "events": { "type": "string", "description": "string[] · optional — replaces the subscription list (a full replacement, not an append)" }, "metadata": { "type": "string", "description": "object · optional — caller-defined data" } } } ``` ## Response | Status | Description | | --- | --- | | `200` | OK | | `4xx` | Client error | For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md). ## Notes An empty body returns 400 rather than a silent 200: an empty patch usually means a field name was misspelled, and a silent success would leave the caller believing the change took effect. The secret is not returned. --- # Redeliver a Delivery Canonical: https://docs.bluehola.com/docs/webhooks/post-v1-webhook-endpoints-id-deliveries-deliveryid-redeliver OpenAPI: https://docs.bluehola.com/openapi.yaml
POST/v1/webhook-endpoints/{id}/deliveries/{deliveryId}/redeliver
Send a finished (`delivered` or `failed`) delivery again. A new delivery record is created and returned; the original is kept. :::note[Authentication] Send `Authorization: Bearer ` in the request headers. Which resources an API Key can reach is determined by its current authorization scope. ::: ## Request Base URL: `https://api.bluehola.com` ### Parameters | Name | In | Required | Type / constraints | Description | | --- | --- | --- | --- | --- | | `id` | path | Yes | string | The callback endpoint ID, `whe_...` | | `deliveryId` | path | Yes | string | The delivery to resend, `wd_...`, from [List Deliveries](get-v1-webhook-endpoints-id-deliveries.md) | No request body. ## Response | Status | Description | | --- | --- | | `202` | Accepted — the new delivery is queued | | `4xx` | Client error | ### 202 response schema The new delivery record, in the same shape as an item of [List Deliveries](get-v1-webhook-endpoints-id-deliveries.md); its `redeliveredFrom` is the original delivery's ID. ```json { "type": "object", "properties": { "id": { "type": "string" }, "endpointId": { "type": "string" }, "eventId": { "type": [ "string", "null" ] }, "eventType": { "type": "string" }, "status": { "type": "string", "enum": [ "pending", "queued", "delivered", "failed" ] }, "attempts": { "type": "integer" }, "responseStatus": { "type": [ "integer", "null" ] }, "responseBodyPreview": { "type": [ "string", "null" ] }, "lastError": { "type": [ "string", "null" ] }, "nextRetryAt": { "type": [ "string", "null" ], "format": "date-time" }, "redeliveredFrom": { "type": [ "string", "null" ] }, "createdAt": { "type": "string", "format": "date-time" }, "completedAt": { "type": [ "string", "null" ], "format": "date-time" } } } ``` For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md). ### Errors | Status | `details.reason` | Meaning | | --- | --- | --- | | `409` | `delivery_in_progress` | The original delivery has not finished (`pending` / `queued`); it keeps retrying on its own | | `409` | `endpoint_not_active` | The endpoint is not `active`; [re-enable](post-v1-webhook-endpoints-id-enable.md) or [verify](post-v1-webhook-endpoints-id-verify.md) it first | | `409` | `redelivery_in_progress` | A redelivery of the same event is already in progress | | `404` | — | The delivery does not belong to the endpoint in the path | ## Notes Use it to recover events your endpoint missed during an outage — automatic retries give up after about 38.6 hours (see [Webhook Integration](../guides/webhook-integration.md)). `202` only means the redelivery is queued; check the result in [List Deliveries](get-v1-webhook-endpoints-id-deliveries.md). - The redelivery is sent to the endpoint's **current** URL and signed with its **current** secret, so it verifies even after a secret rotation. - **De-duplication:** under the connection protocol, the redelivery carries the **same `Webhook-Id`** as the original, so your receiver can de-duplicate it. Under the default scheme `X-Delivery-Id` is the new delivery's ID, so de-duplicate on the event content instead (for example the message `id` / `wamid`) if you redeliver an event your endpoint may already have processed. - The original delivery record is never modified. --- # Re-enable Disabled Endpoint Canonical: https://docs.bluehola.com/docs/webhooks/post-v1-webhook-endpoints-id-enable OpenAPI: https://docs.bluehola.com/openapi.yaml
POST/v1/webhook-endpoints/{id}/enable
Re-enable an endpoint that was disabled (DELETE). :::note[Authentication] Send `Authorization: Bearer ` in the request headers. Which resources an API Key can reach is determined by its current authorization scope. ::: ## Request Base URL: `https://api.bluehola.com` ### Parameters | Name | In | Required | Type / constraints | Description | | --- | --- | --- | --- | --- | | `id` | path | Yes | string | The callback endpoint ID, `whe_...` | ## Response | Status | Description | | --- | --- | | `201` | Created | | `4xx` | Client error | For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md). ## Notes #### Why this endpoint needs to exist `DELETE {id}` is a **soft disable**, while `PATCH {id}` only accepts url / events / metadata — before this endpoint existed, disabling was a **one-way door**: delivery stopped permanently, and the only way out was to delete and recreate, at the cost of a new endpoint id, lost delivery history, and the integration having to update its configuration. Meanwhile the rotate-secret documentation itself recommends "disable, then rotate" — anyone who follows that advice would otherwise turn their own endpoint into a brick. #### Which state it returns to is decided by the platform, not the caller An endpoint that was already verified (`verifiedAt` is non-null) returns to `active` — it has already proven it controls that address, and disabling it does not undo that. **An unverified endpoint on the connection protocol returns to `pending`** and must go through ownership verification again: otherwise "create an endpoint pointing at someone else's server → disable → enable" would be a three-call way around verification, turning an anti-abuse mechanism into decoration. An endpoint created the old way (predating the verification flow, active from creation) returns to `active`, because it has no verification flow to go through — giving it `pending` would mean it can never deliver again. Calling this on an endpoint that is already active or pending is **idempotent**: it returns to whatever state it should be in and clears `disabledAt`. The secret is not returned. --- # Rotate Signing Secret Canonical: https://docs.bluehola.com/docs/webhooks/post-v1-webhook-endpoints-id-rotate-secret OpenAPI: https://docs.bluehola.com/openapi.yaml
POST/v1/webhook-endpoints/{id}/rotate-secret
Rotate the signing secret, returning a one-time new plaintext value. :::note[Authentication] Send `Authorization: Bearer ` in the request headers. Which resources an API Key can reach is determined by its current authorization scope. ::: ## Request Base URL: `https://api.bluehola.com` ### Parameters | Name | In | Required | Type / constraints | Description | | --- | --- | --- | --- | --- | | `id` | path | Yes | string | The callback endpoint ID, `whe_...` | ## Response | Status | Description | | --- | --- | | `201` | Created | | `4xx` | Client error | For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md). ## Notes **Takes effect immediately, with no overlap period**: the very next delivery is signed with the new secret. Deliveries that arrive at the receiver before the new secret has been saved will fail signature verification, and a failed verification typically shows up as a 4xx — which, under the delivery policy, is **a permanent failure that is not retried**. So rotate during a quiet period, or follow the order "disable → rotate → save → re-enable/verify" (the way back is `POST {id}/enable`). The plaintext appears only in this response, the same rule as at creation. --- # Send Test Event Canonical: https://docs.bluehola.com/docs/webhooks/post-v1-webhook-endpoints-id-test OpenAPI: https://docs.bluehola.com/openapi.yaml
POST/v1/webhook-endpoints/{id}/test
Send a test event (the same mechanism as verify). :::note[Authentication] Send `Authorization: Bearer ` in the request headers. Which resources an API Key can reach is determined by its current authorization scope. ::: ## Request Base URL: `https://api.bluehola.com` ### Parameters | Name | In | Required | Type / constraints | Description | | --- | --- | --- | --- | --- | | `id` | path | Yes | string | The callback endpoint ID, `whe_...` | ## Response | Status | Description | | --- | --- | | `201` | Created | | `4xx` | Client error | For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md). ## Notes This deliberately reuses the `webhook.verification` challenge rather than inventing a separate "test event": what a test really needs to answer is "can this address receive, and can it verify signatures", and the challenge already answers exactly that. Building a separate path would risk the hardest kind of state to debug — a test that passes while real deliveries fail (or the reverse). So this endpoint behaves the same as `/verify`, including advancing the endpoint's state. --- # Trigger Ownership Verification Canonical: https://docs.bluehola.com/docs/webhooks/post-v1-webhook-endpoints-id-verify OpenAPI: https://docs.bluehola.com/openapi.yaml
POST/v1/webhook-endpoints/{id}/verify
Trigger ownership verification (the second stage of the two-stage protocol). :::note[Authentication] Send `Authorization: Bearer ` in the request headers. Which resources an API Key can reach is determined by its current authorization scope. ::: ## Request Base URL: `https://api.bluehola.com` ### Parameters | Name | In | Required | Type / constraints | Description | | --- | --- | --- | --- | --- | | `id` | path | Yes | string | The callback endpoint ID, `whe_...` | ## Response | Status | Description | | --- | --- | | `201` | Created | | `4xx` | Client error | For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md). ## Notes #### Why two stages The secret is only returned in the creation response, and the caller can only save it after receiving that response. If the platform sent the verification challenge immediately at creation time, the receiving end would not yet have a secret to verify against, the challenge would inevitably fail, and the endpoint would be stuck at `pending` forever. So the order is fixed: create (get the secret) → save it yourself → call this endpoint. #### The shape of the challenge The platform **synchronously** POSTs a `webhook.verification` event to the endpoint, with `data.challenge` holding a one-time random value, **signed exactly the way a normal delivery is** — which is the whole point of the verification: if this one verifies, every subsequent real event will too. The receiver must return a 2xx and echo the same `challenge` back in the response JSON (either at the top level or as `data.challenge`). #### Outcome Success → the status becomes `active` and delivery starts. Failure → it **stays `pending`** (it does not become disabled), with the reason recorded in `metadata.last_verification_error`; once the receiving end is fixed, call it again. If the receiving end's failure response carries a well-formed `CF-Ray`, the failure reason includes that value, so the receiver's administrators can locate the block record. The challenge times out after 5s, and only the first 4 KB of the response body is read. --- # Create Account Callback Endpoint Canonical: https://docs.bluehola.com/docs/webhooks/post-v1-webhook-endpoints OpenAPI: https://docs.bluehola.com/openapi.yaml
POST/v1/webhook-endpoints
Create an account callback endpoint. Callbacks carry X-Webhook-Signature-256: sha256=...; computed as an HMAC-SHA256 of the raw request body using the endpoint secret, which is returned only once. :::note[Authentication] Send `Authorization: Bearer ` in the request headers. Which resources an API Key can reach is determined by its current authorization scope. ::: ## Request Base URL: `https://api.bluehola.com` ### Request body A request body is required. ### Request body fields | Field | Type | Required | Description | | --- | --- | --- | --- | | `url` | URL | Yes | The HTTPS address that receives callbacks. Must be https in production, and must not point at a private network, loopback, or cloud metadata address; a failure returns `400 VALIDATION_FAILED` | | `events` | string[] | No | Events to subscribe to. Each entry is one of: `message`, `status`, `change`, `probe`, `job.completed`, `job.failed`, `usage.updated`, `webhook.verification`, `contact.identity_changed`, `contact.info_shared`, `marketing.preference_updated`, `phone_number.username_updated`, `*`. Anything else returns `400`; prefix wildcards such as `job.*` are not supported | | `secret` | string | No | The signing secret. If you supply your own it must be **at least 16 characters**; if omitted the platform generates one prefixed `whsec_` | | `customerId` | string | Required for customer Keys | Receive events for **every Business Portfolio the customer entity (`cust_...`) currently owns**, resolved per event rather than snapshotted, so Portfolios added or moved later need no reconfiguration. The customer entity must belong to this account and have `status: active`, otherwise `400`. A customer Key must pass its own customer entity (otherwise `403`). Mutually exclusive with `projectId` | | `projectId` | string | No | Receive events only for that single Business Portfolio (`bm_...`). Mutually exclusive with `customerId`; passing both returns `400`. **Customer Keys cannot use it** — use `customerId` | | `connectionId` | string | No | Use the **connection protocol**: switches to the `Webhook-Signature: v1,` scheme, and the endpoint starts out `pending`, delivering nothing until `POST {id}/verify` passes. Equivalent to setting `metadata.connection_id` | | `metadata` | object | No | Arbitrary JSON, stored verbatim and returned when reading the endpoint | Content-Type: `application/json` Schema: ```json { "type": "object", "properties": { "url": { "type": "string", "description": "URL · required — the HTTPS address that receives callbacks" }, "events": { "type": "array", "items": { "type": "string", "enum": [ "message", "status", "change", "probe", "job.completed", "job.failed", "usage.updated", "webhook.verification", "contact.identity_changed", "contact.info_shared", "marketing.preference_updated", "phone_number.username_updated", "*" ] }, "description": "optional — events to subscribe to; saved as [\"*\"] if omitted" }, "secret": { "type": "string", "minLength": 16, "description": "string · optional — at least 16 characters; generated by the platform if omitted" }, "customerId": { "type": "string", "description": "string · optional — receive events for every Business Portfolio the customer entity (cust_...) currently owns; mutually exclusive with projectId" }, "projectId": { "type": "string", "description": "string · optional — receive events only for that single Business Portfolio (bm_...); mutually exclusive with customerId" }, "connectionId": { "type": "string", "description": "string · optional — use the connection protocol: new signature scheme + starts pending + requires verification" }, "metadata": { "type": "object", "additionalProperties": true, "description": "object · optional — arbitrary JSON, stored verbatim" } }, "required": [ "url" ], "additionalProperties": false } ``` ## Response | Status | Description | | --- | --- | | `201` | Created | | `4xx` | Client error | For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md). ## Notes #### Binding levels | Binding | Receives | | --- | --- | | `customerId` (recommended) | Events for every Business Portfolio the customer entity currently owns. Ownership is resolved for each event, so a Portfolio the customer adds later is covered from that moment. | | `projectId` | Events for that one Business Portfolio only. | | Neither (account-level) | Every event under this account. If the account serves several customers, this means one customer's message content goes to the same URL as another's — make sure that is intended before giving the URL to an external receiver. | `customerId` and `projectId` are mutually exclusive; passing both returns `400` instead of silently picking one. When an event's ownership cannot be resolved (for example the phone number or WABA has not finished onboarding), it is **not** delivered to endpoints that have a binding — a missed delivery can be found in the delivery records, a delivery to the wrong party cannot be recalled. While a customer entity's `status` is not `active`, endpoints bound to it receive no events. Reading an endpoint returns its binding as `customerEntityId` / `portfolioId` (`null` when not set). If the secret is omitted the platform generates one automatically; the generated value is returned only in this one creation response, and the server afterwards stores only its hash, so it can never be retrieved in plaintext again — a lost secret can only be replaced by recreating the endpoint (or by calling `POST {id}/rotate-secret` for a new one). Omitting `events` is saved as `["*"]`, meaning **subscribed to everything, including types added in future** — not "subscribed to nothing", and not only the four Meta inbound event kinds either. Platform events (`job.completed` / `job.failed` / `usage.updated` / `webhook.verification`) and the normalized events below are delivered too, so an endpoint subscribed to `*` must tolerate event types it does not recognize. #### Normalized events Besides the Meta-shaped `message` / `status` / `change`, the platform publishes an **additional** normalized event for a few kinds of Meta notification. They use the platform event envelope (`id` / `type` / `api_version` / `created_at` / `account_id` / `project_id` / `data`), with snake_case fields; a field Meta did not provide is `null`, never inferred. The original event is still forwarded as before — both carry the same content in different shapes: - `contact.identity_changed`: a user's BSUID changed (`user_id_update`, with `data.user_id = { previous, current }` and `conversations_remapped`, the number of conversations moved within this account), or an identity-change system message (where `user_id.previous` is `null`, because Meta gives no structured previous value); - `contact.info_shared`: a user shared contact details (a `contacts` message); `contacts[].origin` is `contact_request` (they tapped a request button and shared their own details), `other` (they sent a contact card directly) or `null` (Meta did not say); - `marketing.preference_updated`: a user stopped or resumed marketing messages in WhatsApp (`value` is `stop` / `resume`); `wa_id` may be empty with only `user_id` (BSUID) present; `applies_to_meta_phone_number_id` is the sending number this preference applies to; - `phone_number.username_updated`: a business username status change; `applied: false` means this was a late, older event and the platform did not use it to overwrite a newer value. See [Webhook Integration](../guides/webhook-integration.md) for the payload fields. #### Whether delivery starts immediately depends on connectionId Without `connectionId` (and without `metadata.connection_id`), the endpoint is `active` straight away and **delivery starts as soon as it is created**. With it, the endpoint starts out `pending` and only becomes `active` once `POST /v1/webhook-endpoints/{id}/verify` completes ownership verification; no event is received before that. The request body is strict: any field outside the table above returns `400 VALIDATION_FAILED` rather than being silently ignored. For the full signature verification, event types and retry schedule, see [Webhook Integration](../guides/webhook-integration.md).