br-resource-cpt

Create RESTful CRUD endpoints for Laravel apps and a REST API for the same purpose.

21|1|Updated Apr 29, 2026
One-click install
npx skills add https://github.com/Lonsdale201/wp-agent-skills --skill br-resource-cpt
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: br-resource-cpt
Source: https://github.com/Lonsdale201/wp-agent-skills/tree/main/better-route/br-resource-cpt
Command: npx skills add https://github.com/Lonsdale201/wp-agent-skills --skill br-resource-cpt

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill enables developers to generate a complete REST CRUD endpoint suite for a WordPress custom post type by leveraging Better Route's Resource API, reducing boilerplate and ensuring consistent behavior across actions.

Core Features & Use Cases

  • Fluent CPT-to-REST generation using Resource::make(...)->sourceCpt(...)->fields(...)->policy(...)->register($router) to emit list/get/create/update/patch/delete routes.
  • Fine-grained access control with policy and fieldPolicy, plus dynamic visibility via cptVisibleStatuses and cptVisibilityPolicy.
  • Built-in validation via writeSchema and payloadSchema aliases, plus filter and sort allowlists to secure inputs.
  • Automatic route registration under a required restNamespace, with options for deleteMode and envelope shaping.
  • Suitable for migrating hand-rolled register_rest_route setups into a single Resource-based workflow.

Quick Start

Create the CPT REST API by configuring a Resource with a source CPT, policy, and router, then register it to expose CRUD endpoints.

Frequently Asked Questions about br-resource-cpt

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

FAQPage Schema
How do I generate REST API endpoints for a WordPress custom post type?

To generate REST API endpoints for a WordPress custom post type, use the Better Route Resource API fluent builder to configure a source CPT, define fields, set policies, and register routes with a router. This emits list, get, create, update, patch, and delete endpoints automatically.

Can I enforce field-level validation when creating WordPress CPT REST routes?

Yes, you can enforce field-level validation for WordPress CPT REST routes by applying writeSchema and payloadSchema aliases within the Resource API builder. This secures inputs by validating data payloads before they reach the create or update endpoints.

What is the best way to add access control to a custom post type REST API?

The best way to add access control to a custom post type REST API is configuring policy and fieldPolicy rules within the Resource API builder. You can also apply dynamic visibility using cptVisibleStatuses and cptVisibilityPolicy to restrict endpoint access.

Does the Resource API support migrating hand-rolled register_rest_route setups?

Yes, the Resource API supports migrating hand-rolled register_rest_route setups into a single Resource-based workflow. By consolidating the configuration into one fluent builder, you eliminate boilerplate and ensure consistent behavior across all CRUD actions.

How do I secure inputs with filter and sort allowlists in a WordPress REST API?

You secure inputs in a WordPress REST API by defining filter and sort allowlists within the Resource API configuration. This restricts query parameters to approved fields, preventing unauthorized data access or malicious queries against the endpoints.

Do I need a restNamespace to auto-register routes for a WordPress CPT?

Yes, a restNamespace is required to auto-register routes for a WordPress CPT. The Resource API automatically registers the generated CRUD endpoints under this specified namespace, with additional options for configuring deleteMode and envelope shaping.