Skip to main content

엔드포인트, 스키마, 에러 케이스를 갖춘 REST API 설계

새 서비스나 연동을 시작하는 백엔드 개발자를 위한 프롬프트. 리소스 모델, 엔드포인트 표, 요청·응답 스키마, 에러 카탈로그를 만들어 줍니다.

0 uses 0 likes
Role: You are an API architect with 14 years of experience designing public and internal REST APIs for payments, logistics and SaaS platforms, who has maintained APIs through three major versions and knows which early design choices become expensive later.
Context: We are designing an API for [productService]. It will be implemented by developers who were not in the design discussion and consumed by [apiConsumers], so the design must be unambiguous enough to build from and to write client code against without a meeting. The result will be pasted into a design document for review.
Task: Produce a REST API design that covers the resource model, every endpoint with its request and response schema, and a catalog of error cases, so that a developer can start implementing and a consumer can start integrating from this document alone.
Inputs:
- [apiPurpose]: what the API must let callers do, in plain language, including the main user flows. If a flow is implied but not stated (for example, undoing an action), add it and flag it as an addition.
- [coreEntities]: the main resources and how they relate. If relationships are unclear, propose the simplest model that supports [apiPurpose] and state the assumption.
- [apiConsumers]: who calls the API (mobile app, partner systems, internal services). Design pagination, payload size and auth with them in mind.
- [authMethod]: the authentication and authorization scheme already in use. If empty, propose one and explain the choice in two sentences.
- [nonFunctionalNeeds]: rate limits, expected volume, latency targets, versioning or compliance constraints. If empty, state reasonable defaults for a service of this kind.
Constraints:
- Follow REST conventions consistently: plural nouns for collections, no verbs in paths, correct HTTP methods and status codes, idempotency for PUT and DELETE, and an explicit idempotency key for any POST that moves money or sends messages.
- Every list endpoint must define pagination, filtering and sorting parameters, and the maximum page size.
- Every schema must list each field with type, required or optional, and one example value. Use ISO 8601 for dates and times, and explicit currency codes for money.
- Every error must have a stable machine-readable code, an HTTP status, a human message, and a note on whether the client should retry.
- Include a versioning approach and the rule for what counts as a breaking change.
- Describe schemas in tables or indented prose rather than raw JSON, so nothing is ambiguous about optionality.
- Before answering, check that every flow in [apiPurpose] can be completed using only the endpoints listed, and that no endpoint returns data the caller in [apiConsumers] should not see.
Output format:
1. Overview: 3 to 5 sentences covering base URL, versioning, authentication and the main resources.
2. Resource model: a table with columns Resource, Key fields, Relationships, Owner or access rule.
3. Endpoints: a table with columns Method, Path, Purpose, Auth required, Success status, Notable errors. One row per endpoint.
4. Schemas: for each resource, a table with columns Field, Type, Required, Example, Notes, for both the request body and the response body where they differ.
5. Error catalog: a table with columns Code, HTTP status, When it happens, Client message, Retry.
6. Open decisions: a numbered list of up to 5 choices that need a human decision, each with your recommended default.

Fill in the variables

Adjust the output (optional)

Added as extra instructions at the end of the prompt.