---
title: "assign_snippet — AI Ability"
description: "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."
url: "https://wpwebhooks.org/docs/ability-assign-snippet/"
---

[WP Webhooks](https://wpwebhooks.org/) / [Docs](https://wpwebhooks.org/docs/) / assign\_snippet

AI Ability since v1.3.0

# 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

[preview\_snippet](https://wpwebhooks.org/docs/ability-preview-snippet/)[Code Glue](https://wpwebhooks.org/docs/code-glue/)[REST API reference](https://wpwebhooks.org/webhook-wordpress-plugin-api/)

/Ready

## Your next automation is  
one sentence away.

[Try the Live Preview](https://playground.wordpress.net/?blueprint-url=https://wpwebhooks.org/blueprint.json) [See the Plugin →](https://wpwebhooks.org/wordpress-webhook-plugin/)

$ wp plugin install flowsystems-webhook-actions --activate

## Structured data

```json
{"@context":"https://schema.org","@type":"TechArticle","name":"assign_snippet — AI Ability — Webhook Actions Docs","description":"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.","url":"https://wpwebhooks.org/docs/ability-assign-snippet/","isPartOf":{"@type":"WebSite","name":"WP Webhooks","url":"https://wpwebhooks.org"},"about":{"@type":"SoftwareApplication","name":"Webhook Actions","applicationCategory":"WordPress Plugin"}}
```
