Add a Cron Job
Add a cron job.
Method
POSTEndpoint
https://api.easycron.com/v1/cron-jobsExample API call
curl \--include \--request POST \--header 'Content-Type: application/json' \--header 'X-API-Key: <API_KEY>' \--data '{"url": "https://www.example.com", "cron_expression": "* * * * * *"}' \"https://api.easycron.com/v1/cron-jobs"Example Success Response
Together with the HTTP code 201, the following content will be responded:
{"cron_job_id":CRON_JOB_ID}Example Failure Response
Together with the HTTP code of the error, the following error message will be responded:
{"message":"ERROR_MESSAGE"}JSON Parameters in Request Body
| name | type | required | default | description | limits |
|---|---|---|---|---|---|
| url | string | required | URL to call. | Maximum 1024 chars | |
| cron_expression | string | required | Cron expression following these syntax. | Maximum 1000 chars | |
| http_auth_user | string | optional | HTTP basic authentication user. | Maximum 100 chars | |
| http_auth_pw | string | optional | HTTP basic authentication password. | Maximum 100 chars | |
| timezone_from | int | optional | 1 | Specify the source of timezone used to calculate the executing times of the cron job. Allowed values:
| |
| timezone | int | optional | UTC | Timezone used to calculate executing times when timezone_from = 2.Allowed values: TZ Timezones. | |
| http_method | string | optional | GET | HTTP method used in the HTTP requests to your cron job script. Allowed values: GET, POST, HEAD, PUT, PATCH, DELETE, CONNECT, OPTIONS and TRACE. | |
| http_headers | string | optional | HTTP headers sent with the HTTP requests to your cron job script. | Maximum 10240 chars | |
| http_message_body | string | optional | HTTP message body sent with the HTTP requests to your cron job script if the HTTP method is POST, PUT or PATCH. It contains variable-value pairs or JSON payload. E.g. param1=val1¶m2=val2 or {"name":"John","age":30}. | Maximum 10240 chars | |
| timeout | int | optional | 0 | The max allowed execution time (in seconds) of your cron job. Execeeding this time, your cron job will time out and be marked as “failed”. Allowed values:
| |
| success_criterion | int | optional | 1 | Rules for considering if the execution of a cron job succeeded or failed. Allowed values:
| |
| success_regexp | string | optional | The regular expression to match when success_criterion is set to 2. | Maximum 255 chars | |
| failure_regexp | string | optional | The regular expression to match when success_criterion is set to 3. | Maximum 255 chars | |
| send_email | int | optional | 0 | Email notification setting of the cron job. Allowed values:
| |
| email_threshold | int | optional | 1 | Only after encountering this amount of failures, the failure notification email will get sent. Allowed values: 1 to 5. | |
| send_slack | int | optional | 0 | Slack notification setting of the cron job. Allowed values:
| |
| slack_sensitivity | int | optional | 1 | Only after encountering this amount of failures, the failure Slack notification will get sent. Allowed values: 1 to 5. | |
| slack_url | string | optional, required if send_slack is 1 or 2 | URL that the Slack notification is sent to. | Maximum 1024 chars | |
| send_webhook | int | optional | 0 | Webhook notification setting of the cron job. Allowed values:
| |
| webhook_url | string | optional, required if send_webhook is 1 or 2 | URL that the webhook request is sent to. | Maximum 1024 chars | |
| webhook_http_method | string | optional | GET | HTTP method that your cron job webhook requests will use. Allowed values: GET, POST, HEAD, PUT, PATCH, DELETE, CONNECT, OPTIONS and TRACE. | |
| webhook_data | string array | optional | Information that your cron job webhook requests will send. Valid values include CRON_JOB_ID, CRON_JOB_NAME, CRON_JOB_URL, CRON_JOB_HTTP_STATUS_CODE, CRON_JOB_EXECUTION_STATUS and CRON_JOB_EXECUTION_ERROR. E.g. ["CRON_JOB_ID","CRON_JOB_NAME"] | ||
| status | int | optional | 1 | Status of the cron job. Allowed values:
| |
| cron_job_name | string | optional | Name of the cron job. | Maximum 100 chars | |
| description | string | optional | Description of the cron job. | Maximum 1024 chars | |
| cron_job_group_id | int | optional | 0 | Group ID of the cron job. You could find the group ID in the group pages. If this parameter is set to 0, the cron job doesn’t belong to any group. |