API Reference

The Cronhooks REST API allows you to schedules webhooks, manage groups and environment variables.

API Key

You'll need to include an API key in every API request. If you do not yet have a Cronhooks account, please sign up for a free account ↗. Your API key is located in your profile ↗.

Authorization: Bearer <YOUR_API_TOKEN>

Schedules

The schedules API allows you to create, retrieve, update, delete, trigger, pause and resume scheduled webhooks.

Create a schedule

POST https://api.cronhooks.io/schedules

PARAMETERS

Name Required
groupId
provide group's id
Optional
title
title of webhook schedule
Required
url
webhook url
Required
timezone
IANA Timezone
Required
method
Http method
Required
headers
{} Object
Optional
payload
{} Object or "" String
Optional
contentType
Content Type for recieving webhook
Required
isRecurring
Trigger webhook repeatedly or not
Required
runAt
Only applicable for non-recurring schedules
Required
sendCronhookObject
Send Cronhook schedule object along with provided payload
Required
sendFailureAlert
If false no alerts will be sent on any channel
Required
cronExpression
Only applicable for recurring schedules
Required
startsAt
Only applicable for recurring schedules
Optional
endsAt
Only applicable for recurring schedules
Optional
retryCount
Only applicable for ad-hoc schedules
Optional
retryIntervalSeconds
Only applicable for ad-hoc schedules
Optional
runAt, startsAt, endsAt must not contain timezone offset. Valid: 2019-03-04T17:10:00, Invalid: 2019-03-04T17:10:00+05, 2019-03-04T17:10:Z

REQUEST

curl https://api.cronhooks.io/schedules \
  -X POST \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer <YOUR_API_TOKEN>' \
  -d \
  '{
     "groupId": null | group_id,
     "title": "Send email to inactive users",
     "description": "Send email to inactive users",
     "url": "https://example.com/webhooks/inactive-email",
     "timezone": "asia/karachi",
     "method": "POST",
     "headers": {
       "additionalProp1": "string",
       "additionalProp2": "string",
       "additionalProp3": "string"
     },
     "payload": {
       "additionalProp1": "string",
       "additionalProp2": "string",
       "additionalProp3": "string"
     },
     "contentType": "application/json; charset=utf-8",
     "isRecurring": false,
     "cronExpression": "",
     "runAt": "2019-02-01T12:48:26.983", // if isRecurring => false
     "sendCronhookObject": true,
     "sendFailureAlert": true,
     "startsAt": "2023-02-01T13:00:00", // if isRecurring => true
     "endsAt": "2023-03-01T13:00:00" // if isRecurring => true
     "retryCount": "3", // if isRecurring => false
     "retryIntervalSeconds": "5" // if isRecurring => false
  }'

Response

{
  "id": "3a012d1f-fe83-4855-2860-84f8a85e154c",
  "groupId": "3a0136ac-123f-c222-5b2d-ae5b0c5937a6",
  "title": "Send email to inactive users",
  "description": "Send an email to users who are inactive for more than 60 days and offer a discount for upgrading subscriptions.",
  "url": "https://example.com/webhooks/inactive-email",
  "timezone": "asia/karachi",
  "method": "POST",
  "headers": {
    "additionalProp1": "string",
    "additionalProp2": "string",
    "additionalProp3": "string"
  },
  "payload": "{
      \"additionalProp1\": \"string\",
      \"additionalProp2\": \"string\",
      \"additionalProp3\": \"string\"
  }",
  "contentType": "application/json; charset=utf-8",
  "status": "scheduled",
  "errorMessage": "",
  "isRecurring": false,
  "cronExpression": "",
  "runAt": "2019-02-01T12:48:26.983",
  "sendCronhookObject": true,
  "sendFailureAlert": true,
  "startsAt": "2023-02-01T13:00:00",
  "endsAt": "2023-03-01T13:00:00",
  "retryCount": "3",
  "retryIntervalSeconds": "5",
  "creationTime": "2019-02-01T09:35:27.568Z",
  "lastModificationTime": "2019-02-01T09:35:27.568Z"
}
Update a schedule

PUT https://api.cronhooks.io/schedules/{id}

PARAMETERS

