> For the complete documentation index, see [llms.txt](https://docs.complycube.com/documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.complycube.com/documentation/api-reference/other-resources/webhooks/create-a-webhook.md).

# Create a webhook

### URL

<mark style="color:green;">**POST**</mark> `https://api.complycube.com/v1/webhooks`

Creates a new webhook. Returns the webhook endpoint object with the `secret` field populated.\
\
You can create up to a **maximum of 20 webhooks.**

### Headers

<table><thead><tr><th width="271">Name</th><th width="100">Type</th><th>Description</th></tr></thead><tbody><tr><td>Content-Type<mark style="color:red;">*</mark></td><td>string</td><td>The content-type must always be set to <code>application/json</code>.</td></tr><tr><td><code>Authorization</code><mark style="color:red;">*</mark></td><td>string</td><td>The API <code>live</code> or <code>test</code> key.</td></tr></tbody></table>

### Body

<table><thead><tr><th width="272">Name</th><th width="101">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>url</code><mark style="color:red;">*</mark></td><td>string</td><td>The URL of the webhook endpoint.</td></tr><tr><td><code>description</code></td><td>string</td><td>A description of what the webhook is used for.</td></tr><tr><td><code>enabled</code><mark style="color:red;">*</mark></td><td>boolean</td><td>Determines whether the webhook should be active.</td></tr><tr><td><code>events</code><mark style="color:red;">*</mark></td><td>array</td><td>The list of <strong>event types</strong> to which the endpoint is subscribed for.</td></tr></tbody></table>

### Example request

{% tabs %}
{% tab title="cURL" %}

```bash
curl -X POST https://api.complycube.com/v1/webhooks \
     -H 'Authorization: <YOUR_API_KEY>' \
     -H 'Content-Type: application/json' \
     -d '{
          "description": "This is my webhook, I like it a lot",
          "url": "https://yoursite.com/my/webhook/endpoint",
          "enabled": true,
          "events": [
                 "check.pending",
                 "check.completed"
          ]
        }'
```

{% endtab %}

{% tab title="Node.js" %}

```javascript
const { ComplyCube } = require("@complycube/api");

const complycube = new ComplyCube({ apiKey: "<YOUR_API_KEY>" });

const webhook = await complycube.webhook.create({
    description: "This is my webhook, I like it a lot",
    url: "https://yoursite.com/my/webhook/endpoint",
    enabled: true,
    events: [
        "check.pending",
        "check.completed"
    ]
});
```

{% endtab %}

{% tab title="Python" %}

```python
from complycube import ComplyCubeClient
cc_api = ComplyCubeClient(api_key='<YOUR_API_KEY>')

my_hook = {
    'description': 'This is my webhook, I like it a lot',
    'url': 'https://yoursite.com/my/webhook/endpoint',
    'enabled': True,
    'events': ['check.pending','check.completed']
}

webhook = cc_api.webhooks.create(**my_hook)
```

{% endtab %}

{% tab title="PHP" %}

```php
use ComplyCube\ComplyCubeClient;

$ccapi = new ComplyCubeClient('<YOUR_API_KEY>');

$webhook = $ccapi->webhooks()->create([
    'description' => 'This is my webhook, I like it a lot',
    'url' => 'https://yoursite.com/my/webhook/endpoint',
    'enabled' => true,
    'events' => ['check.pending', 'check.completed']
]);
```

{% endtab %}

{% tab title=".NET" %}

```csharp
using ComplyCube.Net;
using ComplyCube.Net.Resources.Webhooks;

var webhookApi = new WebhookApi(new ComplyCubeClient("<YOUR_API_KEY>"));

var webhookRequest = new WebhookRequest {
  url = "https://yoursite.com/my/webhook/endpoint",
  description = "This is my webhook, I like it a lot",
  enabled = true,
  events = new string[] {
    "check.completed",
    "check.pending"
  }
};

var webhook = await webhookApi.CreateAsync(webhookRequest);
```

{% endtab %}
{% endtabs %}

### Example responses

{% tabs %}
{% tab title="Success (200)" %}

```json
{
  "id": "5ed1712e99c81a0007b9a3d6",
  "description": "This is my webhook, I like it a lot",
  "url": "https://example.com/my/webhook/endpoint",
  "enabled": true,
  "events": [
    "check.created",
    "check.completed"
  ],
  "secret": "akuPkDmpn1lFiMchfmSjsQMj0sUQ4IRH",
  "createdAt": "2020-01-29T20:31:42.375Z",
  "updatedAt": "2020-01-29T20:31:42.375Z"
}
```

{% endtab %}

{% tab title="Invalid Request (400)" %}

```json
{
    "type": "invalid_request",
    "message": "'events' should be equal to one of the allowed values:check.created, check.completed",
    "param": "type"
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.complycube.com/documentation/api-reference/other-resources/webhooks/create-a-webhook.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
