Skip to main content
Version: v5.6.1

opschain triggers create

triggers

opschain triggers create <project> -f <file.yaml>

Creates a trigger from a flat YAML definition whose keys mirror the API's writable trigger attributes verbatim — the file is the write payload. The accepted keys, exactly:

code, name, description, enabled, subject, events, scope_path, conditions, action_type, action_params, throttle_per_minute, run_as, owned_by

The file is loaded strictly: an unknown key fails naming the accepted set rather than being silently dropped, and code — the trigger's per-project identity — is the one key the CLI itself requires. Everything else (the subject and event vocabulary, condition shapes, per-action-type params) is validated by the create verb (v2 TriggerService.CreateTrigger), the same validation an API or GUI edit runs.

This flat format is deliberately not the nested when/then interchange document triggers export writes — feeding an export file here is refused with a pointer to triggers import, and vice versa.

On success: created trigger <project>/<code> (<id>) (-o json|yaml prints the created trigger document instead). Needs a server target (--server <url>, OPSCHAIN_SERVER, or the active context).

Flags​

FlagMeaning
-f, --file <file>The YAML trigger definition (required).

Exit codes​

CodeMeaning
0Trigger created.
1The command failed (server-side validation refused the definition).
2Usage error — missing -f, unreadable/invalid file, no server target.

Named errors​

  • <file> must set code (the trigger's per-project identity) — exit 2.
  • <file>: unknown trigger attribute(s) <keys> (accepted: code, name, description, enabled, subject, events, scope_path, conditions, action_type, action_params, throttle_per_minute, run_as, owned_by) — exit 2.
  • <file> is a trigger interchange document (trigger/when/then) — load it with opschain triggers import`` — exit 2.

Example​

# promote.yaml
code: promote_on_success
description: promote dev web deploys
subject: change
events: [finished]
scope_path: /projects/demo/environments/dev
conditions:
- event.source.action eq web:deploy
action_type: workflow_run
action_params:
workflow: release
throttle_per_minute: 5
opschain triggers create demo -f promote.yaml
created trigger demo/promote_on_success (0199c81e-…)

See also​

  • opschain docs cli/triggers-update — partial edits with the same file format.
  • opschain docs cli/triggers-import — the interchange lane for restoring exported triggers.
  • opschain docs cli/triggers-test — prove the new trigger matches before relying on it.
  • opschain learn 5.2.