# Create Webhook

There are two ways to create webhooks in ZapSign: via the web interface or by calling the API endpoint. This allows you to configure webhooks in a flexible and efficient way, ensuring that your system is notified in real-time about important events.

{% hint style="info" %}
**Remember:** One webhook applies to all documents within your account. **It’s not necessary to create more than one webhook.** You will only need to perform the following setup once, not for each document.
{% endhint %}

#### In this section:

* [Creating webhooks via the web interface;](#creating-webhooks-via-web-interface)
* [Creating webhooks via the API;](#creating-webhooks-via-api)
* [Configuring Headers  for webhooks;](#configuring-headers-for-webhooks)

***

#### Creating webhooks via web interface

**Step 1:** In your account, go to **Settings > Integrations > ZapSign API > Webhooks**.

**Step 2:** Enter the endpoint (URL) of your server that will receive the webhook data. This endpoint must be ready to process POST requests and handle the JSON data that ZapSign will send.

**Step 3:** Choose which events you want to monitor. ZapSign allows you to select from five types of events:

* [Document Created](/english/webhooks/eventos/document/doc_created.md)
* [Document Signed](/english/webhooks/eventos/document/doc_signed.md)
* [Document Refused;](/english/webhooks/eventos/document/doc_refused.md)
* [Document Deleted;](/english/webhooks/eventos/document/doc_deleted.md)
* [Email Bounce;](/english/webhooks/eventos/signer/email_bounce.md)
* [Doc Expired;](/english/webhooks/eventos/document/doc-expired.md)

{% hint style="danger" %}
**The "All" option** only includes document-related events (created, signed, removed, and rejected). It does **not include the "Email Bounce" event (**&#x66;or email delivery failures). **To monitor that event, you will need to register it separately.**
{% endhint %}

**Step 4:** Configure whether you want to add a filter to receive notifications only for documents created from a specific template. Additionally, you can set up retry attempts in case a notification fails.

<figure><img src="/files/FDt6J6tsc1gNG1kRuf6z" alt=""><figcaption></figcaption></figure>

***

### Creating webhooks via API

You can also create your endpoints via the API, adjusting the headers and events as needed for your workflow to ensure a seamless integration!

<figure><img src="/files/Jf26V4Dj0WPpCJLCLROD" alt=""><figcaption></figcaption></figure>

{% hint style="warning" %}
**Attention**: The "All" option includes only document events (created, signed, deleted, and refused). It does not include the "Email bounce" event (for email delivery failures). For this event, you need to register it separately.
{% endhint %}

## Create a webhook

<mark style="color:green;">`POST`</mark> `https://api.zapsign.com.br/api/v1/user/company/webhook/`

#### Headers

<table><thead><tr><th width="147.81536865234375">Name</th><th width="118.20953369140625">Type</th><th>Description</th></tr></thead><tbody><tr><td>Authorization<mark style="color:red;">*</mark></td><td>string</td><td><p>apiToken ahead of the "Bearer" text. </p><p>Ex: Bearer c7f35c84-7893-4087-b4fb-d1f06c23</p></td></tr></tbody></table>

#### Request Body

<table><thead><tr><th width="137.71234130859375">Name</th><th width="88.4901123046875">Type</th><th>Description</th></tr></thead><tbody><tr><td>url<mark style="color:red;">*</mark></td><td>string</td><td>Ex: <strong>”https://api.yoursite.com/webhook-zapsign/”</strong></td></tr><tr><td>type<mark style="color:red;">*</mark></td><td>string</td><td>Types of events you want to receive: "" (all) | "doc_signed" | "doc_created" | "doc_deleted"</td></tr><tr><td>doc_token</td><td>string</td><td>Document`s token to associate with. When defined, all the webhooks triggered will be for this document only.</td></tr><tr><td>headers</td><td>Array&#x3C;Header></td><td>Headers to be sent when the webhook is triggered. The configuration for each header is above</td></tr></tbody></table>

{% tabs %}
{% tab title="200: OK Webhook created successfully" %}

```
{
    "id": // Você receberá um ID de resposta//
}
```

{% endtab %}

{% tab title="403-Forbidden" %}

```
Make sure your API TOKEN is correct.
```

{% endtab %}
{% endtabs %}

***

### Configuring headers for webhooks

It is also possible to implement headers in webhooks, ensuring greater security in data transmission and optimizing performance between applications.<br>

**Webhook** - JSON root:

* **headers** - for each header:

  * **name (string) -** Name of the HTTP header to be sent.&#x20;

  &#x20;     **Ex:** Authorization

  * **value (string)** - Value of the HTTP header to be sent.&#x20;

  &#x20;     **Ex:** Bearer YOUR\_AUTHENTICATION\_TOKEN\
  \ <mark style="color:green;">`POST`</mark>` ``{{api_url}}/api/v1/user/company/webhook/header/`

```
{
    "id": {{webhook_id}},
    "headers": [
        {
            "name": "Authorization",
            "value": "Bearer YOUR_AUTHENTICATION_TOKEN"
        }
    ]
}

```

### Example of a request

{% embed url="<https://www.postman.com/zapsign/workspace/zapsign-workspace/request/27495556-3413e0f8-be2d-4161-9ffa-b449443dc68d?ctx=documentation>" %}


---

# Agent Instructions: 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:

```
GET https://docs.zapsign.com.br/english/webhooks/create-webhook.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
