Skip to main content

Complete Onboarding

POST/v1/onboarding/embedded-signup

Complete onboarding, returning 201 and a trackable operation record.

Authentication

Send Authorization: Bearer <API_KEY> 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​

FieldTypeRequiredDescription
portfolioIdstringNoThe platform's Business Portfolio ID, bm_... Use exactly one of this and customerEntityId
customerEntityIdstringNoCustomer 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
codestringYesA one-time Meta OAuth authorization code
wabaIdstringYesThe WABA ID returned by Meta
phoneNumberIdstringNoThe Phone Number ID returned by Meta. May be absent: as of ES v3, a customer can finish without a number and add one later
esVersionv2 | v3 | v4NoVersion used by the authorization page, for diagnostics. New sessions use v4.
sessionInfoobjectNoThe 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:

{
"customerEntityId": "cust_x",
"code": "<META_OAUTH_CODE>",
"wabaId": "<META_WABA_ID>",
"phoneNumberId": "<META_PHONE_NUMBER_ID>"
}

Schema:

{
"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": "<META_OAUTH_CODE>",
"wabaId": "<META_WABA_ID>",
"phoneNumberId": "<META_PHONE_NUMBER_ID>"
}
}

Response​

StatusDescription
201Created
4xxClient error

For the common error envelope and how to handle it, see Error Codes.

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.