SDK API Reference
CloudClient
import { CloudClient } from "@cronlet/sdk";
const cronlet = new CloudClient({ apiKey: process.env.CRONLET_API_KEY!, baseUrl: process.env.CRONLET_BASE_URL, orgId: "org_123", userId: "user_456", role: "admin",});Constructor options
interface CloudClientOptions { apiKey: string; baseUrl?: string; orgId?: string; userId?: string; role?: "viewer" | "member" | "admin" | "owner";}tasks
tasks.create(input, createdBy?)
Creates a task.
source is not a caller-managed field in normal SDK usage:
- direct SDK calls are sent with
source: "sdk" - calls made through the agent/MCP path with
createdBy.type === "agent"are sent withsource: "mcp"
const task = await cronlet.tasks.create( { name: "Daily report", handler: { type: "webhook", url: "https://api.example.com/report", method: "POST", }, schedule: { type: "daily", times: ["09:00"], }, timezone: "UTC", retryAttempts: 1, retryBackoff: "linear", retryDelay: "1s", timeout: "30s", active: true, }, { type: "agent", id: "assistant_123", name: "support-agent", });Input shape:
interface TaskCreateRequest { name: string; description?: string; handler: HandlerConfigInput; schedule: ScheduleConfigInput | string; timezone?: string; retryAttempts?: number; retryBackoff?: "linear" | "exponential"; retryDelay?: string; timeout?: string; active?: boolean; callbackUrl?: string; metadata?: Record<string, unknown>; maxRuns?: number; expiresAt?: string;}tasks.list()
const tasks = await cronlet.tasks.list();tasks.get(taskId)
const task = await cronlet.tasks.get(taskId);tasks.patch(taskId, input)
await cronlet.tasks.patch(taskId, { active: false, maxRuns: null, callbackUrl: null,});tasks.delete(taskId)
await cronlet.tasks.delete(taskId);tasks.trigger(taskId)
const run = await cronlet.tasks.trigger(taskId);tasks.pause(taskId)
Equivalent to patch(taskId, { active: false }).
tasks.resume(taskId)
Equivalent to patch(taskId, { active: true }).
runs
runs.list(taskId?, limit?)
const allRuns = await cronlet.runs.list();const taskRuns = await cronlet.runs.list(taskId, 20);runs.get(runId)
const run = await cronlet.runs.get(runId);secrets
secrets.list()
const secrets = await cronlet.secrets.list();secrets.create(input)
await cronlet.secrets.create({ name: "SLACK_TOKEN", value: "xoxb-...",});secrets.delete(name)
await cronlet.secrets.delete("SLACK_TOKEN");usage
usage.get()
const usage = await cronlet.usage.get();audit
audit.record(input)
This is exposed by the SDK but documented as internal-use oriented.
await cronlet.audit.record({ action: "task.created", targetType: "task", targetId: "task_123", actorType: "agent", actorId: "assistant_456", metadata: { source: "agent-loop", },});Return types you will see often
TaskRecord
Notable fields:
idorgIdnamedescriptionsourcehandlerTypehandlerConfigscheduleTypescheduleConfigtimezonenextRunAtretryAttemptsretryBackoffretryDelaytimeoutactivecreatedBycallbackUrlmetadatamaxRunsexpiresAtrunCountcreatedAtupdatedAt
source is one of:
"dashboard""mcp""sdk"
Reference shape:
interface TaskRecord { id: string; orgId: string; name: string; description: string | null; source: "dashboard" | "mcp" | "sdk"; handlerType: HandlerType; handlerConfig: HandlerConfig; scheduleType: ScheduleType; scheduleConfig: ScheduleConfig; timezone: string; nextRunAt: string | null; retryAttempts: number; retryBackoff: "linear" | "exponential"; retryDelay: string; timeout: string; active: boolean; createdBy: CreatedBy | null; callbackUrl: string | null; metadata: Record<string, unknown> | null; maxRuns: number | null; expiresAt: string | null; runCount: number; createdAt: string; updatedAt: string;}RunRecord
Notable fields:
idtaskIdstatustriggerattemptdurationMsoutputlogserrorMessage
Tool exports
import { cronletTools, openaiTools, anthropicTools, langchainTools, createToolHandler,} from "@cronlet/sdk";cronletTools
cronletTools.openaicronletTools.anthropiccronletTools.langchaincronletTools.definitionscreateToolHandler(client)
Returns helpers for:
execute(name, args)handleOpenAI(toolCall)handleAnthropic(toolUse)
CronletError
import { CronletError } from "@cronlet/sdk";
try { await cronlet.tasks.get("missing");} catch (error) { if (error instanceof CronletError) { console.log(error.message); console.log(error.code); console.log(error.status); }}Current behavioral notes
CloudClientassumes JSON API responses and throwsCronletErroron non-OK payloads.tasks.create()andtasks.patch()accept schedule objects and supported schedule strings.
REST reference
GET /v1/org-status
Returns a viewer-readable org setup snapshot used by the dashboard.
Response shape:
interface OrgStatusSnapshot { hasApiKeys: boolean;}Current fields:
hasApiKeys:trueif the organization has at least one API key configured- string schedules are parsed client-side into
ScheduleConfigobjects before request serialization. - naive
oncedatetime strings are interpreted as UTC unless the string includes timezone information. - Use the SDK from server-side code only.
Reference types
For exact TypeScript shapes, see:
packages/cloud-sdk/src/client.tspackages/cloud-sdk/src/tools.tspackages/cloud-shared/src/types.tspackages/cloud-shared/src/schemas.ts