assign_snippet
Assign a Code Glue snippet to a webhook — Attach a snippet to a webhook+trigger as its pre-dispatch (payload transform) or post-dispatch (after-response side effects) Code Glue and enable it.
Attach a snippet to a webhook+trigger as its pre-dispatch (payload transform) or post-dispatch (after-response side effects) Code Glue and enable it. Attaching to a LIVE (enabled) webhook requires confirmation, since the snippet's PHP runs on every real dispatch from then on; on a still-disabled webhook being built it runs without one. A snippet error never breaks a delivery (the payload falls back unmodified). Pass snippet_id 0 to unassign, or enabled false to keep it assigned but paused. Registered as the WordPress Ability flowsystems-webhook-actions/assign-snippet, so external AI tools (Claude Code, Cursor) can call it over MCP, or over the Abilities REST route with a scoped API token.
/ Plan step shape
{ "ability": "assign_snippet", "input": { "webhook_id": …, "trigger": …, "stage": …, "snippet_id": …, "enabled": … } }
/ Scope & confirmation
Minimum API-token scope for external (MCP/REST) callers: full. Pauses for explicit user confirmation only when the webhook is enabled (live); on a disabled webhook it runs without a pause. External MCP/REST callers targeting a live webhook get a 428 and must re-send the same call with "confirmed": true.
/ Input fields
| Name | In | Type | Req | Description |
|---|---|---|---|---|
| webhook_id | param | integer | yes | |
| trigger | param | string | yes | |
| stage | param | string | yes | pre = transform payload before dispatch; post = run after the response. pre | post |
| snippet_id | param | integer | yes | 0 to unassign. |
| enabled | param | boolean | — | Default true. |
/ Examples
Plan step as Build with AI proposes it
{ "id": "step_1", "ability": "assign_snippet", "summary": "…", "input": { "webhook_id": 12, "trigger": "woocommerce_order_status_completed", "stage": "pre", "snippet_id": 4, "enabled": true } }
/ Related