Course overview
Lesson 1 of 8 · 3 promptsAI for Backend Developers
LESSON 01 OF 8

API Endpoint Drafting

3 prompts for Backend Developers

Prompts for Backend Developers: copy one, fill it in, paste it into your AI.

Track progress as a member

In this lesson

  1. 01Draft REST Endpoint SkeletonUse this when you need a working controller and route scaffold in your framework before the real logic exists.
  2. 02Write Request Validation RulesUse this when you need to define and enforce input schemas for an endpoint.
  3. 03Generate OpenAPI Spec for an EndpointUse this when you need to document an API for frontend or partner teams.
1Copy the promptClick Copy on the prompt you need.
2Paste it into your AIChatGPT, Claude, Gemini or Copilot.
3Fill in the {{brackets}}Your own details, or let the AI ask you.
4Follow up and checkUse the follow-ups, then check the facts.
01

Draft REST Endpoint Skeleton

Use this when you need a working controller and route scaffold in your framework before the real logic exists.

Prompt

Role You are a backend engineer who drafts idiomatic REST endpoint scaffolds that drop into an existing service and can be wired up without rework.

Context you provide

  • {{framework}} and {{language}} with the routing style in use
  • {{resource_name}} and the actions needed (list, read, create, update, delete)
  • {{api_version}} and base path prefix
  • {{auth_scheme}} and which roles may call each action
  • {{fields}} with types, required or optional, and validation rules
  • {{db_layer}} and the table or collection names
  • {{error_conventions}} status codes and error body shape
  • {{existing_patterns}} folder layout and shared middleware

Instructions

  1. Ask for any missing inputs, then restate the resource, actions, and response shape for confirmation.
  2. Draft route registration for each action using the versioned path.
  3. Write one handler per action: parse input, validate it, call a named service function, return the response.
  4. Leave the service layer as a stub with the expected signature and a TODO.
  5. Map each validation or lookup failure to the agreed status code and error body.
  6. Mark where authentication and role checks belong in the chain.
  7. Close with a list of what the developer must still implement.

Output format Three fenced code blocks: route registration, handlers, service stubs. Follow with a short file map and TODO list. Comment only where intent is not obvious. Stay under 150 lines. Skip migrations, tests, and deployment config.

Guardrails

  • Do not invent framework APIs, package names, or library versions. If unsure, use a plain placeholder and say so.
  • Flag every assumption about schema, auth, or status codes at the end.
  • Tell the user to confirm details against their framework version docs and have a senior engineer review before merging.

Example Framework: FastAPI, language: Python, resource: invoices, api version: v1, auth: bearer token, roles: admin and viewer.

Open as its own page

02

Write Request Validation Rules

Use this when you need to define and enforce input schemas for an endpoint.

Prompt

Role You are a backend engineer who turns endpoint requirements into precise, testable request validation rules that block malformed or unsafe input before it reaches business logic.

Context you provide

  • {{endpoint_method_and_path}}: e.g. POST /v1/orders
  • {{resource_or_entity}}: what the endpoint creates or updates
  • {{field_inventory}}: each field, type, required or optional, constraints, allowed values
  • {{content_types}}: expected request body format and content types
  • {{auth_and_role_context}}: caller role and any tenant or ownership scoping
  • {{error_response_convention}}: status codes and error body shape
  • {{framework_and_validation_library}}: language, framework, existing validation tool
  • {{localization_requirements}}: error message language and tone

Instructions

  1. Ask for any missing inputs, then draft the validation rules.
  2. Split fields into required and optional; note types and constraints.
  3. For each field, define rules: presence, type, length, range, pattern, enum, trimming.
  4. Add object-level rules: unknown fields, conditional requirements, cross-field checks, array limits.
  5. Map every failure to a clear error code, message, and HTTP status.
  6. State where each rule runs (middleware, controller, or model) and any performance notes.
  7. Provide example valid and invalid payloads and a test checklist.

Output format Return a markdown document with: a short summary; a field-level rules table (field, type, required, constraints, error code); object-level rules; error response examples; and a test checklist. Keep it concise and skip full implementation code unless asked. Leave out generic security advice and unrelated endpoint details.

Guardrails

  • Do not invent field names, constraints, or standards numbers; if a constraint is missing, mark it as an open question for the user.
  • Flag any rule that depends on framework-specific behavior or requires a security or compliance review.
  • Tell the user to check the framework or validation library documentation for exact syntax and edge-case behavior.

Example POST /v1/orders, order entity, fields: customer_id (UUID, required), items (array of {sku, quantity}), notes (string, optional, max 500), content-type application/json, auth: customer role, errors: {error: {code, message, field}}, stack: TypeScript with a web framework and schema validation library, localization: English.

Open as its own page

03

Generate OpenAPI Spec for an Endpoint

Use this when you need to document an API for frontend or partner teams.

Prompt

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

  1. Ask for any missing inputs, then continue once you have them.
  2. Confirm the resource model and naming conventions before writing.
  3. Draft a complete OpenAPI 3.0 document for this single endpoint: paths, operation, parameters, requestBody, responses and security.
  4. Include one realistic request example and one success response example.
  5. Add error responses for each status code supplied, with a short description.
  6. 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.

Open as its own page

Skills for these tasks

Give your AI these skills and it does these tasks the expert way. Connect your AI once and it picks them up by itself.