---
title: "Register a task"
---

> 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.

# Register a task

Path: Simplcron API › Tasks

`POST /v1/tasks`

Register an HTTPS handler. Store its one-time signing secret before delivering work. The destination must be allowlisted.

## Authentication

Requires one of the following:

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

## Request body

_Required._

- `name` (`createTask.name`; string, required)
  - maxLength: `100` · minLength: `1`
- `slug` (`createTask.slug`; string, required)
  - maxLength: `64` · pattern: `^[a-z0-9]+(?:-[a-z0-9]+)*$`
- `url` (`createTask.url`; string, required) — Allowed public HTTPS destination on port 443; redirects are not followed.
  - format: `uri` · maxLength: `2048`
- `description` (`createTask.description`; string, optional)
  - maxLength: `200`
- `maxAttempts` (`createTask.maxAttempts`; integer, optional)
  - maximum: `5` · minimum: `1` · default: `3`

## Example request

```json
{
  "name": "string",
  "slug": "string",
  "url": "http://example.com",
  "description": "string",
  "maxAttempts": 3
}
```

## Code samples

### cURL

```bash
curl --request POST \
  --url '<base-url>/v1/tasks' \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "name": "string",
  "slug": "string",
  "url": "http://example.com",
  "description": "string",
  "maxAttempts": 3
}
'
```

### TypeScript

```typescript
const url = '<base-url>/v1/tasks';
const options = {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    Authorization: 'Bearer <token>'
  },
  body: JSON.stringify({
    name: 'string',
    slug: 'string',
    url: 'http://example.com',
    description: 'string',
    maxAttempts: 3
  })
};

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/tasks"

payload = {
    "name": "string",
    "slug": "string",
    "url": "http://example.com",
    "description": "string",
    "maxAttempts": 3
}
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer <token>"
}

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

print(response.text)
```

## Responses

### 201

Task registered

#### Example

```json
{
  "task": {
    "id": "string",
    "name": "string",
    "slug": "string",
    "url": "http://example.com",
    "description": "string",
    "starterId": "string",
    "maxAttempts": 3,
    "createdAt": "2019-08-24T14:15:22Z"
  },
  "secret": "string"
}
```

- `task` (`createTask.response.201.task`; object, required)
  - `id` (`createTask.response.201.task.id`; string, required)
  - `name` (`createTask.response.201.task.name`; string, required)
    - maxLength: `100` · minLength: `1`
  - `slug` (`createTask.response.201.task.slug`; string, required)
    - maxLength: `64` · pattern: `^[a-z0-9]+(?:-[a-z0-9]+)*$`
  - `url` (`createTask.response.201.task.url`; string, required) — An allowlisted public HTTPS handler or a fixture URL for a built-in starter.
    - format: `uri` · maxLength: `2048`
  - `maxAttempts` (`createTask.response.201.task.maxAttempts`; integer, required)
    - maximum: `5` · minimum: `1` · default: `3`
  - `createdAt` (`createTask.response.201.task.createdAt`; string, required)
    - format: `date-time`
  - `description` (`createTask.response.201.task.description`; string, optional)
    - maxLength: `200`
  - `starterId` (`createTask.response.201.task.starterId`; string, optional) — The catalog identifier when this task was registered from a starter.
- `secret` (`createTask.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` (`createTask.response.400.error`; string, required)

### 401

Authentication is required

#### Example

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

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

### 403

The credential lacks permission

#### Example

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

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

### 409

Task slug already registered

#### Example

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

- `error` (`createTask.response.409.error`; string, required)

### 429

Task limit reached

#### Example

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

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


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