> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stateset.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Usage By Template V1

> Cost / token / job-count rollup grouped by agent_type. Joins UsageRecord against Job to pick up the template name…

Cost / token / job-count rollup grouped by `agent_type`.

Joins UsageRecord against Job to pick up the template name. Sorted
by cost descending so the biggest line items surface first.

### Response

`UsageByTemplateResponse`

<ResponseField name="rows" type="UsageByTemplateRow[]" required>
  Sorted by cost descending. Empty when the tenant has no usage.

  <Expandable title="UsageByTemplateRow">
    <ResponseField name="template" type="string" required>
      `agent_type` value (built-in or tenant-owned).
    </ResponseField>

    <ResponseField name="jobs" type="integer" required />

    <ResponseField name="tokens" type="integer" required />

    <ResponseField name="cost_usd" type="number" required />
  </Expandable>
</ResponseField>

<ResponseField name="total_jobs" type="integer" required />

<ResponseField name="total_tokens" type="integer" required />

<ResponseField name="total_cost_usd" type="number" required />

### Status codes

| Code  | Meaning             |
| ----- | ------------------- |
| `200` | Successful Response |

<RequestExample>
  ```bash cURL theme={null}
  curl --request GET \
    --url 'https://api.computer.stateset.app/api/v1/usage/by-template' \
    --header 'X-API-Key: YOUR_API_KEY'
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "rows": [
      {
        "template": "string",
        "jobs": 1,
        "tokens": 1,
        "cost_usd": 1.5
      }
    ],
    "total_jobs": 1,
    "total_tokens": 1,
    "total_cost_usd": 1.5
  }
  ```
</ResponseExample>
