Gateway enforcement
How live requests are authenticated, enforced, routed, and metered.
How live requests are authenticated, enforced, routed, and metered.
The gateway is the runtime that protects live products. It runs in front of the upstream API and decides whether each subscriber request should be forwarded.
For a typical request, the gateway:
Core stores the source of truth. The gateway needs a fast runtime shape.
When products, plans, subscriptions, or keys change, core publishes compiled runtime artifacts. The gateway reads those artifacts from edge configuration and caches them. That avoids a control-plane request on every API call.
The gateway can enforce:
Gateway errors use a flat public shape:
{
"error": "Usage limit exceeded",
"code": "usage_limit_exceeded"
}
The error is for humans. The code is for client logic and support workflows.
Gateway configuration is cached so requests stay fast. Most product and key changes propagate through edge publishing rather than direct gateway calls.
If a recent change is not visible yet, wait for the publish/refresh path and retry with a fresh request. Do not assume the upstream is broken until you know whether the gateway denied the request.
Gateway denials usually return a platform code. Upstream failures usually
look like your API's own error response.
When debugging, first identify whether the request was denied before forwarding or forwarded and failed upstream.
Durable Objects coordinate hot runtime state such as usage allocation and concurrency. High-traffic products can be spread across multiple shards so one object does not become the bottleneck.
See Gateway sharding for the product-facing model.