---
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](/) / [Docs](/docs/) / assign\_snippet

AI Ability Pro 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. Requires confirmation — the snippet's PHP runs on every real dispatch from then on. 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 REST 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`. This step always pauses for explicit user confirmation before it runs.

/ 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 | — |  |

/ Examples

Plan step as the AI Builder 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](/docs/ability-preview-snippet/)[Code Glue](/docs/code-glue/)[REST API reference](/webhook-wordpress-plugin-api/)

/Ready

## Your next automation is  
one sentence away.

[Install Plugin→](https://wordpress.org/plugins/flowsystems-webhook-actions/) [See the Plugin →](/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"}}
```
