Overview

The Automation API surfaces Gizzi Code’s cron/routine/loop runtime through the Allternit platform API. A goal is a platform-owned objective that can own routines (persistent scheduled jobs) and loops (session-scoped recurring jobs). Routines and loops can execute locally or in the cloud via the Gizzi cron daemon.

Base URL

For local development:

Authentication

All automation routes require a valid bearer token. See Authentication.

Data models

Goal

Routine

The local scheduler keeps these keys in metadata:

Loop

Endpoints

Goals

Routines

Loops

Local scheduler

Create a goal

Request body

Example request

Example response

Create a routine

Request body

Example request

Example response

Routines and bots

A local routine runs as a turn in its bot’s chat, so it must have a bot.
  • POST /routines without agent_id for a local routine returns 400 with {"error": "agent_required", "message": "..."}. An agent_id that names no agent returns 400 agent_not_found.
  • Local routines that have no bot (created before this rule) are never run. The scheduler sets metadata.needsAgent = true and clears next_run_at; the Bots UI lists them under Needs a bot.

Assign a routine to a bot

Sets the routine’s bot, removes needsAgent, consecutiveFailures and autoPaused, and resets next_run_at so the scheduler arms the next run from the schedule. Other fields are unchanged. An empty agent_id means no change; a routine cannot be unassigned.

Pause, resume and automatic pause

PUT with {"status": "paused"} pauses a routine; {"status": "active"} resumes it and clears consecutiveFailures and autoPaused, so it gets 3 more tries. After 3 failed runs in a row the scheduler sets status to paused, records metadata.autoPaused, and appends a routine.paused event to the bot’s activity ledger (next to the routine.failed event for each failed run).

Trigger a routine

Local routines run at once on this API and answer {"status": "running", "routineId": "...", "domain": "local"}; the result lands in the run history and the bot’s chat. A local routine with no bot returns 409 agent_required; one that is already running returns 409 already_running. Cloud routines run through the Gizzi cron daemon.

List routine runs

Returns stored runs for the routine, newest first, and for cloud routines attempts to sync the latest history from the Gizzi cron daemon. A local run’s row is written with status: "running" when it starts and completed in place when it ends. Its metadata holds: status is one of running, succeeded, failed, skipped or cancelled (stopped; a cloud run the daemon reports as aborted is stored as cancelled). A run left running when the API stopped is marked failed with outcome_reason: "runtime_restart" at the next start.

Example response

Recent runs in the routine list

Each routine gains recentRuns, newest first, for a run-history strip without one request per routine. A local run in progress is listed first with status: "running" even before its row is read.

Watch a run in progress

While a local run is going this reads its thread and answers {"running": true, "runId", "startedAt", "sessionId", "steps", "apps", "model", "text", "canStop": true}. steps is the turn’s todo list so far and text is the last 600 characters it has written. For a cloud run it answers running with empty steps and apps (the daemon does not report them). When nothing is running it answers {"running": false}. Poll it every few seconds while a run is going.

Stop a run

Cancels the run’s turn. The run ends with status: "cancelled", outcome_reason: "stopped" and the text it had written as output. A stopped run does not count toward the automatic pause and opens no “Something needs fixing” item. Answers {"status": "stopping", "runId"}. A run that already finished returns 409 not_running. For a cloud routine the API asks the Gizzi cron daemon to stop the job’s run (POST /jobs/:id/abort); a daemon too old to stop runs returns 502 stop_failed.

Create a loop

Same request shape as a routine, plus an optional session_id and expires_at.

List local schedules

Returns all routines and loops whose execution_domain is local.

Example response

Routines and loops tied to a thread

A routine or loop created from inside a bot thread belongs to that thread. On create, when metadata.sessionId (routine) or sessionId (loop) is one of a thread’s sessions, the server stamps metadata.sourceThreadId. When the thread is resolved, archived or paused by its owner, its tied routines and loops are set to paused with metadata.closedWithThread, and the matching Gizzi cron jobs stop. Reopening the thread sets them back to active. See Threads and subagents.

Error codes

Cloud by default

When the account has a cloud computer (paid plans; free accounts don’t get one), the apps (Desktop, ai.allternit.com, m.allternit.com) create new routines on the cloud computer, so they run with your own computer closed:
  • The cloud computer is the first wakeable runtime in GET /api/v1/runtime-presence, the same list the bot’s Stay on picker uses.
  • The routine is created on that computer’s own API. When the page talks to another computer, the request goes through the cloud relay (POST /api/v1/runtime-devices/:id/proxy). The routine list shows both computers’ routines, and calls for a cloud routine (run, runs, live, stop, metrics, edit, delete) go to the cloud computer.
  • Changing Runs on for a routine moves it: it is created on the other computer and removed from the first. Its run history stays behind.
  • Event-triggered routines and phone-skill replays stay on this computer, since they depend on it.
  • The bot has to exist on the cloud computer, so the app copies it there first, every time (an upsert, so Soul and memory edits stay fresh): GET /api/v1/agents/:id/package on this computer, then PUT /api/v1/agents/:id/package on the cloud computer through the relay. See Copy a bot to another computer. If the copy fails, nothing is saved and the app says Couldn't copy <bot name> to your cloud computer: <reason>. A create for a bot the computer doesn’t have still fails with agent_not_found.
  • The cloud computer needs its own brain sign-in: model sign-ins are not copied.
  • A run on the cloud computer that finds a brain signed out fails with reason lane_blocked, and the app shows “Something needs fixing” as for any failed run.