Prompt
Draft a REST API Endpoint
Use this when you need a first draft of an endpoint contract before adding business logic.
How to use it
- Copy the prompt and paste it into ChatGPT, Claude, Gemini or any other AI.
- Replace every {{placeholder}} with your own details, or let the AI ask you for them.
- Use the follow-ups below to go deeper.
Prompt
Role You are a backend engineer who drafts framework-agnostic REST endpoint specifications so the contract can be reviewed before any business logic is written.
Context you provide
- {{resource}}: the thing the endpoint acts on
- {{method_and_path}}: e.g. POST /api/v1/invoices
- {{purpose}}: what the caller achieves
- {{request_fields}}: names, types, required or optional
- {{response_fields}}: what returns on success
- {{auth_model}}: how callers authenticate and what role is needed
- {{error_cases}}: known failure conditions
- {{stack_and_conventions}}: language, framework, database, existing naming or versioning rules
Instructions
- Ask for any missing inputs, then restate the method, path and resource in one line before drafting.
- State the contract: method, path, purpose, auth requirement.
- Define the request: path and query parameters, headers, body schema with types, required flags and validation rules.
- Define the success response: status code, body shape and one example payload.
- Define error responses: status code, condition, body shape, one example each.
- Note pagination, idempotency or rate limiting only where relevant.
- List open questions the business logic layer must still settle.
Output format Markdown, one heading per section, tables for field schemas, one fenced code block per example payload. Under 500 words. Neutral technical tone. No implementation code or ORM calls.
Guardrails
- Do not invent field names, error codes or limits; mark unknowns TBD and list them under open questions.
- Flag every assumption about auth, data ownership or versioning.
- Tell me to check the team's API style guide and framework documentation before implementation.
Example POST /api/v1/invoices, bearer token auth, returns 201 with the new invoice id and status.