Skip to content

Update a Cron Job

Update a cron job.

Method

PATCH

Endpoint

https://api.easycron.com/v1/cron-jobs/{cron_job_id}

Example API call

Terminal window
curl \
--include \
--request PATCH \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <API_KEY>' \
--data '{"cron_job_name": "newCronJobName"}' \
"https://api.easycron.com/v1/cron-jobs/{cron_job_id}"

Example Success Response

Together with the HTTP code 200, 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

nametypedescriptionlimits
urlstringURL to call.Maximum 1024 chars
cron_expressionstringCron expression following these syntax.Maximum 1000 chars
http_auth_userstringHTTP basic authentication user.Maximum 100 chars
http_auth_pwstringHTTP basic authentication password.Maximum 100 chars
timezone_fromintSpecify the source of timezone used to calculate the executing times of the cron job.
Allowed values:
  • 1: use the timezone in your EasyCron account.
  • 2: use the timezone in the cron job.
timezoneintTimezone used to calculate executing times when timezone_from = 2.
Allowed values: TZ Timezones.
http_methodstringHTTP method used in the HTTP requests to your cron job script.
Allowed values: GET, POST, HEAD, PUT, PATCH, DELETE, CONNECT, OPTIONS and TRACE.
http_headersstringHTTP headers sent with the HTTP requests to your cron job script.Maximum 10240 chars
http_message_bodystringHTTP 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&param2=val2 or {"name":"John","age":30}.Maximum 10240 chars
timeoutintThe 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:
  • 0: use your plan’s default timeout.
  • Any value up to your plan’s default timeout.
success_criterionintRules for considering if the execution of a cron job succeeded or failed.
Allowed values:
  • 1: consider execution succeeded when the HTTP code is 2xx.
  • 2: consider execution succeeded when the HTTP code is 2xx and the HTTP body messge matches success_regexp.
  • 3: consider execution failed when the HTTP code is 2xx and the HTTP body messge matches failure_regexp.
success_regexpstringThe regular expression to match when success_criterion is set to 2.Maximum 255 chars
failure_regexpstringThe regular expression to match when success_criterion is set to 3.Maximum 255 chars
send_emailintEmail notification setting of the cron job.
Allowed values:
  • 0: never send email notification.
  • 1: send email if execution fails.
email_thresholdintOnly after encountering this amount of failures, the failure notification email will get sent.
Allowed values: 1 to 5.
send_slackintSlack notification setting of the cron job.
Allowed values:
  • 0: never send Slack notification.
  • 1: send Slack notification if execution fails.
  • 2: send Slack notification after each execution.
slack_sensitivityintOnly after encountering this amount of failures, the failure Slack notification will get sent.
Allowed values: 1 to 5.
slack_urlstringURL that the Slack notification is sent to.Maximum 1024 chars
send_webhookintWebhook notification setting of the cron job.
Allowed values:
  • 0: never send webhook notification.
  • 1: send webhook if execution fails.
  • 2: send webhook after each execution.
webhook_urlstringURL that the webhook request is sent to.Maximum 1024 chars
webhook_http_methodstringHTTP method that your cron job webhook requests will use.
Allowed values: GET, POST, HEAD, PUT, PATCH, DELETE, CONNECT, OPTIONS and TRACE.
webhook_datastring arrayInformation 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"]
statusintStatus of the cron job.
Allowed values:
  • 0: create a disabled cron job.
  • 1: create an enabled cron job.
cron_job_namestringName of the cron job.Maximum 100 chars
descriptionstringDescription of the cron job.Maximum 1024 chars
cron_job_group_idintGroup 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.