# API reference: Webhooks

> The Webhooks endpoints (10 operations), generated from the OpenAPI document (https://faraatarjomeh.com/api/v1/openapi.json). For task-level walkthroughs use the guides; for error handling use /api/v1/docs/errors. The full reference: /api/v1/docs/reference.

## At a glance

- Auth on every call: `Authorization: Bearer $FARA_API_KEY`
- `scope`: `read` for GET/HEAD, `write` for the rest
- **spends Fara**: the call holds or charges Fara; get the price first and send `Idempotency-Key`
- Path parameters in the examples are shell variables (`$JOB_ID`, `$ID` …)
- Errors: `application/problem+json` with a stable `code` (not repeated per endpoint below)

## Index

- **Webhooks**: [GET /api/v1/webhook-endpoints/event-types](#listWebhookEventTypes), [GET /api/v1/webhook-endpoints](#listWebhookEndpoints), [POST /api/v1/webhook-endpoints](#createWebhookEndpoint), [GET /api/v1/webhook-endpoints/{id}](#getWebhookEndpoint), [PATCH /api/v1/webhook-endpoints/{id}](#updateWebhookEndpoint), [DELETE /api/v1/webhook-endpoints/{id}](#deleteWebhookEndpoint), [POST /api/v1/webhook-endpoints/{id}/rotate-secret](#rotateWebhookSecret), [POST /api/v1/webhook-endpoints/{id}/test](#sendWebhookTestEvent), [GET /api/v1/webhook-endpoints/{id}/deliveries](#listWebhookDeliveries), [POST /api/v1/webhook-endpoints/{id}/deliveries/{deliveryId}/retry](#retryWebhookDelivery)

## Webhooks

Get told when a job changes status.

<a id="listWebhookEventTypes"></a>
### GET /api/v1/webhook-endpoints/event-types

List webhook event types

- operationId `listWebhookEventTypes` · scope `read` · free

**Response `200`**

[`WebhookEventTypes`](#schema-webhook-event-types)

**Responses**

- `200` Event types. (`application/json`)
- Errors: `401`, `403`, `429`, `503` — problem+json, see /api/v1/docs/errors

**Example**

```bash
curl -sS -X GET "https://faraatarjomeh.com/api/v1/webhook-endpoints/event-types" \
  -H "Authorization: Bearer $FARA_API_KEY"
```

<a id="listWebhookEndpoints"></a>
### GET /api/v1/webhook-endpoints

List webhook endpoints

- operationId `listWebhookEndpoints` · scope `read` · free

All endpoints of the account (there are only a few, so no pagination).

**Response `200`**

[`WebhookEndpointList`](#schema-webhook-endpoint-list)

**Responses**

- `200` Endpoints. (`application/json`)
- Errors: `401`, `403`, `404`, `429`, `503` — problem+json, see /api/v1/docs/errors

**Example**

```bash
curl -sS -X GET "https://faraatarjomeh.com/api/v1/webhook-endpoints" \
  -H "Authorization: Bearer $FARA_API_KEY"
```

<a id="createWebhookEndpoint"></a>
### POST /api/v1/webhook-endpoints

Add a webhook endpoint

- operationId `createWebhookEndpoint` · scope `write` · free · send `Idempotency-Key`

The answer contains the signing `secret`. It is shown only once.

**Parameters**

| Name | In | Type | Required | Notes |
|---|---|---|---|---|
| `Idempotency-Key` | header | string | no | see /api/v1/docs/conventions#idempotency |

**Request body** `application/json` (required)

[`WebhookEndpointCreateRequest`](#schema-webhook-endpoint-create-request)

**Response `201`**

[`WebhookEndpointWithSecret`](#schema-webhook-endpoint-with-secret)

**Responses**

- `201` Created. (`application/json`)
- Errors: `400`, `401`, `403`, `404`, `409`, `422`, `429`, `503` — problem+json, see /api/v1/docs/errors

**Example**

```bash
curl -sS -X POST "https://faraatarjomeh.com/api/v1/webhook-endpoints" \
  -H "Authorization: Bearer $FARA_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"url":"string"}'
```

<a id="getWebhookEndpoint"></a>
### GET /api/v1/webhook-endpoints/{id}

Get a webhook endpoint

- operationId `getWebhookEndpoint` · scope `read` · free

**Parameters**

| Name | In | Type | Required | Notes |
|---|---|---|---|---|
| `id` | path | string | yes | Webhook endpoint id. |

**Response `200`**

[`WebhookEndpoint`](#schema-webhook-endpoint)

**Responses**

- `200` The endpoint. (`application/json`)
- Errors: `401`, `403`, `404`, `429`, `503` — problem+json, see /api/v1/docs/errors

**Example**

```bash
curl -sS -X GET "https://faraatarjomeh.com/api/v1/webhook-endpoints/$ID" \
  -H "Authorization: Bearer $FARA_API_KEY"
```

<a id="updateWebhookEndpoint"></a>
### PATCH /api/v1/webhook-endpoints/{id}

Change a webhook endpoint

- operationId `updateWebhookEndpoint` · scope `write` · free · send `Idempotency-Key`

**Parameters**

| Name | In | Type | Required | Notes |
|---|---|---|---|---|
| `id` | path | string | yes | Webhook endpoint id. |
| `Idempotency-Key` | header | string | no | see /api/v1/docs/conventions#idempotency |

**Request body** `application/json` (required)

[`WebhookEndpointUpdateRequest`](#schema-webhook-endpoint-update-request)

**Response `200`**

[`WebhookEndpoint`](#schema-webhook-endpoint)

**Responses**

- `200` Updated. (`application/json`)
- Errors: `400`, `401`, `403`, `404`, `409`, `422`, `429`, `503` — problem+json, see /api/v1/docs/errors

**Example**

```bash
curl -sS -X PATCH "https://faraatarjomeh.com/api/v1/webhook-endpoints/$ID" \
  -H "Authorization: Bearer $FARA_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{}'
```

<a id="deleteWebhookEndpoint"></a>
### DELETE /api/v1/webhook-endpoints/{id}

Delete a webhook endpoint

- operationId `deleteWebhookEndpoint` · scope `write` · free · send `Idempotency-Key`

**Parameters**

| Name | In | Type | Required | Notes |
|---|---|---|---|---|
| `id` | path | string | yes | Webhook endpoint id. |
| `Idempotency-Key` | header | string | no | see /api/v1/docs/conventions#idempotency |

**Responses**

- `204` Deleted.
- Errors: `400`, `401`, `403`, `404`, `409`, `422`, `429`, `503` — problem+json, see /api/v1/docs/errors

**Example**

```bash
curl -sS -X DELETE "https://faraatarjomeh.com/api/v1/webhook-endpoints/$ID" \
  -H "Authorization: Bearer $FARA_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

<a id="rotateWebhookSecret"></a>
### POST /api/v1/webhook-endpoints/{id}/rotate-secret

Replace the signing secret

- operationId `rotateWebhookSecret` · scope `write` · free · send `Idempotency-Key`

The old secret stops working at once. The new one is shown only in this answer.

**Parameters**

| Name | In | Type | Required | Notes |
|---|---|---|---|---|
| `id` | path | string | yes | Webhook endpoint id. |
| `Idempotency-Key` | header | string | no | see /api/v1/docs/conventions#idempotency |

**Response `200`**

[`WebhookEndpointWithSecret`](#schema-webhook-endpoint-with-secret)

**Responses**

- `200` New secret. (`application/json`)
- Errors: `400`, `401`, `403`, `404`, `409`, `422`, `429`, `503` — problem+json, see /api/v1/docs/errors

**Example**

```bash
curl -sS -X POST "https://faraatarjomeh.com/api/v1/webhook-endpoints/$ID/rotate-secret" \
  -H "Authorization: Bearer $FARA_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

<a id="sendWebhookTestEvent"></a>
### POST /api/v1/webhook-endpoints/{id}/test

Send a test event

- operationId `sendWebhookTestEvent` · scope `write` · free · send `Idempotency-Key`

Sends one `webhook.test` event now and reports what your endpoint answered. Not retried.

**Parameters**

| Name | In | Type | Required | Notes |
|---|---|---|---|---|
| `id` | path | string | yes | Webhook endpoint id. |
| `Idempotency-Key` | header | string | no | see /api/v1/docs/conventions#idempotency |

**Response `200`**

[`WebhookTestResult`](#schema-webhook-test-result)

**Responses**

- `200` Result. (`application/json`)
- Errors: `400`, `401`, `403`, `404`, `409`, `422`, `429`, `503` — problem+json, see /api/v1/docs/errors

**Example**

```bash
curl -sS -X POST "https://faraatarjomeh.com/api/v1/webhook-endpoints/$ID/test" \
  -H "Authorization: Bearer $FARA_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

<a id="listWebhookDeliveries"></a>
### GET /api/v1/webhook-endpoints/{id}/deliveries

List deliveries to an endpoint

- operationId `listWebhookDeliveries` · scope `read` · free

**Parameters**

| Name | In | Type | Required | Notes |
|---|---|---|---|---|
| `id` | path | string | yes | Webhook endpoint id. |
| `limit` | query | integer | no | Items per page (1-100). — default: `20`; min 1; max 100 |
| `startingAfter` | query | string | no | Cursor: the `nextCursor` (or last `id`) of the previous page. |

**Response `200`**

[`WebhookDeliveryPage`](#schema-webhook-delivery-page)

**Responses**

- `200` One page. (`application/json`)
- Errors: `400`, `401`, `403`, `404`, `429`, `503` — problem+json, see /api/v1/docs/errors

**Example**

```bash
curl -sS -X GET "https://faraatarjomeh.com/api/v1/webhook-endpoints/$ID/deliveries" \
  -H "Authorization: Bearer $FARA_API_KEY"
```

<a id="retryWebhookDelivery"></a>
### POST /api/v1/webhook-endpoints/{id}/deliveries/{deliveryId}/retry

Send a failed delivery again

- operationId `retryWebhookDelivery` · scope `write` · free · send `Idempotency-Key`

**Parameters**

| Name | In | Type | Required | Notes |
|---|---|---|---|---|
| `id` | path | string | yes | Webhook endpoint id. |
| `deliveryId` | path | string | yes | Webhook delivery id. |
| `Idempotency-Key` | header | string | no | see /api/v1/docs/conventions#idempotency |

**Response `202`**

[`WebhookDelivery`](#schema-webhook-delivery)

**Responses**

- `202` Queued again. (`application/json`)
- Errors: `400`, `401`, `403`, `404`, `409`, `422`, `429`, `503` — problem+json, see /api/v1/docs/errors

**Example**

```bash
curl -sS -X POST "https://faraatarjomeh.com/api/v1/webhook-endpoints/$ID/deliveries/$DELIVERY_ID/retry" \
  -H "Authorization: Bearer $FARA_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

## Schemas

Named request and response objects used above. Nested objects are flattened as `parent.child`; arrays as `parent[].child`.

<a id="schema-webhook-delivery"></a>
### WebhookDelivery

| Field | Type | Required | Notes |
|---|---|---|---|
| `id` | string | yes | Delivery id. Also the pagination cursor. |
| `eventId` | string | yes | Same as the `webhook-id` header. |
| `eventType` | string | yes |  |
| `status` | string | yes | `pending`, `succeeded`, or `failed`. |
| `attempts` | integer | no |  |
| `nextAttemptAt` | string \| null | no | may be null |
| `lastAttemptAt` | string \| null | no | may be null |
| `lastResponseStatus` | integer \| null | no | may be null |
| `lastError` | string \| null | no | may be null |
| `createdAt` | string \| null | no | may be null |

<a id="schema-webhook-delivery-page"></a>
### WebhookDeliveryPage

One page of deliveries, newest first. Kept for 30 days.

| Field | Type | Required | Notes |
|---|---|---|---|
| `data` | object[] | yes |  |
| `data[].id` | string | yes | Delivery id. Also the pagination cursor. |
| `data[].eventId` | string | yes | Same as the `webhook-id` header. |
| `data[].eventType` | string | yes |  |
| `data[].status` | string | yes | `pending`, `succeeded`, or `failed`. |
| `data[].attempts` | integer | no |  |
| `data[].nextAttemptAt` | string \| null | no | may be null |
| `data[].lastAttemptAt` | string \| null | no | may be null |
| `data[].lastResponseStatus` | integer \| null | no | may be null |
| `data[].lastError` | string \| null | no | may be null |
| `data[].createdAt` | string \| null | no | may be null |
| `hasMore` | boolean | yes | True when there are more items after this page. |
| `nextCursor` | string \| null | yes | Pass as `startingAfter` to get the next page. Null on the last page. — may be null |

<a id="schema-webhook-endpoint"></a>
### WebhookEndpoint

| Field | Type | Required | Notes |
|---|---|---|---|
| `id` | string | yes |  |
| `url` | string | yes |  |
| `description` | string | no |  |
| `events` | string[] | yes | Event types sent to this endpoint. `["*"]` means all. |
| `enabled` | boolean | yes |  |
| `disabledReason` | string \| null | no | `disabled_by_user`, `endpoint_gone` (answered 410), or `failing_for_days`. — may be null |
| `createdAt` | string \| null | no | may be null |
| `updatedAt` | string \| null | no | may be null |
| `lastSuccessAt` | string \| null | no | may be null |
| `lastFailureAt` | string \| null | no | may be null |

<a id="schema-webhook-endpoint-create-request"></a>
### WebhookEndpointCreateRequest

| Field | Type | Required | Notes |
|---|---|---|---|
| `url` | string | yes | Public https URL that will receive events. |
| `events` | string[] | no | Event types to send. Default `["*"]` (all). |
| `description` | string | no | Up to 200 characters. |

<a id="schema-webhook-endpoint-list"></a>
### WebhookEndpointList

| Field | Type | Required | Notes |
|---|---|---|---|
| `data` | object[] | yes |  |
| `data[].id` | string | yes |  |
| `data[].url` | string | yes |  |
| `data[].description` | string | no |  |
| `data[].events` | string[] | yes | Event types sent to this endpoint. `["*"]` means all. |
| `data[].enabled` | boolean | yes |  |
| `data[].disabledReason` | string \| null | no | `disabled_by_user`, `endpoint_gone` (answered 410), or `failing_for_days`. — may be null |
| `data[].createdAt` | string \| null | no | may be null |
| `data[].updatedAt` | string \| null | no | may be null |
| `data[].lastSuccessAt` | string \| null | no | may be null |
| `data[].lastFailureAt` | string \| null | no | may be null |

<a id="schema-webhook-endpoint-update-request"></a>
### WebhookEndpointUpdateRequest

| Field | Type | Required | Notes |
|---|---|---|---|
| `url` | string | no |  |
| `events` | string[] | no |  |
| `description` | string | no |  |
| `enabled` | boolean | no | Turn the endpoint off or back on. Turning it on clears the failure count. |

<a id="schema-webhook-endpoint-with-secret"></a>
### WebhookEndpointWithSecret

| Field | Type | Required | Notes |
|---|---|---|---|
| `id` | string | yes |  |
| `url` | string | yes |  |
| `description` | string | no |  |
| `events` | string[] | yes | Event types sent to this endpoint. `["*"]` means all. |
| `enabled` | boolean | yes |  |
| `disabledReason` | string \| null | no | `disabled_by_user`, `endpoint_gone` (answered 410), or `failing_for_days`. — may be null |
| `createdAt` | string \| null | no | may be null |
| `updatedAt` | string \| null | no | may be null |
| `lastSuccessAt` | string \| null | no | may be null |
| `lastFailureAt` | string \| null | no | may be null |
| `secret` | string | yes | Signing secret, `whsec_` + base64. Shown only in this response. Store it safely. |

<a id="schema-webhook-event-types"></a>
### WebhookEventTypes

| Field | Type | Required | Notes |
|---|---|---|---|
| `data` | string[] | yes |  |

<a id="schema-webhook-test-result"></a>
### WebhookTestResult

| Field | Type | Required | Notes |
|---|---|---|---|
| `deliveryId` | string | no |  |
| `eventId` | string | no |  |
| `delivered` | boolean | no | True when your endpoint answered 2xx. |
| `responseStatus` | integer \| null | no | may be null |
| `error` | string \| null | no | may be null |
