Design or extend an HTTP, RPC or library interface with consistent naming, errors, pagination, idempotency, versioning, auth and documented examples. Use for "design the API for", "add an endpoint", "what should this interface look like", "review the API contract".
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Design Api?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/kinzarra-design-api)
---
name: design-api
description: Design or extend an HTTP, RPC or library interface with consistent naming, errors, pagination, idempotency, versioning, auth and documented examples. Use for "design the API for", "add an endpoint", "what should this interface look like", "review the API contract".
---
# Design an API
The result is a contract a client can build against without reading the implementation: operations, inputs, outputs, errors and examples, consistent with what the project already exposes.
## 1. Start from the callers
- List who will call it (the project's own frontend, another service, third parties, a command-line user) and the 3 to 7 tasks they need done. Design for those tasks, not for the storage tables.
- Read the existing interface first: its naming, casing, envelope, error shape, pagination, auth, date and money formats. A new endpoint follows the existing style even where another style would be better; note the disagreement in the report instead of mixing styles.
- Write the calling code for each task before the server side. If a task needs 5 calls or the client must know internal identifiers, the design is wrong.
## 2. Resources and naming
- Name things in the domain's words, the ones users use. One concept has one name everywhere.
- HTTP: nouns for resources, plural collections, stable identifiers in the path, filters in the query. Use the methods for what they mean: reading has no side effects, replace and delete are idempotent. An action that is not create, read, update or delete becomes a sub-resource or a clearly named action, in the style the project already uses.
- RPC and library: verb plus noun, one job per operation. Required parameters are positional or explicit, optional ones are named with defaults; no boolean parameters that flip the meaning of a call.
- Fields: one casing; explicit units in the name or the type (`timeout_ms`); timestamps in UTC in one standard format; money as integer minor units plus currency, never floating point; enumerations as strings; identifiers as opaque strings.
- Decide for each field: required or optional, nullable or absent, default, limits (length, range, allowed values). Absent and null must not mean two things by accident.
- Return what was created or changed, so that the client does not need a second call.
## 3. Errors
- One error shape for the whole interface: a stable machine code, a human message, the field at fault for validation errors, a request identifier for support.
- Map to the transport's own categories: invalid input, not authenticated, not allowed, not found, conflict, rate limited, server failure, dependency failure. Never report an error inside a success response.
- Report all validation errors of a request at once.
- The message says what to do next. It leaks no stack trace, query, internal path or secret, and it does not reveal whether a resource the caller may not see exists.
- Document for each operation which errors it can return and which are safe to retry.
## 4. Lists, bulk and long operations
- Every list is paginated from day one, with a default and a maximum page size (for example 50 and 200) and a stable sort with a unique tie-breaker. Prefer cursors for data that grows or changes; offsets only for small, stable sets.
- Filtering and sorting only on fields the storage can serve efficiently. Name the allowed ones.
- Bulk operations state whether they are all-or-nothing or per-item, and return a per-item result in the second case. Cap the batch size.
- Work longer than a few seconds returns at once with an operation the client can poll or subscribe to, with states and a result.
## 5. Idempotency and concurrency
- Any operation that creates or charges accepts a client-supplied idempotency key. The same key with the same body returns the first result; the same key with a different body is an error. State how long keys are kept.
- Updates guard against lost writes with a version or an entity tag and return a conflict when it is stale.
- Say which operations are safe to retry and what a timeout means for the caller.
## 6. Versioning and compatibility
- Compatible: adding an optional request field, a response field, an operation, an error code where clients were told to expect unknown ones.
- Breaking: removing or renaming anything, changing a type or a meaning, making an optional field required, tightening validation, changing a default, the sort order or an error code.
- A breaking change needs a new version or a parallel field or operation, a deprecation notice with a date, and a migration note. Follow the versioning scheme the project already has.
- Check existing clients in the repository against the change. List the ones that must change.
## 7. Auth and limits
- Every operation states who may call it and on which objects. Check ownership per object, not only per endpoint.
- Never accept the caller's identity or role from the request body. No secrets in URLs.
- Rate limits and size limits (body, upload, page) are stated, with the error returned when they are hit.
- Return only the fields the caller is allowed to see. Mark personal and sensitive fields.
## 8. Output
Write the contract in the format the project already uses (an interface description file, schema files, typed signatures, or a document next to the code), and report:
1. **Operations**: for each, purpose, input, output, errors, auth, idempotency, one request and response example that was run or validated against the schema.
2. **Decisions** with reasons, and the alternatives rejected.
3. **Compatibility**: what changes for existing clients and the migration steps.
4. **Open questions** for the owner.
Rules: design and documentation only, unless the task also asks for the implementation. Examples use invented data and placeholder credentials. Do not commit or push unless the task says so. When blocked, state exactly which decision is needed.