Skip to navigation

Prepaid credit bundles

Adatum captures operating procedures from video for manufacturers and field-services companies. Its agents run time studies on process videos and blur faces in footage, and customers pay for both from one prepaid balance of Adatum Credits. Customers buy credits in yearly bundles priced on a volume curve, and each agent burns credits per minute of video it processes.

This example uses:

The calls below omit the headers every request sends: Authorization, Paid-Version, the Paid-Beta opt-in for each resource’s beta (for example orders=v1 or credits=v1), and an Idempotency-Key on writes. See request headers and idempotency.

Pricing

Burn rates. A time study costs 15 credits a minute for the first 30 minutes of each video and 20 credits a minute after that. Face blurring costs 3 credits a minute.

Bundles. Credits are sold in yearly bundles on a graduated curve:

CreditsPrice per credit
First 50,000$0.70
50,001 to 100,000$0.65
Above 100,000$0.60

So 50,000 credits cost $35,000, 70,000 cost $48,000, 100,000 cost $67,500 and 500,000 cost $307,500. One price on this curve replaces a list of fixed bundle sizes.

Credits are prepaid, shared across every agent, and roll over for 3 months after the year they were granted for.

Money amounts on prices (unitAmount) are decimal strings in cents, so "70" is $0.70. On a price quoted in a credit currency, unitAmount is in that unit, so "15" is 15 credits. Money objects, such as a discount amount, are integers in cents. Credit amounts are decimal strings.

Setup

Create a credit currency for Adatum Credits. The conversion sets what a credit costs once a customer’s balance runs out: 70 cents of overage per credit.

POST /v1/credit-currencies
{
"key": "adatum_credits",
"name": "Adatum Credits",
"conversion": { "currency": "usd", "unitAmount": "70" }
}

Create one product, so invoices read “Adatum Platform” however many agents ship:

POST /v1/products
{
"externalId": "adatum_platform",
"name": "Adatum Platform"
}

Create a meter for each agent that sums the minutes of the videos it processed:

POST /v1/meters
{
"key": "time_study_minutes",
"name": "Time study video analysis",
"eventNames": ["time_study.video_analysed"],
"measure": {
"type": "events",
"events": {
"aggregation": { "type": "sum", "sum": { "path": "payload.minutes" } },
"unit": "minute"
}
}
}

Create face_blur_minutes the same way, for face_blur.completed events. unit on a meter is what it counts (minute); the prices below say what each unit costs.

Create the bundle price: a yearly recurring price on the volume curve, in dollars, where the order line’s quantity is the number of credits bought. Its grant gives one credit per unit of quantity each year. The credits expire after 12 months, and whatever is left rolls over for 3 more.

POST /v1/prices
{
"product": "adatum_platform",
"name": "Adatum Credits",
"currency": "usd",
"type": "recurring",
"recurring": {
"interval": "year",
"unit": "credit",
"pricing": {
"type": "graduated",
"graduated": {
"tiers": [
{ "upTo": "50000", "unitAmount": "70" },
{ "upTo": "100000", "unitAmount": "65" },
{ "upTo": null, "unitAmount": "60" }
]
}
},
"grants": [
{
"creditCurrency": "adatum_credits",
"amountPerUnit": "1",
"grantedOn": "activation",
"expiresAfter": { "value": "12", "unit": "month" },
"rollover": {
"maxAmount": null,
"duration": { "value": "3", "unit": "month" }
}
}
]
}
}

The response’s id (say prc_bundle01) is what orders refer to.

Then create the burn rates as usage prices in adatum_credits. The time study rate uses graduated tiers with tierScope: "event", so the tiers restart for every video: the first 30 minutes of each video cost 15 credits a minute and the rest cost 20.

POST /v1/prices
{
"product": "adatum_platform",
"name": "Time studies",
"creditCurrency": "adatum_credits",
"type": "usage",
"usage": {
"meter": "time_study_minutes",
"pricing": {
"type": "graduated",
"graduated": {
"tierScope": "event",
"tiers": [
{ "upTo": "30", "unitAmount": "15" },
{ "upTo": null, "unitAmount": "20" }
]
}
}
}
}
POST /v1/prices
{
"product": "adatum_platform",
"name": "Face blurring",
"creditCurrency": "adatum_credits",
"type": "usage",
"usage": {
"meter": "face_blur_minutes",
"pricing": { "type": "perUnit", "perUnit": { "unitAmount": "3" } }
}
}

These return prc_timestudy01 and prc_blur01.

To charge a whole video at the rate of the tier it ends in, use volume instead of graduated. A 45-minute video then costs 45 × 20 = 900 credits instead of 750.

Signing Contoso Manufacturing

Create the customer from Adatum’s CRM record:

POST /v1/customers
{
"externalId": "crm-00412",
"name": "Contoso Manufacturing",
"currency": "usd"
}

Adatum’s own platform knows Contoso as fw-1042. Create an alias so events sent under that ID reach the same customer:

POST /v1/customers/crm-00412/aliases
{
"value": "fw-1042",
"source": "adatum-platform"
}

