---
title: API keys
description: Check a key and replace it without interrupting your integration.
url: "https://mediaseer.ai/docs/guides/api-keys/"
---

# API keys

Create and revoke keys on the [API keys page](https://mediaseer.ai/app/api-keys). [Accounts and auth](https://mediaseer.ai/docs/auth/#api-keys) explains their permissions and shared quota.

## Analytics permission

Ordinary backend operations inherit the owning account’s analytics permission. A shared key does not identify the human using it. The CLI and MCP server send no client telemetry; their explicit analytics-status operation reads permission only and cannot change consent or request erasure. Manage those controls in [Account → Analytics](https://mediaseer.ai/app/account#analytics); see [analytics settings](https://mediaseer.ai/docs/guides/analytics/).

## Check a key

Set `MEDIASEER_API_URL` and `MEDIASEER_API_KEY` as described in the [quickstart](https://mediaseer.ai/docs/guides/quickstart/#prepare). The example reads your usage and starts nothing. It keeps the key off curl’s command line and ignores your curl configuration.

```bash title="check-key.sh"
#!/usr/bin/env bash
#
# Checks that MEDIASEER_API_KEY works, without creating or starting anything: it asks for the account's
# usage. Run it with a new key before you revoke the old one.
set -euo pipefail

base="${MEDIASEER_API_URL:?the API origin, without /api/v1}"
base="${base%/}/api/v1"
: "${MEDIASEER_API_KEY:?the API key to check}"

api() { curl -q -sS -H @- "$@" <<<"X-Api-Key: $MEDIASEER_API_KEY"; }

tmp="$(mktemp -d)"
trap 'rm -rf "$tmp"' EXIT

status="$(api -o "$tmp/usage.json" -w '%{http_code}' "$base/usage")" || {
  echo "usage got no answer: curl exit $?" >&2
  exit 1
}
if [[ "$status" != 200 ]]; then
  code="$(jq -r '.code // empty' "$tmp/usage.json" 2>/dev/null || true)"
  echo "the key doesn't work: usage answered $status $code" >&2
  exit 1
fi
jq -r '.jobs | "the key works: \(.used) of \(.limit) analysis slots used, \(.remaining) left"' "$tmp/usage.json"
```

## Replace a key

- Create a new key and switch your integration to it.
- Check the new key with the example.
- Confirm every job uses the new key before revoking the old one. `lastUsedAt` in the app is a delayed hint, not proof.
- Revoke the old key; its next request returns `401` `UNAUTHENTICATED`.

If a key leaked, revoke it first, then create a replacement.
