---
name: api-documentation-writer
description: "Turns one endpoint into a reference page a developer can integrate from without asking questions: parameter tables, auth, a cURL call that works as written, and every error response spelled out. Use when an API endpoint needs reference documentation with parameter tables, cURL examples, and documented error responses. Do not use for writing an OpenAPI or Swagger spec file, or documenting a whole API's architecture and auth flow. Related topics: coding, api, documentation."
---

# API Documentation Writer

Turns one endpoint into a reference page a developer can integrate from without asking questions: parameter tables, auth, a cURL call that works as written, and every error response spelled out.

## When to use

Use this skill when an API endpoint needs reference documentation with parameter tables, cURL examples, and documented error responses. Do not use it for writing an OpenAPI or Swagger spec file, or documenting a whole API's architecture and auth flow.

## Workflow

1. Ask the user for each input listed below in a single message, skipping any they have already given. Where options are listed, offer them, but accept other answers too.
2. Extract every field from the example request and response into parameter tables with name, type, required flag, and meaning, marking guessed types with (confirm).
3. Write the summary paragraph and the authentication requirement so a reader knows what the call does and which credential it needs before any detail.
4. Build a cURL example that includes the auth header, the content type, and the example payload exactly, so it runs unchanged.
5. Document the success response with its JSON and a field table, then one subsection per selected error code with its trigger condition and sample body.
6. Read the page top to bottom as a first-time integrator and remove any sentence that does not help them make the call.

## Inputs

- **Endpoint method and path** (free text, e.g. "POST /api/v1/users")
- **What the endpoint does** (longer free text)
- **Authentication** (choose one: None, Bearer token, API key, Basic auth)
- **Request body format** (choose one: JSON, Form data, Query parameters, None)
- **Example request payload** (longer free text)
- **Example success response** (longer free text)
- **Error responses to document** (choose any: 400 Bad Request, 401 Unauthorized, 403 Forbidden, 404 Not Found, 409 Conflict, 422 Unprocessable Entity, 429 Too Many Requests, 500 Server Error)

## Output

A Markdown reference page in this order: summary, authentication, request (parameters table, headers, body table), cURL example, success response, error responses. Every payload sits in a fenced code block.

## Prompt template

Fill the inputs into this template and follow it as the full instruction.

### API Documentation Writer

Write the reference documentation for one API endpoint.

- Endpoint method and path: {{Endpoint method and path}}
- What the endpoint does: {{What the endpoint does}}
- Authentication: {{Authentication}}
- Request body format: {{Request body format}}
- Example request payload: {{Example request payload}}
- Example success response: {{Example success response}}
- Error responses to document: {{Error responses to document}}

Work from the example payloads: every field they contain becomes a row in a parameter table with name, type, required or optional, and a one-line meaning inferred from the field name and value. Mark anything you had to guess with "(confirm)" so the owner can correct it rather than ship a wrong type. Open with a one-paragraph summary and the authentication requirement, then the request section (path and query parameters, headers, body table), then a cURL example that would succeed as written, then the success response with its JSON and a field table, then one subsection per selected error code with the condition that triggers it and a sample body. Use fenced code blocks for every payload and keep prose to what a developer needs to make the call.

## Pitfalls

- Inventing field types or constraints the example does not show; a wrong type in docs costs more than an honest (confirm) marker.
- Listing every error code the service can emit; document only the ones this endpoint actually returns so readers trust the list.
- Writing a cURL example without the auth header, which fails on first copy and makes the reader doubt the rest of the page.
