# Add a webhook endpoint

Source: https://deeperesearch.com/docs/api/reference/operations/createwebhook/

POST

/v1/webhooks

```js
const url = 'https://deeperesearch.com/v1/webhooks';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"url":"https://example.com/hooks/deeper","events":["research.completed","research.failed"]}'
};


try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```sh
curl --request POST \
  --url https://deeperesearch.com/v1/webhooks \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{ "url": "https://example.com/hooks/deeper", "events": [ "research.completed", "research.failed" ] }'
```

Registers a public https URL for events. The signing secret is returned only here, so store it.

## Authorizations

- **[apiKey](https://deeperesearch.com/docs/api/reference/#apikey)**

## Request Bodyrequired

application/json

object

**url**

required

A public https URL.

string

\>= 1 characters <= 2000 characters

**events**

Event types to send. Defaults to all of them.

Array\<string>

\>= 1 items

Allowed values: research.completed research.failed research.cancelled research.run.completed research.merge.completed research.merge.failed

### Example

```json
{
  "url": "https://example.com/hooks/deeper",
  "events": [
    "research.completed",
    "research.failed"
  ]
}
```

## Responses

### 201

The endpoint and its signing secret

application/json

object

**id**

required

string format: uuid

**object**

required

string

Allowed value: webhook_endpoint

**url**

required

string

**events**

required

Array\<string>

Allowed values: research.completed research.failed research.cancelled research.run.completed research.merge.completed research.merge.failed

**created_at**

required

string

**secret**

required

string

#### Example

```json
{
  "object": "webhook_endpoint",
  "events": [
    "research.completed"
  ]
}
```

### 400

The body isn’t valid JSON (invalid_json)

application/json

object

**error**

required

object

**code**

required

Stable, machine-readable error code. See Errors in the docs.

string

**message**

required

What went wrong, written for people

string

#### Example generated

```json
{
  "error": {
    "code": "example",
    "message": "example"
  }
}
```

### 401

Missing or invalid API key (unauthorized)

application/json

object

**error**

required

object

**code**

required

Stable, machine-readable error code. See Errors in the docs.

string

**message**

required

What went wrong, written for people

string

#### Example generated

```json
{
  "error": {
    "code": "example",
    "message": "example"
  }
}
```

### 403

The key lacks the scope this needs (forbidden)

application/json

object

**error**

required

object

**code**

required

Stable, machine-readable error code. See Errors in the docs.

string

**message**

required

What went wrong, written for people

string

#### Example generated

```json
{
  "error": {
    "code": "example",
    "message": "example"
  }
}
```

### 413

The body is over 128 KB (body_too_large)

application/json

object

**error**

required

object

**code**

required

Stable, machine-readable error code. See Errors in the docs.

string

**message**

required

What went wrong, written for people

string

#### Example generated

```json
{
  "error": {
    "code": "example",
    "message": "example"
  }
}
```

### 422

Invalid request; the message names the field (invalid_request, exceeds_max_cost, vendor_unavailable, …)

application/json

object

**error**

required

object

**code**

required

Stable, machine-readable error code. See Errors in the docs.

string

**message**

required

What went wrong, written for people

string

#### Example generated

```json
{
  "error": {
    "code": "example",
    "message": "example"
  }
}
```

### 429

Rate limit, spending limit or quota reached (rate_limited, limit_reached, quota_exceeded). See Retry-After.

application/json

object

**error**

required

object

**code**

required

Stable, machine-readable error code. See Errors in the docs.

string

**message**

required

What went wrong, written for people

string

#### Example generated

```json
{
  "error": {
    "code": "example",
    "message": "example"
  }
}
```
