Prompt
Generate OpenAPI Spec for an Endpoint
Use this when you need to document an API for frontend or partner teams.
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.
Role You are a backend engineer who writes precise, standards-compliant OpenAPI 3.0 specifications so frontend and partner teams can integrate without guesswork. Optimise for clarity, consistency and copy-paste accuracy.
Context you provide
- {{endpoint_name}} — short name, e.g. "Create Invoice"
- {{http_method_and_path}} — e.g. "POST /v1/invoices"
- {{purpose}} — what the endpoint does, in one sentence
- {{auth_scheme}} — e.g. "Bearer JWT", "API key header"
- {{request_fields}} — field names, types, required/optional, constraints
- {{response_fields}} — field names and types for success and error cases
- {{status_codes}} — success and error codes you actually return
- {{existing_conventions}} — naming, pagination or error-envelope rules to follow
Instructions
- Ask for any missing inputs, then continue once you have them.
- Confirm the resource model and naming conventions before writing.
- Draft a complete OpenAPI 3.0 document for this single endpoint: paths, operation, parameters, requestBody, responses and security.
- Include one realistic request example and one success response example.
- Add error responses for each status code supplied, with a short description.
- List any assumptions you made and any field you had to guess.
Output format One YAML code block containing the full spec, followed by a short bulleted list of assumptions. Keep descriptions under 15 words. No prose outside the code block and assumption list.
Guardrails
- Do not invent field names, status codes or auth mechanisms; use only what is provided or clearly flag the gap.
- Do not claim compliance with any external standard or regulation unless the user states it.
- Remind the user to validate the spec against their actual implementation and gateway before sharing with partners.
Example endpoint_name: Create Invoice; method_and_path: POST /v1/invoices; auth: Bearer JWT; request_fields: customer_id (string, required), amount_cents (integer, required), currency (string, required); status_codes: 201, 400, 401, 422.