superpowers-sage:wp-rest-api

Designs native WordPress REST API endpoints with register_route validation and authentication.

13|Updated Mar 19, 2026
One-click install
npx skills add https://github.com/hekivo/superpowers-sage --skill superpowers-sage-wp-rest-api-hekivo
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: superpowers-sage:wp-rest-api
Source: https://github.com/hekivo/superpowers-sage/tree/main/skills/wp-rest-api
Command: npx skills add https://github.com/hekivo/superpowers-sage --skill superpowers-sage-wp-rest-api-hekivo

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

It helps you design, implement, and debug WordPress REST API endpoints safely and correctly, especially when authentication, schema validation, and REST routing details become confusing.

Core Features & Use Cases

  • Native REST endpoint registration patterns: Guides you to use rest_api_init, define register_rest_route() entries with permission_callback, and structure route callbacks properly (e.g., controller methods instead of closures).
  • Schema and response correctness: Shows how to add argument schemas and return proper REST responses using rest_ensure_response(), enabling reliable client-side integration and validation.
  • Authentication and interoperability: Helps you choose the right auth approach (cookie + X-WP-Nonce, Application Passwords, JWT via middleware) and coordinate REST with Acorn Routes for clear URL separation and non-duplicated resources.
  • Debugging and verification: Provides checks for common failure modes like 401, 404/rest_no_route, schema validation errors, and permalink/setup issues, plus a workflow for namespace discovery.

Quick Start

Use the superpowers-sage:wp-rest-api skill to implement a new custom endpoint under myapp/v1 and make it authenticated, schema-validated, and easy to debug.

Frequently Asked Questions about superpowers-sage:wp-rest-api

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I register a custom WordPress REST API endpoint with proper authentication and schema validation?

Register a custom WordPress REST API endpoint by mapping requirements to register_rest_route within rest_api_init, enforcing permission_callback, defining argument schemas, and returning standardized WP_REST_Response objects for reliable integration.

Why does my WordPress REST API route return a 404 or rest_no_route error?

A WordPress REST API route returning 404 or rest_no_route typically indicates incorrect namespace versioning, permalink setup issues, or missing rest_api_init registration, requiring diagnostic checks on route paths and discovery via wp-json namespaces.

What is the best way to choose authentication for a WordPress REST API endpoint?

Choosing WordPress REST API authentication depends on your consumer: use cookie with X-WP-Nonce for logged-in users, Application Passwords for external systems, or JWT via middleware for decoupled app logic.

How do I coordinate WordPress REST API routes with Acorn Routes to avoid duplicate URLs?

Coordinate WordPress REST API routes with Acorn Routes by establishing clear URL separation, using REST endpoints for external consumers or Gutenberg clients and Acorn Routes for internal application logic to prevent duplicated resources.

Why does my WordPress REST API endpoint fail with a 401 unauthorized error?

A 401 unauthorized error on a WordPress REST API endpoint usually means the permission_callback is blocking access or the selected authentication method, such as nonce cookies or Application Passwords, is incorrectly configured.

Can I use controller methods instead of closures when registering WordPress REST API routes?

Yes, you can use controller methods instead of closures for WordPress REST API routes, which structures route callbacks properly and improves code maintainability when defining register_rest_route entries.