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

# Manage webhooks

## Create webhook

POST `/webhooks`

This endpoint lets you create a new webhook to track changes to the stock or price of a product.&#x20;

**Headers**

| Header          | Type   | Description   |
| --------------- | ------ | ------------- |
| `Authorization` | string | Bearer token. |

**Request body**

```json
{
    "webhookUrl": "https://test.com",
    "webhookType": "stock.alert" //options are stock.alert and price.alert
}
```

**Response**

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

```json
{
    "success": true,
    "message": "Webhook created successfully",
    "data": {
        "id": "69416e629e0508a7d6bb34a0",
        "webhookUrl": "https://test.com",
        "webhookType": "stock.alert",
        "apiKey": "693fc81db7259fa413a3844e",
        "parentId": "69119256f34516a8f3dbc536"
    }
}
```

{% endtab %}

{% tab title="400" %}

```json
{
  "success": false,
  "message": "Validation error",
  "error": "Webhook validation failed: ..."
}
```

{% endtab %}

{% tab title="500" %}

```json
{
  "success": false,
  "message": "Failed to create webhook",
  "error": error message
}
```

{% endtab %}
{% endtabs %}

## Delete webhook

DEL `/webhooks/{webhook_id}`

This endpoint lets you delete a webhook.

**Headers**

| Header          | Type   | Description   |
| --------------- | ------ | ------------- |
| `Authorization` | string | Bearer token. |

**Response**

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

```json
{
    "success": true,
    "message": "Webhook deleted successfully"
}
```

{% endtab %}

{% tab title="400" %}

```json
{
  "success": false,
  "message": "Webhook ID is required"
}
```

{% endtab %}

{% tab title="404" %}

```json
{
  "success": false,
  "message": "Webhook not found or you do not have permission to delete it"
}
```

{% endtab %}

{% tab title="500" %}

```json
{
  "success": false,
  "message": "Failed to delete webhook",
  "error": Error Message
}
```

{% endtab %}
{% endtabs %}
