From f4c6891a41dac9f267a75e70fa87558a6a57c515 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Mar 2026 06:01:22 +0000 Subject: [PATCH 1/3] Add Bruno collection examples for the Entitlements feature Adds a new Entitlements folder under Products & Pricing with examples demonstrating hybrid billing with bundled credit entitlements. https://claude.ai/code/session_01W63js9R3m7nEKV9jzuiUuD --- .../Entitlements/Create a Credit Asset.bru | 36 +++++++++ .../Create a Product with Entitlements.bru | 80 +++++++++++++++++++ .../Entitlements/Get Product Details.bru | 16 ++++ .../Entitlements/Simulate Usage.bru | 31 +++++++ .../Entitlements/folder.bru | 8 ++ 5 files changed, 171 insertions(+) create mode 100644 bruno/credyt-api/Features/Products & Pricing/Entitlements/Create a Credit Asset.bru create mode 100644 bruno/credyt-api/Features/Products & Pricing/Entitlements/Create a Product with Entitlements.bru create mode 100644 bruno/credyt-api/Features/Products & Pricing/Entitlements/Get Product Details.bru create mode 100644 bruno/credyt-api/Features/Products & Pricing/Entitlements/Simulate Usage.bru create mode 100644 bruno/credyt-api/Features/Products & Pricing/Entitlements/folder.bru diff --git a/bruno/credyt-api/Features/Products & Pricing/Entitlements/Create a Credit Asset.bru b/bruno/credyt-api/Features/Products & Pricing/Entitlements/Create a Credit Asset.bru new file mode 100644 index 0000000..09b4ad8 --- /dev/null +++ b/bruno/credyt-api/Features/Products & Pricing/Entitlements/Create a Credit Asset.bru @@ -0,0 +1,36 @@ +meta { + name: Create a Credit Asset + type: http + seq: 1 +} + +post { + url: {{credytApiUrl}}/assets + body: json + auth: inherit +} + +body:json { + { + "code": "CREDIT", + "name": "Credits", + "precision": 2, + "symbol": "C", + "label": "CREDIT", + "rates": [ + { + "source": "USD", + "rate": 0.01 + } + ] + } +} + +script:pre-request { + bru.setEnvVar("assetCode", req.getBody().code); +} + +settings { + encodeUrl: true + timeout: 0 +} diff --git a/bruno/credyt-api/Features/Products & Pricing/Entitlements/Create a Product with Entitlements.bru b/bruno/credyt-api/Features/Products & Pricing/Entitlements/Create a Product with Entitlements.bru new file mode 100644 index 0000000..3e1d922 --- /dev/null +++ b/bruno/credyt-api/Features/Products & Pricing/Entitlements/Create a Product with Entitlements.bru @@ -0,0 +1,80 @@ +meta { + name: Create a Product with Entitlements + type: http + seq: 2 +} + +post { + url: {{credytApiUrl}}/products + body: json + auth: inherit +} + +body:json { + { + "name": "Premium Plan", + "code": "premium_monthly", + "entitlements": [ + { + "name": "Monthly Credit Allowance", + "asset": "CREDIT", + "amount": 1000, + "purpose": "bundled", + "refresh": { + "interval": "month", + "strategy": "expire_and_replace" + }, + "accounting": { + "revenue_basis": 0, + "cost_basis": "auto" + } + } + ], + "prices": [ + { + "name": "API Usage", + "type": "usage_based", + "billing_model": { + "type": "real_time" + }, + "usage_calculation": { + "event_type": "api_call", + "usage_type": "count", + "source_reference_field": "request_id" + }, + "pricing": [ + { + "asset": "CREDIT", + "values": [ + { + "name": "API Call", + "values": [ + { + "unit_rate": 1 + } + ] + } + ] + } + ] + } + ], + "publish": true + } +} + +script:post-response { + if(res.status === 201){ + const responseJson = res.getBody(); + + if (responseJson && responseJson.id) { + bru.setEnvVar("productId", responseJson.id); + bru.setEnvVar("productCode", responseJson.code); + } + } +} + +settings { + encodeUrl: true + timeout: 0 +} diff --git a/bruno/credyt-api/Features/Products & Pricing/Entitlements/Get Product Details.bru b/bruno/credyt-api/Features/Products & Pricing/Entitlements/Get Product Details.bru new file mode 100644 index 0000000..2ec3f87 --- /dev/null +++ b/bruno/credyt-api/Features/Products & Pricing/Entitlements/Get Product Details.bru @@ -0,0 +1,16 @@ +meta { + name: Get Product Details + type: http + seq: 3 +} + +get { + url: {{credytApiUrl}}/products/{{productId}} + body: none + auth: inherit +} + +settings { + encodeUrl: true + timeout: 0 +} diff --git a/bruno/credyt-api/Features/Products & Pricing/Entitlements/Simulate Usage.bru b/bruno/credyt-api/Features/Products & Pricing/Entitlements/Simulate Usage.bru new file mode 100644 index 0000000..1c18f5f --- /dev/null +++ b/bruno/credyt-api/Features/Products & Pricing/Entitlements/Simulate Usage.bru @@ -0,0 +1,31 @@ +meta { + name: Simulate Usage + type: http + seq: 4 +} + +post { + url: {{credytApiUrl}}/products/{{productId}}/default/simulate-usage + body: json + auth: inherit +} + +body:json { + { + "events": [ + { + "id": "{{$randomUUID}}", + "event_type": "api_call", + "occurred_at": "{{$isoTimestamp}}", + "subject": "req_{{$randomUUID}}", + "description": "API Call", + "data": {} + } + ] + } +} + +settings { + encodeUrl: true + timeout: 0 +} diff --git a/bruno/credyt-api/Features/Products & Pricing/Entitlements/folder.bru b/bruno/credyt-api/Features/Products & Pricing/Entitlements/folder.bru new file mode 100644 index 0000000..882155a --- /dev/null +++ b/bruno/credyt-api/Features/Products & Pricing/Entitlements/folder.bru @@ -0,0 +1,8 @@ +meta { + name: Entitlements + seq: 2 +} + +auth { + mode: inherit +} From cd337de58e54ebf5122b4bb37c07fd39025dc229 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Mar 2026 06:04:35 +0000 Subject: [PATCH 2/3] Add customer creation, subscription, and balance check to entitlements example Adds Create a Customer step (with subscription to the product), renames Simulate Usage to Send Usage Events using the /events endpoint with customer_id, and adds Check Customer Balances to verify credit deductions. https://claude.ai/code/session_01W63js9R3m7nEKV9jzuiUuD --- .../Entitlements/Check Customer Balances.bru | 16 ++++++ .../Entitlements/Create a Customer.bru | 52 +++++++++++++++++++ .../Entitlements/Get Product Details.bru | 2 +- ...mulate Usage.bru => Send Usage Events.bru} | 14 +++-- 4 files changed, 78 insertions(+), 6 deletions(-) create mode 100644 bruno/credyt-api/Features/Products & Pricing/Entitlements/Check Customer Balances.bru create mode 100644 bruno/credyt-api/Features/Products & Pricing/Entitlements/Create a Customer.bru rename bruno/credyt-api/Features/Products & Pricing/Entitlements/{Simulate Usage.bru => Send Usage Events.bru} (63%) diff --git a/bruno/credyt-api/Features/Products & Pricing/Entitlements/Check Customer Balances.bru b/bruno/credyt-api/Features/Products & Pricing/Entitlements/Check Customer Balances.bru new file mode 100644 index 0000000..efdecc2 --- /dev/null +++ b/bruno/credyt-api/Features/Products & Pricing/Entitlements/Check Customer Balances.bru @@ -0,0 +1,16 @@ +meta { + name: Check Customer Balances + type: http + seq: 6 +} + +get { + url: {{credytApiUrl}}/customers/{{customerId}}/wallet + body: none + auth: inherit +} + +settings { + encodeUrl: true + timeout: 0 +} diff --git a/bruno/credyt-api/Features/Products & Pricing/Entitlements/Create a Customer.bru b/bruno/credyt-api/Features/Products & Pricing/Entitlements/Create a Customer.bru new file mode 100644 index 0000000..1edce84 --- /dev/null +++ b/bruno/credyt-api/Features/Products & Pricing/Entitlements/Create a Customer.bru @@ -0,0 +1,52 @@ +meta { + name: Create a Customer + type: http + seq: 3 +} + +post { + url: {{credytApiUrl}}/customers + body: json + auth: inherit +} + +body:json { + { + "name": "{{$randomFullName}}", + "external_id": "{{customerExternalId}}", + "email": "{{$randomEmail}}", + "subscriptions": [ + { + "products": [ + { + "code": "{{productCode}}" + } + ] + } + ] + } +} + +script:pre-request { + const { v4 } = require('uuid'); + + const generateUuidWithoutHyphens = () => v4().replace(/-/g,""); + + const externalId = `${generateUuidWithoutHyphens()}`; + bru.setVar("customerExternalId", externalId); +} + +script:post-response { + if(res.status === 201){ + const responseJson = res.getBody(); + + if (responseJson && responseJson.id) { + bru.setEnvVar("customerId", responseJson.id); + } + } +} + +settings { + encodeUrl: true + timeout: 0 +} diff --git a/bruno/credyt-api/Features/Products & Pricing/Entitlements/Get Product Details.bru b/bruno/credyt-api/Features/Products & Pricing/Entitlements/Get Product Details.bru index 2ec3f87..86a130d 100644 --- a/bruno/credyt-api/Features/Products & Pricing/Entitlements/Get Product Details.bru +++ b/bruno/credyt-api/Features/Products & Pricing/Entitlements/Get Product Details.bru @@ -1,7 +1,7 @@ meta { name: Get Product Details type: http - seq: 3 + seq: 4 } get { diff --git a/bruno/credyt-api/Features/Products & Pricing/Entitlements/Simulate Usage.bru b/bruno/credyt-api/Features/Products & Pricing/Entitlements/Send Usage Events.bru similarity index 63% rename from bruno/credyt-api/Features/Products & Pricing/Entitlements/Simulate Usage.bru rename to bruno/credyt-api/Features/Products & Pricing/Entitlements/Send Usage Events.bru index 1c18f5f..c62a842 100644 --- a/bruno/credyt-api/Features/Products & Pricing/Entitlements/Simulate Usage.bru +++ b/bruno/credyt-api/Features/Products & Pricing/Entitlements/Send Usage Events.bru @@ -1,25 +1,29 @@ meta { - name: Simulate Usage + name: Send Usage Events type: http - seq: 4 + seq: 5 } post { - url: {{credytApiUrl}}/products/{{productId}}/default/simulate-usage + url: {{credytApiUrl}}/events body: json auth: inherit } +headers { + Content-Type: application/json +} + body:json { { + "customer_id": "{{customerId}}", "events": [ { "id": "{{$randomUUID}}", "event_type": "api_call", "occurred_at": "{{$isoTimestamp}}", "subject": "req_{{$randomUUID}}", - "description": "API Call", - "data": {} + "description": "API Call" } ] } From e20b6ce70f6e2362d4b87805e041faa66207efee Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Mar 2026 06:44:04 +0000 Subject: [PATCH 3/3] Update entitlements examples to match official docs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Asset: precision 0, symbol ⭐, label CR, rate $0.05 - Product: add $20/month fixed subscription fee, image_generated event type with unit_price 10, description field, correct product code - Customer: add return_url/failure_url for billing portal - Events: use image_generated event type - Add Free Tier promotional entitlements example (daily 50 credits) https://claude.ai/code/session_01W63js9R3m7nEKV9jzuiUuD --- .../Entitlements/Check Customer Balances.bru | 2 +- .../Entitlements/Create a Credit Asset.bru | 8 +- .../Entitlements/Create a Customer.bru | 4 +- ...eate a Free Tier Product (Promotional).bru | 74 +++++++++++++++++++ .../Create a Product with Entitlements.bru | 37 +++++++--- .../Entitlements/Get Product Details.bru | 2 +- .../Entitlements/Send Usage Events.bru | 8 +- 7 files changed, 113 insertions(+), 22 deletions(-) create mode 100644 bruno/credyt-api/Features/Products & Pricing/Entitlements/Create a Free Tier Product (Promotional).bru diff --git a/bruno/credyt-api/Features/Products & Pricing/Entitlements/Check Customer Balances.bru b/bruno/credyt-api/Features/Products & Pricing/Entitlements/Check Customer Balances.bru index efdecc2..9cd109b 100644 --- a/bruno/credyt-api/Features/Products & Pricing/Entitlements/Check Customer Balances.bru +++ b/bruno/credyt-api/Features/Products & Pricing/Entitlements/Check Customer Balances.bru @@ -1,7 +1,7 @@ meta { name: Check Customer Balances type: http - seq: 6 + seq: 7 } get { diff --git a/bruno/credyt-api/Features/Products & Pricing/Entitlements/Create a Credit Asset.bru b/bruno/credyt-api/Features/Products & Pricing/Entitlements/Create a Credit Asset.bru index 09b4ad8..caab42d 100644 --- a/bruno/credyt-api/Features/Products & Pricing/Entitlements/Create a Credit Asset.bru +++ b/bruno/credyt-api/Features/Products & Pricing/Entitlements/Create a Credit Asset.bru @@ -14,13 +14,13 @@ body:json { { "code": "CREDIT", "name": "Credits", - "precision": 2, - "symbol": "C", - "label": "CREDIT", + "precision": 0, + "symbol": "⭐", + "label": "CR", "rates": [ { "source": "USD", - "rate": 0.01 + "rate": 0.05 } ] } diff --git a/bruno/credyt-api/Features/Products & Pricing/Entitlements/Create a Customer.bru b/bruno/credyt-api/Features/Products & Pricing/Entitlements/Create a Customer.bru index 1edce84..25da161 100644 --- a/bruno/credyt-api/Features/Products & Pricing/Entitlements/Create a Customer.bru +++ b/bruno/credyt-api/Features/Products & Pricing/Entitlements/Create a Customer.bru @@ -1,7 +1,7 @@ meta { name: Create a Customer type: http - seq: 3 + seq: 4 } post { @@ -17,6 +17,8 @@ body:json { "email": "{{$randomEmail}}", "subscriptions": [ { + "return_url": "https://glitch.ai/account", + "failure_url": "https://glitch.ai/callbacks/credyt/failure", "products": [ { "code": "{{productCode}}" diff --git a/bruno/credyt-api/Features/Products & Pricing/Entitlements/Create a Free Tier Product (Promotional).bru b/bruno/credyt-api/Features/Products & Pricing/Entitlements/Create a Free Tier Product (Promotional).bru new file mode 100644 index 0000000..97a9607 --- /dev/null +++ b/bruno/credyt-api/Features/Products & Pricing/Entitlements/Create a Free Tier Product (Promotional).bru @@ -0,0 +1,74 @@ +meta { + name: Create a Free Tier Product (Promotional) + type: http + seq: 3 +} + +post { + url: {{credytApiUrl}}/products + body: json + auth: inherit +} + +body:json { + { + "name": "Free Tier Product", + "code": "free_tier_01", + "entitlements": [ + { + "name": "Daily Reward", + "asset": "CREDIT", + "amount": 50, + "purpose": "promotion", + "refresh": { + "interval": "day", + "strategy": "expire_and_replace" + }, + "accounting": { + "revenue_basis": 0.0, + "cost_basis": "auto" + } + } + ], + "prices": [ + { + "name": "Image Generation", + "type": "usage_based", + "billing_model": { + "type": "real_time" + }, + "usage_calculation": { + "event_type": "image_generated", + "usage_type": "unit" + }, + "pricing": [ + { + "asset": "CREDIT", + "values": [ + { + "unit_price": 5 + } + ] + } + ] + } + ], + "publish": true + } +} + +script:post-response { + if(res.status === 201){ + const responseJson = res.getBody(); + + if (responseJson && responseJson.id) { + bru.setEnvVar("freeProductId", responseJson.id); + bru.setEnvVar("freeProductCode", responseJson.code); + } + } +} + +settings { + encodeUrl: true + timeout: 0 +} diff --git a/bruno/credyt-api/Features/Products & Pricing/Entitlements/Create a Product with Entitlements.bru b/bruno/credyt-api/Features/Products & Pricing/Entitlements/Create a Product with Entitlements.bru index 3e1d922..5dcacbc 100644 --- a/bruno/credyt-api/Features/Products & Pricing/Entitlements/Create a Product with Entitlements.bru +++ b/bruno/credyt-api/Features/Products & Pricing/Entitlements/Create a Product with Entitlements.bru @@ -13,7 +13,8 @@ post { body:json { { "name": "Premium Plan", - "code": "premium_monthly", + "code": "premium_monthly_01", + "description": "Standard monthly subscription with included credit allowance.", "entitlements": [ { "name": "Monthly Credit Allowance", @@ -32,27 +33,41 @@ body:json { ], "prices": [ { - "name": "API Usage", + "name": "Monthly Subscription Fee", + "type": "fixed", + "billing_model": { + "type": "recurring", + "recurring": { + "interval": "month" + } + }, + "pricing": [ + { + "asset": "USD", + "values": [ + { + "unit_price": 20 + } + ] + } + ] + }, + { + "name": "Image Generation", "type": "usage_based", "billing_model": { "type": "real_time" }, "usage_calculation": { - "event_type": "api_call", - "usage_type": "count", - "source_reference_field": "request_id" + "event_type": "image_generated", + "usage_type": "unit" }, "pricing": [ { "asset": "CREDIT", "values": [ { - "name": "API Call", - "values": [ - { - "unit_rate": 1 - } - ] + "unit_price": 10 } ] } diff --git a/bruno/credyt-api/Features/Products & Pricing/Entitlements/Get Product Details.bru b/bruno/credyt-api/Features/Products & Pricing/Entitlements/Get Product Details.bru index 86a130d..a6ca375 100644 --- a/bruno/credyt-api/Features/Products & Pricing/Entitlements/Get Product Details.bru +++ b/bruno/credyt-api/Features/Products & Pricing/Entitlements/Get Product Details.bru @@ -1,7 +1,7 @@ meta { name: Get Product Details type: http - seq: 4 + seq: 5 } get { diff --git a/bruno/credyt-api/Features/Products & Pricing/Entitlements/Send Usage Events.bru b/bruno/credyt-api/Features/Products & Pricing/Entitlements/Send Usage Events.bru index c62a842..fa78430 100644 --- a/bruno/credyt-api/Features/Products & Pricing/Entitlements/Send Usage Events.bru +++ b/bruno/credyt-api/Features/Products & Pricing/Entitlements/Send Usage Events.bru @@ -1,7 +1,7 @@ meta { name: Send Usage Events type: http - seq: 5 + seq: 6 } post { @@ -20,10 +20,10 @@ body:json { "events": [ { "id": "{{$randomUUID}}", - "event_type": "api_call", + "event_type": "image_generated", "occurred_at": "{{$isoTimestamp}}", - "subject": "req_{{$randomUUID}}", - "description": "API Call" + "subject": "img_{{$randomUUID}}", + "description": "Image Generated" } ] }