Skip to content

Consumers and API keys

How-to guideThe steps for one task.

A consumer is an application that calls your APIs: a mobile app, a partner's integration, an internal batch job. It owns API keys, optional address restrictions and subscriptions to products.

Create an application and issue a key

Publish → Consumers → New application, name it (mobile-app), then Issue a key. The key is shown once with a copy button and a ready-made curl line; the gateway keeps a hash only.

curl -H "X-API-Key: apk_…" https://api.example.com/orders/items

The api-key policy accepts the key in the X-API-Key header by default; in and name change that to another header, Authorization: ApiKey …, or a query parameter for callers that cannot set headers. The key is stripped before the backend, which receives X-Apinx-Application: mobile-app and X-Apinx-Application-Id.

Several keys per application

Issue one key per deployment or per environment of the caller, name them, and revoke them one at a time. Keys can have an expiry date.

Rotation without downtime

Rotate issues a replacement and keeps the old key working for an overlap window you choose, so the caller can switch at its own pace. The replacement inherits the key's allowed sources. Revoke the old key when the caller confirms.

Revocation is immediate

Revoke blocks the key on the next request; no deployment. The trace of a refused call shows APX-PL-0002 with the key's name.

Allowed sources

Limit an application to calls from listed addresses and ranges (203.0.113.0/24), and narrow individual keys further. Calls from elsewhere get 403 APX-PL-0023. Behind a load balancer, enable trust_x_forwarded_for on the api-key policy and list your proxies in trusted_proxies so the real client address is checked.

Restricting an API to some applications

The api-key policy's allow_applications lists the applications an API or an operation accepts; every other valid key gets 403. For commercial access control, prefer products and plans.

The application's dashboard

Each application has a dashboard: requests, errors by cause with first and last occurrence, latency, its keys with last use, subscriptions with quota used this period, and its recent requests with the inspector. Give a partner a screenshot of it instead of a log extract.

Tokens instead of keys

An application can also get client credentials, a client ID and secret it trades for short-lived access tokens with refresh tokens, accepted by the Apinx access token policy. Keys and tokens can be accepted side by side while an application moves. See Protecting APIs with Apinx-issued tokens.

What is never exposed

  • Keys are stored as hashes with a peppered hash; the pepper is encrypted with your master key.
  • A key appears once, at issue time; not in exports, audit, traces or logs.
  • The inspector redacts the key header on every request.