---
title: "Trigger a task via webhook"
---

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

# Trigger a task via webhook

Path: Simplcron API › Jobs

`POST /v1/triggers/{slug}`

Call a task-specific inbound webhook from a server or automation. It creates the same kind of job as POST /v1/jobs. Use waitUntil for starter-wait-until or replyTimeoutSeconds for starter-wait-for-reply.

## Authentication

- `bearerAuth`, http bearer, header `Authorization`

## Path parameters

- `slug` (`triggerTask.path.slug`; string, required) — Registered task slug.
  - maxLength: `64` · pattern: `^[a-z0-9]+(?:-[a-z0-9]+)*$`

## Header parameters

- `Idempotency-Key` (`triggerTask.header.Idempotency-Key`; string, optional) — Reuse the same value when repeating the same submission. Reusing it with different inputs returns a conflict.
  - maxLength: `160` · minLength: `1`

## Request body

_Required._

- `payload` (`triggerTask.payload`; object, required)
- `maxAttempts` (`triggerTask.maxAttempts`; integer, optional) — Defaults to the task's maximum attempts.
  - maximum: `5` · minimum: `1`
- `runAt` (`triggerTask.runAt`; string, optional) — An explicit-offset RFC 3339 timestamp for a delayed start. Omit when using a wait starter.
  - format: `date-time`
- `waitUntil` (`triggerTask.waitUntil`; string, optional) — Required for starter-wait-until and available only for that starter. Give an explicit-offset RFC 3339 resume time. For new submissions it must be in the future, up to 30 days ahead. Omit runAt.
  - format: `date-time`
- `replyTimeoutSeconds` (`triggerTask.replyTimeoutSeconds`; integer, optional) — Available only for starter-wait-for-reply. The timeout starts when Simplcron accepts the job. Omit runAt and waitUntil.
  - maximum: `2592000` · minimum: `5` · default: `60`

## Example request

```json
{
  "payload": {
    "event": "order.completed",
    "orderId": "sample-order-001"
  }
}
```

## Code samples

### cURL

```bash
curl --request POST \
  --url '<base-url>/v1/triggers/<slug>' \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "payload": {
    "event": "order.completed",
    "orderId": "sample-order-001"
  }
}
'
```

### TypeScript

```typescript
const url = '<base-url>/v1/triggers/<slug>';
const options = {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    Authorization: 'Bearer <token>'
  },
  body: JSON.stringify({payload: {event: 'order.completed', orderId: 'sample-order-001'}})
};

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/triggers/<slug>"

payload = { "payload": {
        "event": "order.completed",
        "orderId": "sample-order-001"
    } }
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer <token>"
}

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

print(response.text)
```

## Responses

### 200

Previously accepted run with the same idempotency key

#### Example

```json
{
  "id": "string",
  "runId": "string",
  "task": "string",
  "taskName": "string",
  "status": "scheduled",
  "source": "string",
  "attempt": 5,
  "maxAttempts": 3,
  "payload": {},
  "output": null,
  "error": "string",
  "createdAt": "2019-08-24T14:15:22Z",
  "startedAt": "2019-08-24T14:15:22Z",
  "finishedAt": "2019-08-24T14:15:22Z",
  "runAt": "2019-08-24T14:15:22Z",
  "nextAttemptAt": "2019-08-24T14:15:22Z",
  "waitUntil": "2019-08-24T14:15:22Z",
  "waitStartedAt": "2019-08-24T14:15:22Z",
  "waitResumedAt": "2019-08-24T14:15:22Z",
  "replyTimeoutSeconds": 5,
  "waitOutcome": "reply",
  "reply": {
    "receivedAt": "2019-08-24T14:15:22Z",
    "payload": {}
  },
  "durationMs": 0,
  "previousRunId": "string"
}
```

- `id` (`triggerTask.response.200.id`; string, required)
- `task` (`triggerTask.response.200.task`; string, required)
  - maxLength: `64` · pattern: `^[a-z0-9]+(?:-[a-z0-9]+)*$`
- `status` (`triggerTask.response.200.status`; string, required)
  - one of `"scheduled"`, `"queued"`, `"waiting"`, `"running"`, `"retrying"`, `"succeeded"`, `"failed"`, `"cancelled"`
- `attempt` (`triggerTask.response.200.attempt`; integer, required)
  - maximum: `5` · minimum: `0`
- `maxAttempts` (`triggerTask.response.200.maxAttempts`; integer, required)
  - maximum: `5` · minimum: `1` · default: `3`
- `createdAt` (`triggerTask.response.200.createdAt`; string, required)
  - format: `date-time`
- `runId` (`triggerTask.response.200.runId`; string, optional)
- `taskName` (`triggerTask.response.200.taskName`; string, optional)
- `source` (`triggerTask.response.200.source`; string, optional)
- `payload` (`triggerTask.response.200.payload`; object, optional)
- `output` (`triggerTask.response.200.output`; unknown, optional)
- `error` (`triggerTask.response.200.error`; any of, optional)
  - any of the following: `string`, `null`
- `startedAt` (`triggerTask.response.200.startedAt`; any of, optional)
  - any of the following: `string`, `null`
- `finishedAt` (`triggerTask.response.200.finishedAt`; any of, optional)
  - any of the following: `string`, `null`
- `runAt` (`triggerTask.response.200.runAt`; any of, optional)
  - any of the following: `string`, `null`
- `nextAttemptAt` (`triggerTask.response.200.nextAttemptAt`; any of, optional)
  - any of the following: `string`, `null`
- `waitUntil` (`triggerTask.response.200.waitUntil`; string, optional) — Planned resume time for Wait Until or the reply deadline for Wait for Reply.
  - format: `date-time`
- `waitStartedAt` (`triggerTask.response.200.waitStartedAt`; string | null, optional) — Time when a wait run entered its pause, or null until it has paused.
  - format: `date-time`
- `waitResumedAt` (`triggerTask.response.200.waitResumedAt`; string | null, optional) — Time when a wait run resumed, or null before resumption.
  - format: `date-time`
- `replyTimeoutSeconds` (`triggerTask.response.200.replyTimeoutSeconds`; integer, optional) — Timeout applied to this Wait for Reply run.
  - maximum: `2592000` · minimum: `5`
- `waitOutcome` (`triggerTask.response.200.waitOutcome`; string | null, optional) — Outcome of a Wait for Reply run. Null until the run resumes.
  - one of `"reply"`, `"timeout"`, `null`
- `reply` (`triggerTask.response.200.reply`; object | null, optional) — The accepted reply on a full Wait for Reply run record. Null while there is no accepted reply, including after timeout. Run summaries omit this field.
  - `receivedAt` (`triggerTask.response.200.reply.receivedAt`; string, required)
    - format: `date-time`
  - `payload` (`triggerTask.response.200.reply.payload`; object, required)
- `durationMs` (`triggerTask.response.200.durationMs`; any of, optional)
  - any of the following: `number`, `null`
- `previousRunId` (`triggerTask.response.200.previousRunId`; any of, optional)
  - any of the following: `string`, `null`

### 202

Run accepted

#### Example

```json
{
  "id": "string",
  "runId": "string",
  "task": "string",
  "taskName": "string",
  "status": "scheduled",
  "source": "string",
  "attempt": 5,
  "maxAttempts": 3,
  "payload": {},
  "output": null,
  "error": "string",
  "createdAt": "2019-08-24T14:15:22Z",
  "startedAt": "2019-08-24T14:15:22Z",
  "finishedAt": "2019-08-24T14:15:22Z",
  "runAt": "2019-08-24T14:15:22Z",
  "nextAttemptAt": "2019-08-24T14:15:22Z",
  "waitUntil": "2019-08-24T14:15:22Z",
  "waitStartedAt": "2019-08-24T14:15:22Z",
  "waitResumedAt": "2019-08-24T14:15:22Z",
  "replyTimeoutSeconds": 5,
  "waitOutcome": "reply",
  "reply": {
    "receivedAt": "2019-08-24T14:15:22Z",
    "payload": {}
  },
  "durationMs": 0,
  "previousRunId": "string"
}
```

