# The partner's usage across its workspaces

> Usage summed over the partner's child workspaces. `group_by=day` gives one row per UTC day; `group_by=workspace` gives one row per workspace, named by `external_user_id`, and pages it.

Source: https://docs.spicrawl.com/api-reference/partner/partner-usage

## GET /v1/partner/usage

Operation ID: `partnerUsage`. API key scope: `partner`.

Usage summed over the partner's child workspaces. `group_by=day` gives one row per UTC day;
`group_by=workspace` gives one row per workspace, named by `external_user_id`, and pages it.
The window is `from` (inclusive) to `to` (exclusive), default the last 30 days, at most 400 days.

### Example

```bash
curl "https://api.spicrawl.com/v1/partner/usage" \
  -H "Authorization: Bearer $SPICRAWL_API_KEY"
```

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `from` | query | string (date) | no |  |
| `to` | query | string (date) | no | Exclusive. |
| `group_by` | query | string: `day`, `workspace`; default `"day"` | no |  |
| `sort` | query | string: `credits`, `requests`, `fail_rate`, `last_active`; default `"credits"` | no | Workspace grouping only. Descending, ties broken by external_user_id. |
| `limit` | query | integer; default `50` | no | Workspace grouping only, 1 to 200. |
| `offset` | query | integer; default `0` | no | Workspace grouping only. |
| `q` | query | string | no | Workspace grouping only. A prefix of external_user_id. |

### Responses

#### 200

The partner's usage.

`application/json`.

| Field | Type | Required | Description |
|---|---|---|---|
| `period` | object | yes |  |
| `group_by` | string: `day`, `workspace` | yes |  |
| `totals` | object (`PartnerUsageTotals`) | yes |  |
| `rows` | array of object | yes | `day` rows carry the totals fields plus `day`; `workspace` rows are PartnerUsageWorkspace. |
| `page` | object | no | Present for group_by=workspace. |

#### 400

The request is invalid. Not retryable; fix the request using `code` and `diagnostics.hint`.

Headers: `X-Request-Id`.

`application/problem+json` (`Problem` schema).

#### 401

Missing, invalid, revoked or expired key. Not retryable with the same key.

Headers: `X-Request-Id`.

`application/problem+json` (`Problem` schema).

#### 403

The key lacks the scope this route requires (`ERR::AUTH::INSUFFICIENT_SCOPE`), or the action is not permitted.

Headers: `X-Request-Id`.

`application/problem+json` (`Problem` schema).

#### 500

Internal error. Retryable when `retryable` is true.

Headers: `X-Request-Id`.

`application/problem+json` (`Problem` schema).

Full OpenAPI spec: https://docs.spicrawl.com/openapi.yaml
