Skip to main content
POST
Create a Loop
A Loop woken by events opens a Session per event; webhook events sharing an X-Webhook-Correlation-Key continue one Session. A Loop with a webhook returns webhook.url and webhook.key in this response only; store the key now, it is never readable again. The workspace’s plan and credits must be able to run the Loop’s model (402 loop_model_not_fundable). A workspace holds at most 2,000 live Loops across everyone in it; a new one past that is refused with 409 loop_limit_reached (existing Loops keep running). Its schedules together may run at most 1,000 times a day; a schedule past that is refused with 409 schedule_budget_reached, whose message gives the counts. Scope: automations:write

Authorizations

Authorization
string
header
required

Your Reason API key from Settings › API keys. New keys use reason_; legacy ara_ keys remain accepted. Keys are capability-scoped: run, mcp:read, mcp:write, secrets:read, secrets:write, sessions:read, sessions:debug, devices:read, devices:write, devices:use, computers:read, computers:write, ssh:write, knowledge:read, memory:read, memory:write, skills:read, skills:write, pages:read, pages:write, repos:read, repos:write, reviews:read, reviews:write, deployment:read, analytics:read, org:read, org:write, attachments:read, attachments:write, guardrails:read, guardrails:write, network:read, network:write, automations:read, automations:write, agent_auth:read. devices:write, devices:use, computers:read, computers:write, ssh:write, network:read and network:write are opt-in, excluded from default keys. computers:read lists visible cloud and connected computers without waking them or granting execution access. devices:read discovers local Device targets; devices:use separately consents to local execution, so a discover-and-run local workflow needs both. devices:write manages enrollment and device grants; computers:write creates or deletes cloud computers; ssh:write manages retained SSH access. network:read reads the saved workspace network policy; network:write replaces custom allowed hosts and requires a current organization owner/admin. Legacy project PATCH requests containing network_allowed_hosts also require network:write plus their existing run scope and project management permission; saved project hosts do not affect current session egress. Only owners/admins can mint or manage keys with network:write; keys cannot grant themselves more authority. See /docs/network-policies for replacement semantics and runtime applicability. mcp:write manages MCP server configuration only; it does not authorize remote MCP-tool execution. sessions:read reads sessions, including the assistant, reasoning and tool activity in their events. sessions:debug is privileged: only for organization owners/admins, it expands session events to the full diagnostic projection (diagnostic event kinds, status text and raw event metadata).

Scopes

automations:write

Path Parameters

orgId
string
required

Organization id or slug. Resolve it with GET /v3/self.

reasonId
string<uuid>
required

The Reason id, returned as id by listReasons and createReason.

Body

application/json

A new Loop filed under the Reason. It is the caller's: its runs act as the Reason, are billed to the workspace as the caller's, and need the caller's access to any Session, computer, repository or Slack channel it names.

prompt
string
required

The instructions the Reason follows on each wake. An event's body reaches it as untrusted data, never as instructions.

Required string length: 1 - 100000
wake_on
object[]
required

Everything that wakes the Loop: at most one schedule, one webhook and one Slack listener, and GitHub events on one repository. A Loop woken by several things at once is in early access for some workspaces (403 wake_on_unavailable elsewhere). On update it replaces what wakes the Loop.

Required array length: 1 - 8 elements

Wake on a schedule.

Example:
name
string

Label in the Reason's Loops list. Defaults to the start of prompt.

Required string length: 1 - 200
enabled
boolean
default:true

Send false to create it paused.

until
string<date-time> | null

End of a scheduled Loop: no wake after this time, then it reads completed. null clears it. A Loop woken by events has no end of its own.

max_runs
integer | null

How many runs a scheduled Loop makes before it reads completed, counted from when it is set. null clears it.

Required range: 1 <= x <= 100000
owner_user_id
string<uuid>

Workspace member credited for each Loop run. Defaults to its creator. Changing it does not transfer execution access or billing.

Pattern: ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
execution_mode
enum<string>

session continues one Session across wakes, the one in session_id or else one of the Loop's own that its first wake opens; new_session opens a fresh Session on every wake. A Loop woken by events opens a Session per event (events sharing a correlation key continue one), so it takes neither.

Available options:
session,
new_session
session_id
string<uuid> | null

An existing Session of the caller's that each wake continues. null unbinds it.

device_id
string<uuid> | null

A connected computer of the caller's (listDevices) that its runs use; null runs them on a Reason cloud machine.

notification_policy
enum<string>

When the Loop tells the person about a run: on important updates (the default) or only when a run fails.

Available options:
important_updates,
failed_runs_only
model
string | null

Model the Loop asks for when it opens a new Session, as a Session model id: each scheduled run with execution_mode new_session, and the first run of a Loop that opens its own Session. The workspace's plan and model routing decide what serves it, as for any Session. null or auto sets none, and a Session it opens takes its usual default. It does not override the model of a Session the Loop continues: a run added there as a turn starts from that Session's own settings; send that Session a message with model to change those. An id the workspace cannot pin returns 400 invalid_model.

Required string length: 1 - 200
flex_minutes
integer

Early access (Settings › Experiments, Flexible Loop schedules): a cron schedule runs at one fixed point up to this many minutes after each scheduled time, the same point every time, instead of on the dot; 0 runs on the dot. Use it for work that only needs to run around a time, so Loops on the same schedule don't all start together. Only a cron schedule takes it (400 invalid_routine otherwise); off in this workspace returns 403 flexible_schedule_unavailable. Left out on update, the Loop keeps its window.

Required range: 0 <= x <= 120
timezone
string

IANA time zone name, such as America/Los_Angeles, that a wake_on schedule is read in. Defaults to UTC. A name that is not a known time zone returns 400 invalid_routine when a schedule is read in it.

Required string length: 1 - 120

Response

The new Loop, and its webhook's URL and key when it has one.

The Loop as saved, and the webhook it just gave out, when it did.

loop
object
required

A Loop: standing work a Reason does, woken by a schedule or an event. Each wake opens or continues a Session of the Reason.

webhook
object

The webhook a Loop just gave out, returned once.