QSourceAI.
Menu

Backend API Design Interviews: Contracts, Authorization and Errors

Design endpoints as reliable client contracts.

Illustrated guide: Backend API Design Interviews: Contracts, Authorization and Errors

Strong backend developers think beyond request handlers to permissions, retries, evolution and failure visibility.

Define the resource and contract

What is the client trying to do? Choose identifiers, request fields, response shapes, pagination and filtering rules. Start with a primary user journey before adding optional endpoints. Clarify whether an operation can be repeated and how clients learn its final state.

Enforce ownership on the server

Authentication is only the first step; authorization checks whether the caller may touch this particular resource. Validate input, restrict fields that may be changed and rate-limit sensitive endpoints. Do not assume a hidden UI control prevents direct API calls.

Design state transitions for failure

A client may retry after a timeout even when the first request succeeded. Use idempotency keys where duplicated creation would be damaging. Define useful validation, conflict, not-found and retryable server responses. Log request identifiers without leaking personal data or credentials.

Walk through a permission bug

Suppose GET /projects/123 returns a project's details. Authentication verifies that the caller is signed in, but the endpoint looks up project 123 without checking organization membership. A user can change the ID and retrieve another customer's information. Explain the fix: authorization must be applied to the resource query or explicitly verified against the caller's permitted scope. The UI must not be the security boundary. For updates, restrict accepted fields so a client cannot arbitrarily change ownership or billing state. Add a test that attempts cross-account access and expects denial. For a create endpoint, pair input validation with idempotency so repeated network requests do not create duplicate resources. These details make an API design interview feel like real production engineering rather than a list of REST verbs.

PUT IT INTO WORDS

A practical example

For POST /orders, authorize the customer, validate inventory, accept an idempotency key, persist a consistent order state and return its identifier. Concurrent stock changes should produce a clear conflict.

Try this today

Design a subscription API with create, retrieve, cancel and list actions. Write one success response and three distinct errors, then explain the behavior of repeated cancellation.

Before you move on

  • Define a stable contract
  • Authorize every resource access
  • Make retries safe
YOUR REAL-TIME INTERVIEW CO-PILOT

Real questions. Answers built around you.

Rehearse API design trade-offs in QSourceAI with real services you built.

Try QSourceAI for Windows ↗