How to Document a WordPress REST API with AI
AI can draft WordPress REST API documentation from registered routes, schemas and tests, but it must not invent endpoints, permissions, side effects or examples that were not verified against the running implementation.
AI is most useful here as an evidence organizer, comparison engine and drafting assistant. It can make a complex WordPress task easier to inspect, but it cannot create missing authority, certify facts it did not observe or silently convert a recommendation into permission to act.
In one sentence: AI can draft WordPress REST API documentation from registered routes, schemas and tests, but it must not invent endpoints, permissions, side effects or examples that were not verified against the running implementation.
What this guide helps you accomplish
Build versioned, evidence-backed API documentation that describes routes, methods, authentication, permission callbacks, schemas, side effects, errors and tested examples.
- A route and method inventory tied to source and runtime evidence.
- Request and response schemas with required, conditional and read-only fields.
- Authentication and authorization behavior, including expected denials.
- Tested examples, error cases, version notes and deprecation status.
The finished artifact should be understandable by the person responsible for the decision and reproducible by someone who did not participate in the original prompt. A fluent answer is not enough. Every material conclusion needs a source, a scope and a verification path. When the evidence cannot establish something, the correct output is an explicit unknown or a testable hypothesis.
Evidence and inputs to prepare
- Registered route output from the intended environment.
- Controller and callback source at an exact commit.
- Schemas, permission callbacks and capability requirements.
- Integration tests and redacted request-response fixtures.
- Versioning, deprecation and backward-compatibility policy.
Before supplying evidence to an assistant, remove credentials, secret values and unrelated personal information. Preserve the identifiers, versions, timestamps, locale, units and source labels needed to interpret what remains. A screenshot without a URL, state or date may be useful context, but it is rarely sufficient authority for a production decision.
Do not begin with a broad request such as “review this,” “fix this” or “make it better.” Define the decision the work must support, the population included, the source that is authoritative for each field, the allowed operations and the actions that remain forbidden. Authenticated WordPress access or a controlled export is required for this task.
Discovery and documentation are different
A route can be registered without complete schema, useful examples or clear side-effect documentation. Runtime discovery is an input, not the finished reference.
Authentication is not authorization
A valid application password identifies a user; each endpoint still needs a permission decision appropriate to the action and object.
Examples are executable claims
A copied request implies that method, path, fields and response are current. Examples should be generated from or verified by tests.
Keep observation, inference and authority separate
A controlled review should distinguish at least four states:
- Observed: directly present in a named record, file, response, rendered page or executed test.
- Inferred: a plausible interpretation supported by evidence but not directly established.
- Recommended: a proposed human decision or next action.
- Authorized and verified: a separately approved change that was executed and then checked against acceptance criteria.
AI output usually begins in the first three states. It does not become authorized merely because it is detailed, internally consistent or technically convincing. Preserve this distinction in tables, reports, tickets and public case studies.
A safe workflow
- Freeze the plugin or application version and target environment.
- Collect route discovery, source definitions, schemas and tests.
- Normalize endpoints by namespace, path, method and version.
- Ask AI to draft documentation with explicit evidence references and unknowns.
- Verify every authentication, permission, validation and side-effect statement.
- Execute examples against an isolated fixture and redact sensitive values.
- Review developer usability, error guidance and backward compatibility.
- Publish the versioned reference and retest it in release CI.
This sequence deliberately places accountable review between analysis and implementation. If a later stage needs broader access, create a new task, a new identity or an explicit permission change. Do not quietly upgrade the analytical identity because it reached a correct boundary.
Prompt recipe
Replace every value in square brackets before using the prompt. Do not paste passwords, API keys, authentication cookies, private customer records or unrelated personal information.
You are reviewing [TASK SCOPE] for [SITE, REPOSITORY OR DATASET] using only the supplied evidence.
Objective:
Build versioned, evidence-backed API documentation that describes routes, methods, authentication, permission callbacks, schemas, side effects, errors and tested examples.
Return the following fields:
- Namespace
- Route
- Method
- Purpose
- Authentication
- Permission
- Arguments
- Schema
- Side effect
- Success response
- Error response
- Test fixture
- Version
Rules:
1. Do not invent routes, fields, capabilities or status codes.
2. Separate authentication from endpoint authorization.
3. Preserve namespace, method, field and enum tokens exactly.
4. Use redacted examples generated from safe fixtures.
5. Do not call production write endpoints.
For every finding:
- identify the exact source, record, URL, file, line, object ID, state or dataset row;
- preserve dates, versions, units, locale, identifiers and denominators;
- separate observation, inference, recommendation and unknown;
- state what evidence was not available;
- do not change WordPress, source code, commerce data, analytics, external systems or published content.
Why this prompt is structured this way
The prompt creates an evidence contract before asking for recommendations. It makes missing data visible, reduces the chance that a model will complete an incomplete record with plausible prose and produces an output that can be reviewed systematically. Structured fields also make it easier to compare repeated runs or hand an approved subset to a later implementation workflow.
A production implementation may add JSON schema, typed tool inputs or automated validation. Those mechanisms improve consistency, but they do not establish that the source evidence is true, complete or current. Human review and system-specific verification remain required.
Recommended access boundary
Use Read Only for the stage described in this guide. The exact capabilities available to an identity must come from the installed product version, the published coverage contract and the connection method actually in use.
What must remain outside this task
- Production requests
- Secret exposure
- Fabricated examples
- Permission generalization
- Undocumented breaking changes
A refused action can be useful evidence that the control boundary is working. Do not respond to an expected refusal by granting a broad administrator account or Full Power. First determine whether the action belongs in the current mandate at all. If it does, create a separately authorized stage with the narrowest required capability.
How WP Agent Control fits
The guided private folder for Claude Code or Codex uses WordPress REST and an Application Password with a dedicated read-only profile. Existing Read Only, Draft, Content Editor and Publisher profiles remain under Advanced. They are not automatically converted to OAuth and do not inherit the remote task and exact-approval model.
Get structured site information and inspect selected published pages after connecting. No temporary task is needed for this public reading. You can also browse public pages without the plugin; Agent Control adds structured access and a path toward authorized WordPress work.
Connect your AI: docs first profile · See features and compatibility: coverage
Verification checklist
- The task, population, period, environment and decision are explicit.
- Every material observation is linked to exact evidence or labelled as a hypothesis.
- Stable IDs, URLs, versions, dates, units, locales and denominators are preserved.
- Missing evidence and coverage limits remain visible.
- The analytical or research identity performed no prohibited mutation.
- A qualified owner reviewed security, accessibility, legal, commerce or release implications where applicable.
- Any implementation has a separate mandate, access level, backup and verification plan.
- Temporary identities, fixtures and sensitive evidence are revoked, reset or disposed of after the task.
Common failure modes
- Source-only docs: Conditional registration or runtime filters make the deployed route set differ from the code read by the assistant.
- Success-only examples: Consumers learn nothing about validation, authorization or conflict responses.
- Admin-equals-allowed: The reference describes broad role assumptions rather than the actual permission callback.
- Stale generated reference: Documentation is not tied to CI and drifts from the released package.
A recurring cross-cutting failure is permission drift: the initial task encounters a limit, and the operator broadens access before determining whether the missing operation is necessary, supported or safe. This destroys the evidence value of the refusal and makes later results difficult to attribute.
Advanced note
Generate documentation from a versioned intermediate representation that combines registered routes, schemas and executed contract tests. Human-authored explanations can then enrich the reference without becoming a second authority for endpoint facts.
Related guides
- How to Build a WordPress Permission Test Matrix for AI Agents
- How to Review WordPress Plugin Code with AI
- WordPress Abilities API Guide for AI Workflows
- How to Expose a Custom WordPress Ability through MCP
Next step
Continue with the most relevant supporting guide and use the access-level guide before any authenticated task. When temporary WordPress access is no longer needed, finish by revoking the identity.
Sources and verification
This page was checked against the following primary sources. Last source review: .
- Reference — REST API Handbook · WordPress.org
- Adding Custom Endpoints · WordPress.org
- Controller Classes · WordPress.org
- Authentication — REST API Handbook · WordPress.org
- Application Passwords: Integration Guide · WordPress.org