XenonStack

DevOps

XenonStack Blog API Design Best Practices: Principles for Enterprises

and | Published | Updated

API Design Best Practices: Principles for Enterprises
15:49

Key takeaway

  • API design best practices: resource naming, HTTP methods, RFC 9457 errors, versioning, OpenAPI contracts and the OWASP API Top 10 for enterprises.

API design is the set of decisions that shape how other teams, partners and software agents will use your interface: which resources it exposes, how requests and errors look, how change is introduced and what each caller is allowed to do. The best API design practices for enterprise teams are consistent resource naming, correct use of HTTP methods and status codes, a standard error format, deliberate versioning, a written contract in OpenAPI and security decisions made at design time against the OWASP API Security Top 10 (2023).

This guide covers design decisions only. For the wider lifecycle of building, testing and retiring APIs, read our API development best practices guide, and for caller identity see API authentication methods. Each section below answers one question a design review should settle.

What is API design and why does it matter for enterprises?

An API (application programming interface) lets one application request data or actions from another without knowing how it is built. API design is the work of deciding what that interface looks like before and while it is implemented. Once other teams depend on an interface, changing it costs coordination, so early design choices are the cheapest to get right. The Microsoft Azure Architecture Center web API design guidance treats a web API as an abstraction of the underlying data and services, which keeps clients isolated from changes in the schema behind it.

What principles make an API well designed?

Four principles recur in good API design. They are practical tests for a design review, not standards.

PrincipleWhat it means in practiceDesign review question
ConsistentThe same naming, parameters, error shape and documentation style across every endpoint. Each inconsistency becomes extra code in every client.Would a developer who learned one endpoint guess the next?
Hard to misuseClear names, strict validation and informative errors make the wrong call difficult to write.What happens when a client sends bad input or retries a request?
Complete and conciseEnough resources for consumers to build real applications, without exposing every internal table.Does each resource map to a business concept consumers recognise?
Easy to evolveAdditive change by default, with a stated process for breaking change.How will we add a field or retire an endpoint without surprising callers?

How should resources and URIs be modelled?

Use nouns and plural collections

The Microsoft Azure Architecture Center web API design guidance says to use nouns for resource names, so /orders rather than /create-order, because the HTTP method already carries the action. It also uses plural collections: /customers is the collection and /customers/5 is one item. A single, predictable convention is worth more than the choice itself.

Two-column diagram mapping design questions to rules: resource naming to nouns and shallow URIs, errors to RFC 9457, breaking change to Deprecation and Sunset headers, security risk to OWASP API Top 10 controls.

Keep nesting shallow

The same guidance recommends avoiding URIs more complex than collection/item/collection, for example /customers/1/orders and /orders/99/products rather than /customers/1/orders/99/products. It also warns against chatty designs that expose many small resources and force clients into many requests.

Match each HTTP method to its meaning

MethodTypical useDesign rule from the Azure guidance
GETRetrieve a resource or collectionReturns a representation; no side effects expected
POSTCreate an item in a collection or submit work for processingClient posts to the collection URI and the server assigns the new URI
PUTReplace an itemMust be idempotent: sending the same request again leaves the state unchanged
PATCHPartial updateNot guaranteed idempotent; JSON Merge Patch (RFC 7396) is simpler, JSON Patch (RFC 6902) is more expressive
DELETERemove an itemReturns 204 on success and 404 if the item is absent

Idempotency matters most for payments, orders and any call a client may retry after a timeout, so decide it per operation before implementation.

Which status codes and error format should an API return?

Return the status code that matches the outcome, so clients can handle each class of problem without parsing text. The Azure guidance lists, for example, 200, 204 and 404 for GET, 201 with a Location header for POST, 409 for conflicting PUT or PATCH requests, 415 for an unsupported media type and 406 when no acceptable media type can be matched. RFC 6585 adds 429 Too Many Requests for rate limiting, and the response may include a Retry-After header.

For the body, use RFC 9457 (Problem Details for HTTP APIs, July 2023, which obsoletes RFC 7807). It defines the media type application/problem+json with the members type, status, title, detail and instance, and lets problem types add extension members. Adopting it means every service reports errors the same way instead of each team inventing a format. Do not put stack traces or internal identifiers in detail.