- `id` (`triggerTask.response.202.id`; string, required)
- `task` (`triggerTask.response.202.task`; string, required)
  - maxLength: `64` · pattern: `^[a-z0-9]+(?:-[a-z0-9]+)*$`
- `status` (`triggerTask.response.202.status`; string, required)
  - one of `"scheduled"`, `"queued"`, `"waiting"`, `"running"`, `"retrying"`, `"succeeded"`, `"failed"`, `"cancelled"`
- `attempt` (`triggerTask.response.202.attempt`; integer, required)
  - maximum: `5` · minimum: `0`
- `maxAttempts` (`triggerTask.response.202.maxAttempts`; integer, required)
  - maximum: `5` · minimum: `1` · default: `3`
- `createdAt` (`triggerTask.response.202.createdAt`; string, required)
  - format: `date-time`
- `runId` (`triggerTask.response.202.runId`; string, optional)
- `taskName` (`triggerTask.response.202.taskName`; string, optional)
- `source` (`triggerTask.response.202.source`; string, optional)
- `payload` (`triggerTask.response.202.payload`; object, optional)
- `output` (`triggerTask.response.202.output`; unknown, optional)
- `error` (`triggerTask.response.202.error`; any of, optional)
  - any of the following: `string`, `null`
- `startedAt` (`triggerTask.response.202.startedAt`; any of, optional)
  - any of the following: `string`, `null`
- `finishedAt` (`triggerTask.response.202.finishedAt`; any of, optional)
  - any of the following: `string`, `null`
- `runAt` (`triggerTask.response.202.runAt`; any of, optional)
  - any of the following: `string`, `null`
- `nextAttemptAt` (`triggerTask.response.202.nextAttemptAt`; any of, optional)
  - any of the following: `string`, `null`
- `waitUntil` (`triggerTask.response.202.waitUntil`; string, optional) — Planned resume time for Wait Until or the reply deadline for Wait for Reply.
  - format: `date-time`
- `waitStartedAt` (`triggerTask.response.202.waitStartedAt`; string | null, optional) — Time when a wait run entered its pause, or null until it has paused.
  - format: `date-time`
- `waitResumedAt` (`triggerTask.response.202.waitResumedAt`; string | null, optional) — Time when a wait run resumed, or null before resumption.
  - format: `date-time`
- `replyTimeoutSeconds` (`triggerTask.response.202.replyTimeoutSeconds`; integer, optional) — Timeout applied to this Wait for Reply run.
  - maximum: `2592000` · minimum: `5`
- `waitOutcome` (`triggerTask.response.202.waitOutcome`; string | null, optional) — Outcome of a Wait for Reply run. Null until the run resumes.
  - one of `"reply"`, `"timeout"`, `null`
- `reply` (`triggerTask.response.202.reply`; object | null, optional) — The accepted reply on a full Wait for Reply run record. Null while there is no accepted reply, including after timeout. Run summaries omit this field.
  - `receivedAt` (`triggerTask.response.202.reply.receivedAt`; string, required)
    - format: `date-time`
  - `payload` (`triggerTask.response.202.reply.payload`; object, required)
- `durationMs` (`triggerTask.response.202.durationMs`; any of, optional)
  - any of the following: `number`, `null`
- `previousRunId` (`triggerTask.response.202.previousRunId`; any of, optional)
  - any of the following: `string`, `null`

### 400

Invalid input

#### Example

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

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

### 401

Authentication is required

#### Example

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

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

### 403

The credential lacks permission

#### Example

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

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

### 404

Task not found in this environment

#### Example

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

- `error` (`triggerTask.response.404.error`; string, required)

### 409

An idempotency key already exists for different inputs

#### Example

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

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

### 429

Workspace run limit reached

#### Example

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

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


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