Graine AI

Aggregate usage over a date range

Aggregate call volume, connected minutes and spend for the organization.

Aggregate call volume, connected minutes and spend for the organization.

Backed by ONE call_records aggregate, scoped by organization_id AND the B2B surface filter AND merged_into absent — all three are load-bearing. The collection serves two products, so an organization filter alone would fold native-app screening calls into a customer's numbers, and merged orphan legs would double-count retries.

The result is cached for 60 seconds per organization and filter set. This is deliberately NOT backed by the credit ledger's spending history: that is an unbounded group over the whole organization's debits with no date filter and no cache.

Note that calls.voicemail is a dimension rather than an outcome — a voicemail pickup is stored as no-answer plus a flag, so it is also counted in calls.no_answer and the outcome fields do not sum to calls.total.

Errors: 400 (to_date before from_date, or a range longer than 366 days, or an unknown group_by), 401, 403, 422, 429, 503.

Rate limit: 600 requests per minute per organization (bucket executions.list). Exceeding it returns 429 with Retry-After; the X-RateLimit-* response headers report your remaining allowance on every call.

GET
/v2/usage
/v2/usage?from_date=2026-08-01T00%3A00%3A00%2B05%3A30&to_date=2026-08-27T00%3A00%3A00%2B05%3A30&agent_id=6c6f4cc3-f56c-479d-8422-7f76694daa29&group_by=agent

The Authorization access token

Authorization

Authorization
Required
Bearer <token>

Your Graine API key. Create one in the dashboard under Developers, or via POST /v2/api-keys. Send it as Authorization: Bearer <key>.

In: header

Query Parameters

from_dateFrom Date

Start of the window, ISO-8601 with a timezone offset. Defaults to 30 days ago.

to_dateTo Date

End of the window, ISO-8601 with a timezone offset. Defaults to now.

agent_idAgent Id

Restrict to one agent.

group_byGroup By

Breakdown to return alongside the totals: none, agent or day.

Default: "none"

organization_idOrganization Id

Optional; must match the key's organization.

Response Body

200

Call counts, connected minutes and spend, with an optional breakdown.

period
Required
Period

The window these numbers cover.

calls
Required
Calls

Call counts by outcome.

minutes
Required
Minutes

Connected minutes.

cost
Required
Cost

Spend, with its per-service split.

groups
Required
Groups

The same numbers split by agent or by day. Empty unless group_by was sent.

400

1000 — malformed or contradictory input. 1002 — a required parameter is missing.

error
Required
Error

Stable integer code from the /v2 error table. Branch on this.

message
Required
Message

One human-readable sentence. Wording may change; the code will not.

401

1100 — missing, unknown or inactive API key. 1101 — a browser session token was presented instead of an API key.

error
Required
Error

Stable integer code from the /v2 error table. Branch on this.

message
Required
Message

One human-readable sentence. Wording may change; the code will not.

403

1102 — the key is valid but lacks the scope this endpoint requires, or names another organization. GET /v2/scopes reports what a key holds.

error
Required
Error

Stable integer code from the /v2 error table. Branch on this.

message
Required
Message

One human-readable sentence. Wording may change; the code will not.

422

1001 — the body or query failed validation; the message names the first offending field.

error
Required
integer

Stable integer code from the error table. Branch on this, not on the message.

message
Required
string

One human-readable sentence. Wording may change; the code will not.

429

1300 — the per-organization request rate or concurrent-call limit was reached. Carries Retry-After.

error
Required
Error

Stable integer code from the /v2 error table. Branch on this.

message
Required
Message

One human-readable sentence. Wording may change; the code will not.

503

1501 — a service this endpoint depends on is unreachable or returned a 5xx.

error
Required
Error

Stable integer code from the /v2 error table. Branch on this.

message
Required
Message

One human-readable sentence. Wording may change; the code will not.

curl -X GET "https://api.graine.ai/v2/usage?from_date=2026-08-01T00%3A00%3A00%2B05%3A30&to_date=2026-08-27T00%3A00%3A00%2B05%3A30&agent_id=6c6f4cc3-f56c-479d-8422-7f76694daa29&group_by=agent&organization_id=string" \
  -H "Authorization: Bearer <token>"

Call counts, connected minutes and spend, with an optional breakdown.

{
  "period": {
    "from": "2026-07-28T00:00:00.000Z",
    "to": "2026-08-27T00:00:00.000Z"
  },
  "calls": {
    "total": 1842,
    "completed": 1201,
    "failed": 288,
    "busy": 143,
    "no_answer": 178,
    "voicemail": 22,
    "in_flight": 10
  },
  "minutes": {
    "total": 5127.4
  },
  "cost": {
    "total": 993.24,
    "currency": "USD",
    "breakdown": {
      "llm": 124.75,
      "network": 136.41,
      "platform": 108.78,
      "synthesizer": 557.49,
      "transcriber": 65.81
    }
  },
  "groups": [
    {
      "key": "6c6f4cc3-f56c-479d-8422-7f76694daa29",
      "calls": 812,
      "minutes": 2264.9,
      "cost": 438.12
    }
  ]
}