Overview
All types are exported from the cuey package. This page provides a complete reference of all available types.
Importing Types
import type {
Cron,
Event,
HttpMethod,
EventStatus,
RetryConfig,
CreateCronInput,
UpdateCronInput,
CreateEventInput,
UpdateEventInput,
CronsQueryParams,
EventsQueryParams,
CueyConfig,
} from "cuey";
Core Types
Cron
Represents a recurring cron job.
Interface representing a cron job.
Unique identifier (UUID).
Cron expression defining the schedule (e.g., 0 0 * * *).
Timezone for the cron schedule (e.g., America/New_York). null for UTC.
Webhook URL that will be called.
HTTP method used for the webhook request.
Custom headers to include in the webhook request. null if not set.
Payload to send with the webhook request. null if not set.
Retry configuration for failed webhooks. null if not set.Show RetryConfig properties
Maximum retry attempts. Range: 1-10.
Backoff delay in milliseconds. Range: 100-5000.
Backoff strategy. Values: exponential, linear.
Whether the cron job is active. null defaults to true.
ISO 8601 timestamp when the cron job was created.
ISO 8601 timestamp when the cron job was last updated.
Team ID associated with the cron job.
Event
Represents a scheduled event.
Interface representing a scheduled event.
Unique identifier (UUID).
Parent cron ID if this event was created by a cron job. null if created manually.
Original event ID if this is a retry attempt. null for original events.
ISO 8601 timestamp when the event is scheduled to execute.
ISO 8601 timestamp when the event was executed. null if not yet executed.
Current status of the event. See EventStatus type for possible values.
Webhook URL that will be called.
HTTP method used for the webhook request.
Custom headers included in the webhook request. null if not set.
Payload sent with the webhook request. null if not set.
Retry configuration for failed webhooks. null if not set.
HTTP status code from the webhook response. null if not yet executed.
Response headers from the webhook. null if not yet executed.
Response body from the webhook (truncated to 1_KB). null if not yet executed.
Duration of the webhook request in milliseconds. null if not yet executed.
Error message if the webhook execution failed. null if successful or not yet executed.
ISO 8601 timestamp when the event was created.
ISO 8601 timestamp when the event was last updated.
Team ID associated with the event.
HttpMethod
Supported HTTP methods for webhook requests.
Union type of supported HTTP methods.
POST request method (default).
EventStatus
Status values for event execution.
Union type of event status values.
Event is scheduled but not yet executed.
Event is currently being executed.
Event executed successfully.
Event execution failed (after all retries).
RetryConfig
Retry configuration for webhooks.
Interface for retry configuration.Show RetryConfig properties
Maximum retry attempts. Range: 1-10.
Backoff delay in milliseconds. Range: 100-5000.
Backoff strategy. Values: exponential, linear.
Json
JSON type for API payloads.
Recursive union type representing any JSON-serializable value.
Object with string keys and Json values.
Input for creating a cron job.
Interface for creating a cron job.Show CreateCronInput properties
Full URL or relative path of the webhook endpoint.
HTTP method to use. Defaults to POST.
Cron expression defining the schedule.
Timezone for the cron schedule. null for UTC.
Custom headers to include in the webhook request.
Payload to send with the webhook request.
Retry configuration for failed webhooks.
Whether the cron job should be active immediately. Defaults to true.
Input for updating a cron job (same structure as CreateCronInput).
Interface for updating a cron job. Same structure as CreateCronInput.
Input for creating an event.
Interface for creating an event.Show CreateEventInput properties
Full URL or relative path of the webhook endpoint.
HTTP method to use. Defaults to POST.
ISO 8601 timestamp when the event should execute. Must be in the future.
Custom headers to include in the webhook request.
Payload to send with the webhook request.
Retry configuration for failed webhooks.
Input for updating an event (same structure as CreateEventInput).
Interface for updating an event. Same structure as CreateEventInput.
Query Parameter Types
CronsQueryParams
Query parameters for listing crons.
Interface for query parameters when listing crons.Show CronsQueryParams properties
Page number (0-indexed). Defaults to 0.
Number of items per page. Range: 1-1000. Defaults to 100.
Filter by active status. true for active crons, false for inactive crons.
EventsQueryParams
Query parameters for listing events.
Interface for query parameters when listing events.Show EventsQueryParams properties
Page number (0-indexed). Defaults to 0.
Number of items per page. Range: 1-1000. Defaults to 100.
Filter events by the cron job that created them.
Configuration Types
CueyConfig
Configuration options for the Cuey client.
Interface for Cuey client configuration.Show CueyConfig properties
Base URL for resolving relative webhook URLs.
API key for authentication.
API Response Types
ApiSuccess
Standard API success response.
Generic interface for API success responses.Show ApiSuccess properties
The response data. Type parameter T represents the data type.
Paginated API success response.
Generic interface for paginated API success responses.Show ApiSuccessWithPagination properties
Array of response items. Type parameter T represents the item type.
Pagination information.Show Pagination properties
Current page number (0-indexed).
Number of items per page.
Total number of items across all pages.
Error Types
See the Error Handling page for complete error type documentation.
Base error class for all Cuey API errors. Extends JavaScript’s Error.
Union type of all possible error codes.Show CueyErrorCode values
Authentication failed or API key is invalid/missing.
Requested resource does not exist.
Request validation failed.
Type Guards and Utilities
Checking Event Status
function isPending(event: Event): boolean {
return event.status === "pending";
}
function isSuccess(event: Event): boolean {
return event.status === "success";
}
function isFailed(event: Event): boolean {
return event.status === "failed";
}
Type Narrowing
function handleEvent(event: Event) {
switch (event.status) {
case "pending":
// TypeScript knows event.status is "pending"
console.log("Scheduled for:", event.scheduled_at);
break;
case "success":
// TypeScript knows event.status is "success"
console.log("Response:", event.response_status);
break;
case "failed":
// TypeScript knows event.status is "failed"
console.log("Error:", event.response_error);
break;
}
}
Type-Safe Payload Handling
interface MyPayload {
action: string;
userId: string;
data: Record<string, unknown>;
}
const cron = await cuey.crons.create({
webhook_url: "https://api.example.com/webhook",
cron_expression: "0 0 * * *",
payload: {
action: "daily_report",
userId: "123",
data: {},
} satisfies MyPayload,
});
Error Handling
Learn about error types and handling.
Advanced Configuration
Learn about configuration options.
Events
See events resource methods.
Crons
See crons resource methods.