> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.withpersona.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.withpersona.com/_mcp/server.

# Create a Webhook

POST https://api.withpersona.com/api/v1/webhooks
Content-Type: application/json

Creates a new webhook with response defaults.

Reference: https://docs.withpersona.com/api-reference/webhooks/create-a-webhook

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, where token is your auth token.

## Request

### Query parameters

- `include` (string, optional) — A comma-separated list of relationship paths. This can be used to customize which related resources will be fully serialized in the `included` key in the response. See [Serialization](https://docs.withpersona.com/serialization#inclusion-of-related-resources) for more details.
- `fields` (map from string to string, optional) — Comma-separated list(s) of attributes to include in the response. This can be used to customize which attributes will be serialized in the response. See [Serialization](https://docs.withpersona.com/serialization#sparse-fieldsets) for more details.

### Headers

- `Key-Inflection` (enum, optional) — Determines casing for the API response.
  - Allowed values: `camel`, `kebab`, `snake`
- `Idempotency-Key` (string, optional) — Ensures the request is idempotent.
- `Persona-Version` (enum, optional) — Server API version. More info on versioning can be found [here](https://docs.withpersona.com/versioning).
  - Allowed values: `2025-12-08`, `2025-10-27`, `2023-01-05`, `2022-09-01`, `2021-08-18`, `2021-07-05`, `2021-02-21`, `2020-05-18`

### Body (application/json)

This endpoint expects an object.

- `data` (WebhooksPostRequestBodyContentApplicationJsonSchemaData, required)

## Response

### 201

This endpoint returns a Webhook object.

- `data` (webhook-with-secret, required) — A Webhook object
- `included` (list of any, optional) — Excluded from the response by default. Will be an empty array when the `include` query parameter in the request was explicitly set to empty.

## Errors

### 400 Bad Request Error

The request was unacceptable, often due to invalid parameters.

- `errors` (list of WebhooksPostResponsesContentApplicationJsonSchemaErrorsItems, optional)

### 401 Unauthorized Error

An invalid API key was provided.

- `errors` (list of WebhooksPostResponsesContentApplicationJsonSchemaErrorsItems, optional)

### 403 Forbidden Error

The given API key doesn’t have permissions to perform the request or a quota has been exceeded.

- `errors` (list of WebhooksPostResponsesContentApplicationJsonSchemaErrorsItems, optional)

### 409 Conflict Error

The request conflicts with another request, often due to attempting to create a duplicate resource.

- `errors` (list of WebhooksPostResponsesContentApplicationJsonSchemaErrorsItems, optional)

### 422 Unprocessable Entity Error

The request modifies the resource in an unacceptable way, often due to an invalid action or parameter.

- `errors` (list of WebhooksPostResponsesContentApplicationJsonSchemaErrorsItems, optional)

### 429 Too Many Requests Error

Your organization’s rate limit has been exceeded. We recommend an exponential backoff on requests.

- `errors` (list of WebhooksPostResponsesContentApplicationJsonSchemaErrorsItems, optional)

## Types

### WebhooksPostRequestBodyContentApplicationJsonSchemaData

- `attributes` (webhook-request-attributes, required)

### webhook-with-secret

A Webhook object

- `type` ("webhook", optional)
- `id` (string, optional)
- `attributes` (WebhookWithSecretAttributes, optional)

### WebhooksPostResponsesContentApplicationJsonSchemaErrorsItems

- `title` (string, optional)
- `details` (string, optional)

### webhook-request-attributes

- `name` (string, optional, nullable) — A name for remembering webhook
- `description` (string, optional, nullable) — An optional description for this webhook
- `url` (string, optional) — URL to which webhook events are forwarded.
- `enabled-events` (list of WebhookRequestAttributesEnabledEventsItems, optional) — Supported events that you want to receive webhooks for. Set `*` to enable all events. Descriptions of all events can be found [here](https://docs.withpersona.com/events). Retrieve Events for your organization using the [Events API](https://docs.withpersona.com/api-reference/events/list-all-events). Custom events you emit yourself may also be subscribed to by name.
- `api-version` (enum, optional) — API version that will be used for incoming webhook requests. Defaults to the API version used when making this request.
  - Allowed values: `2025-12-08`, `2025-10-27`, `2023-01-05`, `2022-09-01`, `2021-08-18`, `2021-07-05`, `2021-02-21`, `2020-05-18`
- `api-key-inflection` (enum, optional, default: kebab) — Default key inflection for attribute keys in incoming webhook requests. For more info see the [Key Inflection docs](https://docs.withpersona.com/key-inflection).
  - Allowed values: `camel`, `kebab`, `snake`
- `api-attributes-blocklist` (list of string, optional) — Attributes blocked from webhook requests. For more info see [Webhook Attributes Blocklist](https://docs.withpersona.com/webhook-blocklists#attribute-blocklist).
- `file-access-token-expires-in` (integer, optional) — How soon any file access tokens in webhook requests expire. For more info see [Downloading Files](https://docs.withpersona.com/downloading-files).
- `payload-filter` (WebhookRequestAttributesPayloadFilter, optional) — Filter webhook events based on payload data. Only available for enterprise clients. For more info see [Webhook Event Filters](https://docs.withpersona.com/webhook-event-filters).
- `included-allowlist` (included-allowlist, optional) — Controls which related objects appear in the `included` array of webhook payloads. The default is `include_none`. When `state` is `custom`, `event-types` configures which related objects to include per event type: event types you are subscribed to (via `enabled-events`) but do not list are excluded, and event types you list but are not subscribed to are dropped on save. A `custom` config whose event types are all `["*"]` is equivalent to, and is normalized to, `include_all`.
- `relationship-allowlist` (relationship-allowlist, optional) — Controls whether relationships are serialized in webhook payload objects. The default is `include_all`. The object shape leaves room for future granular relationship configuration.
- `custom-http-headers` (WebhookRequestAttributesCustomHttpHeaders, optional) — Custom HTTP headers to include in webhook requests. For more info see [Webhook Custom HTTP Headers](https://docs.withpersona.com/webhook-custom-http-headers).

### WebhookWithSecretAttributes

- `status` (string, optional)
- `url` (string, optional)
- `name` (string, optional, nullable)
- `description` (string, optional, nullable)
- `secret` (string, optional) — secret is deprecated in favor of secrets
- `secrets` (list of WebhookWithSecretAttributesSecretsItems, optional)
- `api-version` (enum, optional) — Server API version. More info on versioning can be found [here](https://docs.withpersona.com/versioning).
  - Allowed values: `2025-12-08`, `2025-10-27`, `2023-01-05`, `2022-09-01`, `2021-08-18`, `2021-07-05`, `2021-02-21`, `2020-05-18`
- `api-key-inflection` (string, optional)
- `api-attributes-blocklist` (list of string, optional)
- `file-access-token-expires-in` (integer, optional)
- `enabled-events` (list of string, optional)
- `payload-filter` (WebhookWithSecretAttributesPayloadFilter, optional, nullable)
- `included-allowlist` (included-allowlist, optional, nullable) — Controls which related objects appear in the `included` array of webhook payloads. The default is `include_none`. When `state` is `custom`, `event-types` configures which related objects to include per event type: event types you are subscribed to (via `enabled-events`) but do not list are excluded, and event types you list but are not subscribed to are dropped on save. A `custom` config whose event types are all `["*"]` is equivalent to, and is normalized to, `include_all`.
- `relationship-allowlist` (relationship-allowlist, optional) — Controls whether relationships are serialized in webhook payload objects. The default is `include_all`. The object shape leaves room for future granular relationship configuration.
- `created-at` (datetime, optional)

### WebhookRequestAttributesEnabledEventsItems

### WebhookRequestAttributesPayloadFilter

Filter webhook events based on payload data. Only available for enterprise clients. For more info see [Webhook Event Filters](https://docs.withpersona.com/webhook-event-filters).

- `data` (map from string to any, optional)

### included-allowlist

Controls which related objects appear in the `included` array of webhook payloads. The default is `include_none`. When `state` is `custom`, `event-types` configures which related objects to include per event type: event types you are subscribed to (via `enabled-events`) but do not list are excluded, and event types you list but are not subscribed to are dropped on save. A `custom` config whose event types are all `["*"]` is equivalent to, and is normalized to, `include_all`.

### relationship-allowlist

Controls whether relationships are serialized in webhook payload objects. The default is `include_all`. The object shape leaves room for future granular relationship configuration.

### WebhookRequestAttributesCustomHttpHeaders

Custom HTTP headers to include in webhook requests. For more info see [Webhook Custom HTTP Headers](https://docs.withpersona.com/webhook-custom-http-headers).

- `Authorization` (string, optional)
- `Calling-Application` (string, optional)
- `CF-Access-Client-Id` (string, optional)
- `CF-Access-Client-Secret` (string, optional)
- `X-API-Key` (string, optional)

### WebhookWithSecretAttributesSecretsItems

- `value` (string, optional)
- `expires-at` (datetime, optional, nullable)

### WebhookWithSecretAttributesPayloadFilter

### Include all

- `state` ("include_all", required) — Include all related objects for every subscribed event type.

### Include none

- `state` ("include_none", required) — Include no related objects (the default).

### Custom

- `state` ("custom", required) — Configure included related objects per event type via `event-types`.
- `event-types` (list of IncludedAllowlistOneOf2EventTypesItems, required) — Per-event-type include configuration. At most one entry per event type.

### Include all

- `state` ("include_all", required) — Include relationship linkages in webhook payload objects.

### Include none

- `state` ("include_none", required) — Omit relationship linkages from webhook payload objects.

### IncludedAllowlistOneOf2EventTypesItems

- `event-type` (string, required) — Event type identifier (e.g. `inquiry`, `account`).
- `relationships` (list of string, required) — Related object names to include for this event type, or `["*"]` to include all related objects. `"*"` cannot be combined with named relationships.

## Examples

**Request**

```json
{
  "data": {
    "attributes": {
      "name": "Inquiry Webhook",
      "url": "https://withpersona.com",
      "enabled-events": [
        "account.created",
        "verification.created"
      ],
      "included-allowlist": {
        "state": "include_all"
      },
      "relationship-allowlist": {
        "state": "include_all"
      }
    }
  }
}
```

**Response**

```json
{
  "data": {
    "type": "webhook",
    "id": "wbh_ABC123",
    "attributes": {
      "status": "disabled",
      "url": "https://withpersona.com",
      "secret": "wbhsec_abcdefgh-1234-5678-9ijk-lmnopqrstuvw",
      "secrets": [
        {
          "value": "wbhsec_abcdefgh-1234-5678-9ijk-lmnopqrstuvw",
          "expires-at": null
        }
      ],
      "api-version": "2023-01-05",
      "api-key-inflection": "kebab",
      "api-attributes-blocklist": [
        "address-*",
        "name-last",
        "/data/attributes/fields/*-number"
      ],
      "file-access-token-expires-in": 21600,
      "enabled-events": [
        "account.created",
        "verification.created"
      ],
      "payload-filter": {
        "data": {
          "relationships": {
            "inquiry-template": {
              "data": {
                "id": "itmpl_abc123def456"
              }
            }
          }
        }
      },
      "included-allowlist": {
        "state": "include_all"
      },
      "relationship-allowlist": {
        "state": "include_all"
      },
      "created-at": "2023-08-17T23:18:13.000Z"
    }
  }
}
```

**SDK Code**

```python Created
import requests

url = "https://api.withpersona.com/api/v1/webhooks"

payload = { "data": { "attributes": {
            "name": "Inquiry Webhook",
            "url": "https://withpersona.com",
            "enabled-events": ["account.created", "verification.created"],
            "included-allowlist": { "state": "include_all" },
            "relationship-allowlist": { "state": "include_all" }
        } } }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Created
const url = 'https://api.withpersona.com/api/v1/webhooks';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"data":{"attributes":{"name":"Inquiry Webhook","url":"https://withpersona.com","enabled-events":["account.created","verification.created"],"included-allowlist":{"state":"include_all"},"relationship-allowlist":{"state":"include_all"}}}}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Created
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.withpersona.com/api/v1/webhooks"

	payload := strings.NewReader("{\n  \"data\": {\n    \"attributes\": {\n      \"name\": \"Inquiry Webhook\",\n      \"url\": \"https://withpersona.com\",\n      \"enabled-events\": [\n        \"account.created\",\n        \"verification.created\"\n      ],\n      \"included-allowlist\": {\n        \"state\": \"include_all\"\n      },\n      \"relationship-allowlist\": {\n        \"state\": \"include_all\"\n      }\n    }\n  }\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Created
require 'uri'
require 'net/http'

url = URI("https://api.withpersona.com/api/v1/webhooks")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"data\": {\n    \"attributes\": {\n      \"name\": \"Inquiry Webhook\",\n      \"url\": \"https://withpersona.com\",\n      \"enabled-events\": [\n        \"account.created\",\n        \"verification.created\"\n      ],\n      \"included-allowlist\": {\n        \"state\": \"include_all\"\n      },\n      \"relationship-allowlist\": {\n        \"state\": \"include_all\"\n      }\n    }\n  }\n}"

response = http.request(request)
puts response.read_body
```

```java Created
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.withpersona.com/api/v1/webhooks")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"data\": {\n    \"attributes\": {\n      \"name\": \"Inquiry Webhook\",\n      \"url\": \"https://withpersona.com\",\n      \"enabled-events\": [\n        \"account.created\",\n        \"verification.created\"\n      ],\n      \"included-allowlist\": {\n        \"state\": \"include_all\"\n      },\n      \"relationship-allowlist\": {\n        \"state\": \"include_all\"\n      }\n    }\n  }\n}")
  .asString();
```

```php Created
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.withpersona.com/api/v1/webhooks', [
  'body' => '{
  "data": {
    "attributes": {
      "name": "Inquiry Webhook",
      "url": "https://withpersona.com",
      "enabled-events": [
        "account.created",
        "verification.created"
      ],
      "included-allowlist": {
        "state": "include_all"
      },
      "relationship-allowlist": {
        "state": "include_all"
      }
    }
  }
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Created
using RestSharp;

var client = new RestClient("https://api.withpersona.com/api/v1/webhooks");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"data\": {\n    \"attributes\": {\n      \"name\": \"Inquiry Webhook\",\n      \"url\": \"https://withpersona.com\",\n      \"enabled-events\": [\n        \"account.created\",\n        \"verification.created\"\n      ],\n      \"included-allowlist\": {\n        \"state\": \"include_all\"\n      },\n      \"relationship-allowlist\": {\n        \"state\": \"include_all\"\n      }\n    }\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Created
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["data": ["attributes": [
      "name": "Inquiry Webhook",
      "url": "https://withpersona.com",
      "enabled-events": ["account.created", "verification.created"],
      "included-allowlist": ["state": "include_all"],
      "relationship-allowlist": ["state": "include_all"]
    ]]] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.withpersona.com/api/v1/webhooks")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```