Contoso signs for 325,000 credits a year at a negotiated $48,000. Create the order with the bundle at its real quantity, the two burn rates, and the discount as a negotiated pricing entry with its own display name. A billing cycle of 12 months bills it annually, and the purchase order number is printed on every invoice.

POST /v1/orders
{
"customer": "crm-00412",
"externalId": "contoso-2026",
"purchaseOrderNumber": "PO-CON-4471",
"startsAt": "2026-10-01T00:00:00Z",
"endsAt": "2027-10-01T00:00:00Z",
"billingCycle": { "interval": "month", "intervalCount": 12 },
"lines": [
{ "type": "price", "price": { "price": "prc_bundle01", "quantity": 325000 } },
{ "type": "price", "price": { "price": "prc_timestudy01" } },
{ "type": "price", "price": { "price": "prc_blur01" } }
],
"negotiatedPricing": [
{
"key": "contoso_discount",
"type": "discount",
"discount": {
"type": "amount",
"amount": { "amountOff": { "amount": 15450000, "currency": "usd" } }
},
"target": { "type": "price", "price": { "price": "prc_bundle01" } },
"displayName": "Negotiated discount"
}
]
}

The discount has no startsAt or endsAt, so it lasts as long as the order. Activate the order to start billing:

POST /v1/orders/ord_123/activate

Activation grants 325,000 credits and issues the first yearly invoice, billed in advance:

LineAmount
Adatum Credits, 325,000 credits (50,000 at $0.70 + 50,000 at $0.65 + 225,000 at $0.60)$202,500.00
Negotiated discount−$154,500.00
Total$48,000.00

The bundle line shows the real 325,000 credits, and the discount is its own negative line. Each anniversary invoice grants the next year’s credits.

Sending usage

Adatum’s platform sends one event per agent per video, under its own customer ID. The alias routes it to Contoso. A face_blur.completed event with the same payload and a dedupe key ending :face_blur follows for the same video.

POST /v1/events
{
"eventName": "time_study.video_analysed",
"customer": "fw-1042",
"product": "adatum_platform",
"dedupeKey": "vid_88213:time_study",
"payload": { "minutes": 45, "videoId": "vid_88213" }
}

Each event comes back with Contoso’s cus_ ID in customer and fw-1042 in sentAs.customer. This 45-minute video spends 30 × 15 + 15 × 20 = 750 credits on the time study and 45 × 3 = 135 credits on face blurring, both from Contoso’s one balance.

An illustrative month

In its first month Contoso processes 40 videos under 30 minutes (800 minutes in all), 6 videos of 45 minutes, and 300 minutes of face blurring.

UsageArithmeticCredits
Time studies, short videos800 min × 1512,000
Time studies, long videos6 × (30 × 15 + 15 × 20) = 6 × 7504,500
Face blurring300 min × 3900
Credits burned17,400

Usage priced in credits spends the balance rather than adding money to the invoice. After the month Contoso has 325,000 − 17,400 = 307,600 credits, 94.6% available. Only if the balance ran out would further usage be billed as overage, at $0.70 a credit.

At this rate Contoso spends 12 × 17,400 = 208,800 credits a year, well within its bundle. A customer on a 70,000-credit bundle would run out in about four months.

Extending to three years

Contoso extends its one-year term to three, still billed annually. Preview the amendment first. extendLines moves the lines to the new end date. The discount has no endsAt, so it ends with the order:

POST /v1/orders/ord_123/amendments/preview
{
"expectedVersion": 1,
"changes": [
{
"type": "updateTerm",
"updateTerm": { "endsAt": "2029-10-01T00:00:00Z", "extendLines": true }
}
]
}

Then create the amendment at POST /v1/orders/ord_123/amendments with the same body plus the previewToken the preview returned.

Only the end date moves, so nothing is prorated. The next yearly invoices, each for $48,000 with 325,000 credits, come on 1 October 2027 and 2028.

A customer with two business units

Fabrikam buys through two businesses: a 70,000-credit bundle ($48,000) and a 50,000-credit bundle ($35,000). If each should spend only its own credits, make them two customers with an order each. If they share a budget, make one customer with two customer units:

POST /v1/customers/fabrikam/units
{
"externalId": "fabrikam-windows",
"name": "Fabrikam Windows and Doors",
"kind": "business"
}

Then create one order per bundle on Fabrikam, for a shared 120,000 credits a year. Only one of the orders carries the two burn-rate prices, since a meter can be priced by only one active order per customer. Events name the unit in customerUnit, so usage summaries report each business separately.

Showing customers their balance

Adatum shows each customer its credit balance in-product. The alias works here too:

GET /v1/credit-balances?customer=fw-1042&creditCurrency=adatum_credits

The burn history comes from credit transactions: each entry carries balanceAfter, the event and the meter, so it shows which video spent what, and expired credits appear as expiry entries. Minutes per agent per month come from usage summaries with granularity=month. Adatum’s sales team finds every customer below 20% of its credits with percentAvailable[lte]=20 on the balances list.