Consumers
In this document, you will learn the basic concepts of consumers in API7 Enterprise and why you need them. You will be introduced to a few relevant concepts, including how to pass consumer information to upstream, consumer access restriction, as well as consumer authentication and authorization.
Overview
A consumer represents a user, application, or host that sends requests to the API gateway and consumes backend services. It is used together with the authentication system. Each consumer must be configured with at least one authentication credential or integrated with an external authentication system using plugins like Authz Keycloak plugin or OpenID Connect plugin.
The following diagram illustrates an example of API7 Gateway with one route and two consumers. One consumer, FetchBot
, is a data fetching bot, and the other consumer, JohnDoe
, is a user. The route and consumers are enabled with the key-auth
plugin. Therefore, requests will be authenticated with API keys. To access the internal service, FetchBot
sends its requests with bot-key
and JohnDoe
sends his request with john-key
.

This configuration ensures that only authenticated requests can interact with the internal service exposed on /petstore
.
- If a request is sent to API7 Gateway without any key or with the wrong key, the request is rejected.
- If a request is sent to API7 Gateway with
bot-key
, the request is authenticated and sent byFetchBot
to fetch data from the internal service. The Limit Count plugin on theFetchBot
consumer takes effect, limiting the number of requests within a 5-second window to2
. If the rate-limiting threshold has not been met, the request is forwarded to the upstream service. Otherwise, it is rejected. - If a request is sent to API7 Gateway with
john-key
, the request is authenticated and sent byJohnDoe
, subsequently being forwarded to the upstream endpoint.
In this scenario, the authentication plugin is executed before the Limit Count rate limiting plugin in accordance with the plugins execution phases.
Passing Consumer Information to Upstream
For certain use cases, such as logging, analytics, and auditing, you might want to pass consumer information to upstream services. Consumer information, by default, is not exposed to upstream; however, you can use Attach Consumer Label plugin to include the needed information in the header.