Name Required
id
schedules's id
Required
groupId
provide group's id
Optional
title
title of webhook schedule
Required
url
webhook url
Required
timezone
IANA Timezone
Required
method
Http method
Required
headers
{} Object
Optional
payload
{} Object or "" String
Optional
contentType
Content Type for recieving webhook
Required
isRecurring
Trigger webhook repeatedly or not
Required
runAt
Only applicable for non-recurring schedules
Required
sendCronhookObject
Send Cronhook schedule object along with provided payload
Required
sendFailureAlert
If false no alerts will be sent on any channel
Required
cronExpression
Only applicable for recurring schedules
Required
startsAt
Only applicable for recurring schedules
Optional
endsAt
Only applicable for recurring schedules
Optional
retryCount
Only applicable for ad-hoc schedules
Optional
retryIntervalSeconds
Only applicable for ad-hoc schedules
Optional
runAt, startsAt, endsAt must not contain timezone offset. Valid: 2019-03-04T17:10:00, Invalid: 2019-03-04T17:10:00+05, 2019-03-04T17:10:Z

REQUEST

curl https://api.cronhooks.io/schedules/3a0136ac-123f-c222-5b2d-ae5b0c5937a6 /
  -X PUT \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer <YOUR_API_TOKEN>' \
  -d \
  '{
     "groupId": null | group_id,
     "title": "Send email to inactive users",
     "description": "Send email to inactive users",
     "url": "https://example.com/webhooks/inactive-email",
     "timezone": "asia/karachi",
     "method": "POST",
     "headers": {
       "additionalProp1": "string",
       "additionalProp2": "string",
       "additionalProp3": "string"
     },
     "payload": {
       "additionalProp1": "string",
       "additionalProp2": "string",
       "additionalProp3": "string"
     },
     "contentType": "application/json; charset=utf-8",
     "isRecurring": false,
     "cronExpression": "",
     "runAt": "2019-02-01T12:48:26.983", // if isRecurring => false
     "sendCronhookObject": true,
     "sendFailureAlert": true,
     "startsAt": "2023-02-01T13:00:00", // if isRecurring => true
     "endsAt": "2023-03-01T13:00:00" // if isRecurring => true
     "retryCount": "3", // if isRecurring => false
     "retryIntervalSeconds": "5" // if isRecurring => false
  }'

Response

{
  "id": "3a012d1f-fe83-4855-2860-84f8a85e154c",
  "groupId": "3a0136ac-123f-c222-5b2d-ae5b0c5937a6",
  "title": "Send email to inactive users",
  "description": "Send an email to users who are inactive for more than 60 days and offer a discount for upgrading subscriptions.",
  "url": "https://example.com/webhooks/inactive-email",
  "timezone": "asia/karachi",
  "method": "POST",
  "headers": {
    "additionalProp1": "string",
    "additionalProp2": "string",
    "additionalProp3": "string"
  },
  "payload": "{
      \"additionalProp1\": \"string\",
      \"additionalProp2\": \"string\",
      \"additionalProp3\": \"string\"
  }",
  "contentType": "application/json; charset=utf-8",
  "status": "scheduled",
  "errorMessage": "",
  "isRecurring": false,
  "cronExpression": "",
  "runAt": "2019-02-01T12:48:26.983",
  "sendCronhookObject": true,
  "sendFailureAlert": true,
  "startsAt": "2023-02-01T13:00:00",
  "endsAt": "2023-03-01T13:00:00",
  "retryCount": "3",
  "retryIntervalSeconds": "5",
  "creationTime": "2019-02-01T09:35:27.568Z",
  "lastModificationTime": "2019-02-01T09:35:27.568Z"
}
Retrieve a schedules

GET https://api.cronhooks.io/schedules/{id}

PARAMETERS

Name Required
id
The ID of the schedule to retrieve.
Required

REQUEST

curl "https://api.cronhooks.io/schedules/3a012d1f-fe83-4855-2860-84f8a85e154c" \
-H "Authorization: Bearer <YOUR_API_TOKEN>"

Response

