---
title: "Subscribe to lifecycle events"
---

> Documentation Index
> Fetch the complete documentation index at: https://simplcron.dev/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Subscribe to lifecycle events

Path: Simplcron API › Webhooks

`POST /v1/webhooks`

Register an allowed HTTPS endpoint for execution, completion and failure events. Store the returned one-time signing secret.

## Authentication

Requires one of the following:

- `bearerAuth`, http bearer, header `Authorization`
- `browserSession`, apiKey, in cookie
- `localBrowserSession`, apiKey, in cookie

## Request body

_Required._

- `url` (`createWebhook.url`; string, required) — Allowed public HTTPS destination on port 443; redirects are not followed.
  - format: `uri`
- `events` (`createWebhook.events`; array of string, required)
  - one of `"task.execution"`, `"task.completed"`, `"task.failed"`

## Example request

```json
{
  "url": "http://example.com",
  "events": [
    "task.execution"
  ]
}
```

## Code samples

### cURL

```bash
curl --request POST \
  --url '<base-url>/v1/webhooks' \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "url": "http://example.com",
  "events": [
    "task.execution"
  ]
}
'
```

### TypeScript

```typescript
const url = '<base-url>/v1/webhooks';
const options = {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    Authorization: 'Bearer <token>'
  },
  body: JSON.stringify({url: 'http://example.com', events: ['task.execution']})
};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "<base-url>/v1/webhooks"

payload = {
    "url": "http://example.com",
    "events": ["task.execution"]
}
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer <token>"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
```

## Responses

### 201

Created subscription

#### Example

```json
{
  "webhook": {
    "id": "string",
    "url": "http://example.com",
    "events": [
      "task.execution"
    ],
    "createdAt": "2019-08-24T14:15:22Z",
    "revokedAt": "2019-08-24T14:15:22Z"
  },
  "secret": "string"
}
```

- `webhook` (`createWebhook.response.201.webhook`; object, required)
  - `id` (`createWebhook.response.201.webhook.id`; string, required)
  - `url` (`createWebhook.response.201.webhook.url`; string, required) — Allowed public HTTPS destination on port 443; redirects are not followed.
    - format: `uri`
  - `events` (`createWebhook.response.201.webhook.events`; array of string, required)
    - one of `"task.execution"`, `"task.completed"`, `"task.failed"`
  - `createdAt` (`createWebhook.response.201.webhook.createdAt`; string, optional)
    - format: `date-time`
  - `revokedAt` (`createWebhook.response.201.webhook.revokedAt`; any of, optional)
    - any of the following: `string`, `null`
- `secret` (`createWebhook.response.201.secret`; string, required) — One-time HMAC signing secret. Store it in your application’s secret store.

### 400

Invalid input

#### Example

```json
{
  "error": "string"
}
```

- `error` (`createWebhook.response.400.error`; string, required)

### 401

Authentication is required

#### Example

```json
{
  "error": "string"
}
```

- `error` (`createWebhook.response.401.error`; string, required)

### 403

The credential lacks permission

#### Example

```json
{
  "error": "string"
}
```

- `error` (`createWebhook.response.403.error`; string, required)

### 429

Webhook limit reached

#### Example

```json
{
  "error": "string"
}
```

- `error` (`createWebhook.response.429.error`; string, required)


Source: https://simplcron.dev/docs/api/create-webhook/index.md
