Skip to content

Sold ​

3 endpoint-uri. Fiecare cale de mai jos este relativă la URL-ul de bază al API-ului și include deja prefixul /api/v1 — vezi convențiile pentru autentificare, paginare, erori și idempotență.

Endpoint
GET/billing/balanceReturn the credit balance with reserved funds, burn rate, projected runway and estimated minutes left
GET/billing/ledgerList credit ledger entries for a period with the balance after each, filterable by entry type
GET/billing/ledger/reconcileRecompute the balance from the ledger and report drift

Endpoint-uri ​

Return the credit balance with reserved funds, burn rate, projected runway and estimated minutes left ​

GET/billing/balance
  • Necesită billing.read.
  • Provisions a billing account on first read if one does not yet exist, so a GET can create a row
bash
curl -X GET "$CALLAGENT_API_URL/billing/balance" \
  -H "Authorization: Bearer $CALLAGENT_API_KEY" \
  -H "Accept: application/json"
js
const response = await fetch(`${process.env.CALLAGENT_API_URL}/billing/balance`, {
  method: 'GET',
  headers: {
    Authorization: `Bearer ${process.env.CALLAGENT_API_KEY}`,
    Accept: 'application/json',
  },
});

if (!response.ok) {
  const { error } = await response.json();
  throw new Error(`${error.type}: ${error.message}`);
}

const { data } = await response.json();
php
<?php

$handle = curl_init(getenv('CALLAGENT_API_URL') . '/billing/balance');

curl_setopt_array($handle, [
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('CALLAGENT_API_KEY'),
        'Accept: application/json',
    ],
]);

$body = json_decode(curl_exec($handle), true);
$status = curl_getinfo($handle, CURLINFO_HTTP_CODE);
curl_close($handle);

if ($status >= 400) {
    throw new RuntimeException("{$body['error']['type']}: {$body['error']['message']}");
}

$data = $body['data'];
python
import os, requests

response = requests.get(
    f"{os.environ['CALLAGENT_API_URL']}/billing/balance",
    headers={"Authorization": f"Bearer {os.environ['CALLAGENT_API_KEY']}"},
    timeout=30,
)
response.raise_for_status()
data = response.json()["data"]

Răspunsuri

StatusCorp
200data-wrapped object

Erori

StatusCând apare
403Neither the API key scope nor the session user's permission allows billing.read

Exemplu de răspuns, generat din schemă:

json
{
  "data": {
    "currency": "string",
    "balance": "string",
    "available_balance": "string",
    "reserved": "string",
    "billing_mode": "string",
    "status": "string",
    "outbound_frozen": true,
    "credit_limit": "string",
    "dunning_stage": 1,
    "burn_rate_per_day": "string",
    "projected_runway_hours": "string",
    "estimated_minutes_remaining": "string",
    "daily_spend_cap": "string"
  }
}

List credit ledger entries for a period with the balance after each, filterable by entry type ​

GET/billing/ledger
  • Necesită billing.read.
  • Defaults to the last 30 days. from/to go straight to Carbon::parse with no validation, so a malformed date is a 500 rather than a 422.
bash
curl -X GET "$CALLAGENT_API_URL/billing/ledger" \
  -H "Authorization: Bearer $CALLAGENT_API_KEY" \
  -H "Accept: application/json"
js
const response = await fetch(`${process.env.CALLAGENT_API_URL}/billing/ledger`, {
  method: 'GET',
  headers: {
    Authorization: `Bearer ${process.env.CALLAGENT_API_KEY}`,
    Accept: 'application/json',
  },
});

if (!response.ok) {
  const { error } = await response.json();
  throw new Error(`${error.type}: ${error.message}`);
}

const { data } = await response.json();
php
<?php

$handle = curl_init(getenv('CALLAGENT_API_URL') . '/billing/ledger');

curl_setopt_array($handle, [
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('CALLAGENT_API_KEY'),
        'Accept: application/json',
    ],
]);

$body = json_decode(curl_exec($handle), true);
$status = curl_getinfo($handle, CURLINFO_HTTP_CODE);
curl_close($handle);

if ($status >= 400) {
    throw new RuntimeException("{$body['error']['type']}: {$body['error']['message']}");
}

$data = $body['data'];
python
import os, requests

response = requests.get(
    f"{os.environ['CALLAGENT_API_URL']}/billing/ledger",
    headers={"Authorization": f"Bearer {os.environ['CALLAGENT_API_KEY']}"},
    timeout=30,
)
response.raise_for_status()
data = response.json()["data"]

Răspunsuri

StatusCorp
200data-wrapped array

Erori

StatusCând apare
403Neither the API key scope nor the session user's permission allows billing.read

Exemplu de răspuns, generat din schemă:

json
{
  "data": [
    {
      "id": null,
      "type": "string",
      "amount": "string",
      "currency": "string",
      "balance_after": "string",
      "description": "string",
      "source_type": "string",
      "source_id": "01JQ0000000000000000000000",
      "call_id": "01JQ0000000000000000000000",
      "created_at": "2026-01-01T12:00:00+00:00"
    }
  ],
  "meta": {
    "current_page": 1,
    "per_page": 25,
    "total": 1,
    "last_page": 1
  }
}

Recompute the balance from the ledger and report drift ​

GET/billing/ledger/reconcile

Exposed on purpose: a customer who thinks their balance is wrong should be able to make us prove it against the ledger rather than trust a cache.

  • Necesită billing.read.
  • Read-only from the API: the service's repair mode is never enabled here, so repaired is always false
bash
curl -X GET "$CALLAGENT_API_URL/billing/ledger/reconcile" \
  -H "Authorization: Bearer $CALLAGENT_API_KEY" \
  -H "Accept: application/json"
js
const response = await fetch(`${process.env.CALLAGENT_API_URL}/billing/ledger/reconcile`, {
  method: 'GET',
  headers: {
    Authorization: `Bearer ${process.env.CALLAGENT_API_KEY}`,
    Accept: 'application/json',
  },
});

if (!response.ok) {
  const { error } = await response.json();
  throw new Error(`${error.type}: ${error.message}`);
}

const { data } = await response.json();
php
<?php

$handle = curl_init(getenv('CALLAGENT_API_URL') . '/billing/ledger/reconcile');

curl_setopt_array($handle, [
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('CALLAGENT_API_KEY'),
        'Accept: application/json',
    ],
]);

$body = json_decode(curl_exec($handle), true);
$status = curl_getinfo($handle, CURLINFO_HTTP_CODE);
curl_close($handle);

if ($status >= 400) {
    throw new RuntimeException("{$body['error']['type']}: {$body['error']['message']}");
}

$data = $body['data'];
python
import os, requests

response = requests.get(
    f"{os.environ['CALLAGENT_API_URL']}/billing/ledger/reconcile",
    headers={"Authorization": f"Bearer {os.environ['CALLAGENT_API_KEY']}"},
    timeout=30,
)
response.raise_for_status()
data = response.json()["data"]

Răspunsuri

StatusCorp
200data-wrapped object

Erori

StatusCând apare
403Neither the API key scope nor the session user's permission allows billing.read

Exemplu de răspuns, generat din schemă:

json
{
  "data": {
    "organization_id": "01JQ0000000000000000000000",
    "ledger_settled": "string",
    "ledger_reserved": "string",
    "cached_settled": "string",
    "cached_reserved": "string",
    "settled_drift": "string",
    "reserved_drift": "string",
    "ledger_entry_count": 1,
    "cached_entry_count": 1,
    "has_drift": true,
    "repaired": true
  }
}

Scrisă după cod. Ce nu este încă implementat este marcat ca atare, niciodată descris ca funcțional.