Skip to the guide
All guides

REST API

Build, debug or review WordPress REST routes, including their arguments, authentication, object permissions, responses and pagination.

app WordPress DevKit 2.0.3checked reading 4 minutes

On this page

When to use it

Use this skill for REST problems such as 401, 403 or 400 responses, nonce or Application Password trouble, a route with no permission_callback, and collections or caching that behave oddly.

It does not cover admin screens. The skill owns the request boundary: routes, authentication, validation, responses and cache behavior.

What it hands off

  • Plugin bootstrap, hooks and storage go to wp-devkit-plugin-development.
  • The admin screens that call the API go to wp-devkit-admin-ui-development.
  • WPGraphQL and decoupled front ends go to wp-devkit-headless-and-wpgraphql.
  • Broad exploit analysis goes to wp-devkit-security-review.

Run a review in Claude

With the plugin loaded, start a read-only review of one bounded target:

Text
/wp-devkit:rest-review <target-path>

The shorter /wp-devkit:rest asks for a quick scan instead.

Run a review in Codex, ChatGPT or Antigravity

Name the installed skill and keep the request small. Replace the target with your own files or journey.

Text
$wp-devkit-rest-api-development
Review the target without editing files.
Read the project instructions and the skill's engineering contract first.
Separate confirmed findings from candidates and state the evidence and checks you could not run.

The engineering contract is the set of rules every DevKit skill follows. It covers how findings are rated and what counts as evidence.

How a review works

  1. The agent finds where routes are registered: register_rest_route, a controller's register_routes, register_rest_field, and register_meta with show_in_rest. It then follows a request in the order WordPress handles it: authentication, route match, required and validate_callback checks, sanitization, permission_callback, the handler and the response. This order is confirmed in WP_REST_Server::dispatch() and respond_to_request().
  2. It writes down the expected method, object scope, inputs, response shape and error behavior, taken from the existing contract. It does not add a new endpoint to get around a failing one.
  3. It checks object-level authorization for reads and writes, including every identifier in the payload. A public submission can be valid by design, so for those routes the agent looks at data exposure, side effects and abuse controls instead of asking for a login.
  4. It checks validation where it really happens. A custom sanitize_callback replaces the automatic schema validation, parameters resolve body first, and the permission callback and the handler must read the same identifier.
  5. It checks responses: which fields are returned, the right context, a WP_Error with a status, pagination limits and headers, and cache headers for private data.
  6. It describes checks for an anonymous caller, an authorized caller, the wrong owner and malformed input. It sends no requests that change data during a review.
  7. It rates each concern under the engineering contract. Search matches stay candidates, and the result is insufficient evidence when the authentication model, WordPress version or CDN rules are unknown.

Reference files

The agent starts with the workbook and loads the others only when the task needs them:

  • rest-api-development-workbook.md is read first. It helps sort symptoms, shows worked decisions, lists harmless code that looks like a bug, and gives verification recipes.
  • route-registration-and-schema.md covers registration rules, controllers, how core validates arguments, schema keywords and type coercion, fields and meta, and versioning.
  • authentication-and-permissions.md covers cookie nonces, Application Passwords, the difference between 401 and 403, object checks, public routes, CORS and abuse controls.
  • responses-collections-and-caching.md covers errors and status codes, pagination, _fields and _embed, caching and CDNs, idempotency and retries.

What you get back

A review opens with the result and the scope it covered. Each confirmed finding gives the file and line, who triggers it, the reachable path, the impact, the confidence, the severity, a minimal fix and a regression check. Candidates and missing evidence come in a separate list.

An implementation lists the contract, the boundaries it changed, each command with its exit status, the checks it could not run and the risk that remains.

Note

Reviews are read-only. A clean review covers the inspected scope and is not a certification. Ask for implementation as a separate, bounded task with a regression check.

Where to go next

Use review to fix for a bounded implementation and Doctor and reports for environment and evidence tooling.