---
title: "get_usage"
method: GET
path: "/v1/usage"
tags: ["operations"]
---

# get_usage

`GET /v1/usage`

## Request

- Base URL: `https://ndi-api.nace.ai` (the document declares no server; this is the origin it was published from)
- URL: `https://ndi-api.nace.ai/v1/usage`
- Auth: API key in header `X-API-Key`
- TypeScript: <https://skmtc.dev/nace/apis/ndi-service/docs/v1/usage/get.ts> (a function with typed inputs; its response is checked against the schema)

Aggregate job units for a billing period. Cost class: fast.

``credits`` is what the period bills; ``units`` are measured work, including
failed and cancelled jobs that are not billed. The admission allowance also counts failed and cancelled
work and in-flight reservations, so a ``quota_exceeded`` ``credits_used`` can
exceed ``credits_total``.

``pages`` and ``bytes_ingested`` aggregate the per-job processing volume
the workers record at completion time. ``credits`` sums only jobs whose
usage is final; ``unfinalized_jobs`` counts the ones still open.

Args:
    session: Database session.
    caller: The authenticated tenant.
    period_start: Start of the billing window (inclusive).
    period_end: End of the billing window (inclusive).
    workspace_id: When set, restrict aggregation to one workspace.
    group_by: Aggregation key: ``day`` (default), ``kind``,
        ``workspace``, or ``tenant`` (a partner's roll-up over its child
        tenants, keyed by ``external_ref``).

Returns:
    A usage report with per-bucket breakdowns and a total unit count.

Raises:
    PlatformError: ``invalid_request`` when ``period_end < period_start``,
        or when ``group_by=tenant`` comes from anything but a partner key
        acting as itself or names a workspace; ``tenant_required`` when a
        partner key without ``X-NDI-Tenant`` asks for any other grouping.

## Query parameters

- `period_start` string, date, required: Start of the billing window, inclusive.
- `period_end` string, date, required: End of the billing window, inclusive.
- `workspace_id` string, uuid, nullable: Restrict to one workspace. Omit to aggregate all jobs for this API key.
- `group_by` 'day' | 'kind' | 'workspace' | 'tenant': Aggregation key: calendar day, job kind, or workspace. `tenant` is for a partner key sent without `X-NDI-Tenant`: one bucket per child tenant, keyed by its `external_ref`.

## Response `200`

Successful Response

- NdiServiceAppPlatformApiOperationsSchemasUsageResponse: Usage report covering ``[period_start, period_end]``. ``units_total`` sums measured work, including free failed and cancelled jobs. ``credits_total`` sums final billable credits for the period.
  - `period_start` string, date, required
  - `period_end` string, date, required
  - `group_by` string, required
  - `buckets` UsageBucket[], required
    - `key` string, required
    - `units` integer, required
    - `jobs` integer, required
    - `pages` integer, required
    - `bytes_ingested` integer, required
    - `credits` integer, required: Final credits of the jobs in this bucket whose usage is final. What a bill charges.
    - `unfinalized_jobs` integer, required: Jobs in this bucket whose usage is not final yet, so they are not in `credits`.
  - `units_total` integer, required
  - `credits_total` integer, required: Sum of `credits` across all buckets: final credits for the period.

## Other responses

- `400`: Bad Request
- `401`: Unauthorized
- `402`: Payment Required
- `403`: Forbidden
- `404`: Not Found
- `409`: Conflict
- `410`: Gone
- `413`: Request Entity Too Large
- `422`: Unprocessable Entity
- `424`: Failed Dependency
- `429`: Too Many Requests
- `500`: Internal Server Error
- `501`: Not Implemented
- `503`: Service Unavailable
- `504`: Gateway Timeout

---

[API](https://skmtc.dev/nace/apis/ndi-service.md) - [All operations](https://skmtc.dev/nace/apis/ndi-service/llms.txt) - [OpenAPI document](https://skmtc.dev/nace/apis/ndi-service/revisions/d9d1f8ec2207?raw)
