API Contracts and Schema Design Questions

Defining the interface contract between producers and consumers: request/response payload shapes, data models, field-level validation, nullability, and enum/typing decisions (including safely evolving an enum's allowed values without breaking clients). Covers contract-first design with OpenAPI and JSON Schema (authoring specs, generating SDKs and mock servers, catching breaking changes in CI), mapping internal domain models to external DTOs as both evolve independently, and designing a stable error-response contract (structured error codes, correlation IDs, retryable classification). Also covers the leadership and behavioral practice of establishing and governing contract standards across teams. The contract is the durable artifact clients depend on.

HardTechnical
40 practiced

You need to add new enum values to a public API response without breaking older clients that may error or crash on an unrecognized value. Propose both server-side and client-side strategies to make this safe, and describe how you would migrate the schema and communicate the change to minimize client impact.

MediumSystem Design
75 practiced

Design an error contract for an API that aggregates calls to multiple third-party services. The contract should expose meaningful high-level errors to consumers while masking internal or third-party-sensitive details. Include how you would categorize transient versus permanent errors and propagate a correlation ID for debugging.

MediumTechnical
53 practiced

Write a minimal OpenAPI 3.1 specification (YAML) for a POST /orders endpoint on an e-commerce service. Include the request body schema (items: an array of objects with product_id and quantity), a 201 success response schema (order_id, total_amount), 400 and 401 error responses, and an example request and response embedded in the spec.

MediumTechnical
54 practiced

Draft a concise API contract (endpoints, request/response examples, and audit behavior) for an internal feature-flagging service used by multiple teams. Include endpoints for creating a flag, evaluating a flag on a low-latency path, toggling a flag, and retrieving audit logs. Note the performance and safety considerations your schema choices need to account for.

MediumTechnical
42 practiced

Write a JSON Schema (draft 2020-12 or later) for a POST endpoint /v1/apps/{app_id}/events that accepts an event payload with properties: eventType (enum), timestamp (ISO 8601 string), actor (object with id and type), metadata (optional object with string values), and items (array of objects with id and quantity). Include validation rules, required fields, and example success and validation-error responses.

Unlock Full Question Bank

Get access to all 17 API Contracts and Schema Design interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.