Prompt Library coding intermediate

ChatGPT Prompts for API Docs: Developer-Friendly Documentation

ChatGPT prompts for API documentation. OpenAPI specs, endpoint references, code examples, and quickstart guides that developers actually use.

Tested on: GPT-4oClaude 4

The Prompt

Act as a technical writer who specializes in developer documentation for APIs used by 10,000+ developers.
Write API documentation for:
API name: {API name}
Endpoint: {HTTP method + path — e.g. POST /api/v1/users}
Purpose: {what this endpoint does}
Authentication: {API key / OAuth / JWT / none}
Request parameters: {list all query params, path params, and body fields with types}
Response structure: {describe the response object fields and types}
Error codes: {list error codes this endpoint returns}
Code example language(s): {JavaScript / Python / curl / Ruby / Go — pick 1-3}

Documentation output:
1. Endpoint overview (2-3 sentences: what it does, when to use it, key limitations)
2. Authentication section (how to authenticate for this endpoint specifically)
3. Request reference table:
   | Parameter | Type | Required | Description | Example value |
4. Response reference (full example JSON response + field descriptions)
5. Code examples (complete, runnable — for each requested language)
6. Error reference table:
   | Status code | Error code | Meaning | How to handle |
7. Rate limiting notes (if applicable)
8. Related endpoints (logical next steps in the API workflow)

Constraints:
- Code examples must be runnable as-is — no placeholder variables without explanation
- Response examples must use realistic data, not "string" or "123"
- Error reference must tell developers how to recover, not just what went wrong
- Language must be plain — no jargon that assumes advanced API experience

Variables to fill in

  • {endpoint} HTTP method and path
  • {request parameters} All query params, path params, and body fields
  • {response structure} The response object fields and their types
  • {error codes} Error codes this endpoint returns
  • {code example languages} 1-3 languages to generate examples for

How to use this prompt

  1. Run this for each endpoint in your API — produce consistent docs across the entire surface
  2. Use the realistic example values in the request table as your test fixtures
  3. Include the error reference in your SDK's error handling documentation
  4. Use the related endpoints section to build your navigation structure
API documentation page on developer portal with code examples
Photo by Pankaj Patel on Unsplash

The code example is the most-read part of any API doc

Developers copy-paste code examples before they read the prose. A working, realistic code example in their language of choice is worth 500 words of description. The prompt’s constraint — ‘runnable as-is, no unexplained placeholders’ — ensures developers can integrate your API in minutes, not hours.

Error handling docs prevent 70% of support tickets

The most common support request is ‘I’m getting a 422 error — what does it mean?’ An error reference that tells developers what each code means AND how to recover from it eliminates the most common integration failures. The ‘how to handle’ column is what most API docs omit.

Realistic example values signal production-readiness

An API response example that shows "name": "string" instead of "name": "Sarah Chen" looks like it was generated by a schema export, not written for humans. Realistic values — UUIDs, real-looking dates, plausible amounts — make the documentation feel like it was written by someone who actually used the API.