/procedures/triggers
operations of the API: create it to run as you, copy or change it, and find the runs it started.
Every trigger operation on this page is alpha: it can change without the usual deprecation
notice. See Stability levels.
You need an API key for a member who is not read-only, and a
published procedure. Creating and changing a trigger needs permission to manage its procedure;
reading one needs permission to run it.
Spec
The spec is strict: give exactly one of
schedule, folder and event, and no other fields.
A name can’t change later, and a deleted trigger’s name stays taken. Who the trigger runs as and
whether it is enabled are not part of the spec: each create and replace says them in its own
enabled and runAs, which are never stored with the spec. A spec copied from a trigger
therefore never carries anyone’s authority with it.
Prefer "version": "live". It follows the procedure’s
live version. A newly published version
becomes live on its own only when it keeps the live version’s inputs and output, so the trigger’s
inputs keep working, and live can lag behind the newest version. Someone can still make a
version with different inputs live. The trigger’s fixed inputs may then no longer match, and its
firings fail to start runs; lastError says why. When you make such a version live,
replace the trigger’s spec with inputs that match it.
Schedule
Each expression must fire no more often than once an hour.
Folder
Each new file in the folder starts one run, with the file bound to
folder.input as
{ "uri": "artifact://<id>" }. That input name can’t also appear in inputs.
Event
Events are always your workspace’s own. The input receives the whole event, with its details
under
payload.
email_received fires when email arrives at one of your workspace’s inbound addresses that
points to the trigger. See Receive email at an address
to create the address. The payload includes the sender, subject, plain-text body and references
to attachments.
rsl_log_written fires once for each write an RSL submission log
keeps: opening the log, and every write that records entries. A preview, a refused write, and a
retry answered from its idempotency key fire nothing.
The step names are
opened, answered, noted, signed_off, attached, retracted,
withdrawn, renamed, receipt, offered, accepted, closed and moved. The statuses are
incomplete, referred, ineligible, ready, accepted, refused and ended.
The payload holds program, releaseVersion, log, head, steps, role, actor and
status, and procedureId and procedureRunId when a procedure made the write. It holds no
answers or outcomes: read the log for those. stage and decision are also present but
deprecated; read status.
A procedure that writes to the log it watches starts itself again unless match leaves its own
writes out. Match the steps or roles of the other writers, and write in a different role.
procedure_run_terminal fires when a procedure run in your workspace finishes: completed,
failed or cancelled.
The payload holds
logical_run_id, procedure_id, procedure_version and outcome. Set
match.procedureId to the procedure you follow: without it, the trigger’s own runs finishing
start it again.
Declare the event input
Declare the event input with a schema that requires what the procedure reads, and allows the rest:loss-notice-intake.procedure.md
Create a trigger
Create it enabled
Publish the procedure first. Then send the spec with"enabled": true and "runAs": "self":
201:
inputs as it would for a run, and that the folder or Project exists.
A spec it can’t accept is refused with 422 invalid_trigger, such as a version that isn’t
published, inputs that don’t match it, or a cron expression that fires more than hourly. If the
trigger can’t be enabled, the request is refused and nothing is created. A refused request, any
4xx, stores nothing, so you can fix it and send it again. After a 5xx or a lost response, the
trigger may exist and be enabled, because Effective registers its schedule after storing it. Get
the trigger by name: if it exists, enable it again rather than
creating it again. Setting projectId also needs permission to manage that Project.
enabledis required. There is no default."enabled": trueneeds"runAs": "self", and"enabled": falsetakes norunAs; either mismatch is refused with400 invalid_request.- Who it runs as.
"runAs": "self", the only value, records you as the person the trigger’s runs act as. You can only authorize yourself. - Which credentials can enable. Enable signed in, or with an API key that acts as you in full.
Resource-scoped API keys and app credentials are refused with
403 forbiddenbefore anything is created, because a later run would carry your access rather than the key’s limits. - Every firing checks again. Each run starts with your access at that time. If you can no longer run the procedure, later firings don’t start runs.
runAs.state is stale when the recorded authorization belongs to an earlier revision or can no
longer be used. Enable the trigger again to fix it.
Create it disabled
To set a trigger up without turning it on, send"enabled": false and leave out runAs. The
trigger is created disabled and runs as no one. Any credential that can manage the procedure can
do this, including a resource-scoped API key.
"enabled": false and "runAs": null. Enable it later as below.
Enable a disabled trigger
Turn a disabled trigger on, to run as you:inputs and Project again first, and needs the same credentials as
creating a trigger enabled. Enabling an enabled trigger records you again and changes nothing
else.
Manage triggers
Every path below takes the trigger’sid or its name. A trigger set up outside the API that
watches an event type or match field the API doesn’t offer is left out of lists and answers
404.
List
List triggers, ordered by name. Filter withprocedureId and projectId, and set limit
(at most 200). For the next page, send the response’s nextCursor as cursor with the same
filters and limit; it is null on the last page. See Pagination.
Get
Get one trigger, with its spec,revision, whether it is enabled, who it runs as, nextRunAt,
runCount and lastError, the reason its latest firing didn’t start a run, if one didn’t:
Copy a trigger
A trigger you get is not a request you can send back as it is. Its spec is these fields of the response:name, procedureId, version, projectId, schedule, folder, event and
inputs. The rest, id, kind, revision, enabled, runAs, nextRunAt, runCount,
lastError and runTriggerId, are its state. A create or replace that sends a state field is
refused with 400 invalid_request, so whose access a trigger runs with is never copied.
To copy a trigger, send its spec fields to create under a new name, with your own enabled
and runAs. Unused sources can stay null:
Replace the spec
Send the trigger’s spec fields, changed, withexpectedRevision set to the revision you last
read and enabled saying whether the new spec runs. name can’t change: a replace that sends
another name is refused with 422 invalid_trigger.
"enabled": true and "runAs": "self", the new spec is enabled in the same request, to run as
you, with the same credentials as creating it enabled. With
"enabled": false, the trigger ends up disabled and runs as no one.
A replace isn’t atomic. The trigger is disabled while its spec is replaced, and if the request
fails after that, it is left disabled at its new revision, even with "enabled": true. After
an error, get the trigger. If it is at the new revision and disabled,
enable it or replace it again from that revision. If someone
changed the trigger since expectedRevision, the replace is refused with 409 conflict and the
trigger is unchanged; get it again and decide.
Disable
Disable the trigger. It stops firing, and runs it already started go on. Enabling it again records whoever enables it.Run now
Run now starts one run of a schedule trigger immediately, as you, with its version and inputs, whether or not it is enabled. It doesn’t move the schedule. Folder and event triggers fire only from their files and events, and are refused with422 invalid_trigger. Run now needs permission
to run the procedure. As with enable, resource-scoped API keys and app credentials are refused
with 403.
202. requested means a run is starting; find it as in
Find a trigger’s runs. already_running means an earlier run-now of this
trigger is still starting, so no run was added.
Delete
Delete the trigger. It stops firing, and runs it already started go on and keep naming it. Its name stays taken. The response is204 with no body.
Retries
Trigger operations take noIdempotency-Key. Each is safe to repeat for its own reason:
A create refused with a
4xx stored nothing, so you can send it again under the same name. After
a 5xx or a lost response, get the trigger by name: if it exists, it may already be enabled, so
enable it again rather than creating it again.
Errors
Errors use the shared envelope.How firings behave
- At most one run per firing. A trigger starts at most one run for each scheduled time, file or event.
- No overlap for schedules. A scheduled firing is skipped while an earlier run from the same trigger is still active. Folder and event triggers start a run for each file or event, even while earlier runs are still active.
- No catch-up. Enabling a trigger doesn’t replay firings missed while it was disabled.
- The version is chosen per firing. With
"version": "live", each firing starts the version that is live at that moment, and the run keeps it.
Find a trigger’s runs
A run a trigger started hascause.kind trigger and the trigger’s runTriggerId in
cause.triggerId. To list a trigger’s runs, pass runTriggerId as triggerId:
runTriggerId your trigger returns. --data-urlencode encodes the @ and : it
contains.
See also
- Run procedures from your system: start runs from your own events through the API.
- Receive email at an address: point an inbound address at an
email_receivedtrigger. - Runs and versions: the live version and what a run pins.
wait: pause inside a run until a time or a condition.