Loops

Partial update. A paused Loop resumes from its next slot. wake_on replaces everything that wakes the Loop (send it alone, or with name, prompt, notification_policy, until, max_runs and model; a single entry of the kind already waking it changes that in place); a webhook it adds returns its URL and key once, as on create. Switching the Loop on, or onto another Session or model, checks the workspace can fund it (402 loop_model_not_fundable). Who sees and changes a Loop follows its Reason: the people who can use the Reason see and change its Loops, except that a teammate's Loop on a team Reason stays that teammate's (the Reason's owner may see and stop it). Workspace owners and admins may pause and delete any Loop.What a Loop runs in (its Session or computer), its Slack channels and what wakes it stay with its creator, since each is checked against their access (403 loop_creator_only_change).

<sub>Scope: automations:write</sub>

patch/v3/organizations/{orgId}/reasons/{reasonId}/loops/{loopId}

Request

  • Base URL
    https://api.reasonmachines.com
  • URL
    https://api.reasonmachines.com/v3/organizations/{orgId}/reasons/{reasonId}/loops/{loopId}
  • Auth
    HTTP bearer

Request body

promptstring

New instructions for its future wakes.

namestring
enabledboolean

false pauses it; true resumes it from its next slot.

schedulestring

A new schedule for a Loop that has one, in the same forms as a wake_on schedule.

untilstring date-time nullable

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_runsinteger nullable

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

execution_mode'session' | 'new_session'

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.

session_idstring uuid nullable

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

device_idstring uuid nullable

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

notification_policy'important_updates' | 'failed_runs_only'

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

timezonestring

IANA time zone a cron schedule is read in, such as America/Los_Angeles. Defaults to UTC, or keeps the Loop's own on update.

modelstring nullable

Model its runs use, as a Session model id. null or auto runs it on the model of the Session it continues, or the workspace's. An id the workspace cannot pin returns 400 invalid_model.

Example request

{
  "wake_on": [
    {
      "schedule": "0 9 * * 1-5"
    },
    {
      "webhook": {}
    }
  ]
}

Response

The updated Loop, and a webhook it just gave out.

Changes