# 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

<div class="endpoint"><span class="endpoint-method endpoint-method--post">POST</span><code class="endpoint-path">/v1/onboarding/invitations/{token}/complete</code></div>

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

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

## 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.
