# Management API

Authenticate Management API requests and find endpoints for own keys, customer keys, usage and white label domains

Source: https://zerocopy.sh/docs/reference/management-api

Use the Management API to manage your team's own and customer API keys, read traffic
and configure white label domains. The base URL is
`https://console.zerocopy.sh/api/v1`.

The [Management API guide](/docs/account/management-api) covers customer keys, domain
setup and retries. The [Metrics API guide](/docs/account/metrics-api) covers Prometheus scraping,
Grafana and historical queries.

## Authentication and scopes [#scopes]

Create a [management key](/docs/api-keys#management-keys) and send it in
`Authorization: Bearer YOUR_MANAGEMENT_KEY`. An SWQoS API key cannot authenticate
these requests. The API ignores session cookies. If the management key has IP
restrictions, the request must come from an allowed address.

| Scope | Access |
| --- | --- |
| `keys:read` | Retrieve your team's own API keys |
| `keys:write` | Create, update and revoke your team's own API keys |
| `usage:read` | Retrieve key statistics, transactions and metrics |
| `partner:read` | Retrieve white label settings, tip accounts, domains, customer keys and customer usage |
| `partner:write` | Manage domains and create, update, revoke, pause or resume customer keys |

A write scope does not grant its read scope. The current-key endpoint needs no
additional scope. White label operations require an enrolled partner team; other
teams receive HTTP `404`. Enrollment leaves your own keys on company tip accounts
until all eight vanity accounts are live. You can prepare domains while ZeroCopy
reviews the accounts. Customer keys can only be created after the vanity set is
live. Use the [customer-key endpoints](#white-label) or
[White label > Customer keys](/docs/account/white-label#customer-keys) to manage them.

## Rate limits [#rate-limits]

Each management key may make 600 GET requests and 60 other requests per minute.
Authenticated responses carry `RateLimit-Limit`, `RateLimit-Remaining` and
`RateLimit-Reset`. Exceeding a key's limit returns `429 rate_limited` with a
`Retry-After` header.

A team may run two management analytics requests concurrently. Excess requests
return `429 analytics_busy` with `Retry-After: 1`. Prometheus cache hits do not
count toward this concurrent query limit. Use one scrape job per team and let
Grafana query the collected metrics.

## Request conventions [#request-conventions]

Every response carries `Request-Id`. Keep it when reporting a failed request on
[Discord](https://discord.gg/zerocopy).

JSON request and response fields use snake_case. Times use RFC 3339 unless the
field specifies another format. POST and PATCH bodies have a 64 KiB limit,
including streamed bodies. The Prometheus endpoint returns text exposition with
explicit minute-end timestamps.

### Idempotency [#idempotency]

Send `Idempotency-Key` on POST requests when retrying after a timeout. Use 1 to
255 printable ASCII characters. The same management key, idempotency key and
request replay the saved successful response for 24 hours, with
`Idempotent-Replayed: true`. Refusals are not saved.

A different request under the same key returns `409 idempotency_key_reused`.
A concurrent repeat returns `409 idempotency_in_progress`. The
[retry guide](/docs/account/management-api#idempotency) covers recovery when
a saved response is unavailable.

### Conditional updates [#conditional-updates]

Key responses include an `ETag`. Send that value in `If-Match` on key PATCH,
DELETE or customer-key pause and resume requests to reject a stale version with
`412 precondition_failed`.

### Pagination [#pagination]

Paginated lists accept `limit` from 1 to 100. Supply the response's
`next_cursor` as the next request's `cursor`. A null cursor ends the collection.
The endpoint pages state which lists support pagination and their defaults.

### Errors [#errors]

Errors use `application/problem+json` with `title`, `status`, `code`, `detail`
and `request_id`. Validation errors can include an `errors` array of
`{ path, message }` strings. Match on the stable `code` field. These objects
differ from [SWQoS rejections](/docs/reference/errors).

## Account [#account]

| Operation | Method and path | Scope |
| --- | --- | --- |
| [Retrieve the current key](/docs/reference/management-api/retrieve-the-current-key) | `GET /me` | None |

## API keys [#api-keys]

| Operation | Method and path | Scope |
| --- | --- | --- |
| [List API keys](/docs/reference/management-api/list-api-keys) | `GET /keys` | `keys:read` |
| [Create an API key](/docs/reference/management-api/create-an-api-key) | `POST /keys` | `keys:write` |
| [Retrieve an API key](/docs/reference/management-api/retrieve-an-api-key) | `GET /keys/{id}` | `keys:read` |
| [Update an API key](/docs/reference/management-api/update-an-api-key) | `PATCH /keys/{id}` | `keys:write` |
| [Revoke an API key](/docs/reference/management-api/revoke-an-api-key) | `DELETE /keys/{id}` | `keys:write` |
| [Retrieve key statistics](/docs/reference/management-api/retrieve-key-statistics) | `GET /keys/{id}/stats` | `usage:read` |

## Usage [#usage]

| Operation | Method and path | Scope |
| --- | --- | --- |
| [List transactions](/docs/reference/management-api/list-transactions) | `GET /transactions` | `usage:read` |

## Metrics [#metrics]

| Operation | Method and path | Scope |
| --- | --- | --- |
| [Retrieve Prometheus metrics](/docs/reference/management-api/retrieve-prometheus-metrics) | `GET /metrics` | `usage:read` |
| [Retrieve metric history](/docs/reference/management-api/retrieve-metric-history) | `GET /metrics/series` | `usage:read` |

## White label [#white-label]

| Operation | Method and path | Scope |
| --- | --- | --- |
| [Retrieve partner settings](/docs/reference/management-api/retrieve-partner-settings) | `GET /partner` | `partner:read` |
| [List tip accounts](/docs/reference/management-api/list-tip-accounts) | `GET /partner/tip-accounts` | `partner:read` |
| [List customer keys](/docs/reference/management-api/list-customer-keys) | `GET /customer-keys` | `partner:read` |
| [Create a customer key](/docs/reference/management-api/create-a-customer-key) | `POST /customer-keys` | `partner:write` |
| [Retrieve customer usage](/docs/reference/management-api/retrieve-customer-usage) | `GET /customer-keys/usage` | `partner:read` |
| [Retrieve a customer key](/docs/reference/management-api/retrieve-a-customer-key) | `GET /customer-keys/{id}` | `partner:read` |
| [Update a customer key](/docs/reference/management-api/update-a-customer-key) | `PATCH /customer-keys/{id}` | `partner:write` |
| [Revoke a customer key](/docs/reference/management-api/revoke-a-customer-key) | `DELETE /customer-keys/{id}` | `partner:write` |
| [Pause a customer key](/docs/reference/management-api/pause-a-customer-key) | `POST /customer-keys/{id}/pause` | `partner:write` |
| [Resume a customer key](/docs/reference/management-api/resume-a-customer-key) | `POST /customer-keys/{id}/resume` | `partner:write` |
| [Retrieve customer key statistics](/docs/reference/management-api/retrieve-customer-key-statistics) | `GET /customer-keys/{id}/stats` | `partner:read` |
| [List domains](/docs/reference/management-api/list-domains) | `GET /domains` | `partner:read` |
| [Add a domain](/docs/reference/management-api/add-a-domain) | `POST /domains` | `partner:write` |
| [Retrieve a domain](/docs/reference/management-api/retrieve-a-domain) | `GET /domains/{hostname}` | `partner:read` |
| [Remove a domain](/docs/reference/management-api/remove-a-domain) | `DELETE /domains/{hostname}` | `partner:write` |

## OpenAPI [#openapi]

<a href="/docs/openapi/management-api.json" download="zerocopy-management-api.json">Download the OpenAPI JSON</a>.
The console also publishes the live contract at
[`/api/v1/openapi.json`](https://console.zerocopy.sh/api/v1/openapi.json), cached
for five minutes.
