Batch subscriptions
A consumer can submit several API/plan selections together. Daikoku stores one
SubscriptionBatchDemand parent and one ordinary SubscriptionDemand child per
selected plan. The parent groups producer approvals and tracks independent
outcomes; it does not replace the existing subscription workflow.
Consumer selection
The multi-API flow preserves selected APIs across catalog pages. The consumer first chooses a team using the existing team selector, then chooses plans and keyrings. In environment mode, compatible plans with the same environment name can share one new or existing keyring across APIs. Different Otoroshi bindings or read-only settings form separate groups; plans that forbid aggregation keep individual keyrings.
Already subscribed plans without multiple-key support, pending unit requests, open batch items, unauthorized plans and unsupported processes are excluded.
Prepare API keys
After team selection, /apis/subscriptions/keyrings opens the API key
preparation workspace. Each key in the draft represents a keyring: the
credentials that will be shared by its accepted subscriptions.
- Use Prepare an API key to add a new key and give it a name, or Import API keys to search and select several existing team keys.
- Select a key in the list to inspect its requested access. For an imported key, existing access is displayed separately and cannot be removed here.
- Drag one plan, or a selection of plans, onto a key in the list or its detail panel. Without dragging, check the plans, focus the destination key in the list and press Enter to assign them.
- Remove an assigned plan to return it to the unassigned list. Removing a key from the draft returns all its requested plans to that list; it never deletes an existing key or its subscriptions.
Search filters the unassigned plans by API or plan name. In environment mode, plans are displayed by environment, with an action to select all visible plans in an environment.
Arrange by environment
In environment mode, Arrange by environment organizes the unassigned plans while preserving assignments already made. It reuses compatible keys already in the draft, preferring imported keys, or prepares new keys when needed. Import existing keys first if you want the arrangement to use them.
If several destinations are possible, the workspace asks you to choose. If subscription processes are incompatible, choose a compatible set; the other plans remain unassigned. Different Otoroshi bindings, read-only modes and aggregation permissions can require separate keys even within the same environment.
Undo arrangement restores the draft as it was before the arrangement. This action remains available until a subsequent change to the prepared keys or their assignments.
Compatibility rules
Sharing a key requires aggregation to be allowed by both the portal and the plans. Plans sharing a key must target the same Otoroshi instance and have compatible read-only settings. The selected subscription processes must also be compatible with the batch workflow.
In environment mode, when environmentAggregationApiKeysSecurity is enabled,
plans sharing a key must have the same environment name. A single request can
still contain dev and prod plans assigned to separate keys. Imported keys
are also checked against their existing subscriptions.
An incompatible move explains the violated rule and leaves the entire selection unchanged. These rules are checked again before submission and by the server.
Review and submit
Review request opens a summary separating new keys from additions to existing keys. Expand each key to inspect its requested plans. Plans left unassigned are listed separately and will not be submitted; keys without additions are ignored. Deprecated APIs are highlighted with a warning. Use Edit preparation to return to the draft without submitting.
Nothing is created or requested until Submit grouped request. If the selected process requires a motivation form, it is presented before sending. Requested access remains subject to the applicable approvals: submitting does not mean every plan has been accepted.
Unsaved draft
The preparation is local to the page, not a saved server-side draft. Once keys have been added to the draft, leaving through application navigation asks for confirmation. Reloading or closing the page uses the browser's unsaved-changes warning. Confirming departure discards the preparation.
Reloading retains the initial API and team selection from navigation history, but resets the prepared keys and assignments. Return to the catalog to change the initial selection. Opening the workspace URL without that selection displays a link back to the catalog.
Submission payload
The submission contains the consumer team, API/plan pairs, keyring choices, an idempotency key and optional motivation answers. For example:
{
"team": "consumer-team",
"idempotencyKey": "selection-2026-10-15",
"items": [
{
"api": "catalog",
"plan": "dev",
"keyringChoice": { "type": "new", "creation": "dev-keyring" }
},
{
"api": "billing",
"plan": "dev",
"keyringChoice": { "type": "new", "creation": "dev-keyring" }
}
],
"newKeyrings": [
{ "_id": "dev-keyring", "customName": "Development APIs" }
]
}
The tenant and requester come from the authenticated context. The server validates the whole selection before saving the parent. An invalid selection rejects the submission, rather than silently creating a partial selection. Repeating the same submission key reuses the existing batch.
Direct progression, without a scheduled job
Submission prepares the selected keyrings, creates all eligible children and advances their workflows in the same action. There is no periodic batch job, global scan, slice size or delayed creation of the next group of children.
Submission
|
+-- validate and persist the parent
+-- prepare each shared keyring once
+-- create all eligible child demands
+-- advance executable children
|
+-- automatic HTTP step: one call per child, sequentially
+-- producer approval: one notification per API and phase
+-- human input or callback: persist and wait
+-- completion: save the independent outcome
Producer decisions and form/email validation continue the affected batch directly. If advancing one child opens a phase barrier for an earlier sibling, that sibling continues within the same action. Waiting for input does not schedule background work.
Cancellation, explicit failure reconciliation and the _resume action also
operate directly on the requested batch. After a server interruption, use
POST /api/subscription/team/:teamId/batches/:batchId/_resume to continue
persisted work. There is no automatic restart scan.
Deleting an API, plan, consumer team or requester blocks the affected items and directly reconciles their batches, including unused keyring cleanup.
Grouped approvals and partial results
Children of the same API advance by phase: the next phase waits until all participating children have resolved the preceding phase. Finished children do not block the remaining ones; other APIs progress independently.
A TeamAdmin phase creates one ApiSubscriptionBatch notification containing
the exact child demands and steps to decide. Accepting or rejecting it updates
the children and parent transactionally, then immediately continues the batch.
HTTP validation remains individual: one plan can be refused without canceling
the other plans.
Item states are pending, waiting, inProgress, retryableError, accepted,
refused, blocked, failed or canceled. The parent's state is derived from
its items and can finish as partiallyAccepted.
Shared keyring lifecycle
Before creating children, Daikoku persists stable keyring identifiers and credentials. Internal keyrings are ready immediately. For Otoroshi, Daikoku creates or verifies its managed empty group, then creates a disabled API key authorized only on that group. The keyring becomes ready only after successful preparation.
If the Otoroshi configuration has no managed empty-group identity yet, batch preparation allocates and saves it before creating or verifying the group. The configured Otoroshi connection must have permission to manage that group and the API key; provisioning errors are reported rather than granting access without preparation.
When the first child is accepted, Daikoku activates the keyring and replaces the empty-group authorization with the accepted plan's entities. Further accepted children add their rights to the same keyring. Refused children do not remove previously granted access. An unused shell is removed when all its items finish without an accepted subscription, including after cancellation.
If preparation fails, the request reports the error. Retrying reuses the saved identifiers and checks the Otoroshi key's ownership instead of generating new credentials.
Concurrent actions and uncertain external results
Before executing a child, Daikoku reserves its item and target keyring in PostgreSQL. The keyring lock is shared across batches, preventing concurrent operations on the same keyring. Revision guards and transactions protect parent/child updates.
These protections remain necessary even without a scheduled job: a user can repeat an action or two callbacks can arrive concurrently. Reservation expiry does not authorize replaying an uncertain external operation.
The reservation duration defaults to 600,000 ms and is configured with
daikoku.subscriptionBatch.reservationDuration or
DAIKOKU_SUBSCRIPTION_BATCH_RESERVATION_DURATION.
A technical error is reported without preventing independent children from being processed. An uncertain child result remains recorded until a producer team administrator has verified the external outcome. Only after confirming failure should they call:
POST /api/subscription/team/:teamId/batches/:batchId/items/:itemId/_reconcile-failure
This releases the reservation, restores the executable child state and directly continues the batch. Do not use it while the external outcome is still unknown.