5-Minute Quick Start

Go from a fresh ABAXUS deployment to a paid invoice with five API calls.

Prerequisites

Before you begin, you need:

  • ABAXUS running and reachable (see the Kubernetes Setup guide for deployment instructions).
  • A secret API key starting with sk_. Generate one in the ABAXUS dashboard under Settings → API Keys, or via POST /v1/api-keys.
  • curl or any HTTP client. All examples below use curl.

Set your API key as an environment variable so you don’t have to repeat it:

1
2
export ABAXUS_KEY="sk_live_your_key_here"
export ABAXUS_URL="https://billing.your-company.internal"

Step 1 — Create a Metric

A metric defines what you want to measure and how to aggregate raw events into a usage total. Here we create a metric for API calls that sums all events within a billing period.

1
2
3
4
5
6
7
8
9
curl -X POST "$ABAXUS_URL/v1/metrics" \
  -H "Authorization: Bearer $ABAXUS_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "key": "api_calls",
    "name": "API Calls",
    "aggregation": "sum",
    "description": "Total API calls made during the billing period"
  }'

Response:

1
2
3
4
5
6
7
8
{
  "id": "met_01hx8kj2p3q4r5s6t7u8v9w0a",
  "key": "api_calls",
  "name": "API Calls",
  "aggregation": "sum",
  "status": "active",
  "created_at": "2026-04-03T09:00:00Z"
}

The key field (api_calls) is what you’ll reference when sending events and building price plans. Keep it stable — it’s the identifier that ties everything together.


Step 2 — Create a Price Plan

A price plan defines how to charge for measured usage. Here we create a Growth plan with a tiered charge for API calls and a flat monthly base fee.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
curl -X POST "$ABAXUS_URL/v1/price-plans" \
  -H "Authorization: Bearer $ABAXUS_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "id": "plan_growth",
    "name": "Growth",
    "currency": "usd",
    "billing_period": "monthly",
    "charges": [
      {
        "metric_key": "api_calls",
        "pricing_model": "tiered",
        "tiers": [
          { "up_to": 100000, "unit_price": 0 },
          { "up_to": 1000000, "unit_price": 0.0001 },
          { "up_to": null, "unit_price": 0.00005 }
        ]
      },
      {
        "metric_key": null,
        "pricing_model": "flat_fee",
        "amount": 49.00,
        "description": "Growth base fee"
      }
    ]
  }'

Response:

1
2
3
4
5
6
7
8
{
  "id": "plan_growth",
  "version": 1,
  "name": "Growth",
  "status": "active",
  "currency": "usd",
  "billing_period": "monthly"
}

This plan gives customers 100k free API calls, then charges $0.0001 per call up to 1M, dropping to $0.00005 per call beyond that — plus a $49/month base fee.


Step 3 — Create a Customer

Customers represent the entities you bill. Provide a stable id that matches your own user or organization identifier.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
curl -X POST "$ABAXUS_URL/v1/customers" \
  -H "Authorization: Bearer $ABAXUS_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "id": "cust_acme",
    "name": "Acme Corp",
    "email": "billing@acme.io",
    "payment_provider": "stripe",
    "payment_provider_customer_id": "cus_stripe_acme123"
  }'

Response:

1
2
3
4
5
6
7
{
  "id": "cust_acme",
  "name": "Acme Corp",
  "email": "billing@acme.io",
  "payment_provider": "stripe",
  "created_at": "2026-04-03T09:01:00Z"
}

The payment_provider_customer_id links this ABAXUS customer to an existing Stripe Customer object. ABAXUS will use that Stripe customer’s saved payment methods when charging invoices.


Step 4 — Create a Subscription

Subscriptions bind a customer to a plan and lock in the plan version. Once a subscription is created, plan changes won’t affect its billing — customers stay on the plan version they signed up for until you explicitly migrate them.

1
2
3
4
5
6
7
8
curl -X POST "$ABAXUS_URL/v1/subscriptions" \
  -H "Authorization: Bearer $ABAXUS_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "customer_id": "cust_acme",
    "plan_id": "plan_growth",
    "start_date": "2026-04-01T00:00:00Z"
  }'

Response:

1
2
3
4
5
6
7
8
{
  "id": "sub_01hx8km4n5p6q7r8s9t0u1v2w",
  "customer_id": "cust_acme",
  "plan_id": "plan_growth",
  "plan_version": 1,
  "status": "active",
  "start_date": "2026-04-01T00:00:00Z"
}

Note the plan_version: 1 — this subscription is pinned to version 1 of the Growth plan.


Step 5 — Send an Event

Events are the raw usage signals your product emits. Send them as they happen, or in batches. Include an idempotency_key so retries are safe.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
curl -X POST "$ABAXUS_URL/v1/events" \
  -H "Authorization: Bearer $ABAXUS_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "customer_id": "cust_acme",
    "metric_key": "api_calls",
    "value": 1,
    "timestamp": "2026-04-03T09:30:00Z",
    "idempotency_key": "req_7f8a9b2c3d4e5f6a"
  }'

Response: 202 Accepted — the event is queued and will be processed asynchronously.

You can send events from any service in your infrastructure. For high-volume scenarios, use POST /v1/events/batch to send up to 1,000 events in a single request.


Step 6 — Create and Charge an Invoice

When you’re ready to bill, create an invoice for the customer. ABAXUS calculates all charges for the billing period and returns a line-item breakdown.

1
2
3
4
5
6
7
8
# Create the invoice
curl -X POST "$ABAXUS_URL/v1/invoices" \
  -H "Authorization: Bearer $ABAXUS_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "customer_id": "cust_acme",
    "cutoff_date": "2026-04-30T23:59:59Z"
  }'

Response:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
{
  "id": "inv_01hx8kp5q6r7s8t9u0v1w2x3",
  "customer_id": "cust_acme",
  "status": "issued",
  "total_amount": 6449,
  "currency": "usd",
  "period_start": "2026-04-01T00:00:00Z",
  "period_end": "2026-04-30T23:59:59Z",
  "line_items": [
    {
      "description": "API Calls — tiered usage (1,200,000 calls)",
      "amount": 6400,
      "quantity": 1200000
    },
    {
      "description": "Growth base fee",
      "amount": 4900,
      "quantity": 1
    }
  ]
}

Now charge it against Acme’s saved Stripe payment method:

1
2
3
4
curl -X POST "$ABAXUS_URL/v1/invoices/inv_01hx8kp5q6r7s8t9u0v1w2x3/charge" \
  -H "Authorization: Bearer $ABAXUS_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'

Response:

1
2
3
4
5
6
{
  "invoice_id": "inv_01hx8kp5q6r7s8t9u0v1w2x3",
  "status": "paid",
  "payment_intent_id": "pi_3Nx8kStripe123456",
  "charged_at": "2026-04-03T09:45:00Z"
}

The invoice is now marked paid, and a PaymentIntent was created in Stripe. The full audit trail (event log) is available at GET /v1/invoices/:id/events.


What’s Next

You’ve completed the core billing loop. From here:

  • Core Concepts — understand the mental model behind metrics, plans, events, and invoices in depth.
  • Defining Metrics — learn about all 7 aggregation types and how to model complex usage signals.
  • Creating Price Plans — build more sophisticated pricing with mixed models and entitlements.
  • Event Ingestion — high-volume event ingestion, batching, and idempotency patterns.