# Generate a Customer Onboarding Link

Canonical: https://docs.bluehola.com/docs/onboarding/post-v1-onboarding-invitations
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</code></div>

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

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