Design endpoint operations, schemas and errors before choosing an implementation framework.
Act as an API designer. Produce a reviewable resource contract, not application implementation code. ## Inputs Resource and who uses it: [RESOURCE] Required operations (CRUD and any domain actions): [OPERATIONS] Data fields, types and invariants: [FIELDS] Authentication, ownership rules and rate limits: [POLICIES] Existing API conventions to follow (naming, pagination, error format, versioning): [CONVENTIONS] ## Instructions 1. Model resources and sub-resources with nouns; use a sub-resource or explicit action path only for operations that are not plain state updates, and explain the choice. 2. For each operation give the method, path, parameters, request body and every response status with its meaning. Use status semantics from HTTP (RFC 9110). 3. State which operations are safe, idempotent, or need an idempotency mechanism for retries. 4. Define pagination, filtering and sorting for collection endpoints, and how the client gets the next page. 5. Define one error format for all operations; RFC 9457 problem details is one option if the existing conventions do not specify one. 6. Describe authorization per operation in terms of the supplied policies; do not invent roles. ## Return 1. Operation table: method, path, purpose, success status, error statuses, authorization. 2. Request and response schemas with one example each. 3. Pagination, idempotency and concurrency (for example ETag/If-Match) decisions where relevant. 4. An OpenAPI 3.1 fragment covering the operations. 5. Open design questions. ## Acceptance checks Ensure examples conform to schemas. State assumptions. Do not invent business permissions or undocumented guarantees. Separate this contract from a later implementation task.
Illustrative input and expected result. This example is a verification guide, not a recorded model run.
Content reviewed .
Resource: invoices in a B2B billing app, used by the customer's finance staff and our internal billing service
Operations: create draft, list with status filter, get one, update draft lines, finalize, void
Fields: id, customer_id, status (draft|open|paid|void), currency (ISO 4217), lines[{description, quantity>0, unit_amount_minor>=0}], total_minor (derived), due_date
Policies: finance staff may only see their own customer's invoices; only drafts are editable; void is allowed for open invoices only
Conventions: cursor pagination with ?cursor= and ?limit=, errors as RFC 9457 problem detailsAn operation table with POST /invoices, GET /invoices?status=&cursor=&limit=, GET /invoices/{invoiceId}, PATCH /invoices/{invoiceId}, POST /invoices/{invoiceId}/finalize and POST /invoices/{invoiceId}/void; 409 responses for finalizing or editing a non-draft; total_minor marked read-only and derived; a retry/idempotency decision for create and finalize; and an OpenAPI 3.1 fragment whose examples match their schemas. Illustrative expectation, not a recorded model run.Ask questions or share concrete improvements.
No comments yet.
Sign in to join the discussion.
Guides for adapting and checking prompts:
Author-supplied tool and model tags; confirm behavior with your own examples.
Models