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


---

# 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.searchagora.com/webhooks/manage-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.
