All snippet endpoints are available since v1.4.0.
GET /snippets
Returns all saved code snippets ordered by ID descending.Response
POST /snippets
Creates a new code snippet. New snippets are saved in a disabled state and must be explicitly enabled.Parameters
A descriptive name for the snippet.
The snippet code. For PHP snippets, the opening
<?php tag is optional and will be stripped before execution.Snippet type:
php, css, or js. Defaults to php.Optional description of what the snippet does.
Response
Returns HTTP201 on success.
Always
true.The newly created snippet object with all fields.
PUT /snippets/
Updates an existing snippet. All parameters are optional — only the provided fields are updated.Parameters
New title for the snippet.
Updated snippet code.
Updated type:
php, css, or js.Updated description.
Response
Always
true.The updated snippet object with all fields.
POST /snippets//toggle
Enables or disables a snippet. Enabled PHP snippets run on every page load via theafter_setup_theme hook.
PHP snippets run with
eval() in the context of the WordPress bootstrap. Test snippets in a staging environment before enabling them on production.Parameters
true to enable the snippet, false to disable it.Response
Always
true.The new enabled state.
DELETE /snippets/
Permanently deletes a snippet.Response
Always
true on success.