# Webhook

### Webhook Properties

| Field        | Description                                                                                         |
| ------------ | --------------------------------------------------------------------------------------------------- |
| `active`     | Whether events should be sent to this webhook. Can be either `true`or `false`. Defaults  to `true`. |
| `created_at` | When a `Webhook` was created on the Malomo Platform.                                                |
| `id`         | Unique identifier per `Webhook`.                                                                    |
| `topic`      | Event that triggers a webhook.                                                                      |
| `updated_at` | When a `Webhook` was last updated.                                                                  |
| `url`        | URL webhook events should be sent to.                                                               |

## Create a Webhook

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

#### Request Body

| Name   | Type    | Description                                              |
| ------ | ------- | -------------------------------------------------------- |
| active | boolean | Whether to send events to a webhook. Defaults to `true`. |
| secret | string  | Key used to sign webhook events.                         |
| topic  | string  | Event that triggers a webhook.                           |
| url    | string  | URL to send webhook events to.                           |

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

```javascript
{
  "active": true,
  "created_at": "2019-01-30T13:30:00Z",
  "id": "be005f40-f068-4ca6-a936-f11b2f902ffc",
  "topic": "events:created",
  "updated_at": "2019-01-30T13:30:00Z",
  "url": "https://myapp.com/webhooks"
}
```

{% endtab %}
{% endtabs %}

## Retrieve a Webhook

<mark style="color:blue;">`GET`</mark> `https://api.gomalomo.com/webhooks/:id`

#### Path Parameters

| Name | Type   | Description                                 |
| ---- | ------ | ------------------------------------------- |
| id   | string | Unique identifier of the desired `Webhook`. |

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

```javascript
{
  "active": true,
  "created_at": "2019-01-30T13:30:00Z",
  "id": "be005f40-f068-4ca6-a936-f11b2f902ffc",
  "topic": "events:created",
  "updated_at": "2019-01-30T13:30:00Z",
  "url": "https://myapp.com/webhooks"
}
```

{% endtab %}
{% endtabs %}

## Retrieve a List of Webhooks

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

#### Query Parameters

| Name | Type   | Description                              |
| ---- | ------ | ---------------------------------------- |
| prev | string | Retrieve webhooks before a given cursor. |
| next | string | Retrieve webhooks after a given cursor.  |

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

```javascript
[
  {
    "active": true,
    "created_at": "2019-01-30T13:30:00Z",
    "id": "be005f40-f068-4ca6-a936-f11b2f902ffc",
    "topic": "events:created",
    "updated_at": "2019-01-30T13:30:00Z",
    "url": "https://myapp.com/webhooks"
  }
]
```

{% endtab %}
{% endtabs %}

## Update a Webhook

<mark style="color:orange;">`PUT`</mark> `https://api.gomalomo.com/webhooks/:id`

#### Path Parameters

| Name | Type   | Description                                   |
| ---- | ------ | --------------------------------------------- |
| id   | string | Unique identifier of the `Webhook` to update. |

#### Request Body

| Name   | Type    | Description                          |
| ------ | ------- | ------------------------------------ |
| active | boolean | Whether to send events to a webhook. |
| url    | string  | URL to send webhook events to.       |

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

```javascript
{
  "active": true,
  "created_at": "2019-01-30T13:30:00Z",
  "id": "be005f40-f068-4ca6-a936-f11b2f902ffc",
  "topic": "events:created",
  "updated_at": "2019-01-30T13:30:00Z",
  "url": "https://myapp.com/webhooks"
}
```

{% endtab %}
{% endtabs %}

## Delete a Webhook

<mark style="color:red;">`DELETE`</mark> `https://api.gomalomo.com/webhooks/:id`

#### Path Parameters

| Name | Type   | Description                                       |
| ---- | ------ | ------------------------------------------------- |
| id   | string | Unique identifier of the `Webhook` to be deleted. |

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

{% endtab %}
{% endtabs %}