{
  "id": "3a012d1f-fe83-4855-2860-84f8a85e154c",
  "groupId": "3a0136ac-123f-c222-5b2d-ae5b0c5937a6",
  "title": "Send email to inactive users",
  "description": "Send an email to users who are inactive for more than 60 days and offer a discount for upgrading subscriptions.",
  "url": "https://example.com/webhooks/inactive-email",
  "timezone": "asia/karachi",
  "method": "POST",
  "headers": {
    "additionalProp1": "string",
    "additionalProp2": "string",
    "additionalProp3": "string"
  },
  "payload": "{
      \"additionalProp1\": \"string\",
      \"additionalProp2\": \"string\",
      \"additionalProp3\": \"string\"
  }",
  "contentType": "application/json; charset=utf-8",
  "status": "scheduled",
  "errorMessage": "",
  "isRecurring": false,
  "cronExpression": "",
  "runAt": "2019-02-01T12:48:26.983",
  "sendCronhookObject": true,
  "sendFailureAlert": true,
  "startsAt": "2023-02-01T13:00:00",
  "endsAt": "2023-03-01T13:00:00",
  "retryCount": "3",
  "retryIntervalSeconds": "5",
  "creationTime": "2019-02-01T09:35:27.568Z",
  "lastModificationTime": "2019-02-01T09:35:27.568Z"
}
List all schedules

GET https://api.cronhooks.io/schedules?skip=0&limit=10

PARAMETERS

Name Required
skip
Number of records to skip.
Required
limit
Number of records to return in response.
Required

REQUEST

curl "https://api.cronhooks.io/schedules?skip=0&limit=10" \
-H "Authorization: Bearer <YOUR_API_TOKEN>"

Response

{
  "totalCount": 0,
  "items": [
    {
      "id": "3a012d1f-fe83-4855-2860-84f8a85e154c",
      "groupId": "3a0136ac-123f-c222-5b2d-ae5b0c5937a6",
      "title": "Send email to inactive users",
      "description": "Send an email to users who are inactive for more than 60 days and offer a discount for upgrading subscriptions.",
      "url": "https://example.com/webhooks/inactive-email",
      "timezone": "asia/karachi",
      "method": "POST",
      "headers": {
        "additionalProp1": "string",
        "additionalProp2": "string",
        "additionalProp3": "string"
      },
      "payload": "{
        \"additionalProp1\": \"string\",
        \"additionalProp2\": \"string\",
        \"additionalProp3\": \"string\"
      }",
      "contentType": "application/json; charset=utf-8",
      "status": "scheduled",
      "errorMessage": "",
      "isRecurring": false,
      "cronExpression": "",
      "runAt": "2019-02-01T12:48:26.983",
      "sendCronhookObject": true,
      "sendFailureAlert": true,
      "startsAt": "2023-02-01T13:00:00",
      "endsAt": "2023-03-01T13:00:00",
      "retryCount": "3",
      "retryIntervalSeconds": "5",
      "creationTime": "2019-02-01T09:35:27.568Z",
      "lastModificationTime": "2019-02-01T09:35:27.568Z"
    }
  ]
}
Delete a schedule

DELETE https://api.cronhooks.io/schedules/{id}

PARAMETERS

Name Required
id
The ID of the schedule to retrieve.
Required

REQUEST

curl "https://api.cronhooks.io/schedules/3a012d1f-fe83-4855-2860-84f8a85e154c" \
-X DELETE \
-H "Authorization: Bearer <YOUR_API_TOKEN>"

Response

200 OK
Trigger a schedule

POST https://api.cronhooks.io/schedules/{id}/trigger

PARAMETERS

Name Required
id
The ID of the schedule to retrieve.
Required

REQUEST

curl "https://api.cronhooks.io/schedules/3a012d1f-fe83-4855-2860-84f8a85e154c/trigger" \
-H "Authorization: Bearer <YOUR_API_TOKEN>"

Response

200 OK
Pause a schedule

POST https://api.cronhooks.io/schedules/{id}/pause

PARAMETERS

Name Required
id
The ID of the schedule to retrieve.
Required

REQUEST

curl "https://api.cronhooks.io/schedules/3a012d1f-fe83-4855-2860-84f8a85e154c/pause" \
-H "Authorization: Bearer <YOUR_API_TOKEN>"

Response

200 OK
Resume a schedule

POST https://api.cronhooks.io/schedules/{id}/resume

PARAMETERS

Name Required
id
The ID of the schedule to retrieve.
Required

REQUEST

curl "https://api.cronhooks.io/schedules/3a012d1f-fe83-4855-2860-84f8a85e154c/resume" \
-H "Authorization: Bearer <YOUR_API_TOKEN>"

Response

200 OK
Create a group

POST https://api.cronhooks.io/groups

PARAMETERS

Name Required
name
group name
Required
environmentVariables
group variables {}
Optional

REQUEST

curl "https://api.cronhooks.io/groups"
  -X POST \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer <YOUR_API_TOKEN>' \
  -d \
  '{
     "name": "Group #1",
     "environmentVariables": [{"key": "BASE_URL", "value": "https://example.com", protected: false}]
   }'

Response

{
  "id": "3a013346-7e3d-eaa5-feee-371f5f8614ad",
  "name": "Group #1",
  "environmentVariables": [{
    "key": "BASE_URL",
    "value": " https://example.com",
    "protected": false
  }],
  "creationTime": "2019-02-01T09:35:27.568Z",
  "lastModificationTime": "2019-02-01T09:35:27.568Z"
}
Update a group

PUT https://api.cronhooks.io/groups/{id}

PARAMETERS

Name Required
id
group id
Required
name
group name
Required
environmentVariables
group variables {}
Optional

REQUEST

curl "https://api.cronhooks.io/groups/3a013346-7e3d-eaa5-feee-371f5f8614ad"
  -X PUT \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer <YOUR_API_TOKEN>' \
  -d \
  '{
     "name": "Group #1",
     "environmentVariables": [{"key": "BASE_URL", "value": "https://example.com", protected: false}]
   }'

Response

{
  "id": "3a013346-7e3d-eaa5-feee-371f5f8614ad",
  "name": "Group #2",
  "environmentVariables": [{
    "key": "BASE_URL",
    "value": " https://example.com",
    "protected": false
  }],
  "creationTime": "2019-02-01T09:35:27.568Z",
  "lastModificationTime": "2019-02-01T09:35:27.568Z"
}
Retrieve a group

GET https://api.cronhooks.io/groups/{id}

PARAMETERS

Name Required
id
group id
Required

REQUEST

curl "https://api.cronhooks.io/groups/3a012d1f-fe83-4855-2860-84f8a85e154c" \
-H "Authorization: Bearer <YOUR_API_TOKEN>"

Response

{
  "id": "3a013346-7e3d-eaa5-feee-371f5f8614ad",
  "name": "Group #1",
  "environmentVariables": [{
    "key": "BASE_URL",
    "value": " https://example.com",
    "protected": false
  }],
  "creationTime": "2019-02-01T09:35:27.568Z",
  "lastModificationTime": "2019-02-01T09:35:27.568Z"
}
Retrieve a group by name

GET https://api.cronhooks.io/groups/getByName?name={name}

PARAMETERS

Name Required
name
group name
Required

REQUEST

curl "https://api.cronhooks.io/groups/getByName?name=Group%20%231" \
-H "Authorization: Bearer <YOUR_API_TOKEN>"

Response

{
  "id": "3a013346-7e3d-eaa5-feee-371f5f8614ad",
  "name": "Group #1",
  "environmentVariables": [{
    "key": "BASE_URL",
    "value": " https://example.com",
    "protected": false
  }],
  "creationTime": "2019-02-01T09:35:27.568Z",
  "lastModificationTime": "2019-02-01T09:35:27.568Z"
}
Retrieve or create a group by name

POST https://api.cronhooks.io/groups/name

PARAMETERS

Name Required
name
group name
Required
environmentVariables
group variables {}
Optional

REQUEST

curl "https://api.cronhooks.io/groups/name" \
-X POST \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer <YOUR_API_TOKEN>" \
-d \
'{
   "name": "Group #1",
   "environmentVariables": [{"key": "BASE_URL", "value": "https://example.com", protected: false}]
 }'

Response

{
  "id": "3a013346-7e3d-eaa5-feee-371f5f8614ad",
  "name": "Group #1",
  "environmentVariables": [{
    "key": "BASE_URL",
    "value": " https://example.com",
    "protected": false
  }],
  "creationTime": "2019-02-01T09:35:27.568Z",
  "lastModificationTime": "2019-02-01T09:35:27.568Z"
}
List all groups

GET https://api.cronhooks.io/groups?skip=0&limit=10

PARAMETERS

Name Required
skip
Number of records to skip.
Required
limit
Number of records to return in response.
Required

REQUEST

curl "https://api.cronhooks.io/groups?skip=0&limit=10" \
-H "Authorization: Bearer <YOUR_API_TOKEN>"

Response

