# Create a Webhook

Creates a webhook in `ACTIVE` state, so it starts receiving notifications immediately. Send the destination `url`, a `name` that is unique within the account, and at least one [trigger](/reference/webhooks#triggers). The response includes the `id` you use to [retrieve](/reference/webhooks/retrieve-webhook), [update](/reference/webhooks/update-webhook) and [delete](/reference/webhooks/delete-webhook) it.

To secure how WHITELABEL calls your endpoint, add the fields of any [delivery authentication](/reference/webhooks#delivery-authentication) method to the same body. They are optional and you can combine them. The secrets you configure come back masked, and the rest come back as `null`.

<Note>
To set `oauth2_scope`, use [Update a Webhook](/reference/webhooks/update-webhook).
</Note>

An account can have several webhooks pointing at the same `url`, as long as they listen to different events. A webhook is rejected with `409 WEBHOOK_ALREADY_EXISTS` when the account already has one with the same `name`, or one with the same `url` that listens to one of the same events.

**POST** `/webhooks`

Base URL: `https://api-sandbox.whitelabel.com/v1`

Creates a webhook in active state, subscribed to the events you select. It requires at least one trigger, and starts receiving notifications immediately.

## Authorization

- public-api-key (apiKey in header)
- private-secret-key (apiKey in header)

## Body

Content type: `application/json`

- `account_id` (string<uuid>, required)
  The unique identifier of the account the webhook belongs to.
- `name` (string, required)
  Your name for the webhook. It must be unique within the account.
- `url` (string, required)
  The endpoint WHITELABEL sends the notifications to. It must be an `http` or `https` URL that resolves to a public, routable address.
- `api_key` (string)
  Sent to your endpoint as the `x-api-key` header on every delivery.
- `secret` (string)
  Sent to your endpoint as the `x-secret` header on every delivery.
- `hmac_client_secret` (string)
  The key WHITELABEL signs the payload with. The signature travels in the `x-hmac-signature` header.
- `oauth2_authentication_url` (string)
  Your token endpoint. It must use HTTPS. Send `oauth2_authentication_url`, `oauth2_client_id`, `oauth2_client_secret` and `oauth2_grant_type` together.
- `oauth2_client_id` (string)
  The client identifier WHITELABEL authenticates with. Send `oauth2_authentication_url`, `oauth2_client_id`, `oauth2_client_secret` and `oauth2_grant_type` together.
- `oauth2_client_secret` (string)
  The client secret WHITELABEL authenticates with. Send `oauth2_authentication_url`, `oauth2_client_id`, `oauth2_client_secret` and `oauth2_grant_type` together.
- `oauth2_grant_type` (string)
  The grant type WHITELABEL requests the token with. Send `oauth2_authentication_url`, `oauth2_client_id`, `oauth2_client_secret` and `oauth2_grant_type` together.
- `oauth2_authorization_name` (string)
  The header WHITELABEL sends the token in. Defaults to `Authorization`.
- `oauth2_include_client_id` (boolean)
  Send the client identifier as a header on the token request as well.
- `enrollment_triggers` ("ENROLL" | "UNENROLL"[])
  The enrollment events the webhook subscribes to.
- `payment_triggers` ("AUTHORIZE" | "CANCEL" | "CAPTURE" | "CHARGEBACK" | "PRECHARGEBACK" | "PURCHASE" | "REFUND" | "VERIFY"[])
  The payment events the webhook subscribes to.
- `report_triggers` ("CREATE" | "UPDATE"[])
  The report events the webhook subscribes to.
- `subscription_triggers` ("ACTIVE" | "CANCEL" | "CLOSE_TO_RENEWAL" | "COMPLETE" | "CREATE" | "PAUSE" | "PLAN_CHANGE_CANCELED" | "PLAN_CHANGE_SCHEDULED" | "PLAN_CHANGED" | "RESUME"[])
  The subscription events the webhook subscribes to.
- `onboarding_triggers` ("BLOCKED" | "CANCELLED" | "CREATED" | "DECLINED" | "ERROR" | "EXPIRED" | "INACTIVE" | "PENDING" | "SUCCEEDED" | "TRANSFERRED" | "UNBLOCKED"[])
  The onboarding events the webhook subscribes to.
- `renewal_days` (integer)
  How many days before a renewal WHITELABEL sends the `CLOSE_TO_RENEWAL` notification. It must be 1 or more, and it is valid only when `subscription_triggers` contains `CLOSE_TO_RENEWAL`.

Example:

```json
{
  "account_id": "493e9374-510a-4201-9e09-de669d75f256",
  "name": "Production payments listener",
  "url": "https://api.acme.com/whitelabel/webhooks",
  "api_key": "my-webhook-key",
  "secret": "my-webhook-secret",
  "hmac_client_secret": "my-hmac-secret",
  "oauth2_authentication_url": "https://api.acme.com/oauth/token",
  "oauth2_client_id": "acme_client_id",
  "oauth2_client_secret": "acme_client_secret",
  "oauth2_grant_type": "client_credentials",
  "oauth2_authorization_name": "Authorization",
  "oauth2_include_client_id": false,
  "enrollment_triggers": [
    "ENROLL",
    "UNENROLL"
  ],
  "payment_triggers": [
    "AUTHORIZE",
    "CAPTURE",
    "REFUND"
  ],
  "report_triggers": [
    "UPDATE"
  ],
  "subscription_triggers": [
    "CREATE",
    "CLOSE_TO_RENEWAL"
  ],
  "onboarding_triggers": [
    "CREATED",
    "SUCCEEDED"
  ],
  "renewal_days": 5
}
```

## Responses

### 201

The webhook you created. The secrets you configured come back masked, and the ones you left out come back as null.

- `id` (string)
  The unique identifier of the webhook.
- `account_id` (string<uuid>)
  The unique identifier of the account the webhook belongs to.
- `name` (string)
  Your name for the webhook.
- `state` ("ACTIVE" | "INACTIVE")
  `ACTIVE` webhooks receive notifications, `INACTIVE` ones do not. A webhook starts out `ACTIVE`.
- `url` (string)
  The endpoint WHITELABEL sends the notifications to.
- `api_key` (string,null)
  Masked as `***`, or `null` when you have not configured it.
- `secret` (string,null)
  Masked as `***`, or `null` when you have not configured it.
- `hmac_client_secret` (string,null)
  Masked as `***`, or `null` when you have not configured it.
- `oauth2_authentication_url` (string,null)
  Your token endpoint.
- `oauth2_client_secret` (string,null)
  Masked as `***`, or `null` when you have not configured it.
- `oauth2_client_id` (string,null)
  The client identifier WHITELABEL authenticates with.
- `oauth2_grant_type` (string,null)
  The grant type WHITELABEL requests the token with.
- `oauth2_scope` (string,null)
  The scope WHITELABEL requests the token with.
- `oauth2_authorization_name` (string,null)
  The header WHITELABEL sends the token in.
- `oauth2_include_client_id` (boolean)
  Whether WHITELABEL also sends the client identifier as a header on the token request.
- `enrollment_triggers` (array,null)
  The enrollment events the webhook subscribes to.
- `payment_triggers` (array,null)
  The payment events the webhook subscribes to.
- `report_triggers` (array,null)
  The report events the webhook subscribes to.
- `subscription_triggers` (array,null)
  The subscription events the webhook subscribes to.
- `onboarding_triggers` (array,null)
  The onboarding events the webhook subscribes to.
- `renewal_days` (integer,null)
  How many days before a renewal WHITELABEL sends the `CLOSE_TO_RENEWAL` notification.
- `created_at` (string<date-time>)
  The date and time the webhook was created, in ISO 8601.
- `updated_at` (string<date-time>)
  The date and time the webhook was last updated, in ISO 8601. It matches `created_at` until you update the webhook for the first time.

Example:

```json
{
  "id": "12345",
  "account_id": "493e9374-510a-4201-9e09-de669d75f256",
  "name": "Production payments listener",
  "state": "ACTIVE",
  "url": "https://api.acme.com/whitelabel/webhooks",
  "api_key": "***",
  "secret": "***",
  "hmac_client_secret": "***",
  "oauth2_authentication_url": "https://api.acme.com/oauth/token",
  "oauth2_client_secret": "***",
  "oauth2_client_id": "acme_client_id",
  "oauth2_grant_type": "client_credentials",
  "oauth2_scope": "webhooks:write",
  "oauth2_authorization_name": "Authorization",
  "oauth2_include_client_id": true,
  "enrollment_triggers": [
    "ENROLL",
    "UNENROLL"
  ],
  "payment_triggers": [
    "AUTHORIZE",
    "CAPTURE",
    "REFUND"
  ],
  "report_triggers": [
    "UPDATE"
  ],
  "subscription_triggers": [
    "CREATE",
    "CLOSE_TO_RENEWAL"
  ],
  "onboarding_triggers": [
    "CREATED",
    "SUCCEEDED"
  ],
  "renewal_days": 5,
  "created_at": "2026-07-09T13:05:36.482913Z",
  "updated_at": "2026-07-11T16:20:44.918330Z"
}
```

### 400

The request is invalid. The `code` tells you which rule it broke.

- `code` ("WEBHOOK_INVALID_REQUEST" | "INVALID_ACCOUNT_ID" | "WEBHOOK_INVALID_TRIGGER" | "WEBHOOK_INVALID_OAUTH2" | "WEBHOOK_INVALID_RENEWAL_DAYS" | "WEBHOOK_URL_UNSAFE")
  Machine-readable error code.
- `messages` (string[])
  Human-readable description of the error.

Example:

```json
{
  "code": "WEBHOOK_INVALID_REQUEST",
  "messages": [
    "string"
  ]
}
```

### 401

Your API credentials are missing or invalid.

- `code` ("NOT_AUTHENTICATED" | "INVALID_CREDENTIALS")
  Machine-readable error code.
- `messages` (string[])
  Human-readable description of the error.

Example:

```json
{
  "code": "NOT_AUTHENTICATED",
  "messages": [
    "string"
  ]
}
```

### 409

The account already has a webhook with that name, or one with the same URL that listens to one of the same events.

- `code` ("WEBHOOK_ALREADY_EXISTS")
  Machine-readable error code.
- `messages` (string[])
  Human-readable description of the error.

Example:

```json
{
  "code": "WEBHOOK_ALREADY_EXISTS",
  "messages": [
    "string"
  ]
}
```

### 502

The webhook service is temporarily unavailable.

- `code` ("WEBHOOK_UPSTREAM_ERROR")
  Machine-readable error code.
- `messages` (string[])
  Human-readable description of the error.

Example:

```json
{
  "code": "WEBHOOK_UPSTREAM_ERROR",
  "messages": [
    "string"
  ]
}
```