Register a cron schedule
const url = 'https://example.com/v1/schedules';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"flowId":"example","flowVersion":"example","agentId":"example","agentVersion":"example","improve":{"agentId":"example","projectId":"2489E9AD-2EE2-8E00-8EC9-32D5F69181C0"},"projectId":"2489E9AD-2EE2-8E00-8EC9-32D5F69181C0","runAsServiceAccountId":"example","runAsProject":true,"config":{"cronExpression":"example","timezone":"example","input":"example"},"catchUp":"latest","overlap":"skip","startingDeadlineSeconds":1,"label":"example","toolsAllowedUnattended":["example"],"sendResultsTo":[{"to":"example","on":["completed"]}]}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://example.com/v1/schedules \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "flowId": "example", "flowVersion": "example", "agentId": "example", "agentVersion": "example", "improve": { "agentId": "example", "projectId": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0" }, "projectId": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "runAsServiceAccountId": "example", "runAsProject": true, "config": { "cronExpression": "example", "timezone": "example", "input": "example" }, "catchUp": "latest", "overlap": "skip", "startingDeadlineSeconds": 1, "label": "example", "toolsAllowedUnattended": [ "example" ], "sendResultsTo": [ { "to": "example", "on": [ "completed" ] } ] }'Registers a kind=cron trigger. nextFireAt is precomputed from the cron expression at register time; the cron scheduler in the runtime fires due triggers. Malformed cron expressions return 400 trigger-invalid-config without registering. An improve schedule is in the project it improves, one per agent and project (a second is 409 schedule-exists), and needs publish on the agent as well as write on the project. Any other schedule the caller registers for themselves, a person with no runAsServiceAccountId or runAsProject, takes run on the project (a runner keeps their own schedules); every other one takes write. toolsAllowedUnattended names the tools whose calls in its runs needn’t wait for a person’s yes, though a tool asks for one in a run no person started: naming it takes admin on the schedule’s project, each id must be a tool what it runs calls, and it’s audited (trigger-tools-allowed-unattended-set).
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Header Parameters
Section titled “Header Parameters”Request Bodyrequired
Section titled “Request Bodyrequired”Name what it runs: flowId with flowVersion, agentId (with an optional agentVersion), or improve (Improve runs). Registering needs write on the project and execute on what it runs; an improve schedule needs publish on the agent for that, and is in the project it improves. Its runs act as the caller.
object
Responses
Section titled “Responses”Schedule registered.
A schedule: what it runs (a flow at a version, or an agent), when (a cron expression in a timezone), as whom (its owner), and what it does after a gap or while a run is still going.
object
Example
{ "owner": { "kind": "user", "isProjectAccount": true }, "catchUp": "latest", "overlap": "skip", "status": "active", "pausedReason": "month-cap", "sendResultsTo": [ { "on": [ "completed" ] } ]}Malformed request body, or runAsProject with runAsServiceAccountId, or for a schedule with no project (bad-input). Or reference-out-of-scope: what it runs isn’t registered in the schedule’s project, its org or the workspace, or the version it names (flowVersion, or agentVersion when given) isn’t one that project runs (details.issues, at /target, whose message names the version). Nothing is registered.
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}Missing / malformed / expired / revoked bearer token.
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}permission-denied: no write on the schedule’s project (run, for a person’s own schedule) or no execute on what it runs (for an improve schedule, publish on the agent); or no admin on the project where it’s needed, for toolsAllowedUnattended or runAsProject; or no act_as on the account runAsServiceAccountId names.
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}runAsServiceAccountId names an unregistered account (service-account-unregistered), a project’s own account (service-account-project-owned: name it with runAsProject), or one that can’t run what the schedule runs (trigger-owner-cannot-run-target). Or, with runAsProject, the project’s own account can’t run what the schedule runs either (trigger-owner-cannot-run-target; the account stays, for the next runAsProject), or an active account someone made already has the project account’s name, project-<projectId> (service-account-name-taken: a tenant admin can unregister it). schedule-exists: the agent has an Improve schedule in the project already (details.scheduleId). Or an idempotency conflict. Or idempotency-key-in-flight (with Retry-After): a request with the same Idempotency-Key still runs, so this one wasn’t run; send it again after Retry-After to get that request’s answer.
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}Headers
Section titled “Headers”The request body is over the API’s limit (request-too-large; details.maxBytes says how much).
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}rate-limit-exceeded with details.limit: "api-requests", on a runtime that sets workspace limits (Kindgi Cloud): this workspace’s limit on API requests a minute is reached, so the request wasn’t run; Retry-After says when to send it again.
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}Headers
Section titled “Headers”Server error (unmapped domain code or framework crash).
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}trigger-operation-unsupported: runAsProject on a runtime that can’t make a project’s own account.
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}The Idempotency-Key store (idempotency-store-unavailable) or the authorization store (authz-backend-unavailable) couldn’t be reached before the request ran, or the database was too busy for its authorization check (database-busy), so nothing was changed; Retry-After (whole seconds) says when to try again with the same key. Or tenant-state-unavailable (with Retry-After), on a runtime serving many workspaces: the workspace’s state couldn’t be read, so nothing was changed.
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}Headers
Section titled “Headers”See also
GET /v1/schedules: List cron schedules- Error code
authz-backend-unavailable - Error code
bad-input - Error code
database-busy - Error code
idempotency-key-in-flight - Error code
idempotency-store-unavailable - Error code
permission-denied - Error code
rate-limit-exceeded - Error code
reference-out-of-scope - Error code
request-too-large - Error code
schedule-exists - Error code
service-account-name-taken - Error code
service-account-project-owned - Error code
service-account-unregistered - Error code
tenant-state-unavailable - Error code
trigger-operation-unsupported - Error code
trigger-owner-cannot-run-target - Every error code