API Documentation Prompt for Clear Docs
A structured prompt that documents your API endpoint — params, responses, errors, and examples — in clean reference style, with a real example.
Enhanced prompt — ready to use
ROLE
You are a senior technical writer with expertise in creating comprehensive and clear API documentation. Your goal is to produce well-structured, user-friendly documentation that enables developers to understand and effectively use the API.
TASK
Write thorough documentation for the user's API, including descriptions of endpoints, request and response formats, authentication methods, error handling, and example usage. Think through this step by step to ensure completeness and clarity.
CONTEXT
The user needs clear and detailed API documentation aimed at software developers who will integrate or interact with the API. The domain involves technical software interfaces and assumes readers have basic understanding of APIs.
REQUIREMENTS
- Include endpoint descriptions with HTTP methods and URLs.
- Provide details on required headers, parameters, and request body formats.
- Explain authentication mechanisms.
- Describe possible error responses with status codes.
- Provide sample requests and responses in code snippets.
- Follow best practices for API docs clarity and usability.
- Before finalizing, verify your answer for correctness and completeness.
OUTPUT FORMAT
A structured API documentation outline with headings and subheadings, supported by paragraphs and formatted code blocks for examples.
or write yours rough and click once
That's what PromptAI produced from this vague prompt: write documentation for my api
Example result
# User's API Documentation
Welcome to the User's API documentation. This document provides a detailed overview of the available endpoints, authentication methods, request and response formats, error handling, and sample usage examples. This API is designed to enable developers to efficiently integrate and interact with the system programmatically.
---
## Table of Contents
1. [Overview](#overview)
2. [Authentication](#authentication)
3. [Endpoints](#endpoints)
- [1. Get User Profile](#1-get-user-profile)
- [2. Create User](#2-create-user)
- [3. Update User](#3-update-user)
- [4. Delete User](#4-delete-user)
4. [Error Handling](#error-handling)
5. [Example Usage](#example-usage)
6. [Contact and Support](#contact-and-support)
---
## Overview
The User's API enables developers to manage and retrieve user information programmatically. All data is exchanged using JSON format over HTTP. The API follows RESTful principles to provide intuitive access patterns.
Base URL:
```
https://api.example.com/v1
```
---
## Authentication
### Method
The API uses **token-based authentication** with Bearer tokens. Every request (except for public or health check endpoints, if any) must include an `Authorization` header with a valid token.
### How to Use
1. Obtain an API token from your account dashboard or via the authentication service.
2. Include the token in the HTTP header as follows:
```
Authorization: Bearer YOUR_ACCESS_TOKEN
```
### Example
```http
GET /v1/users/123 HTTP/1.1
Host: api.example.com
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6...
Content-Type: application/json
```
---
## Endpoints
### 1. Get User Profile
Retrieve detailed information about a specific user.
- **URL:** `/users/{userId}`
- **Method:** `GET`
- **URL Parameters:**
| Parameter | Type | Description | Required |
| --------- | ------ | ----------------------------| -------- |
| userId | string | Unique identifier of the user| Yes |
- **Headers:**
| Header | Value | Required |
| --------------- | ---------------------- | -------- |
| Authorization | Bearer access token | Yes |
| Content-Type | application/json | No |
- **Success Response:**
- **Status:** `200 OK`
- **Content:**
```json
{
"id": "123",
"username": "johndoe",
"email": "johndoe@example.com",
"created_at": "2023-01-15T10:00:00Z",
"profile": {
"first_name": "John",
"last_name": "Doe",
"age": 30
}
}
```
- **Error Responses:**
- `401 Unauthorized` — Missing or invalid token.
- `404 Not Found` — User with specified `userId` does not exist.
- **Example Request:**
```http
GET /v1/users/123 HTTP/1.1
Host: api.example.com
Authorization: Bearer eyJhbGciOiJIUzI1Ni...
```
---
### 2. Create User
Create a new user account in the system.
- **URL:** `/users`
- **Method:** `POST`
- **Headers:**
| Header | Value | Required |
| --------------- | -------------------- | -------- |
| Authorization | Bearer access token | Yes |
| Content-Type | application/json | Yes |
- **Request Body:**
```json
{
"username": "johndoe",
"email": "johndoe@example.com",
"password": "strongPassword123",
"profile": {
"first_name": "John",
"last_name": "Doe",
"age": 30
}
}
```
| Field | Type | Description | Required |
| ---------- | ------ | ---------------------------------| -------- |
| username | string | Unique username |
How to adapt it
- Give it the endpoint, method, and a sample request/response for accurate docs.
- Ask for a copy-pasteable curl example alongside the reference.
Have your own rough prompt? Enhance it in one click.
Enhance your own promptOr use the ChatGPT prompt enhancer right inside ChatGPT, the AI prompt enhancer for every other tool, or the prompt enhancer for Claude Code and Cursor in your editor.
More coding prompts
CodingCode Translation Prompt That Preserves BehaviorView promptCodingCoding Interview Prompt for Real PracticeView promptCodingCron Job Prompt That Gets the Schedule RightView promptCodingData Analysis Prompt That Finds the StoryView promptCodingDocker Compose Prompt for Multi-Service StacksView promptCodingExcel Formula Prompt That Just WorksView prompt