WP Webhooks / Docs / create_snippet
AI Ability Pro since v1.3.0

create_snippet

Create a Code Glue snippet — Create a Code Glue PHP snippet (inert until assigned to a webhook).

$

Create a Code Glue PHP snippet (inert until assigned to a webhook). Write plain PHP without a <?php tag. PRE-dispatch snippets receive $payload (the mapped payload array) and $args ($payload["args"]) and MUST end with return $payload; — return the FULL modified array (a non-array return leaves the payload unchanged). POST-dispatch snippets receive $payload (as sent), $originalPayload, $responseCode and $responseBody, and run for side effects only (return value ignored). The shorthand {{ $args.0.total }} expands to $args[0]["total"]. Always test with preview_snippet before assign_snippet. Registered as the WordPress Ability flowsystems-webhook-actions/create_snippet, so external AI tools (Claude Code, Cursor) can call it over MCP or REST with a scoped API token.

/ Plan step shape

{ "ability": "create_snippet", "input": { "name":, "code":, "tags":} }

/ Scope & confirmation

Minimum API-token scope for external (MCP/REST) callers: full. Runs without a confirmation pause (the overall plan is still user-approved before execution starts).

/ Input fields

NameInTypeReqDescription
nameparamstringyesShort descriptive name.
codeparamstringyesPHP code, no <?php tag.
tagsparamarray

/ Examples

Plan step as the AI Builder proposes it

{
  "id": "step_1",
  "ability": "create_snippet",
  "summary": "…",
  "input": {
    "name": "Add order total tag",
    "code": "$payload[\"tag\"] = {{ $args.0.total }} > 100 ? \"vip\" : \"standard\";\nreturn $payload;",
    "tags": [
      "orders"
    ]
  }
}

/ Related

Ready

Your next automation is
one sentence away.

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