opschain triggers import
triggers
opschain triggers import <project> -f <file.yaml> [--update]
Imports a trigger interchange document — the nested when/then format
triggers export writes — through the ordinary authorised create/update
path: the same validation an API or GUI edit runs, with no second validator
client-side.
- When the project holds no trigger of the document's code, the trigger is
created:
created trigger <project>/<code> (<id>). - When one exists, the import fails unless
--updateis passed; with it the existing trigger is updated in place (code is immutable), and the document fully replaces the stored definition — defaults included, so a restore is exact:updated trigger <project>/<code> from <file>.
The document is parsed strictly (unknown keys at every level fail naming the
accepted set: top-level trigger, name, description, enabled, when,
then, throttle_per_minute, owned_by; when takes subject, events,
scope, conditions; then takes create, run_as, with). Omitted fields take
the documented defaults — enabled true, when.subject external (a
custom-event trigger), name = code, throttle_per_minute 60 — and the
full defaulted payload is what replaces the stored row. The subject and
event vocabulary, condition shapes and per-action-type params are validated
by the server endpoint, never here.
Needs a server target (--server <url>, OPSCHAIN_SERVER, or the active
context). -o json|yaml prints the created/updated document instead of the
confirmation line.
Flags
| Flag | Meaning |
|---|---|
-f, --file <file> | The interchange YAML (required; the format triggers export writes). |
--update | Replace an existing trigger of the same code instead of failing. Harmless when the trigger does not exist yet — the import creates it. |
Exit codes
| Code | Meaning |
|---|---|
| 0 | Trigger created or replaced. |
| 1 | The command failed (already exists without --update, server-side validation refused the definition). |
| 2 | Usage error — malformed document, missing -f, no server target. |
Named errors
trigger <project>/<code> already exists — pass --update to replace its definition from <file>— exit 1.<file>: this is the flat attribute formatopschain triggers create -f/triggers update -fload, not the interchange document (trigger/when/then) thattriggers importaccepts— exit 2.<file>: the document must name the trigger (trigger:)— exit 2.
<file>: unknown trigger document key(s) <keys> (accepted: trigger, name, description, enabled, when, then, throttle_per_minute) — and the
equivalent for the when and then sections — exit 2.
Examples
opschain triggers import demo -f promote.yaml
created trigger demo/promote_on_success (0199c81e-…)
opschain triggers import demo -f promote.yaml --update
updated trigger demo/promote_on_success from promote.yaml
See also
opschain docs cli/triggers-export — produces the document this verb
consumes, byte-identically round-trippable.
opschain docs cli/triggers-create — the flat attribute lane for
authoring a trigger by hand.
opschain learn 8.1 (backup and interchange).