Join WhatsApp
Sample output Ā· AI-generated

2. Endpoints
GET /v1/slots?date=2026-11-03 : list free slots : 200
POST /v1/bookings : create a booking : 201
GET /v1/bookings : list my bookings : 200
GET /v1/bookings/{id} : get one booking : 200
POST /v1/bookings/{id}/cancel : cancel a booking : 200

3. Create a booking
Request (with header Idempotency-Key: 6f1c...)
```json
{
"slot_id": "slot_8812",
"service_id": "haircut_30",
"notes": "First visit"
}
```
Response 201
```json
{
"id": "bkg_1045",
"status": "confirmed",
"starts_at": "2026-11-03T10:30:00+05:30",
"service_id": "haircut_30"
}
```

4. Errors
```json
{
"error": {
"code": "slot_taken",
"message": "This slot was booked by someone else. Please pick another time."
}
}
```
Use 422 for validation errors, 404 for unknown IDs and 409 when the slot is already taken.

5. Lists use cursor pagination: ?limit=20&cursor=abc, returning next_cursor.

7. Open questions: Can users reschedule, or must they cancel and rebook? How long before the start can they cancel?

Text prompt Ā· ChatGPT Ā· Claude Ā· Gemini

API design prompt for clean REST endpoints and errors

Plan a REST API for a feature: endpoints, example requests and responses, status codes, error format and the decisions behind them.

You are an experienced API designer. Design a REST API for [feature or product].

Main things users do: [list actions, e.g. book a slot, cancel, see my bookings]
Data involved: [entities and key fields]
Who calls the API: [web app, mobile app, partners]
Auth: [e.g. bearer token, API key]
Constraints: [e.g. no double booking, rate limits, multi-tenant]

Give me:
1. Resources and their fields.
2. A table of endpoints: method, path, purpose, success status code.
3. For the 2 most important endpoints: an example request and response in JSON.
4. A consistent error format, with examples for validation errors, not found and conflicts.
5. Pagination, filtering and sorting for list endpoints.
6. Versioning and idempotency for create requests.
7. Open questions I should decide.

Use plural nouns for paths, standard HTTP methods and standard status codes.
Type
Text
Fill in
6 blanks
Copies
Be the first

Updated Ā· By

Tip: Share the endpoint table with whoever builds the frontend before writing code; their questions will find gaps faster than any review.

1. CopyTap "Copy prompt" above.
2. Fill the blanksReplace each [bracket] with your own details.
3. Paste + refinePaste it into the chat, then ask for changes.

Why this prompt works

This api design prompt starts from what users do, not from database tables, which leads to endpoints that match real actions such as cancelling a booking. Asking for example requests and responses makes the design concrete enough for frontend and backend developers to agree on before any code is written.

A single error format, idempotency keys for create requests and clear status codes such as 409 for conflicts are the details that make an API easy to use. The open questions section surfaces product decisions early, when they are cheap to change.

How to use this prompt

  1. Tap "Copy prompt".
  2. Replace every part in [square brackets] with your own details.
  3. Paste it into ChatGPT or Claude and send.
  4. Ask a follow-up like "make it shorter" or "give me 3 more options" to fine-tune it.

Variations to try

OpenAPI spec from the design

ChatGPT Claude Gemini
Turn this API design into an OpenAPI 3.1 YAML file: [paste design]. Include schemas for each resource, the error format, auth, and examples for each endpoint. Keep descriptions short.
Type
Text
Fill in
1 blank
Copies
Be the first

Review an existing API

ChatGPT Claude Gemini
Review these endpoints for consistency and common REST design problems: [paste list of methods, paths and example responses]. Check naming, status codes, error formats, pagination and versioning. Suggest changes that would not break current clients, and list the ones that would.
Type
Text
Fill in
1 blank
Copies
Be the first

GraphQL schema version

ChatGPT Claude Gemini
Design a GraphQL schema for [feature] with these actions: [actions] and data: [entities]. Give the types, queries and mutations, how errors are returned, and how to paginate lists.
Type
Text
Fill in
3 blanks
Copies
Be the first

Make it your own

  • Add "partners will call this API" to get notes on API keys, rate limits and documentation.
  • Ask for the endpoints in your framework's routing format, such as Express or FastAPI.
  • Add a webhooks section if other systems need to know when something changes.

Common problems and fixes

  • Paths use verbs everywhere. Ask for plural noun resources and use actions like /cancel only where a state change is not a simple update.
  • Every error returns 500 or 400. Ask for a table that maps each error case to a specific status code.

FAQ

Should I use REST or GraphQL?

REST is simpler for most CRUD apps and public APIs. GraphQL helps when many clients need different shapes of the same data.

How should I version my API?

A version in the path, such as /v1/, is simple and clear. Avoid breaking changes inside a version.

More Coding prompts

See all
ChatGPT Claude Text prompt

Debug code prompt that finds the root cause before fixing

Paste your code and the error message to get the real cause explained first, then a small fix and a test for it.

4 prompts
ChatGPT Claude Text prompt

Explain code prompt for beginners, line by line

Paste any snippet and get a plain-English summary, a line-by-line walkthrough and the concepts you need to understand it.

4 prompts
ChatGPT Claude Text prompt

Unit test prompt for edge cases in pytest or Jest

Get a list of test cases for a function, then ready-to-run tests for normal input, edge cases and errors in your framework.

3 prompts
ChatGPT Claude Text prompt

Refactor code prompt for cleaner, more readable functions

Clean up a messy function while keeping its behaviour the same, with a short list of every change and the reason for it.

4 prompts
ChatGPT Claude Text prompt

SQL query prompt: describe your tables, get the query

Describe your tables and the question you want answered, and get a correct query for your database with a short explanation.

4 prompts
ChatGPT Claude Text prompt

Regex prompt that writes and explains a pattern with tests

Describe what you want to match and get a working pattern for your language, explained piece by piece, with examples that should and should not match.

4 prompts
ChatGPT Claude Text prompt

Code review prompt for bugs, security and readability

A structured review of a pull request or snippet, with issues sorted by severity, each tied to a line and a suggested fix.

3 prompts
ChatGPT Claude Text prompt

Vibe coding prompt: write an app spec before you build

Turn an app idea into a clear spec with features, screens, data and build steps that an AI coding assistant can follow one step at a time.

4 prompts