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

# 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 %}
