Skip to main content

Overview

Update an existing cron job. When you update a cron job, all pending events created by that cron are automatically deleted and new events will be generated based on the updated schedule.
import { cuey } from "cuey";

const updatedCron = await cuey.crons.update("cron-id", {
  webhook_url: "https://api.example.com/webhook",
  cron_expression: "*/30 * * * *", // Every 30 minutes
  timezone: "America/New_York",
  is_active: true,
});

Parameters

id
string
required
The UUID of the cron job to update.
webhook_url
string
required
The full URL of the webhook endpoint to call. Must be a valid HTTP/HTTPS URL.
method
string
HTTP method to use for the webhook request. Options: GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS. Defaults to POST.
cron_expression
string
required
Cron expression defining the schedule (e.g., 0 9 * * * for daily at 9 AM).
timezone
string | null
Timezone for the cron schedule (e.g., America/New_York). null for UTC.
headers
object | null
Custom headers to include in the webhook request. Object with string keys and values.
payload
object | null
Payload to send with the webhook request. Can be any JSON-serializable object.
retry_config
object | null
Retry configuration for failed webhook attempts.
is_active
boolean
Whether the cron job should be active. true to activate, false to deactivate.

Response

cron
Cron
required
The updated cron job object.
{
  "id": "cron-uuid-here",
  "cron_expression": "*/30 * * * *",
  "timezone": "America/New_York",
  "webhook_url": "https://api.example.com/webhook",
  "method": "POST",
  "headers": null,
  "payload": null,
  "retry_config": null,
  "is_active": true,
  "created_at": "2024-01-15T10:30:00Z",
  "updated_at": "2024-01-16T12:00:00Z",
  "team_id": "team-uuid-here"
}

Errors

When you update a cron job, all pending events created by that cron are automatically deleted and new events will be generated based on the updated schedule.
  • NotFoundError: If the cron job doesn’t exist
  • ValidationError: If the update data is invalid (e.g., invalid cron expression)
  • UnauthorizedError: If API key is invalid or missing

Examples

Update Cron Schedule

import { cuey } from "cuey";

const cron = await cuey.crons.get("cron-id");

const updated = await cuey.crons.update(cron.id, {
  webhook_url: cron.webhook_url,
  method: cron.method,
  cron_expression: "*/30 * * * *", // Change to every 30 minutes
  timezone: cron.timezone,
  is_active: cron.is_active,
});

console.log("Cron updated:", updated.id);

Toggle Cron Active Status

import { cuey } from "cuey";

const cron = await cuey.crons.get("cron-id");

// Temporarily disable
await cuey.crons.update(cron.id, {
  webhook_url: cron.webhook_url,
  method: cron.method,
  cron_expression: cron.cron_expression,
  timezone: cron.timezone,
  is_active: false,
});

// Later, reactivate
await cuey.crons.update(cron.id, {
  webhook_url: cron.webhook_url,
  method: cron.method,
  cron_expression: cron.cron_expression,
  timezone: cron.timezone,
  is_active: true,
});