How should an API be versioned and retired?

Choose a versioning approach once, document it and apply it everywhere. The Azure guidance describes five options.

ApproachExampleWhen it fitsTrade-off
No versioningAdditive changes onlyInternal APIs with few consumersRemoving or renaming a field is still a breaking change
URI versioning/v2/customers/3Public or partner APIs that need simple routing and cachingVersion appears in the URI
Query string?version=2Keeping one URI per resourceSome older proxies and browsers do not cache query-string responses
Headerapi-version=2 in a custom headerClients you controlClients must send the header; caching needs more logic
Media typeAccept: application/vnd.contoso.v1+jsonHypermedia-style APIsMost complex for clients to use

For retirement, RFC 9745 (March 2025, Standards Track) defines a Deprecation header that tells clients a resource is or will be deprecated. It is a hint and does not change behaviour. It pairs with the optional Sunset header from RFC 8594, which says when the resource is expected to stop responding. Publish both, with a link to the migration guide, before removing anything.

How should pagination, filtering and long-running work be designed?

Collections should be paged from the start. The Azure guidance suggests limit and offset parameters with defaults and an upper limit on items returned, to help prevent denial-of-service attacks. Filtering and sorting go in the query string, and field selection must validate the requested fields so callers cannot reach fields they should not see. For work that takes longer than a request should, return 202 Accepted with a status endpoint in the Location header, and 303 See Other to the new resource when it completes. Latency targets belong in the design too; see our guide to API latency, response time and SLOs.

Why design the contract first with OpenAPI?

OpenAPI describes REST APIs in a machine-readable file. The Azure guidance notes that it promotes a contract-first approach over implementation-first: agree the contract, review it, then build to it. The same file can generate documentation and client libraries, and gives test tools something to check against, which is how documentation stays accurate. See API testing workflows and tools for how contracts feed testing.

OpenAPI 3.2.0 was announced on 23 September 2025 by the OpenAPI Initiative. It adds tag summary, parent and kind properties, support for the QUERY method, additionalOperations for methods OpenAPI does not define, streaming media types (Server-Sent Events, JSON Lines, JSON Sequences and multipart mixed) with itemSchema, the OAuth 2.0 Device Authorization Flow and an oauth2MetadataUrl property. Check that your gateway and tooling support a version before moving contracts to it.

A gateway can enforce parts of the contract at the edge. Our overview of the KrakenD API gateway for microservices shows one open-source option.

Which security risks should API design address?

Many API security failures are design decisions: which object a caller may read, which properties it may change, how much a single caller may consume. The OWASP API Security Top 10 (2023 edition) is the reference list to design against.

OWASP 2023 itemDesign question
API1 Broken Object Level AuthorizationIs every object access checked against the caller, not just the endpoint?
API2 Broken AuthenticationIs authentication handled by a standard mechanism? See API authentication methods.
API3 Broken Object Property Level AuthorizationCan callers read or write only the properties they should?
API4 Unrestricted Resource ConsumptionAre page sizes, payload sizes and rates capped?
API5 Broken Function Level AuthorizationAre administrative functions separated and checked?
API6 Unrestricted Access to Sensitive Business FlowsCan automation abuse a flow such as purchasing or sign-up?
API7 Server Side Request ForgeryDoes any parameter make the server fetch a caller-supplied URL?
API8 Security MisconfigurationAre defaults, headers and error messages reviewed?
API9 Improper Inventory ManagementIs every version and environment listed, owned and retired on time?
API10 Unsafe Consumption of APIsAre responses from third-party APIs validated?

Source: OWASP API Security Top 10 2023.

What has changed in API design recently?

ChangeStatusEffect on design
RFC 9457 replaces RFC 7807Published July 2023Use application/problem+json as the standard error body
RFC 9745 Deprecation headerPublished March 2025, Standards TrackSignal deprecation in responses, with Sunset for the end date
OpenAPI 3.2.0Announced 23 September 2025Streaming, QUERY method and device flow can be described in the contract
OWASP API Security Top 102023 editionAuthorisation and resource consumption are design concerns, not only code concerns