{
  "totalCount": 2,
  "items": [
    {
      "id": "3a012d1f-fe83-4855-2860-84f8a85e154c",
      "name": "Group #1",
      "environmentVariables": [{
        "key": "BASE_URL",
        "value": " https://example.com",
        "protected": false
      }],
      "creationTime": "2019-02-01T09:35:27.568Z",
      "lastModificationTime": "2019-02-01T09:35:27.568Z"
    },
    {
      "id": "3a013346-7e3d-eaa5-feee-371f5f8614ad",
      "name": "Group #2",
      "environmentVariables": [],
      "creationTime": "2019-02-01T09:35:27.568Z",
      "lastModificationTime": "2019-02-01T09:35:27.568Z"
    }
  ]
}
Delete a group

DELETE https://api.cronhooks.io/groups/{id}

PARAMETERS

Name Required
id
group id
Required

REQUEST

curl "https://api.cronhooks.io/groups/3a012d1f-fe83-4855-2860-84f8a85e154c" \
-X DELETE \
-H "Authorization: Bearer <YOUR_API_TOKEN>"

Response

200 OK
List group schedules

GET https://api.cronhooks.io/groups/{groupId}/schedules?skip=0&limit=10

PARAMETERS

Name Required
groupId
group id
Required
skip
Number of records to skip.
Required
limit
Number of records to return in response.
Required

REQUEST

curl "https://api.cronhooks.io/groups/3a012d1f-fe83-4855-2860-84f8a85e154c/schedules?skip=0&limit=10" \
-H "Authorization: Bearer <YOUR_API_TOKEN>"

Response

{
  "totalCount": 2,
  "items": [
    {
      "id": "3a013346-7e3d-eaa5-feee-371f5f8614ad",
      "groupId": "3a012d1f-fe83-4855-2860-84f8a85e154c",
      "title": "Send email to inactive users",
      "description": "Send an email to users who are inactive for more than 60 days and offer a discount for upgrading subscriptions.",
      "url": "https://example.com/webhooks/inactive-email",
      "timezone": "asia/karachi",
      "method": "POST",
      "headers": {
        "additionalProp1": "string"
      },
      "payload": "{}",
      "contentType": "application/json; charset=utf-8",
      "isRecurring": true,
      "cronExpression": "*/5 * * * *",
      "nextRunAt": "2019-02-01T12:48:26.983",
      "sendCronhookObject": true,
      "sendFailureAlert": true,
      "startsAt": "2023-02-01T13:00:00",
      "endsAt": "2023-03-01T13:00:00",
      "retryCount": "1",
      "retryIntervalSeconds": "5",
      "creationTime": "2019-02-01T09:35:27.568Z",
      "lastModificationTime": "2019-02-01T09:35:27.568Z"
    }
  ]
}
Update variables

PUT https://api.cronhooks.io/environment-variables

PARAMETERS

Name Required
overwrite
Overwrite existing variables
Required
environmentVariables
Variables {}
Required

REQUEST

curl "https://api.cronhooks.io/environment-variables"
  -X PUT \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer <YOUR_API_TOKEN>' \
  -d \
  '{
      overwrite: false,
      environmentVariables: [
      {
        "key": "API_SECRET",
        "value": "sec_b1c4553be9dab17879b4a2ba2c5aecc2c13cafef",
        "protected": true
      }
      ]
  }'

Response

{
  "items": [
    {
      "key": "BASE_URL",
      "value": "https://api.cronhooks.io",
      "protected": false
    },
    {
      "key": "API_KEY",
      "value": "key_b1c4553be9dab17879b4a2ba2c5aecc2c13cafef",
      "protected": true
    },
    {
      "key": "API_SECRET",
      "value": "sec_b1c4553be9dab17879b4a2ba2c5aecc2c13cafef",
      "protected": true
    }
  ]
}
List all variables

GET https://api.cronhooks.io/environment-variables

REQUEST

curl "https://api.cronhooks.io/environment-variables" \
-H "Authorization: Bearer <YOUR_API_TOKEN>"

Response

{
  "items": [
    {
      "key": "BASE_URL",
      "value": "https://api.cronhooks.io",
      "protected": false
    },
    {
      "key": "API_KEY",
      "value": "key_b1c4553be9dab17879b4a2ba2c5aecc2c13cafef",
      "protected": true
    }
  ]
}
System variables

You can access the following system variables in your scheduled webhooks.

PARAMETERS

Name
_CRONHOOK_ID
Id of schedule
_RANDOM
a random number
_UUID
a random uuid
_TIMESTAMP
unix timestamp (seconds)
Escape braces
If you need to escape curly braces you can use this notation:
{%{ {{ escaped_string }} }%} // output => {{ escaped_string }}