Skip to content
Home / Blog / Engineering & Growth

API Design Best Practices for Apps and SaaS Products

API design best practices for REST: naming, versioning, pagination, error formats and authentication, with examples that keep mobile apps and partners happy.

An API is a promise. Once a mobile app, a partner or a customer's system depends on it, every change risks breaking someone. That is why API design best practices matter early: a clear, consistent API is cheaper to build on, easier to document and far less painful to evolve.

This guide covers practical REST conventions that work for mobile apps, web apps and SaaS products. It is aimed at founders who want to review a developer's work and at engineers who want a checklist they can apply this week.

What makes an API well designed?

A good API is predictable. A developer who has used two of your endpoints should be able to guess the third. It is also stable, secure, documented and forgiving of small mistakes by its callers.

Start by designing for the consumer, not for your database. Write down the main tasks a client needs to perform, such as 'create a booking' or 'list my invoices', and shape endpoints around them. Agreeing the contract before coding lets mobile and backend teams work in parallel, which is especially helpful for distributed teams across India and other time zones.

It also helps to write the contract in an OpenAPI-style description first. That document becomes a single source of truth for documentation, test data and generated client code.

How should you name resources and use methods?

REST treats everything as a resource, named with nouns, and uses the standard web methods for actions. Keep names plural, lowercase and consistent.

The pattern below is easy to remember:

  • GET /bookings returns a list; GET /bookings/42 returns one booking.
  • POST /bookings creates a booking.
  • PUT or PATCH /bookings/42 replaces or partially updates it.
  • DELETE /bookings/42 removes or cancels it.
  • Nested paths such as /customers/7/bookings show a clear relationship; avoid nesting more than two levels.

Actions that are not simple CRUD

Some operations are not natural resources, such as 'cancel', 'refund' or 'resend OTP'. Model them as a sub-resource or a clearly named action, for example POST /bookings/42/cancellation. Keep the rule consistent across the whole API so developers are never surprised.

Which status codes and error formats should you use?

Use standard status codes so clients can react correctly: 200 for success, 201 for created, 204 for no content, 400 for a bad request, 401 when not authenticated, 403 when not allowed, 404 when not found, 409 for conflicts, 422 for validation errors and 429 when the client is sending too many requests. Reserve 5xx codes for genuine server faults.

Equally important is a consistent error body. A client should not have to parse different shapes for different failures. A simple, reusable format looks like this: a machine-readable code, a human-readable message, and field-level details when validation fails. Never leak stack traces or database errors.

  • code: stable string such as BOOKING_SLOT_TAKEN, safe for apps to switch on.
  • message: plain language for developers and logs.
  • details: list of fields with problems, for form screens.
  • request_id: a trace id so support can find the matching log.

How do you handle pagination, filtering and sorting?

Never return an unbounded list. A table that holds 50 rows today will hold 500,000 later, and a single request that loads them all will slow the server and the phone. Always paginate and set a maximum page size.

There are two common approaches. Offset pagination uses page and limit, is simple and works for small, stable data. Cursor pagination uses an opaque pointer to the last item and is better for large or fast-changing lists such as chats and feeds, because new items do not shift the pages.

Keep filtering and sorting predictable: use query parameters such as status, from, to and sort, and document which fields are allowed. Allow only indexed fields to avoid slow queries; this ties directly into the database advice in scaling an app from 1,000 to 100,000 users.

How should you version an API without breaking clients?

Mobile apps are a special challenge, because many users stay on old versions for months. If you change a response and the old app cannot handle it, those users see crashes you cannot fix by deploying a server update. So version from the beginning and treat old versions as live commitments.

The most common approach is a version in the path, such as /v1/bookings. Another is a version header. Path versions are easier to see, test and route. Whatever you pick, apply it consistently.

  • Additive changes, such as new optional fields, are usually safe within a version.
  • Removing or renaming fields, changing types or altering behaviour needs a new version.
  • Announce deprecation with a date, send a warning header or message, and track which clients still call the old version.
  • Keep a minimum supported app version and a force-update path for critical issues.

Why this matters for app stores

Because store review and user update timelines are outside your control, backward compatibility is part of your release plan. See mobile app maintenance and support for how updates are planned.

How do you secure and protect an API?

Every endpoint needs an answer to two questions: who is calling, and are they allowed to do this? Use a proven authentication method such as token-based access with short-lived access tokens and refresh tokens, or OAuth where third parties are involved. Do not invent your own scheme, and always use encrypted connections.

Authorisation must be checked on the server for every resource. A classic mistake is trusting an id in the path: if user A requests /invoices/99 and the server never checks that invoice 99 belongs to user A, anyone can read anyone's data. Add rate limits, request size limits and input validation, and keep secrets out of the app binary.

For a wider list, read the app security checklist for startups. If the API handles money, design webhooks and idempotency carefully; payment gateway integration in India explains why repeated calls must not double-charge anyone.

A worked example: designing a booking endpoint

Consider a hypothetical multi-salon booking app. The client needs to create a booking for two services at one salon. A clean design could be POST /v1/bookings with a body containing the salon id, a list of service ids and a start time. The server validates availability and responds with 201 and the booking, or 409 with the code SLOT_TAKEN if someone else got there first.

To prevent duplicate bookings if the phone retries on a weak network, the client sends an idempotency key header. The server stores it and returns the original result on a repeat. The booking list endpoint is paginated with a cursor and filtered by status. Teams that build booking products, including our work on the Kyne apps, depend on these small decisions to stay reliable; see the Kyne Professionals case study for how multiple user roles share one platform.

Conclusion: treat your API as a product

Strong API design best practices come down to consistency, clarity and care for the people who depend on you. Name resources well, use proper status codes, paginate lists, version from day one and secure every call. Document it and test it like any other product. If you are planning an app or SaaS platform and want the API designed properly from the start, share your idea through our free project brief builder. You may also like our guide to building a SaaS product.

Frequently asked questions

Should I use REST or GraphQL?

REST is simple, widely understood and fits most business apps. GraphQL lets clients request exactly the fields they need, which can help complex mobile screens, but it adds tooling and caching considerations. Choose based on your clients' needs and your team's experience, and avoid switching without a clear problem to solve.

When should I introduce API versioning?

From the first public release. Even if you have only one mobile app, old installed versions will keep calling your server after you update it. Starting with a version in the path costs almost nothing and gives you a safe way to change behaviour later.

How do I document an API?

Describe it in an OpenAPI-style specification, then generate interactive documentation from it. Include example requests and responses, error codes, authentication steps and rate limits. Keep the document in the same repository as the code and update it whenever endpoints change, so it never drifts from reality.

How big should a page of results be?

There is no universal number. Many teams default to 20 to 50 items and cap the maximum at a few hundred. Choose based on payload size, mobile network conditions and screen needs, and let clients request a smaller page. Always enforce the cap on the server.

/ Talk to Elevenmonk

Want help with this? Let’s talk.

Tell us what you are planning. A founder or senior engineer replies with honest next steps, from Mumbai, for clients across India and worldwide.

Prefer to share your idea in writing? Use the free project brief builder: answer a few questions and send the brief on WhatsApp in one tap.

WhatsApp us