Software agents are now API consumers too. They call APIs without a person reading each response, so explicit contracts, clear errors and per-action authorisation matter more. ElixirClaw is an agentic OS platform to build, orchestrate and govern AI agents and automation workflows while keeping humans in control, and AgentGRC keeps autonomous agent actions inside policy, with the audit trail risk teams need.

What is a sensible order for adopting these practices?

StepAction
1Write naming, error and versioning conventions as a one-page standard.
2Adopt OpenAPI contracts and review them before implementation.
3Standardise errors on RFC 9457 and add Deprecation and Sunset headers.
4Add page size and rate limits to every collection.
5Review each API against the OWASP list and record the owner.
6Keep a live inventory of versions and environments.

What are the trade-offs, and when should you not follow the rules strictly?

Consistency can conflict with a use case that is naturally an action, and the Azure guidance accepts non-resource operations sparingly. Deep hypermedia (HATEOAS) has no general standard, so its link format is proprietary. Header and media type versioning are tidy but harder for clients and caches. Contract-first work slows the first release and speeds every later one. For a short-lived internal API with one consumer, a lightweight version of these steps is reasonable; for public, partner or agent-facing APIs, apply them in full.

To map one API decision your teams and agents depend on, and the context and policy behind it, book a Context Workshop. See what happens in the workshop.

Frequently asked questions

What are the most important API design best practices?

Use nouns and plural collections, match HTTP methods to their meaning, return correct status codes with an RFC 9457 error body, choose one versioning approach, write the contract in OpenAPI first and design against the OWASP API Security Top 10 (2023).

Should API URLs contain verbs?

No. The Azure guidance recommends nouns such as /orders because the HTTP method already carries the action. Non-resource operations are allowed sparingly.

Which standard should APIs use for error responses?

RFC 9457, Problem Details for HTTP APIs (July 2023), which obsoletes RFC 7807. It defines application/problem+json with type, status, title, detail and instance members.

How do you retire an API version safely?

Send the Deprecation header (RFC 9745) and, optionally, the Sunset header (RFC 8594) with a link to migration guidance, then remove the version only after the stated date.

What is contract-first API design?

It means writing and reviewing the OpenAPI description before implementation, then building to it. Documentation, client libraries and tests can then be generated from the same contract.

What is the difference between API design and API development?

Design settles the interface: resources, methods, errors, versions and security. Development covers building, testing, deploying and retiring it. See our API development best practices guide for the lifecycle.

Table of Contents

navdeep-singh-gill

Navdeep Singh Gill

Global CEO and Founder of XenonStack

LinkedIn profile

Navdeep Singh Gill is serving as Chief Executive Officer and Product Architect at XenonStack. He holds expertise in building SaaS Platform for Decentralised Big Data management and Governance, AI Marketplace for Operationalising and Scaling. His incredible experience in AI Technologies and Big Data Engineering thrills him to write about different use cases and its approach to solutions.

Get the latest articles in your inbox

Subscribe Now

Interested in Solving your Challenges with XenonStack Team
Get Started

Get Started with your requirements and primary focus, that will help us to make your solution

Please Select your Industry
Banking
Fintech
Payment Providers
Wealth Management
Discrete Manufacturing
Semiconductor
Machinery Manufacturing / Automation
Appliances / Electrical / Electronics
Elevator Manufacturing
Defense & Space Manufacturing
Computers & Electronics / Industrial Machinery
Motor Vehicle Manufacturing
Food and Beverages
Distillery & Wines
Beverages
Shipping
Logistics
Mobility (EV / Public Transport)
Energy & Utilities
Hospitality
Digital Gaming Platforms
SportsTech with AI
Public Safety - Explosives
Public Safety - Firefighting
Public Safety - Surveillance
Public Safety - Others
Media Platforms
City Operations
Airlines & Aviation
Defense Warfare & Drones
Robotics Engineering
Drones Manufacturing
AI Labs for Colleges
AI MSP / Quantum / AGI Institutes
Retail Apparel and Fashion

Proceed Next