Applications and subscriptions
Applications
An application groups the subscriptions and the technical identity of a consumer: name,
owning team, the expected client_id for jwt, mtls and oauth2-remote plans, client certificates
and metadata.
It groups identity, never counters: each credential keeps its own quotas.
One API key for every API
An application can call every API with one key — one client id, one secret — instead of one key
per subscription: One API key for every API on the application (console, portal, admin API
shared_credential, Kubernetes sharedCredential).
- Its subscriptions to
apikeyplans then share the credential of the application. The gateway makes it with the first of them; each subscription gets an alias of its own on the gateway, built from its plan, that the calls of the credential to its API are identified as. - The quotas stay per subscription: the rate limit, the quotas, the restrictions and the plugins of each plan apply to the calls of its API, counted apart. Nothing is pooled.
- The calls are attributed to each subscription, and kept under the client id the consumer called with — the credential's — in the analytics and the request log.
- A new secret for the credential — Rotate secret on any of its subscriptions — is taken by every API at once. Suspending, expiring or closing a subscription cuts its API only.
- The choice holds for the subscriptions made from then on: the ones made before keep the key they were made with. A second subscription of the application to the same API (another plan) has a key of its own: the credential names one subscription per API.
- The credential stays when the last subscription is closed — it calls nothing, and the next subscription shares it again —, and leaves the gateway with the application.
- Only
apikeyplans share it for now;oauth2-localsubscriptions keep a key of their own.
Client certificates
An application lists the certificates it presents on mtls plans — the certificate only, never
its private key; the console and the portal read each one (subject, issuer, validity) and offer
its CN as the expected client_id, which is what the plans that read the CN identify the
application as.
While the application has an active subscription to an mtls plan, its certificates are derived as certificates of the gateway — marked as the product's, removed when no such subscription is active any more — so that the TLS handshake accepts them, a self-signed one in particular. Suspending or closing the subscription therefore removes the trust in a self-signed certificate; a certificate signed by a CA the gateway trusts (the trusted CAs of the plan) is not affected.
On these plans the subscription carries the client_id the application declares: the gateway
serves that client id, and no other, while the subscription is active. Two applications cannot
subscribe to the same plan with the same client_id; changing it moves the subscriptions of the
application to the new one.
Whoever can see an application can see its credentials — the members of its team, and the workspace administrators. Reading credentials is recorded in the audit trail.
Subscriptions
A subscription binds an application to a plan. Its states:
┌── auto ──────────────────────────────▶ active ◀──▶ suspended
request ─────────┤ │ │
├── manual ─▶ pending ─▶ accepted ─────────┘ │
│ └▶ rejected │
└── paid ───▶ pending_payment ─▶ payment confirmed ──▶ active
active, suspended ─ end date ─▶ expired ─ renewed ─▶ active
any open state ──▶ closed
A producer can give a subscription an end date. From that day on it expires: it stays on the gateway, its keys disabled — the consumer's calls are refused. A later end date, or none, renews it with the same keys; closing it removes it. The workers expire what is due every minute. A paid subscription ends with its subscription at the payment provider: it takes no end date.
The approval workflow belongs to the product: Otoroshi carries the plan's validation as a
label only. At request time the product checks that the plan is published and subscribable, visible
to the requester, that the usage statement and the terms are given when asked, that a client_id
is declared for token-based plans, and that the application has no open subscription to that plan.
Credentials
A subscription becomes an Otoroshi apikey — only once it is effective: a subscription waiting for a producer or a payment is not on the gateway at all.
- On
apikeyandoauth2-localplans the gateway mints a client id and secret; the product reads them back and shows them in the portal and in the console. - On the other kinds the consumer calls with its own token or certificate; nothing is minted (the client certificates of the application are derived while the subscription is active, see above).
- Rotate secret replaces the secret on the gateway at once.
- Suspend disables the key; resume enables it again.
- Close deletes the subscription from the gateway, and Otoroshi revokes its key with it.
Every operation is projected asynchronously and replayed if the gateway is unreachable: the
console shows the projection state (synced, waiting, error) and offers to replay it. A
secret rotation is the exception: it is written to the gateway at once, and fails while the gateway
is unreachable.
Transfer
A subscription can be transferred to an equivalent plan — same auth mechanism — on the
same API or on another version of it. The key does not change, the subscription keeps its identity
and its history, and Otoroshi applies the target plan's limits to the existing key. A subscription
that shares the key of its application keeps calling with it on the other version — its alias is
made again there —, unless the application already calls that version with it through another
subscription (409).
That single operation covers a tier upgrade, the replacement of a badly designed plan, a renegotiated contract, demoting an abusive consumer instead of cutting it off, and moving to a new version. Transferring between different mechanisms (apikey → jwt) is refused: the credential would change, so it is a new subscription.
Consent
A transfer that degrades the conditions is a change of contract, so it needs the consumer's agreement. The product compares the two plans and treats as a degradation: a lower rate limit, a lower daily or monthly quota, a higher price, different terms of use, or access limited to fewer resources.
| Who starts it | Nothing degrades | Something degrades |
|---|---|---|
| a producer (console, CLI) | applied at once | waits for the consumer's consent, with the reasons |
| a consumer (portal, Change plan) | the producer applies or declines it | the request itself carries the consent |
The consent — who, when, for which reasons — is kept in the transfer history of the subscription. Both sides are notified in-app (the bells of the console and of the portal).
otoroshi-apim subscriptions transfer default sub_01a1… --plan plan_partner
The command says whether the move is done, or waits — for the consumer's consent, or for a payment:
the subscription then has a pending_transfer (-o json), whose status is awaiting_consent.
Notifications
Consumers are notified of what happens to their subscriptions — accepted, rejected, suspended, resumed, closed, moved, a move to agree to — and producers of what they have to decide — a request waiting for review, a move asked by a consumer. Notifications are addressed to teams — the team of the application, the team of the API; for an API of no team, the administrators of its workspace, who decide for it —: every member sees them, and each reads them and marks them done on their own — one member dealing with a request does not hide it from the others.
In the console, the menu of the person signed in shows the unread ones (a dot on the avatar, their
count); opening the menu reads nothing. A notification is read when it is opened or marked read,
and done when dealt with: it leaves the list. All notifications lists them, to deal with,
unread, done, or all. The admin API serves the same: GET …/notifications?filter=open|unread|done|all,
POST …/notifications/read ({"ids": […]}, all of them without), POST …/notifications/done
({"ids": […], "done": true}).
Reviewing
The console lists subscriptions per API, per application and across the workspace, with the request (usage statement, terms acceptance, request form answers). A reviewer accepts or rejects with a message; the decision is recorded on the subscription and in the audit trail.
The requests waiting for review lead to themselves: their count beside APIs in the sidebar, a
notice above the list of APIs that opens them all (/subscriptions?status=pending), on the row of
an API a pending badge that opens its own, and on the page of the API a notice on its overview and
the count on its Subscriptions tab. The home of the workspace lists them too.
otoroshi-apim subscriptions list default --status pending
otoroshi-apim subscriptions accept default sub_01a1… --message "welcome"