Cron Chains

Chain multiple cron jobs into sequential workflows with conditional execution logic. Build deployment pipelines, data processing workflows, and automated run-books.

How Chains Work

A chain is an ordered sequence of steps, where each step executes an existing cron job. Steps run sequentially, and each step can be configured to run based on the previous step's outcome:

ConditionBehavior
on_successRun only if the previous step succeeded (default)
on_failureRun only if the previous step failed
alwaysRun regardless of the previous step's outcome

Trigger Types

TypeDescription
scheduleRuns automatically on a cron schedule
manualTriggered on-demand via dashboard or API
webhookTriggered by an incoming webhook to a linked endpoint

Base URL

https://api.hookwatch.dev/v1/cron/chains

The Chain Object

Json

Properties

FieldTypeDescription
idstringUnique chain identifier
namestringHuman-readable chain name
descriptionstringOptional description
trigger_typestringHow the chain is triggered: schedule, manual, or webhook
trigger_schedulestringCron expression (required when trigger_type is schedule)
trigger_endpoint_idstringWebhook endpoint ID (when trigger_type is webhook)
is_enabledbooleanWhether the chain is active

The Step Object

Json

Step Properties

FieldTypeRequiredDescription
cron_job_idstringYesID of the cron job to execute
step_ordernumberYesExecution order (0-based)
condition_typestringNoWhen to run: on_success (default), on_failure, or always
timeout_secondsnumberNoMax execution time in seconds (default: 3600)

Create Chain

Create a new chain with its steps.

POST /v1/cron/chains

Request Body

FieldTypeRequiredDescription
namestringYesName for the chain
descriptionstringNoOptional description
trigger_typestringYesTrigger mode: schedule, manual, or webhook
trigger_schedulestringNoCron expression (required if trigger_type is schedule)
stepsarrayYesOrdered list of steps to execute (see step fields below)

Example

curl

List Chains

Retrieve all chains for the authenticated user.

GET /v1/cron/chains

Get Chain

Retrieve a specific chain by ID.

GET /v1/cron/chains/:id

Update Chain

Update a chain's metadata and optionally replace all steps. If steps is provided, all existing steps are deleted and replaced.

PUT /v1/cron/chains/:id

Delete Chain

Delete a chain and all its steps.

DELETE /v1/cron/chains/:id

Warning

This action is irreversible. All steps associated with this chain will also be deleted.

Run Chain

Manually trigger a chain execution. Creates a new execution record starting from the first step.

POST /v1/cron/chains/:id/run
curl

The Execution Object

Json

Execution statuses:

  • running — Currently executing
  • completed — All steps finished successfully
  • failed — A step failed and no subsequent steps could run
  • canceled — Manually canceled by user

List Executions

Get execution history for a chain (paginated, newest first).

GET /v1/cron/chains/:id/executions

Query Parameters

FieldTypeDescription
limitnumberMax executions to return (default: 20, max: 100)
offsetnumberNumber of executions to skip

Response

Json

Get Execution

Retrieve a specific execution by ID.

GET /v1/cron/chain-executions/:id

Cancel Execution

Cancel a running execution. Only works if status is running.

POST /v1/cron/chain-executions/:id/cancel

Error Codes

StatusErrorDescription
400Bad RequestMissing name, invalid trigger type, or empty steps
401UnauthorizedInvalid or missing access token
404Not FoundChain or execution not found
409ConflictCannot cancel a non-running execution

Related