Prompt
What’s the best way to route API requests by tenant, region, or version without custom code?
Latest observation
Oct 6, 2026
OpenAI APIWeb search: off
The usual best approach is to use an API gateway or edge proxy with declarative routing rules rather than writing custom routing logic in each service.
Recommended pattern
Use a gateway that can route based on:
- Hostnames:
tenant-a.api.example.com - Path prefixes:
/v1/...,/eu/... - Headers / query params:
X-Tenant: acme,X-Region: eu-west - JWT claims / auth context: tenant, region, plan, version
Good options
- Kong
- NGINX / NGINX Plus
- Envoy
- Traefik
- AWS API Gateway / Application Load Balancer
- Cloudflare / Fastly edge routing
- Apigee / Azure API Management
Best practice by routing dimension
- Tenant: use subdomains or host-based routing
Example:acme.api.example.com -> tenant-acme service - Region: use geo-DNS, edge routing, or region-aware gateway rules
- Version: use path-based versioning (
/v1,/v2) or header-based versioning if you want cleaner URLs
Why this is better than custom code
- Centralized routing policy
- Easier to change without redeploying services
- Better observability and rate limiting
- Supports canary, blue/green, and A/B routing
- Works well with auth, caching, and WAF features
If you want the simplest “no custom code” setup
A very common combo is:
- Hostname per tenant
- Path per version
- Gateway rules per region
Example:
acme.api.example.com/v1/ordersglobex.api.example.com/v2/orders
If you want, I can suggest a concrete setup for AWS, Kubernetes, or a self-hosted stack.