Cron API

Full API reference for managing cron jobs. Create, update, delete, and run scheduled tasks.

Base URL

https://api.hookwatch.dev/v1/cron-jobs

The Cron Job Object

Json

Properties

FieldTypeDescription
idstringUnique identifier for the cron job
namestringHuman-readable name for the job
schedulestringHuman-readable schedule or cron expression
schedule_cronstringNormalized cron expression
commandstringShell command to execute on the assigned CLI agent
working_dirstringWorking directory for command execution
timeout_secondsnumberExecution timeout in seconds (default: 300)
retry_configobjectRetry configuration with max_retries and intervals
notification_configobjectNotification settings (on_failure, on_success)
environmentobjectKey-value environment variables passed to the command
tagsstring[]Tags for organizing and filtering jobs
agent_idstringID of the CLI agent assigned to execute this job
agent_namestringName of the assigned CLI agent
is_enabledbooleanWhether the job is active
last_run_atstring | nullISO 8601 timestamp of last execution
next_run_atstring | nullISO 8601 timestamp of next scheduled run

Create Cron Job

Create a new scheduled cron job.

POST /v1/cron-jobs

Request Body

FieldTypeRequiredDescription
namestringYesName for the cron job
schedulestringYesCron expression or human-readable schedule
commandstringYesShell command to execute
working_dirstringNoWorking directory for the command
timeout_secondsnumberNoTimeout in seconds (default: 300, max: 3600)
retry_configobjectNoCustom retry configuration
notification_configobjectNoNotification preferences (on_failure, on_success)
environmentobjectNoKey-value environment variables
tagsstring[]NoTags for the job
agent_idstringNoID of agent to assign (optional)

Example

curl

List Cron Jobs

Retrieve all cron jobs for the authenticated user.

GET /v1/cron-jobs

Query Parameters

FieldTypeDescription
limitnumberMaximum jobs to return (default: 20, max: 100)
offsetnumberNumber of jobs to skip for pagination
enabledbooleanFilter by enabled status
tagstringFilter by tag

Response

Json

Get Next Scheduled Runs

Get the next scheduled run time for all enabled jobs.

GET /v1/cron-jobs/next

Response

Json

Get Cron Job

Retrieve a specific cron job by ID.

GET /v1/cron-jobs/:id

Update Cron Job

Update an existing cron job's configuration.

PUT /v1/cron-jobs/:id

All fields are optional. Only include fields you want to update.

Delete Cron Job

Permanently delete a cron job and all its execution history.

DELETE /v1/cron-jobs/:id

Warning

This action is irreversible. All execution history for this job will be permanently deleted.

Enable / Disable

Toggle a cron job's enabled status without deleting it.

POST /v1/cron-jobs/:id/enable

Enable the job

POST /v1/cron-jobs/:id/disable

Disable the job

Run Job Now

Manually trigger an immediate execution of a cron job, regardless of its schedule.

POST /v1/cron-jobs/:id/run

Response

Json

Note

Manual runs create an execution with status: "pending" and triggered_by: "manual". The assigned CLI agent picks it up and executes it locally.

Agent-Based Execution

Cron jobs are executed locally by registered CLI agents, not in the cloud. When you create a job, assign it to an agent or let HookWatch use the default agent. The agent runs the shell command on its host machine and reports results back to the cloud.

Error Codes

StatusErrorDescription
400Bad RequestInvalid schedule expression or request body
401UnauthorizedInvalid or missing access token
403ForbiddenCron job limit reached (upgrade plan)
404Not FoundCron job not found

Related