Everything you need to integrate UsageBox into your product—from authentication to billing-grade usage metering.
UsageBox is an independent usage metering API. It records usage events, makes retries idempotent, handles late events, preserves raw history, and produces monthly rollups for the billing system you choose. Use this guide to learn the building blocks and wire the API into your stack in minutes.
The minimum viable integration is a meter, an API key, and one HTTP request. You can set up products, plans, and customers later.
curl -X POST https://api.usagebox.com/api/v1/usage \
-H 'x-api-key: YOUR_API_KEY' \
-H "Idempotency-Key: $(uuidgen)" \
-H 'Content-Type: application/json' \
-d '[{
"value": 42
}]'A 200 with "processed": 1 means the event was recorded. Reuse the sameIdempotency-Key if the request needs a retry.subscription, product_item, and meter values are ingest keysfrom your catalog. They may be omitted for a one-resource starter account; if a supplied key does not resolve, the response explains the skip in skipped_details.Group your resources by environment or product line. Projects let you isolate data, credentials, and configuration.
Represent the services you sell. Each product can expose multiple plans that define how customers are billed.
Attach commercial configuration to a product. Plans group product items and charges so usage can resolve to the correct metering context.
Capture the raw usage signals you want to bill on—API calls, seats, bandwidth, or any measurable unit.
Store account details for the companies or users whose usage you meter. Customers can hold multiple subscriptions.
Connect customers to a plan. Subscriptions define the lifecycle interval and context used to resolve incoming usage events.
Send granular events through the API so UsageBox can resolve them to the correct subscription, product item, meter, and charge, then aggregate the quantity.
Authenticate requests to the UsageBox API. Rotate keys per environment and restrict them to the projects they serve.
UsageBox exposes a RESTful API. All requests are scoped to the active project and use JSON payloads.
https://api.usagebox.com/api/v1/Create an API key in the dashboard and send it as the x-api-key header on every request:
x-api-key: your-api-keyTwo other credentials exist and are easy to confuse with this one. Authorization: Bearer … carries a Firebase ID token and is what the web dashboard uses — an API key sent this way will fail. And an X-RapidAPI-Key works only at the RapidAPI gateway, never against this origin; call through the gateway and it handles authentication for you.
Define the product, plan, item, meter, and charge context that incoming usage should resolve against.
POST /api/v1/products with a name and reference code. Products act as the parent container for plans.
Use POST /api/v1/plans to group the product configuration used by subscriptions and usage resolution.
Attach the product items, meters, and charges your usage events should resolve against.
curl -X POST https://api.usagebox.com/api/v1/products \
-H 'x-api-key: <your_api_key>' \
-H 'Content-Type: application/json' \
-d '{ "name": "Pro API", "description": "Metered REST API" }'Track consumption in real time by wiring your application telemetry to UsageBox meters.
Create meters with POST /api/v1/meters, specifying unit names, aggregation, and the products they belong to.
POST /api/v1/usage with batches of events. Each event requires a value; subscription, product item, and meter ingest keys are optional when the account has one safe candidate.
Use GET /api/v1/usage/rollups (or GET /api/v1/account_activity, or the dashboard) to confirm events resolved correctly and the expected quantities were aggregated.
curl -X POST https://api.usagebox.com/api/v1/usage \
-H 'x-api-key: <your_api_key>' \
-H "Idempotency-Key: $(uuidgen)" \
-H 'Content-Type: application/json' \
-d '[{ "value": 150 }]'Provision customers, activate subscriptions, and preserve the lifecycle context used to attribute usage over time.
POST /api/v1/customers with the identifiers you use in your product (corporate ID, domain, or UUID).
POST /api/v1/subscriptions to connect a customer, plan, and optional trial or contract metadata.
PUT /api/v1/subscriptions/{id} to change status without losing historical usage.
curl -X POST https://api.usagebox.com/api/v1/subscriptions \
-H 'x-api-key: <your_api_key>' \
-H 'Content-Type: application/json' \
-d '{
"customer_account_id": "<customer id from POST /api/v1/customers>",
"plan_id": "<plan id from GET /api/v1/plans>"
}'| Endpoint | Methods | Description |
|---|---|---|
/api/v1/projects | GET, POST, PUT | Fetch your projects and select an active project. |
/api/v1/products | GET, POST, PUT, DELETE | List and create products in the active project. |
/api/v1/plans | GET, POST, PUT, DELETE | Manage plans and pricing tiers linked to products. |
/api/v1/meters | GET, POST, PUT, DELETE | Create meters and inspect meter configuration. |
/api/v1/customers | GET, POST, PUT, DELETE | Create customers and fetch their billing profile. |
/api/v1/subscriptions | GET, POST, PUT, DELETE | Start, update, or view subscription lifecycle state. |
/api/v1/usage | GET, POST | Submit usage events, and read back recent raw events. |
/api/v1/usage/rollups | GET | Monthly aggregated usage per meter, as the pipeline computed it. |
/api/v1/api_keys | GET, POST, PATCH, DELETE | Rotate API credentials and manage access. |
/api/v1/account_activity | GET | Inspect account activity, charges, and recorded events. |
There is no SDK to install. Ingest is one POST with a JSON array, so these are complete — copy one, set UBX_API_KEY, and you are metering.
const res = await fetch('https://api.usagebox.com/api/v1/usage', {
method: 'POST',
headers: {
'x-api-key': process.env.UBX_API_KEY,
'Idempotency-Key': crypto.randomUUID(),
'Content-Type': 'application/json'
},
body: JSON.stringify([{ meter: 'meter.api-requests', value: 1 }])
})
console.log(await res.json())import os, uuid, requests
res = requests.post(
"https://api.usagebox.com/api/v1/usage",
headers={
"x-api-key": os.environ["UBX_API_KEY"],
"Idempotency-Key": str(uuid.uuid4()),
},
json=[{"meter": "meter.api-requests", "value": 1}],
)
print(res.json())body := `[{"meter":"meter.api-requests","value":1}]`
req, _ := http.NewRequest("POST",
"https://api.usagebox.com/api/v1/usage", strings.NewReader(body))
req.Header.Set("x-api-key", os.Getenv("UBX_API_KEY"))
req.Header.Set("Idempotency-Key", uuid.NewString())
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)$ch = curl_init('https://api.usagebox.com/api/v1/usage');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'x-api-key: ' . getenv('UBX_API_KEY'),
'Idempotency-Key: ' . bin2hex(random_bytes(16)),
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([['meter' => 'meter.api-requests', 'value' => 1]]),
]);
echo curl_exec($ch);Documentation evolves as the platform does. Reach out if you have questions or want to share feedback.
Create an account, generate an API key, and start metering usage today.