Skip to main content
Version: v5.6.1

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 --update is 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​

FlagMeaning
-f, --file <file>The interchange YAML (required; the format triggers export writes).
--updateReplace an existing trigger of the same code instead of failing. Harmless when the trigger does not exist yet — the import creates it.

Exit codes​

CodeMeaning
0Trigger created or replaced.
1The command failed (already exists without --update, server-side validation refused the definition).
2Usage 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 format opschain triggers create -f/triggers update -fload, not the interchange document (trigger/when/then) thattriggers import accepts — 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).