zero gravitySOLUTIONS
← All insightsARCHITECTURE / AUTHORITY BOUNDARY GUIDE

API gateway policy or application business logic.

QUICK ANSWER

Use the gateway for appropriate cross-cutting request and identity controls. Keep current resource authorization and transactional invariants with the application, and test cache scope and trusted context so gateway admission cannot become an unintended business bypass.

Inside this article 6 sections

Keep routing, request-shape controls, authentication integration, and broad admission policy at the API gateway when they belong there. Keep resource authorization, business invariants, and transactional state changes with the application that owns the data.

The boundary is about evidence and ownership. A gateway can establish that a credential is valid, but the application may still need current account membership and resource state to decide whether that caller can approve a specific purchase.

Trace one sensitive operation

Consider an illustrative purchase-approval endpoint. The request identifies an account, a purchase, and an approval decision. The gateway can select the route, enforce an allowed method and payload size, validate the credential through the configured mechanism, and reject excessive traffic.

The application must establish whether the purchase belongs to the account, whether the actor has the current approval role, whether the purchase is still awaiting approval, and whether another approval already committed. Those checks depend on business state and often need to occur with the write.

Moving the role check into a gateway policy does not remove the underlying data dependency. It may create a cached copy of membership that can become stale, while the transaction still needs to enforce the final invariant.

Original responsibility map · approve one purchase
Gateway
Admit a well-formed authenticated request

Route, protocol limits, credential validation, and broad traffic policy.

Application
Authorize this actor on this purchase

Account membership, resource ownership, and current workflow state.

Transaction
Commit one valid decision

Concurrency control, durable operation identity, and audit evidence.

Passing the gateway establishes prerequisites. It does not establish every fact needed to commit the business operation.

Use gateway policy for stable cross-cutting rules

Gateway policy is valuable when the same rule applies consistently across many routes and can be evaluated from trusted request context. Examples include supported protocols, route selection, basic schema constraints, and integration with an identity provider.

Keep transformations small and explicit. Renaming a public header or adapting a versioned route can be appropriate. Combining several business writes, interpreting account lifecycle state, or calculating an invoice adjustment creates a second application whose behavior needs its own ownership and tests.

Document where the public contract is defined. If both gateway templates and application code independently validate request fields, keep them compatible and test the resulting error behavior. A request accepted by one layer and rejected mysteriously by another is difficult for API consumers to diagnose.

Review authorizer cache scope

API Gateway Lambda authorizers can use configured identity sources and return authorization results. When caching is enabled, the cache key and returned policy scope must match the intended reuse. A decision derived for one resource should not accidentally authorize another route or account.

Define what may be cached and for how long. A stable token-validation result is different from a rapidly changing account entitlement. If a user's role is revoked, identify which layer observes that revocation and how quickly. Do not rely on a gateway cache as the only enforcement point for a transaction-sensitive permission.

Test two accounts, two resources, and a role change using the same client identity where appropriate. Check that cached results do not cross the intended boundary. Include a request with missing identity context and verify it fails through the expected path.

Carry trusted context without creating a bypass

The backend may consume verified identity claims or authorizer context passed through the gateway. Define which fields are trusted, strip conflicting caller-supplied headers, and authenticate the gateway-to-origin path where the design requires it.

A backend reachable directly must still reject requests that lack the required trusted context or valid customer credentials. Restricting the network path can help, but it should be part of a documented trust model rather than an assumption that nobody knows the origin address.

Keep account identifiers derived from authorized identity and resource relationships. A header named X-Account-ID is not evidence of membership simply because it arrived through a gateway. The tenant-aware operation guide shows how account scope also affects duplicate-safe writes.

Separate traffic controls from business quotas

Gateway throttling and WAF rules can reduce excessive arrivals, but their limits are not interchangeable with exact commercial entitlements or resource reservations. A paid export allowance may require consistent application accounting, while a concurrent-work limit protects the actual worker pool.

Define whether a rejected request created any durable business operation. If the application accepts asynchronous work, return an operation identifier and expose its status. A gateway timeout after the backend commits should not lead the client to create a second operation under a new identity.

The tenant rate-limiting guide separates edge protection, tenant admission, and shared execution capacity. Keep those responsibilities visible even when one provider offers several of the controls.

Keep the gateway’s error vocabulary aligned with the API contract. A client should distinguish expired identity from temporary upstream failure without parsing provider-specific text. Preserve diagnostic detail internally while returning stable, documented error codes that consumers can handle predictably.

Test the boundary through change and failure

Run contract tests for valid requests, malformed payloads, expired credentials, wrong-account resources, stale roles, and duplicate submissions. Then test gateway unavailability, authorizer failure, and a timeout after the application commits. Each case should produce a known customer-visible state.

Version changes across gateway and backend so rolling deployments remain compatible. Review the generated resource policy and integration configuration alongside application tests. A small gateway edit can change access or error semantics across many routes.

Architecture design can define this boundary as an explicit authority map, with trusted context, cache rules, and transaction ownership that remain clear as the API grows.

FROM INSIGHT TO ACTIONSoftware architecture consulting

Define a clear authority boundary for your API.

We can review gateway policy, authorizer caching, trusted context, and application invariants around a real customer operation.

Explore architecture consultingDiscuss your architecture

Start with your goals.
We’ll work through the next step together.