# Create Account Callback Endpoint

Canonical: https://docs.bluehola.com/docs/webhooks/post-v1-webhook-endpoints
OpenAPI: https://docs.bluehola.com/openapi.yaml

<div class="endpoint"><span class="endpoint-method endpoint-method--post">POST</span><code class="endpoint-path">/v1/webhook-endpoints</code></div>

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 <API_KEY>` 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,<hex>` 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).
