Prompt

How do I document REST endpoints with request and response examples?

Technology / Documentation tools1 observationLast seen Oct 4, 2026

Latest observation

Oct 4, 2026OpenAI APIWeb search: off

A good REST API doc usually includes, for each endpoint:

  1. What it does
  2. Method and path
  3. Auth requirements
  4. Request parameters
  5. Request body example
  6. Response examples for success and error cases
  7. Status codes

Recommended structure

1) Endpoint overview

### Create a user
Creates a new user account.

2) Method and URL

POST /api/users

3) Headers

Authorization: Bearer <token>
Content-Type: application/json

4) Request body

List fields with type, required/optional, and description.

FieldTypeRequiredDescription
namestringyesUser’s full name
emailstringyesUser’s email address
ageintegernoUser’s age

### 5) Request example
```json
{
  "name": "Jane Doe",
  "email": "jane@example.com",
  "age": 29
}

6) Response examples

Success: 201 Created

{
  "id": "usr_123",
  "name": "Jane Doe",
  "email": "jane@example.com",
  "age": 29,
  "createdAt": "2026-10-04T12:34:56Z"
}

Error: 400 Bad Request

{
  "error": "Validation failed",
  "details": [
    {
      "field": "email",
      "message": "Must be a valid email address"
    }
  ]
}

7) Status codes

- 201 Created — User created successfully
- 400 Bad Request — Invalid input
- 401 Unauthorized — Missing/invalid token
- 409 Conflict — Email already exists

Best practices

  • Show one real example per common case: success, validation error, auth error.
  • Keep examples consistent with the actual schema and naming.
  • Document formats: dates, enums, IDs, nullability.
  • Use code blocks with syntax highlighting (json, bash, etc.).
  • Include curl examples for quick testing:
curl -X POST "https://api.example.com/api/users" \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Jane Doe",
    "email": "jane@example.com",
    "age": 29
  }'

If you want a standard format

If you’re using OpenAPI/Swagger, you can document request/response examples directly in YAML/JSON and generate interactive docs from it.

Example:

paths:
  /api/users:
    post:
      summary: Create a user
      requestBody:
        required: true
        content:
          application/json:
            example:
              name: Jane Doe
              email: jane@example.com
              age: 29
      responses:
        "201":
          description: Created
          content:
            application/json:
              example:
                id: usr_123
                name: Jane Doe
                email: jane@example.com
                age: 29

If you want, I can give you:

  • a Markdown template
  • an OpenAPI example
  • or a fully documented endpoint example for your API.

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (1 observation for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as dotdotPR. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.