How to document POST endpoints
POST endpoints create resources. Your documentation must clearly describe required fields, validation rules, and failure behavior.
What to document for POST endpoints
For each POST endpoint, include:
- Purpose - What resource gets created
- Method and URL - For example,
POST /api/v1/users - Authentication and headers - Required token and
Content-Type - Request body schema - Field name, type, required status, and validation
- Success response - Usually
201 Createdwith created resource payload - Validation and error responses - Common
400,401, and409patterns
Example: Create a new user
- Endpoint summary: Creates a new user account.
- Method:
POST - URL:
/api/v1/users - Authentication: Bearer token required
- Headers:
Content-Type: application/jsonAuthorization: Bearer <token>
Request body
| Field | Type | Required | Validation | Description |
|---|---|---|---|---|
| name | string | Yes | 2-100 characters | Full name of the user |
| string | Yes | Valid email format, unique | User email address | |
| role | string | No | admin, editor, viewer |
Access role |
Request example
curl -X POST "https://api.example.com/api/v1/users" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <token>" \
-d '{
"name": "Asha Verma",
"email": "asha.verma@example.com",
"role": "editor"
}'
Success response (201)
{
"id": "u_456",
"name": "Asha Verma",
"email": "asha.verma@example.com",
"role": "editor",
"createdAt": "2026-02-24T10:30:00Z"
}
Validation error (400)
{
"error": {
"code": "INVALID_EMAIL",
"message": "email must be a valid email address"
}
}