Skip to content

Cron Jobs API

Schedule recurring HTTP requests to run automatically.

Endpoints

MethodPathDescription
GET/api/organizations/{orgId}/cronList cron jobs
POST/api/organizations/{orgId}/cronCreate cron job
GET/api/organizations/{orgId}/cron/{id}Get cron job
PATCH/api/organizations/{orgId}/cron/{id}Update cron job
DELETE/api/organizations/{orgId}/cron/{id}Delete cron job
POST/api/organizations/{orgId}/cron/{id}/triggerTrigger job manually
GET/api/organizations/{orgId}/cron/{id}/executionsGet execution history

Cron Job Object

json
{
  "id": "cj_abc123",
  "name": "Hourly Sync",
  "description": "Sync data every hour",
  "cronExpression": "0 * * * *",
  "timezone": "UTC",
  "url": "https://api.example.com/sync",
  "method": "POST",
  "headers": {
    "Authorization": "Bearer xxx",
    "Content-Type": "application/json"
  },
  "payload": "{\"full\": false}",
  "timeoutMs": 30000,
  "isActive": true,
  "lastRunAt": "2024-01-15T10:00:00Z",
  "nextRunAt": "2024-01-15T11:00:00Z",
  "createdAt": "2024-01-01T00:00:00Z",
  "updatedAt": "2024-01-15T10:00:00Z"
}

Execution Object

json
{
  "id": "exec_xyz789",
  "cronJobId": "cj_abc123",
  "status": "success",
  "responseStatus": 200,
  "responseBody": "{\"ok\": true}",
  "errorMessage": null,
  "latencyMs": 245,
  "startedAt": "2024-01-15T10:00:00Z",
  "completedAt": "2024-01-15T10:00:00Z"
}

List Cron Jobs

http
GET /api/organizations/{orgId}/cron

Example

bash
curl https://api.hookbase.app/api/organizations/org_123/cron \
  -H "Authorization: Bearer YOUR_TOKEN"

Response

json
{
  "cronJobs": [
    {
      "id": "cj_abc123",
      "name": "Hourly Sync",
      "cronExpression": "0 * * * *",
      "url": "https://api.example.com/sync",
      "method": "POST",
      "isActive": true,
      "lastRunAt": "2024-01-15T10:00:00Z",
      "nextRunAt": "2024-01-15T11:00:00Z"
    }
  ]
}

Create Cron Job

http
POST /api/organizations/{orgId}/cron

Request Body

FieldTypeRequiredDescription
namestringYesDisplay name
cronExpressionstringYes5-field cron expression
urlstringYesTarget URL to call
descriptionstringNoOptional description
timezonestringNoTimezone (default: UTC)
methodstringNoHTTP method (default: POST)
headersobjectNoCustom HTTP headers
payloadstringNoRequest body
timeoutMsnumberNoTimeout in ms (default: 30000)

Cron Expression Format

Standard 5-field cron expression: minute hour day month weekday

FieldRangeSpecial Characters
Minute0-59*, */n, ,, -
Hour0-23*, */n, ,, -
Day of Month1-31*, */n, ,, -
Month1-12*, */n, ,, -
Day of Week0-6*, */n, ,, -

Example

bash
curl -X POST https://api.hookbase.app/api/organizations/org_123/cron \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Daily Cleanup",
    "cronExpression": "0 3 * * *",
    "timezone": "America/New_York",
    "url": "https://api.example.com/cleanup",
    "method": "POST",
    "headers": {
      "Authorization": "Bearer api-key-here"
    },
    "payload": "{\"older_than_days\": 30}",
    "timeoutMs": 60000
  }'

Response

json
{
  "cronJob": {
    "id": "cj_def456",
    "name": "Daily Cleanup",
    "cronExpression": "0 3 * * *",
    "url": "https://api.example.com/cleanup",
    "nextRunAt": "2024-01-16 03:00:00"
  }
}

Get Cron Job

http
GET /api/organizations/{orgId}/cron/{id}

Example

bash
curl https://api.hookbase.app/api/organizations/org_123/cron/cj_abc123 \
  -H "Authorization: Bearer YOUR_TOKEN"

Response

