Flow

Hover a primitive to trace it · click to jump to its code
UsageMoneyCreditsRefers to
Your productEvents it sends
MeteringWhat's billable
CatalogWhat it costs
ContractWho buys it, on what terms
BillingWhat comes out
  1. 1

    Create the product

    POST/v1/productsReference

    A product is the catalog entry for what you sell. It holds no pricing: prices point at it.

    products=v1
    curl https://api.paid.ai/v1/products \
      -H "Authorization: Bearer $PAID_API_KEY" \
      -H "Paid-Version: 2026-11-01" \
      -H "Paid-Beta: products=v1" \
      -H "Idempotency-Key: $(uuidgen)" \
      -H "Content-Type: application/json" \
      -d '{
      "externalId": "support_agent",
      "name": "Support agent",
      "productCode": "HW-AGENT"
    }'
  2. 2

    Create the Agent replies meter

    POST/v1/metersReference

    Counts every ticket.replied event. A meter decides what's billable from the events you send.

    meters=v1
    curl https://api.paid.ai/v1/meters \
      -H "Authorization: Bearer $PAID_API_KEY" \
      -H "Paid-Version: 2026-11-01" \
      -H "Paid-Beta: meters=v1" \
      -H "Idempotency-Key: $(uuidgen)" \
      -H "Content-Type: application/json" \
      -d '{
      "key": "agent_replies",
      "name": "Agent replies",
      "eventNames": [
        "ticket.replied"
      ],
      "measure": {
        "type": "events",
        "events": {
          "aggregation": {
            "type": "count"
          },
          "unit": "reply"
        }
      }
    }'
  3. 3

    Price agent replies

    POST/v1/pricesReference

    A usage price charges for what the meter measures. Amounts are decimal strings in minor units. The response's ID, prc_7Kd2Pw here, is what orders refer to.

    prices=v1
    curl https://api.paid.ai/v1/prices \
      -H "Authorization: Bearer $PAID_API_KEY" \
      -H "Paid-Version: 2026-11-01" \
      -H "Paid-Beta: prices=v1" \
      -H "Idempotency-Key: $(uuidgen)" \
      -H "Content-Type: application/json" \
      -d '{
      "product": "support_agent",
      "currency": "usd",
      "displayName": "Agent replies",
      "type": "usage",
      "usage": {
        "meter": "agent_replies",
        "pricing": {
          "type": "perUnit",
          "perUnit": {
            "unitAmount": "50"
          }
        }
      }
    }'
  4. 4

    Create the customer

    POST/v1/customersReference

    The company you bill. Anywhere the API asks for a customer it takes Paid's cus_ ID or your externalId.

    customers=v1
    curl https://api.paid.ai/v1/customers \
      -H "Authorization: Bearer $PAID_API_KEY" \
      -H "Paid-Version: 2026-11-01" \
      -H "Paid-Beta: customers=v1" \
      -H "Idempotency-Key: $(uuidgen)" \
      -H "Content-Type: application/json" \
      -d '{
      "externalId": "northwind",
      "name": "Northwind Traders",
      "email": "billing@northwind.example",
      "currency": "usd"
    }'
  5. 5

    Create the order

    POST/v1/ordersReference

    An order starts as a draft and bills nothing until it's activated.

    orders=v1
    curl https://api.paid.ai/v1/orders \
      -H "Authorization: Bearer $PAID_API_KEY" \
      -H "Paid-Version: 2026-11-01" \
      -H "Paid-Beta: orders=v1" \
      -H "Idempotency-Key: $(uuidgen)" \
      -H "Content-Type: application/json" \
      -d '{
      "customer": "northwind",
      "startsAt": "2026-11-01T00:00:00Z",
      "billingCycle": {
        "interval": "month"
      },
      "lines": [
        {
          "type": "price",
          "price": {
            "price": "prc_7Kd2Pw"
          }
        }
      ]
    }'
  6. 6

    Activate the order

    POST/v1/orders/ord_PxUHJr/activateReference

    The request has no body. It returns 200 once active, or 202 while it's activating.

    orders=v1
    curl -X POST https://api.paid.ai/v1/orders/ord_PxUHJr/activate \
      -H "Authorization: Bearer $PAID_API_KEY" \
      -H "Paid-Version: 2026-11-01" \
      -H "Paid-Beta: orders=v1" \
      -H "Idempotency-Key: $(uuidgen)"
  7. 7

    Send a ticket.replied event

    POST/v1/eventsReference

    One per reply. The meter counts them. Use an ID your system already has as the dedupeKey, so a retried send is never counted twice.

    events=v1
    curl https://api.paid.ai/v1/events \
      -H "Authorization: Bearer $PAID_API_KEY" \
      -H "Paid-Version: 2026-11-01" \
      -H "Paid-Beta: events=v1" \
      -H "Idempotency-Key: $(uuidgen)" \
      -H "Content-Type: application/json" \
      -d '{
      "eventName": "ticket.replied",
      "customer": "northwind",
      "product": "support_agent",
      "dedupeKey": "reply_91c2e7",
      "correlationId": "ticket_4410",
      "payload": {
        "channel": "email",
        "ticketId": "4410"
      }
    }'
  8. 8

    See usage and spend

    GET/v1/usage-summariesReference

    Each row has a quantity and spend per meter. Rows stay provisional until the period's invoice settles them.

    usage_summaries=v1
    curl -G https://api.paid.ai/v1/usage-summaries \
      -H "Authorization: Bearer $PAID_API_KEY" \
      -H "Paid-Version: 2026-11-01" \
      -H "Paid-Beta: usage_summaries=v1" \
      --data-urlencode "customer=northwind" \
      --data-urlencode "meters[]=agent_replies" \
      --data-urlencode "startsAt=2026-11-01T00:00:00Z" \
      --data-urlencode "endsAt=2026-12-01T00:00:00Z" \
      --data-urlencode "granularity=month"