Skip to main content

Update a Cron Job

caution

Cron jobs are currently in ALPHA and are not considered stable. This feature may change at any time, please use with caution.

Updates a given Cron job

PUT https://app.jiter.dev/api/cronjobs/:cronJobId

Request Parameters

ParameterDescriptionExample
cronJobIdID of the cron job you want to update3

Request Body Parameters

ParameterDescriptionExample
payloadYour stringified payload'{"action":"buyGroceriesReminder","values":["eggs","bacon","pasta","bread"]}'
destinationThe endpoint we should send your cron payload tohttps://your-app.com/webhooks/jiter
expressionA cron expression* * * * *
statusThe cron job status, Active or DisabledDisabled

Response

CodeDescription
200Cron job updated successfully
404We were unable to find the cron job
500Unable to edit the cron job

Example Usage

index.ts
import axios from "axios";

const apiBaseUrl = "https://app.jiter.dev/api";

const updateCronJob = async () => {
try {
const { data } = await axios.put(
`${apiBaseUrl}/cronjobs/3`,
{
status: "Disabled",
},
{ headers: { "x-api-key": "YOUR_API_KEY" } }
);

console.log("cron job updated 🎉", data);
} catch (error) {
console.log("Unable to update cron job", error);
}
};

updateCronJob();

Example Success Response

{
"id": "9",
"history": [],
"status": "Disabled",
"destination": "https://your-app.com/webhooks/jiter",
"org": "3",
"payload": "{'action':'buyGroceriesReminder','values':['eggs','bacon','pasta','bread']}",
"expression": "* * * * *",
"nextExecutionStatus": "Pending",
"nextExecutionDate": "2022-10-25T18:27:00.000Z",
"createdAt": "2022-10-25T18:26:04.000Z",
"updatedAt": "2022-10-25T18:26:04.000Z"
}

Example Error Response

{
"message": "'status' must be one of 'Active' or 'Disabled'"
}