# Usage endpoints

Every path starts at your [API URL](https://docs.qualithm.com/api.md#find-your-api-url). Every response is JSON, and an error has the [error body](https://docs.qualithm.com/api.md#errors).

## Get the team's device and scope counts and its plan quota

`GET /v1/teams/{teamId}/usage`

Needs an [API token](https://docs.qualithm.com/api.md#authenticate) with the `usage.read` permission, which the owner, manager and viewer roles hold.

**Parameters**

| Name | In | Type | Required | Description |
| ---- | -- | ---- | -------- | ----------- |
| `teamId` | path | string | Yes | The team the request acts on |

**Response:** `200` with [Usage](#usage) in `data`.

**[Errors](https://docs.qualithm.com/api.md#errors):** `401`, `403`, `404`, `429`, `500`, `503`

```bash
curl "<your-api-url>/v1/teams/<team-id>/usage" \
  -H "Authorization: Bearer <your-api-token>"
```

## Types

### Usage

The team's device and scope counts, and its plan limits and usage this month.

| Field | Type | Required | Description |
| ----- | ---- | -------- | ----------- |
| `deviceTotal` | integer (int64) | Yes |  |
| `scopeTotal` | integer (int64) | Yes |  |
| `tier` | one of `"free"`, `"plus"`, `"pro"`, `"max"` | Yes |  |
| `month` | string | Yes | The month usage counts over: `YYYY-MM`, UTC |
| `limitGrace` | object or null | Yes | Set while a downgrade's grace period keeps more history than the current plan does. After `endsAt`, history the current plan doesn't keep is deleted |
| `limits` | object | Yes |  |
| `limits.events` | integer (int64) | Yes | Events a month before new events throttle |
| `limits.automations` | integer (int64) | Yes | Automation runs a month before runs are limited |
| `usage` | object | Yes |  |
| `usage.events` | [BillingUsageDimension](#billingusagedimension) | Yes |  |
| `usage.automations` | [BillingUsageDimension](#billingusagedimension) | Yes |  |
| `overage` | object | Yes | Usage past the limits, billed at the plan's rates |
| `overage.enabled` | boolean | Yes | True while usage past each limit keeps going at the plan's rates instead of throttling |
| `overage.reported` | object | Yes | Units past each limit reported for billing this month; they're charged with the next renewal at the plan's rates. Reported every few minutes, so it can trail `used` |
| `overage.reported.events` | integer (int64) | Yes |  |
| `overage.reported.automations` | integer (int64) | Yes |  |
| `overage.capCents` | integer (int64) or null | Yes | The most a month's overage may cost before tax, in cents; once reached, usage past each limit throttles again. Null for no cap |
| `paymentFailed` | object or null | Yes | Set while a payment has failed and the grace period runs; null otherwise |
| `connectedDevices` | object or null | Yes | The team's devices connected at once against its plan's limit; null when the plan sets no limit. Once `connected` reaches `limit`, a new connection is refused. Devices already connected stay connected until they disconnect, and a device that reconnects counts as a new connection. `connected` can lag a connect or disconnect by up to 90 seconds |

### BillingUsageDimension

One metered dimension's usage this month against its limit.

| Field | Type | Required | Description |
| ----- | ---- | -------- | ----------- |
| `used` | integer (int64) | Yes |  |
| `limit` | integer (int64) | Yes |  |
| `throttled` | boolean | Yes | True while this dimension is throttled: devices' new events are refused, or automation runs are recorded as `limited`, until the month resets. Read from the live count the platform enforces, so it can turn true before the hourly `used` reaches `limit` |
| `threshold` | integer (int64) | Yes | The highest share of `limit` used this month that notifies the team's owners: 50, 80 or 100, or 0 below half. Read from the hourly `used` |
