Generate complete API documentation from route code

Generate clear request, response, and error documentation directly from backend handler code. Use it to prepare API docs for frontend developers.

You getEndpoint Overview, authentication & Headers and request Parameters & Body

Prompt

Prompt
Act as a technical writer and API architect. Convert the backend route handler code pasted below into clean, developer-ready endpoint documentation.
- Extract HTTP method, full URL path, URL parameters, query parameters, and request body schema.
- Document exact JSON payloads with data types, nullability, and field descriptions.
- Document all HTTP status codes (2xx, 4xx, 5xx) with representative JSON response bodies.
- List required authentication headers and permissions.
Output format:
1. Endpoint Overview (method, path, summary)
2. Authentication & Headers (table: Header, Type, Required, Description)
3. Request Parameters & Body (tables with field, type, required, description, plus an example JSON)
4. Response Codes & Payloads (status code headers with JSON blocks)

Here is the backend route code:

Example output

Example for: Express route handler for updating a user profile with validation

1. Endpoint Overview
  • Method: PATCH
  • Path: /api/v1/users/:userId/profile
  • Summary: Updates editable profile details for an existing user account.
2. Authentication & Headers
HeaderTypeRequiredDescription
AuthorizationstringYesBearer token (Bearer <token>)
Content-TypestringYesMust be application/json
3. Request Parameters & Body

Path Parameters

ParameterTypeRequiredDescription
userIdstring (UUID)YesUnique identifier of the user record

Request Body

FieldTypeRequiredDescription
displayNamestringNoPublic name, 2 to 50 characters
biostringNoShort biography, max 250 characters
notifyEmailbooleanNoEmail notification preference
{
  "displayName": "Alex Morgan",
  "bio": "Senior developer working on cloud infrastructure.",
  "notifyEmail": true
}
4. Response Codes & Payloads

200 OK

{
  "success": true,
  "data": {
    "userId": "a3b1c2d4-e5f6-7890-abcd-1234567890ef",
    "displayName": "Alex Morgan",
    "bio": "Senior developer working on cloud infrastructure.",
    "notifyEmail": true,
    "updatedAt": "2025-02-14T10:30:00Z"
  }
}

400 Bad Request

{
  "error": "Validation failed",
  "details": ["bio must not exceed 250 characters"]
}

401 Unauthorized

{
  "error": "Missing or invalid authorization token"
}
Written by AI from this prompt. Your results will vary.

Paste your backend controller, handler function, or router code into ChatGPT, Claude, or Gemini. As a follow-up, ask to convert the documentation into an OpenAPI/Swagger 3.0 YAML specification.

Make it repeatable

Keep using this prompt without pasting it in every time.

Keep exploring

More in Coding