json
{
  "cronJob": {
    "id": "cj_abc123",
    "name": "Hourly Sync",
    "description": "Sync data every hour",
    "cronExpression": "0 * * * *",
    "timezone": "UTC",
    "url": "https://api.example.com/sync",
    "method": "POST",
    "headers": "{\"Authorization\":\"Bearer xxx\"}",
    "payload": "{\"full\": false}",
    "timeoutMs": 30000,
    "isActive": true,
    "lastRunAt": "2024-01-15T10:00:00Z",
    "nextRunAt": "2024-01-15T11:00:00Z",
    "createdAt": "2024-01-01T00:00:00Z",
    "updatedAt": "2024-01-15T10:00:00Z"
  }
}

Update Cron Job

http
PATCH /api/organizations/{orgId}/cron/{id}

Request Body

All fields are optional. Only provided fields are updated.

FieldTypeDescription
namestringDisplay name
descriptionstringOptional description
cronExpressionstring5-field cron expression
timezonestringTimezone
urlstringTarget URL
methodstringHTTP method
headersobjectCustom HTTP headers
payloadstringRequest body
timeoutMsnumberTimeout in milliseconds
isActivebooleanEnable/disable the job

Example

bash
curl -X PATCH https://api.hookbase.app/api/organizations/org_123/cron/cj_abc123 \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "cronExpression": "*/30 * * * *",
    "isActive": false
  }'

Response

json
{
  "success": true
}

Delete Cron Job

http
DELETE /api/organizations/{orgId}/cron/{id}

WARNING

Deleting a cron job also deletes all its execution history.

Example

bash
curl -X DELETE https://api.hookbase.app/api/organizations/org_123/cron/cj_abc123 \
  -H "Authorization: Bearer YOUR_TOKEN"

Response

json
{
  "success": true
}

Trigger Job Manually

Execute a cron job immediately, regardless of its schedule.

http
POST /api/organizations/{orgId}/cron/{id}/trigger

Example

bash
curl -X POST https://api.hookbase.app/api/organizations/org_123/cron/cj_abc123/trigger \
  -H "Authorization: Bearer YOUR_TOKEN"

Response (Success)

json
{
  "execution": {
    "id": "exec_xyz789",
    "status": "success",
    "responseStatus": 200,
    "latencyMs": 245
  }
}

Response (Failure)

json
{
  "execution": {
    "id": "exec_abc456",
    "status": "failed",
    "error": "Connection timeout",
    "latencyMs": 30000
  }
}

Get Execution History

http
GET /api/organizations/{orgId}/cron/{id}/executions

Query Parameters

ParameterTypeDescription
limitnumberNumber of executions to return (default: 20)

Example

bash
curl "https://api.hookbase.app/api/organizations/org_123/cron/cj_abc123/executions?limit=10" \
  -H "Authorization: Bearer YOUR_TOKEN"

Response

json
{
  "executions": [
    {
      "id": "exec_xyz789",
      "cron_job_id": "cj_abc123",
      "status": "success",
      "response_status": 200,
      "response_body": "{\"ok\": true}",
      "error_message": null,
      "latency_ms": 245,
      "started_at": "2024-01-15T10:00:00Z",
      "completed_at": "2024-01-15T10:00:00Z"
    },
    {
      "id": "exec_abc456",
      "cron_job_id": "cj_abc123",
      "status": "failed",
      "response_status": null,
      "response_body": null,
      "error_message": "Connection timeout",
      "latency_ms": 30000,
      "started_at": "2024-01-15T09:00:00Z",
      "completed_at": "2024-01-15T09:00:30Z"
    }
  ]
}

Execution Status Values

StatusDescription
runningJob is currently executing
successCompleted with HTTP 2xx response
failedFailed due to error, timeout, or non-2xx response

Error Responses

400 Bad Request

Invalid cron expression:

json
{
  "error": "Invalid cron expression"
}

Invalid URL:

json
{
  "error": "Invalid URL"
}

Missing required fields:

json
{
  "error": "Name, cron expression, and URL are required"
}

404 Not Found

Cron job not found:

json
{
  "error": "Cron job not found"
}

Rate Limits

  • Jobs execute no more frequently than once per minute
  • Maximum timeout per execution: 60 seconds
  • Response body stored in execution logs: 10KB max

Released under the MIT License.