---
title: "Multi-Tenant SaaS API Gateways: Isolation, Quotas, and Tenant-Aware Policy - API7.ai"
description: "Turn verified tenant identity into scoped gateway policy while preserving application authorization, data isolation, and failure boundaries."
url: "https://api7.ai/learning-center/api-gateway-guide/multi-tenant-saas-api-gateway-policy"
---

[Skip to article](#column-content)

Column contentsAPI Gateway Guide

[API Gateway Guide](https://api7.ai/learning-center/api-gateway-guide)

Search this column

01 Gateway Fundamentals

[View this topic · 10](https://api7.ai/learning-center/api-gateway-guide?topic=fundamentals)[1. What Is an API Gateway? API Gateway Software and Use Cases](https://api7.ai/learning-center/api-gateway-guide/what-is-an-api-gateway)[2. Why Do Modern Architectures Need an API Gateway?](https://api7.ai/learning-center/api-gateway-guide/why-do-modern-architectures-need-api-gateway)[3. Reverse Proxy vs Load Balancer vs API Gateway](https://api7.ai/learning-center/api-gateway-guide/api-gateway-vs-reverse-proxy-vs-load-balancer)[4. API Gateway and Microservices: Decoupling and Traffic Management](https://api7.ai/learning-center/api-gateway-guide/api-gateway-and-microservices)[5. Understanding Core API Gateway Features](https://api7.ai/learning-center/api-gateway-guide/core-api-gateway-features)[6. Open Source vs. Commercial API Gateways: How to Choose the Right One?](https://api7.ai/learning-center/api-gateway-guide/open-source-vs-commercial-api-gateway)[7. API Gateway vs Service Mesh: How to Choose?](https://api7.ai/learning-center/api-gateway-guide/api-gateway-vs-service-mesh)[8. Envoy vs NGINX, Java, and Go for API Gateways](https://api7.ai/learning-center/api-gateway-guide/nginx-vs-envoy-vs-java-vs-go)[9. Core Concepts of API Gateway: Service, Route, Upstream, Plugin, and Consumer](https://api7.ai/learning-center/api-gateway-guide/core-concepts-of-api-gateway)[10. API Gateway Comparison: Apache APISIX vs. Kong vs. Traefik vs. KrakenD vs. Tyk](https://api7.ai/learning-center/api-gateway-guide/api-gateway-comparison-apisix-kong-traefik-krakend-tyk)

02 Gateway Architecture and Design

[View this topic · 10](https://api7.ai/learning-center/api-gateway-guide?topic=architecture)[11. Deep Dive into API Gateway Architecture: Core Components and Design Principles](https://api7.ai/learning-center/api-gateway-guide/api-gateway-architecture)[12. Choosing the Right API Gateway for Your Architecture](https://api7.ai/learning-center/api-gateway-guide/api-gateway-monolithic-vs-microservices)[13. How to Architect an API Gateway for High Availability (HA)?](https://api7.ai/learning-center/api-gateway-guide/api-gateway-high-availability)[14. API Gateway Plugin Architecture: How to Extend and Customize Your API Gateway](https://api7.ai/learning-center/api-gateway-guide/api-gateway-plugin-system)[15. How Event-Driven Architecture (EDA) Works with API Gateway?](https://api7.ai/learning-center/api-gateway-guide/api-gateway-event-driven-architecture)[16. API Gateway Request Lifecycle Explained](https://api7.ai/learning-center/api-gateway-guide/api-gateway-request-lifecycle-explained)[17. Cloud-Native API Gateway on Kubernetes](https://api7.ai/learning-center/api-gateway-guide/cloud-native-api-gateway-kubernetes)[18. API Gateway Control Plane vs. Data Plane](https://api7.ai/learning-center/api-gateway-guide/api-gateway-control-plane-vs-data-plane)[19. How API Gateways Work with GitOps: Automating API Management](https://api7.ai/learning-center/api-gateway-guide/api-gateway-gitops-integration)[20. How to Perform A/B Testing and Canary Releases with an API Gateway](https://api7.ai/learning-center/api-gateway-guide/ab-testing-canary-release-api-gateway)

03 Gateway Setup and Traffic Handling

[View this topic · 10](https://api7.ai/learning-center/api-gateway-guide?topic=traffic-protocols)[21. How to Deploy an API Gateway on Kubernetes: Step-by-Step Guide for Engineers](https://api7.ai/learning-center/api-gateway-guide/deploy-api-gateway-on-kubernetes)[22. Hands-on Setup with Apache APISIX API Gateway](https://api7.ai/learning-center/api-gateway-guide/api-gateway-getting-started-guide)[23. API Gateway Auth: OAuth 2.0, JWT & OIDC with APISIX](https://api7.ai/learning-center/api-gateway-guide/api-gateway-authentication-apache-apisix-oauth-jwt-oidc)[24. Mastering Traffic Control: Efficiently Managing API Requests with Gateways](https://api7.ai/learning-center/api-gateway-guide/api-gateway-traffic-control-strategies)[25. Building Reliable API Gateways with Logging and Monitoring](https://api7.ai/learning-center/api-gateway-guide/api-gateway-logging-monitoring-best-practices)[26. Dynamic Routing in API Gateways: Best Practices for Flexible Traffic Management](https://api7.ai/learning-center/api-gateway-guide/api-gateway-dynamic-routing-management)[27. How API Gateways Support WebSocket](https://api7.ai/learning-center/api-gateway-guide/how-api-gateways-support-websocket)[28. API Gateway for GraphQL: Security, Cost, and Caching](https://api7.ai/learning-center/api-gateway-guide/api-gateway-handle-graphql)[29. How API Gateways Handle HTTP/3 QUIC Requests](https://api7.ai/learning-center/api-gateway-guide/api-gateway-http3-quic)[30. How API Gateways Handle MQTT Requests](https://api7.ai/learning-center/api-gateway-guide/api-gateway-mqtt)

04 Gateway Integrations, AI, and MCP

[View this topic · 10](https://api7.ai/learning-center/api-gateway-guide?topic=ai-mcp)[31. How API Gateways Handle gRPC Requests](https://api7.ai/learning-center/api-gateway-guide/api-gateway-grpc-support)[32. How API Gateways Implement Custom Plugins](https://api7.ai/learning-center/api-gateway-guide/api-gateway-custom-plugins)[33. How API Gateways Integrate with Kafka](https://api7.ai/learning-center/api-gateway-guide/api-gateway-kafka-integration)[34. How to Implement API Aggregation in API Gateways](https://api7.ai/learning-center/api-gateway-guide/api-gateway-api-aggregation)[35. How API Gateways Enable Serverless Architecture](https://api7.ai/learning-center/api-gateway-guide/api-gateway-serverless-architecture)[36. How API Gateways Proxy LLM Requests](https://api7.ai/learning-center/api-gateway-guide/api-gateway-proxy-llm-requests)[37. How API Gateways Enhance MCP Servers](https://api7.ai/learning-center/api-gateway-guide/api-gateway-enhance-mcp-server)[38. MCP Gateway vs MCP Proxy vs AI Gateway vs API Gateway](https://api7.ai/learning-center/api-gateway-guide/ai-gateway-vs-mcp-gateway-vs-api-gateway)[39. What Is an AI Gateway? Architecture and Benefits](https://api7.ai/learning-center/api-gateway-guide/what-is-an-ai-gateway)[40. What Is an MCP Gateway? Architecture, Use Cases & How It Works (2026 Guide)](https://api7.ai/learning-center/api-gateway-guide/what-is-mcp-gateway)

05 Gateway Performance

[View this topic · 10](https://api7.ai/learning-center/api-gateway-guide?topic=performance)[41. How API Gateway Reduces Latency: Performance Optimization Strategies](https://api7.ai/learning-center/api-gateway-guide/how-api-gateway-reduces-latency)[42. API Gateway Caching Strategy: Comprehensive Analysis and Implementation Guide](https://api7.ai/learning-center/api-gateway-guide/api-gateway-caching-strategy-analysis)[43. How to Optimize API Gateway Load Balancing: Advanced Strategies and Best Practices](https://api7.ai/learning-center/api-gateway-guide/how-to-optimize-api-gateway-load-balancing)[44. How API Gateway Efficiently Handles Large-Scale Traffic: Architecture and Strategies](https://api7.ai/learning-center/api-gateway-guide/how-api-gateway-handles-large-scale-traffic)[45. How to Improve API Gateway QoS: Traffic Classes, Capacity Protection, and SLOs](https://api7.ai/learning-center/api-gateway-guide/api-gateway-quality-of-service)[46. API Gateway Log Storage: Pipelines, Retention, Security, and Cost](https://api7.ai/learning-center/api-gateway-guide/api-gateway-log-storage)[47. API Gateway Timeouts and Retries: Safe Policies and APISIX Configuration](https://api7.ai/learning-center/api-gateway-guide/api-gateway-timeouts-retries)[48. API Gateway Concurrency Control: Capacity Budgets, Backpressure, and Load Shedding](https://api7.ai/learning-center/api-gateway-guide/api-gateway-concurrency-control)[49. Asynchronous API Gateway Patterns: Queues, Callbacks, and Performance Boundaries](https://api7.ai/learning-center/api-gateway-guide/asynchronous-api-gateway-patterns)[50. API Gateway TLS Performance: Handshakes, Session Reuse, and Measurement](https://api7.ai/learning-center/api-gateway-guide/api-gateway-tls-performance)

06 Gateway Security

[View this topic · 10](https://api7.ai/learning-center/api-gateway-guide?topic=security)[51. DDoS Defense at the API Gateway: Layered Controls and Failure Planning](https://api7.ai/learning-center/api-gateway-guide/api-gateway-ddos-defense)[52. Distributed API Gateway Rate Limiting: Local vs Redis Counters and Accuracy Trade-offs](https://api7.ai/learning-center/api-gateway-guide/distributed-api-gateway-rate-limiting)[53. API Gateway IP Allowlist and Denylist Management: Trust, Proxies, and Operations](https://api7.ai/learning-center/api-gateway-guide/api-gateway-ip-allowlist-denylist-management)[54. API Gateway Security Scanning: What to Test and How to Operationalize Findings](https://api7.ai/learning-center/api-gateway-guide/api-gateway-security-scanning)[55. SQL Injection and XSS at the API Gateway: Detection Limits and Defense in Depth](https://api7.ai/learning-center/api-gateway-guide/sql-injection-xss-api-gateway)[56. API Access Log Auditing: Evidence, Integrity, Retention, and Review](https://api7.ai/learning-center/api-gateway-guide/api-access-log-auditing)[57. Preventing API Scraping and Abuse: Identity, Behavioral Signals, and Rate Controls](https://api7.ai/learning-center/api-gateway-guide/prevent-api-scraping-abuse)[58. API Gateway mTLS: Client Identity, Certificate Rotation, and APISIX Configuration](https://api7.ai/learning-center/api-gateway-guide/api-gateway-mtls)[59. Fine-Grained API Gateway Authorization: RBAC, ABAC, and External Policy Decisions](https://api7.ai/learning-center/api-gateway-guide/fine-grained-api-gateway-authorization)[60. API Gateway and WAF Reference Architecture: Ownership, Header Trust, and Failure Modes](https://api7.ai/learning-center/api-gateway-guide/api-gateway-waf-reference-architecture)

07 Gateway Ecosystem and Comparisons

[View this topic · 10](https://api7.ai/learning-center/api-gateway-guide?topic=ecosystem)[61. Apache APISIX vs Kong: Migration, Operations, and Team Fit](https://api7.ai/learning-center/api-gateway-guide/apache-apisix-vs-kong)[62. Traefik vs Kong vs APISIX: A Reproducible API Gateway Benchmark Method](https://api7.ai/learning-center/api-gateway-guide/traefik-kong-apisix-benchmark-method)[63. Amazon API Gateway Explained: Deployment Models, Trade-offs, and Use Cases](https://api7.ai/learning-center/api-gateway-guide/amazon-api-gateway-explained)[64. API Gateway and Istio: Clear North-South and East-West Boundaries](https://api7.ai/learning-center/api-gateway-guide/api-gateway-istio)[65. API Gateway with NGINX: Layering, Ownership, and Migration Patterns](https://api7.ai/learning-center/api-gateway-guide/api-gateway-nginx)[66. API Gateway with Envoy: Deployment Patterns and Policy Ownership](https://api7.ai/learning-center/api-gateway-guide/api-gateway-envoy)[67. API Gateway with Cloudflare API Shield: Edge and Origin Security Boundaries](https://api7.ai/learning-center/api-gateway-guide/api-gateway-cloudflare-api-shield)[68. Apigee vs MuleSoft vs Amazon API Gateway: A Decision Framework](https://api7.ai/learning-center/api-gateway-guide/apigee-mulesoft-amazon-api-gateway)[69. Should an API Gateway Connect Directly to a Database? Patterns and Risks](https://api7.ai/learning-center/api-gateway-guide/api-gateway-database-access-patterns)[70. API Gateway Architecture for Large-Scale SaaS Platforms](https://api7.ai/learning-center/api-gateway-guide/api-gateway-large-scale-saas-architecture)

08 Industry Applications and Integrations

[View this topic · 10](https://api7.ai/learning-center/api-gateway-guide?topic=applications)[71. API Gateway CI/CD: Validation, Promotion, and Safe Rollback](https://api7.ai/learning-center/api-gateway-guide/api-gateway-ci-cd)[72. API Gateways for AI and ML Inference: Traffic, Security, and Observability](https://api7.ai/learning-center/api-gateway-guide/api-gateways-ai-ml-inference)[73. API Gateway Architecture for Financial Services: Controls and Failure Boundaries](https://api7.ai/learning-center/api-gateway-guide/api-gateway-financial-services)[74. API Gateway Architecture for E-Commerce: Checkout Reliability and Traffic Peaks](https://api7.ai/learning-center/api-gateway-guide/api-gateway-ecommerce)[75. API Gateways for Mobile Applications: Authentication, Payloads, and Versioning](https://api7.ai/learning-center/api-gateway-guide/api-gateways-mobile-applications)[76. API Gateways for Web3 Applications: RPC Traffic, Identity, and Abuse Controls](https://api7.ai/learning-center/api-gateway-guide/api-gateways-web3-applications)[77. OpenAPI-Driven API Gateway Operations: Import, Validation, and Drift Control](https://api7.ai/learning-center/api-gateway-guide/openapi-driven-api-gateway-operations)[78. gRPC-Web and gRPC Transcoding Through an API Gateway](https://api7.ai/learning-center/api-gateway-guide/grpc-web-grpc-transcoding-api-gateway)[79. API Gateway Pricing and Cost Optimization: A Workload-Based Model](https://api7.ai/learning-center/api-gateway-guide/api-gateway-pricing-cost-optimization)[80. Evaluating API Gateway Directions: Evidence and Architectural Impact](https://api7.ai/learning-center/api-gateway-guide/api-gateway-trends)

09 Advanced Gateway Applications

[View this topic · 10](https://api7.ai/learning-center/api-gateway-guide?topic=operations)[81. API Gateways in Zero Trust Architecture: Identity, Policy, and Limits](https://api7.ai/learning-center/api-gateway-guide/api-gateways-zero-trust-architecture)[82. API Gateway Log Analytics: Correlation, Queries, and Operational Signals](https://api7.ai/learning-center/api-gateway-guide/api-gateway-log-analytics)[83. From API Sprawl to Governed Delivery: The Gateway's Role in Modernization](https://api7.ai/learning-center/api-gateway-guide/api-gateway-modernization)[84. API Monetization at the Gateway: Plans, Metering, Entitlements, and Billing Boundaries](https://api7.ai/learning-center/api-gateway-guide/api-monetization-gateway)[85. Safe AI-Assisted API Gateway Optimization: Recommendations, Guardrails, and Approval](https://api7.ai/learning-center/api-gateway-guide/ai-assisted-api-gateway-optimization)[86. API Gateways for Low-Code and No-Code Integration: Governance and Safety](https://api7.ai/learning-center/api-gateway-guide/api-gateways-low-code-no-code-integration)[87. API Gateway and CIAM Integration: Token Validation, Consent, and Identity Context](https://api7.ai/learning-center/api-gateway-guide/api-gateway-ciam-integration)[88. Elastic API Gateway Scaling: Signals, Capacity, and Safe Scale-In](https://api7.ai/learning-center/api-gateway-guide/elastic-api-gateway-scaling)[89. Multi-Tenant SaaS API Gateways: Isolation, Quotas, and Tenant-Aware Policy](https://api7.ai/learning-center/api-gateway-guide/multi-tenant-saas-api-gateway-policy)[90. API Gateway DevSecOps: Policy as Code, Testing, and Runtime Feedback](https://api7.ai/learning-center/api-gateway-guide/api-gateway-devsecops)

10 Platform Engineering and Planning

[View this topic · 10](https://api7.ai/learning-center/api-gateway-guide?topic=platform-governance)[91. API Discovery and Documentation at the Gateway: Inventory, Ownership, and Drift](https://api7.ai/learning-center/api-gateway-guide/api-discovery-documentation-gateway)[92. WebAssembly Plugins for API Gateways: Portability, Isolation, and APISIX Boundaries](https://api7.ai/learning-center/api-gateway-guide/api-gateway-webassembly-plugins)[93. Monitoring API Gateways with Prometheus and Grafana: Metrics, Dashboards, and Alerts](https://api7.ai/learning-center/api-gateway-guide/monitor-api-gateways-prometheus-grafana)[94. API Gateway Reliability Engineering: SLOs, Failure Isolation, and Incident Response](https://api7.ai/learning-center/api-gateway-guide/api-gateway-reliability-engineering)[95. API Gateways for Edge AI Inference: Routing, Constraints, and Observability](https://api7.ai/learning-center/api-gateway-guide/api-gateways-edge-ai-inference)[96. Reducing Cloud Cost with API Gateway Controls: Measurement Before Optimization](https://api7.ai/learning-center/api-gateway-guide/reducing-cloud-cost-api-gateway-controls)[97. Improving API Developer Experience with Gateway Standards and Self-Service](https://api7.ai/learning-center/api-gateway-guide/improving-api-developer-experience-gateway-self-service)[98. API Gateway Change Management: Compatibility, Progressive Delivery, and Rollback](https://api7.ai/learning-center/api-gateway-guide/api-gateway-change-management-rollback)[99. Operating Serverless APIs: Cold Starts, Idempotency, and Asynchronous Handoffs](https://api7.ai/learning-center/api-gateway-guide/operating-serverless-apis-gateway)[100. Planning an API Gateway Roadmap for the Next Five Years](https://api7.ai/learning-center/api-gateway-guide/planning-api-gateway-roadmap-next-five-years)

[API Gateway Guide](https://api7.ai/learning-center/api-gateway-guide)[Advanced Gateway Applications](https://api7.ai/learning-center/api-gateway-guide?topic=operations)

On this page

On this page

- [Key Takeaways](#key-takeaways)

- [Define the Tenant Policy Contract](#define-the-tenant-policy-contract)

- [Establish the Identity-to-Policy Chain](#establish-the-identity-to-policy-chain)

- [Apply Layered Isolation](#apply-layered-isolation)

  - [Route and Operation Isolation](#route-and-operation-isolation)
  - [Capacity Isolation](#capacity-isolation)
  - [Failure-Domain Isolation](#failure-domain-isolation)
  - [Observability Isolation](#observability-isolation)

- [Use APISIX Consumer Groups Deliberately](#use-apisix-consumer-groups-deliberately)

- [Compile Policy Instead of Querying It on Every Request](#compile-policy-instead-of-querying-it-on-every-request)

- [Test Cross-Tenant Negative Paths](#test-cross-tenant-negative-paths)

- [Tenant Policy Checklist](#tenant-policy-checklist)

- [FAQ](#faq)

  - [Is a Consumer Group the same as a SaaS tenant?](#is-a-consumer-group-the-same-as-a-saas-tenant)
  - [Should the tenant ID be part of every rate-limit key?](#should-the-tenant-id-be-part-of-every-rate-limit-key)
  - [Can gateway isolation replace row-level security?](#can-gateway-isolation-replace-row-level-security)

- [Next Steps](#next-steps)

Article 89

# Multi-Tenant SaaS API Gateways: Isolation, Quotas, and Tenant-Aware Policy

API7.ai

September 22, 2026

A multi-tenant API gateway should compile verified tenant context into route access, quota, and observability policy. It must not treat a hostname, path segment, token claim, or `X-Tenant-ID` header as trusted merely because the value is present.

The gateway protects the shared edge. The application and data layer still own object-level authorization and durable tenant isolation. This guide focuses on that policy boundary; the broader cell and regional topology is covered in [API Gateway Architecture for Large-Scale SaaS Platforms](https://api7.ai/learning-center/api-gateway-guide/api-gateway-large-scale-saas-architecture).

## Key Takeaways

- Map an authenticated principal to an authoritative tenant before applying tenant policy.
- Remove, reject, or overwrite caller-supplied tenant context before forwarding an internal value.
- Separate route eligibility, traffic quota, concurrency, cost, and data authorization.
- Treat Consumer Groups as reusable gateway policy, not proof of database isolation.
- Test default, failure, bypass, exception, and credential-rotation paths for every tenant class.
- Keep policy changes scoped so one tenant exception cannot silently weaken all tenants.

## Define the Tenant Policy Contract

A tenant-aware policy needs more than a tenant ID:

| Field                  | Owner                                      | Example decision                                           |
| ---------------------- | ------------------------------------------ | ---------------------------------------------------------- |
| Principal              | Identity system and gateway authentication | Which credential or token was validated?                   |
| Tenant membership      | Authoritative tenant directory             | Which tenants may this principal represent?                |
| Route entitlement      | Product or policy owner                    | Which API and operation may this tenant call?              |
| Runtime budget         | Platform and service owners                | What request, concurrency, payload, or cost limit applies? |
| Resource authorization | Application                                | May this subject act on this order or account now?         |
| Data isolation         | Service and storage layer                  | Which rows, schema, database, region, or key may be used?  |

Do not use one field for all six decisions. A valid tenant membership does not grant access to every object, and a quota label is not an authorization result.

## Establish the Identity-to-Policy Chain

```
sequenceDiagram
    participant C as Client
    participant G as API gateway
    participant I as Identity verifier
    participant D as Tenant directory and policy source
    participant A as Tenant-aware application
    participant S as Isolated data boundary
    C->>G: Credential plus optional tenant hint
    G->>I: Validate credential contract
    I-->>G: Verified principal context
    G->>D: Resolve allowed tenant and policy revision
    D-->>G: Tenant, routes, quota, and cell
    alt Tenant hint conflicts with authorized membership
        G-->>C: Reject request
    else Tenant context is authorized or absent
        G->>G: Remove or replace public tenant hint
        G->>A: Minimal trusted context over protected hop
        A->>A: Object and workflow authorization
        A->>S: Tenant-scoped data operation
        S-->>A: Tenant-scoped result
        A-->>G: Response
        G-->>C: Response
    end
```

The identity verifier owns credential validity. The directory owns membership and placement. The gateway enforces its compiled boundary policy. The application and storage layer enforce domain and data access. Each arrow should have a failure policy and an accountable owner.

If the client chooses among several allowed tenants, treat its hint as a requested context. Compare it with authoritative membership, then create one internal value. The upstream may trust that value only over an authenticated path that the client cannot bypass or impersonate.

## Apply Layered Isolation

### Route and Operation Isolation

Allow a tenant only onto the API product, version, and methods it purchased or was assigned. A coarse route allowlist should fail before upstream work, while the application still validates the requested resource.

### Capacity Isolation

Use separate budgets for requests, concurrent work, long-lived connections, large bodies, and expensive operations. One request can initiate many database queries, connector calls, or model tokens; request count alone is not a fair cost measure.

### Failure-Domain Isolation

Decide whether a noisy or misconfigured tenant can affect a shared gateway, shared counter store, shared upstream pool, or whole region. Use cells or dedicated capacity only when the risk and operating cost justify them.

### Observability Isolation

Tenant labels help incident response but can expose customer names or create high metric cardinality. Prefer stable internal identifiers, access controls, retention limits, and a separate authorized mapping to customer-facing names.

## Use APISIX Consumer Groups Deliberately

Apache APISIX 3.19.0 [Consumer Groups](https://apisix.apache.org/docs/apisix/3.19/terminology/consumer-group/) attach common plugin configuration to Consumers. The [`consumer-restriction` plugin](https://apisix.apache.org/docs/apisix/3.19/plugins/consumer-restriction/) can allow or deny by Consumer, Route, Service, or Consumer Group ID after an authentication plugin selects a Consumer.

The following Admin API request bodies are excerpts. They assume authenticated Consumers have already been bound server-side to `tenant-acme`; the caller cannot set `group_id` on a data-plane request.

```
{
  "plugins": {
    "limit-count": {
      "count": 1200,
      "time_window": 60,
      "policy": "redis",
      "redis_host": "redis.internal",
      "redis_port": 6379,
      "redis_ssl": true,
      "redis_ssl_verify": true,
      "key_type": "constant",
      "key": "tenant-acme",
      "group": "tenant-acme-orders",
      "allow_degradation": false,
      "show_limit_quota_header": true,
      "rejected_code": 429
    }
  }
}
```

```
{
  "plugins": {
    "consumer-restriction": {
      "type": "consumer_group_id",
      "whitelist": ["tenant-acme"],
      "rejected_code": 403
    }
  }
}
```

The first body belongs to the Consumer Group; the second belongs to the protected Route or Service. `key_type: constant` makes the configured tenant group share one key. The separate `group` value allows matching `limit-count` configurations to share a counter across routes; it is not the tenant identity. Redis authentication and trust-store deployment details are intentionally omitted and must be configured for the deployed environment.

The [`limit-count` documentation](https://apisix.apache.org/docs/apisix/3.19/plugins/limit-count/) defines several important defaults and branches:

- `policy` defaults to `local`; each APISIX instance then has its own counter. Redis policies coordinate a counter across instances and add a dependency.
- `key_type` defaults to `var` and `key` to `remote_addr`; omitting both would create source-IP counters, not one tenant quota.
- For the single-node `redis` policy, `redis_ssl` defaults to `false`. The `false` path uses a plaintext Redis connection; `true` enables TLS. `redis_ssl_verify` also defaults to `false`: with TLS enabled, `false` encrypts the connection without authenticating the Redis server certificate, while `true` verifies the certificate against the configured trust and server name. These transport settings authenticate neither the caller nor its tenant; Redis credentials and the certificate trust boundary must be managed separately.
- `allow_degradation` defaults to `false`. With `false`, a counter-backend failure or invalid dynamic count/window returns HTTP `500`; with `true`, the request continues without this rate limit. Neither branch changes how tenant identity is established.
- `show_limit_quota_header` defaults to `true`. With `true`, quota headers are included; with `false`, they are suppressed. The headers expose enforcement state to the caller and must never be used by an upstream as trusted identity or billing evidence.

Consumer plugin priority also matters. APISIX documents that a plugin configured directly on a Consumer takes precedence over the same plugin inherited from its Consumer Group. Governance must prevent an unreviewed per-Consumer override from becoming a permanent tenant exception.

## Compile Policy Instead of Querying It on Every Request

Keep tenant plans, membership, exceptions, and lifecycle in an authoritative system. Compile the gateway-relevant subset into versioned configuration with an owner, effective time, and expiry for exceptions.

For dynamic lookups, define:

- cache lifetime and revocation exposure;
- behavior when the directory is absent, slow, stale, or contradictory;
- whether existing sessions may continue;
- how a tenant move between cells is coordinated;
- how the gateway proves which policy revision it used.

Fail-open and fail-closed are not global moral choices. An optional analytics label may fail open; tenant authentication, cross-tenant routing, or an expensive-operation budget may require fail closed or a smaller emergency allowance.

## Test Cross-Tenant Negative Paths

Positive tests prove only that one allowed request worked. Add a matrix that attempts:

- tenant A credential with tenant B header, host, path, object ID, and cell hint;
- a valid credential with no tenant membership;
- an expired, revoked, wrong-issuer, or wrong-audience credential;
- a Consumer moved between groups while an old credential remains active;
- a direct upstream request that bypasses the gateway;
- counter-store loss with `allow_degradation: false` and, in a separate approved policy, `true`;
- quota exhaustion from several source IPs in one tenant;
- per-Consumer plugin overrides that conflict with the group policy;
- logs and metrics that could reveal another tenant's identifiers or traffic.

## Tenant Policy Checklist

- Is tenant context derived from verified identity and authoritative membership?
- Can any caller-controlled value override the internal tenant mapping?
- Does route policy distinguish product access from object authorization?
- Are request, concurrency, payload, and expensive-operation budgets separate where needed?
- Are local and distributed counter semantics acceptable for the rule?
- Are both `allow_degradation` branches documented and tested?
- Are inherited and per-Consumer plugin priorities reviewed?
- Can a tenant exception expire automatically and be attributed to an owner?
- Can the upstream be reached without the authenticated gateway hop?
- Can an incident be reconstructed without exposing tenant secrets or personal data?

## FAQ

### Is a Consumer Group the same as a SaaS tenant?

No. It can represent a tenant policy cohort when operators bind Consumers correctly, but it does not prove membership, object authorization, or storage isolation.

### Should the tenant ID be part of every rate-limit key?

Only when the key comes from controlled context and matches the intended budget. A group-specific constant can be safer than a public header; per-user or per-operation limits may need additional dimensions.

### Can gateway isolation replace row-level security?

No. The gateway cannot see every internal data access or prove that a service scoped its query correctly. Enforce tenant boundaries again in the application and data layer.

## Next Steps

Connect tenant policy to [large-scale SaaS cells and failure domains](https://api7.ai/learning-center/api-gateway-guide/api-gateway-large-scale-saas-architecture), [distributed quota semantics](https://api7.ai/learning-center/api-gateway-guide/distributed-api-gateway-rate-limiting), and [fine-grained application authorization](https://api7.ai/learning-center/api-gateway-guide/fine-grained-api-gateway-authorization).

[Previous article**Elastic API Gateway Scaling: Signals, Capacity, and Safe Scale-In**](https://api7.ai/learning-center/api-gateway-guide/elastic-api-gateway-scaling)[Next article**API Gateway DevSecOps: Policy as Code, Testing, and Runtime Feedback**](https://api7.ai/learning-center/api-gateway-guide/api-gateway-devsecops)

On this page

- [Key Takeaways](#key-takeaways)

- [Define the Tenant Policy Contract](#define-the-tenant-policy-contract)

- [Establish the Identity-to-Policy Chain](#establish-the-identity-to-policy-chain)

- [Apply Layered Isolation](#apply-layered-isolation)

  - [Route and Operation Isolation](#route-and-operation-isolation)
  - [Capacity Isolation](#capacity-isolation)
  - [Failure-Domain Isolation](#failure-domain-isolation)
  - [Observability Isolation](#observability-isolation)

- [Use APISIX Consumer Groups Deliberately](#use-apisix-consumer-groups-deliberately)

- [Compile Policy Instead of Querying It on Every Request](#compile-policy-instead-of-querying-it-on-every-request)

- [Test Cross-Tenant Negative Paths](#test-cross-tenant-negative-paths)

- [Tenant Policy Checklist](#tenant-policy-checklist)

- [FAQ](#faq)

  - [Is a Consumer Group the same as a SaaS tenant?](#is-a-consumer-group-the-same-as-a-saas-tenant)
  - [Should the tenant ID be part of every rate-limit key?](#should-the-tenant-id-be-part-of-every-rate-limit-key)
  - [Can gateway isolation replace row-level security?](#can-gateway-isolation-replace-row-level-security)

- [Next Steps](#next-steps)
