# Webhooks

## Event types

Webhooks are fired as fast as possible after the event have taken place in our system. These are the supported events:

* **consent\_created:** fired when a consent is created.&#x20;
* **consent\_withdrawn:** fired when a consent is withdrawn.

## List all webhooks

<mark style="color:blue;">`GET`</mark> `https://app.openli.com/api/v1/webhooks`

List all webhooks on the project.

#### Headers

| Name      | Type   | Description  |
| --------- | ------ | ------------ |
| x-api-key | string | Your API key |

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

```javascript
[
  {
    "webhook_endpoint": {
      "public_key":"TRNQzTKQvTxmShKZ4CFyWjdN",
      "target_url":"https://cool.webhook",
      "events":[
        "consent_created",
        "consent_withdrawn"
      ],
      "created_at":"2018-08-21T16:32:18.364Z",
      "updated_at":"2018-08-21T16:32:18.364Z"
    }
  },
  {
    "webhook_endpoint": {
      "public_key":"sDdyTHgDDx4YDYNW5p9hEjMw",
      "target_url":"https://cool.webhook/2",
      "events":[
        "consent_created"
      ],
      "created_at":"2018-08-21T16:32:18.364Z",
      "updated_at":"2018-08-21T16:32:18.364Z"
    }
  }
]
```

{% endtab %}

{% tab title="403 " %}

```javascript
{ "message": "API key not found" }
```

{% endtab %}
{% endtabs %}

## Add a webhook

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

#### Query Parameters

| Name        | Type   | Description                                                                                         |
| ----------- | ------ | --------------------------------------------------------------------------------------------------- |
| target\_url | string | The URL that the webhook should trigger.                                                            |
| events      | string | The events that the webhook should be activated on. If multiple events separated them with a comma. |

#### Headers

| Name      | Type   | Description  |
| --------- | ------ | ------------ |
| x-api-key | string | Your API key |

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

```javascript
[
  {
    "webhook_endpoint": {
      "public_key":"TRNQzTKQvTxmShKZ4CFyWjdN",
      "target_url":"https://cool.webhook",
      "events":[
        "consent_created",
        "consent_withdrawn"
      ],
      "created_at":"2018-08-21T16:32:18.364Z",
      "updated_at":"2018-08-21T16:32:18.364Z"
    }
  },
  {
    "webhook_endpoint": {
      "public_key":"sDdyTHgDDx4YDYNW5p9hEjMw",
      "target_url":"https://cool.webhook/2",
      "events":[
        "consent_created"
      ],
      "created_at":"2018-08-21T16:32:18.364Z",
      "updated_at":"2018-08-21T16:32:18.364Z"
    }
  }
]
```

{% endtab %}
{% endtabs %}

## Delete a webhook

<mark style="color:red;">`DELETE`</mark> `https://app.openli.com/api/v1/webhooks/:public_key`

#### Path Parameters

| Name        | Type   | Description                     |
| ----------- | ------ | ------------------------------- |
| public\_key | string | The public\_key of the webhook. |

#### Headers

| Name      | Type   | Description  |
| --------- | ------ | ------------ |
| x-api-key | string | Your API key |

{% tabs %}
{% tab title="200 The method returns a empty page on 200." %}

```
```

{% endtab %}

{% tab title="403 " %}

```javascript
{ "message": "API key not found" }
```

{% endtab %}
{% endtabs %}


---

# 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.openli.com/docs/documentation/legal-monster-api/webhooks.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.
