wp-rest-api

Build, extend, and debug WordPress REST API endpoints with register_rest_route.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

WordPress REST API development often requires building custom endpoints, validating input, and shaping responses. This Skill guides you through registering routes with register_rest_route and WP_REST_Controller, exposing CPTs/taxonomies via show_in_rest, adding custom fields with register_rest_field, and managing permissions and authentication for robust REST endpoints.

Core Features & Use Cases

  • Register custom routes via register_rest_route and WP_REST_Controller
  • Expose CPTs/taxonomies via show_in_rest
  • Add and manage REST fields and meta with register_rest_field and register_meta
  • Debug permission callbacks, authentication, and response shaping
  • Validate arguments and ensure robust error handling in REST endpoints

Quick Start

Create, tailor, and troubleshoot REST routes in WordPress to expose data, ensure proper permissions, and shape responses.

Frequently Asked Questions about wp-rest-api

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

FAQPage Schema
How do I register custom routes in the WordPress REST API?

Register custom WordPress REST API routes using register_rest_route or by extending WP_REST_Controller. This allows you to define custom endpoints, validate arguments, and shape responses for your specific application data.

How do I expose custom post types and taxonomies in the WordPress REST API?

Expose custom post types and taxonomies in the WordPress REST API by setting show_in_rest to true when registering them. This automatically generates the necessary REST endpoints for your content.

How do I add custom fields to WordPress REST API responses?

Add custom fields to WordPress REST API responses using register_rest_field and register_meta. These functions allow you to append custom meta data to your existing REST API endpoint outputs.

Why are my WordPress REST API permission callbacks returning 401 Unauthorized?

WordPress REST API permission callbacks return 401 Unauthorized when authentication fails or current_user_can checks return false. Debug your permission callbacks to ensure proper user capabilities are verified before granting endpoint access.

What is the best way to debug WordPress REST API endpoints?

The best way to debug WordPress REST API endpoints is to inspect permission callbacks, validate arguments, and review response shaping logic. Ensure robust error handling is implemented within your custom routes to identify issues.

Do I need WP_REST_Controller to build a WordPress REST API endpoint?

You do not strictly need WP_REST_Controller to build a WordPress REST API endpoint, as register_rest_route works independently. However, extending the controller provides a standardized structure for argument validation and response shaping.