A poorly designed API shows its flaws late: when a mobile app is already in production, three clients are integrated, and nobody dares change a field. Designing well from the start costs little; fixing it later costs months of coordination with third parties.
Short answer: A durable REST API uses plural resource names, HTTP verbs with their standard meaning, errors in a consistent format, pagination from day one, and an explicit versioning scheme. The goal is to let you add functionality without breaking the clients that have already integrated your API.
What is a REST API and what makes it "well designed"?
A REST API is an interface that exposes a system's resources (customers, orders, invoices) over HTTP, using URLs to identify them and verbs such as GET, POST, PUT, PATCH and DELETE to operate on them. It is well designed when it is predictable: someone who knows one of its endpoints can guess how the others work. If you are still deciding how to connect systems, first read RPA vs API vs integration: what to automate and how.
Consistency is worth more than theoretical purity. A "not perfectly REST" but coherent API is better than a purist one with exceptions everywhere.
Resources and URLs: name things, not actions
The base rule: the URL identifies a noun and the HTTP verb expresses the action.
| Intent | Poor design | Good design |
|---|---|---|
| List orders | GET /getOrders | GET /orders |
| Create an order | POST /createOrder | POST /orders |
| View one order | GET /order?id=10 | GET /orders/10 |
| A customer's orders | GET /ordersByCustomer | GET /customers/7/orders |
| Cancel an order | POST /cancelOrder | POST /orders/10/cancellation |
A few guidelines that prevent headaches:
- Use plural, lowercase names for all resources, with hyphens when there are several words.
- Do not nest more than two levels; if you need more, expose the child resource on its own route.
- Actions that do not fit a CRUD model (cancel, approve, resend) are modeled as sub-resources or as a clear POST on the resource.
- Use PATCH for partial changes and PUT only when you replace the entire resource.
- Use opaque identifiers (UUID or similar) when you do not want to reveal how many records you have.
What should API errors look like?
Errors are the part of an API that is most often misused. A 200 with an error message inside the body forces every client to invent its own logic.
- Use HTTP status codes with their real meaning: 400 for an invalid request, 401 for unauthenticated, 403 for no permission, 404 not found, 409 conflict, 422 validation failed, 429 too many requests, and 5xx for server failures.
- Always return the same error format. The IETF has published a standard, RFC 9457 (Problem Details for HTTP APIs), which defines fields such as type, title, status and detail; adopting it saves you from designing your own.
- Include a stable, machine-readable error code, separate from the human-facing message, which may change or be translated.
- For validation errors, return the list of fields with their problem, not just "invalid data."
- Never leak internal stack traces, SQL queries or server paths in production.
How do you paginate, filter and sort?
Every collection that can grow needs pagination from day one. Adding it later is a breaking change for clients.
- Page and size pagination: simple and sufficient for admin panels. Limit the maximum size (for example, 100 records).
- Cursor pagination: recommended for long lists or lists that change constantly, such as feeds or transactions, because it avoids skips and duplicates when records are inserted.
- Filters and sorting: through explicit, documented query parameters (
?status=paid&order=-date). Do not accept arbitrary filters without indexes to back them. - Metadata: return the total or, at least, whether a next page exists.
An often overlooked point: decide in advance what happens at the limits. An API with no cap on results invites a poorly written client to bring down your database. This topic connects with optimizing backend performance.
How do you version an API without breaking your clients?
Versioning means agreeing on when a change is compatible and when it is not. Compatible changes (adding an optional field or a new endpoint) do not require a new version. Incompatible ones (renaming or removing a field, changing a type or a rule) do.
| Strategy | Example | Advantage | Watch out for |
|---|---|---|---|
| In the URL | /v1/orders | Visible and easy to route | You duplicate routes per version |
| In a header | Accept with version | Clean URL | Harder to test by hand |
| By date | Version pinned per client | Gradual changes | Requires more infrastructure |
For most small and mid-sized teams, versioning in the URL is the most practical option. What matters is discipline:
- Define what counts as a breaking change and write it down for the team.
- Keep a maximum of two active versions at a time.
- Announce deprecation in advance and in writing; use deprecation warning headers in responses.
- Measure which clients are still using the old version before shutting it down.
Security, idempotency and documentation
- Authentication: short-lived, minimum-scope tokens; never credentials in the URL. Secrets live outside the code, as explained in managing secrets, API keys and credentials.
- Idempotency: for operations that charge money or create records, accept an idempotency key so a retry does not duplicate the order or the payment.
- Rate limits: apply per-client request limiting and return 429 with information on when to retry.
- Documentation: publish the specification with OpenAPI and generate it from the code or verify it in the pipeline so it does not go stale. An API without living documentation becomes tribal knowledge.
- Dates and money: dates in ISO 8601 format with a time zone; amounts as an integer in the smallest unit or as a decimal string, with the currency stated explicitly. This matters a great deal if you operate in several countries.
Common mistakes
- Exposing database tables directly as resources, coupling the API to the internal schema.
- Changing the meaning of a field without changing the version.
- Returning unpaginated collections "because there are only a few records for now."
- Mixing error formats depending on which module produced them.
- Not providing a test environment (sandbox) for the people integrating.
When does something other than REST make sense?
REST covers most enterprise integrations. Consider GraphQL when very different clients need very different data shapes, or gRPC for high-volume internal communication between services. Do not change styles because of fashion; change when the problem calls for it. At DaltoAura we design APIs for mobile apps, portals and third-party systems, and we usually start with an OpenAPI contract reviewed by the team before writing code.
Frequently asked questions
Is it better to version the API in the URL or in a header?
For small and mid-sized teams, the URL (for example /v1/) is usually the better choice, because it is visible and easy to test and route. Headers keep URLs clean but complicate manual testing and documentation. What matters is not the mechanism but applying it consistently and communicating deprecations well in advance.
How many versions of an API should I maintain at the same time?
The healthiest approach is to maintain the current version and, at most, one previous version in a transition period. More versions multiply testing, support and security risks. Set a deprecation deadline, announce it in writing, and check actual usage before shutting down the old version.
Should I use PUT or PATCH to update a resource?
Use PATCH when the client sends only the fields that change and PUT when it replaces the entire resource. In practice, many enterprise APIs prefer PATCH because it prevents a client from accidentally overwriting fields it did not know about. Document which one each endpoint uses.
What page size is reasonable in an API?
It depends on the weight of each record and on usage, but a default of 20 to 50 and a maximum of 100 is a common starting point. What matters is to always enforce a cap and to measure performance with real data before raising it.
Let's talk
If you have a project in mind or want to review the architecture of an existing system, DaltoAura can help you turn it into a concrete plan, with no commitment.