API Access
- Applies to
- Gateway+Developer Portal
- Hosting
- Managed EdgeManaged DedicatedSelf-Hosted
Buckets
Each Zuplo project includes three isolated buckets that mirror your environment structure:
| Bucket | Purpose |
|---|---|
| Working Copy | Your development sandbox for building and testing |
| Preview | Staging environments for validating changes before production |
| Production | Your live environment serving real customers |
Meters, features, plans, and subscriptions are all scoped to a specific bucket. This isolation enables independent development workflows where you can:
- Experiment freely - Test new pricing models or usage tracking in development without affecting production data
- Validate changes - Promote your product catalog configuration through preview environments before going live
- Maintain separation - Keep development test data completely isolated from production customer usage
When you're satisfied with your configuration in one bucket, you can recreate that same configuration in another bucket to promote changes through your deployment pipeline.
Authentication
All Monetization API requests require authentication using a Zuplo API key.
All examples in this documentation assume the following environment variables are set in your terminal:
Code
Include your API key in the Authorization header:
Code
Bucket monetization configuration
Each bucket has an optional MonetizationConfiguration that holds bucket-wide
behavior — whether customers can hold multiple subscriptions, plan display
order, plan-level overrides, and the default payment grace period. The
configuration is read by the runtime and the Developer Portal; it is not stored
in OpenMeter.
Read
Code
When no configuration row exists for the bucket, the endpoint returns a default
body with multipleSubscriptionsEnabled: false, an empty planOrder, empty
planSettings, and maxPaymentOverdueDays: 3.
Upsert
Code
| Field | Type | Description |
|---|---|---|
multipleSubscriptionsEnabled | boolean | When true, a customer can hold several active subscriptions on different plans, each with its own API keys. When false (the default), a customer can hold one active subscription, and creating another returns 409 Conflict. A customer can't hold two subscriptions on the same plan either way. The Developer Portal also reads this flag: with it on, checkout links start a new subscription instead of changing the plan |
planOrder | string[] | Ordered list of plan keys; drives pricing-page sort and upgrade/downgrade direction during plan changes |
planSettings | object | Per-plan overrides keyed by plan key. The supported sub-key today is visiblePhases — an array of phase keys that should appear on the pricing page |
maxPaymentOverdueDays | integer | Bucket-default payment grace period. Must be ≥ 0. Defaults to 3 when not set |
The request body must include at least one of these fields. All four fields are optional in the request — the upsert preserves any field you don't send.
planOrder is consumed when a customer changes plans through the Developer
Portal: a target plan whose index is greater than or equal to the current plan's
index is treated as an upgrade (immediate timing); a lower index is treated as a
downgrade (next-billing-cycle timing). Plans not listed in planOrder default
to upgrade timing.
maxPaymentOverdueDays is the lowest-precedence default for the payment grace
period. See
Subscription and payment validation
for the full precedence chain (customer metadata → plan metadata → bucket
configuration → built-in default).
Delete
Code
After deletion, GET returns the default body again.
Stripe setup and billing readiness
Most users connect Stripe through the Zuplo Portal. For automated provisioning — CI scripts, infrastructure-as-code, or self-hosted control planes — the same flow is available via these API endpoints.
Install the Stripe app
Connect a Stripe account to a bucket and create the default billing profile in one call:
Code
The endpoint validates the Stripe key prefix against the bucket's environment:
- Working-copy and preview buckets accept
sk_test_*orrk_test_* - Production buckets accept
sk_live_*orrk_live_*
The response returns the installed appId. The endpoint fails with a
409 Conflict if a Stripe app is already installed for the bucket.
Read the current Stripe setup
Code
Returns the connected Stripe app summary and the billing profiles linked to it.
Create an additional billing profile
To attach more billing profiles to the same Stripe app:
Code
Check billing readiness
A lightweight check for tooling that gates deploys on Stripe being connected:
Code
Response:
Code
Use this in setup wizards to gate the UI on whether Stripe is connected.
Update a connected app
Rotate the Stripe key on an existing app, or update its name and metadata:
Code
The same key-prefix validation applies — a live key is rejected on a non-production bucket and vice versa.
Manage subscriber API keys
Each subscription is linked to a consumer that holds the subscriber's API keys. You can update or delete those keys, and read them back when you list a customer's subscriptions. These operations don't appear in the generated API reference, so this section documents them.
In the examples, $CONSUMER_ID is the consumer's ID and $API_KEY_ID is the
key's ID. Both appear on the subscription's consumer in the subscription
response.
Update a key
PATCH /v3/metering/{bucketId}/consumers/{consumerId}/keys/{apiKeyId} changes a
key's description, its expiration date, or both. Fields you omit stay as they
are. The request must include at least one field, and a successful call returns
204 No Content.
| Field | Type | Description |
|---|---|---|
description | string | The key's description. An empty string clears it. |
expiresOn | string or null | An RFC 3339 timestamp. A future time sets or extends the expiration. null clears a future expiration. |
Set a description and a future expiration:
Code
Remove a future expiration so the key doesn't expire:
Code
To expire a key now, send a timestamp at or before the current time:
Code
Sending a future timestamp for an expired key reactivates it. You can't clear
the expiration of an already expired key with null; the request returns
400 Bad Request.
The last-active-key rule
A consumer must always have at least one active key, meaning a key with no
expiration or an expiration in the future. If an update that sets expiresOn
would leave the consumer with no active key, the request fails with
400 Bad Request and nothing changes. Roll the key first so a replacement
exists, then expire the old one.
Delete a key
DELETE /v3/metering/{bucketId}/consumers/{consumerId}/keys/{apiKeyId} removes
a key permanently and returns 204 No Content.
Code
A delete succeeds only when all of these are true:
- The key has an expiration date. A key without one is rejected with
400 Bad Request. The expiration can be in the past or in the future, so you can delete a key that is scheduled to expire but hasn't yet. - The consumer has at least one other active key. Otherwise the request returns
400 Bad Request. - The consumer has an active subscription. Otherwise the request returns
404 Not Found.
To delete a key that has no expiration, first set an expiration with the update operation, after making sure another active key exists.
Return key values with key-format
By default, the subscription endpoints return API keys as a placeholder. Add the
key-format query parameter to
GET /v3/metering/{bucketId}/customers/{customerId}/subscriptions to change
that:
| Value | Key in the response |
|---|---|
none | A placeholder (****). This is the default. |
masked | The key with only its suffix visible |
visible | The full key |
Code
Each subscription's consumer.apiKeys array includes the key's id,
description, createdOn, expiresOn (omitted when the key doesn't expire),
and key. Treat responses that use key-format=visible as secrets.
API Reference
For complete API operations, see the API Reference documentation: