Rotate keys and secrets
Replace each key and secret ClipMux uses without stopping playback, and what to do when one leaks.
Every key ClipMux issues or holds can be replaced while the server keeps running, and in most cases while viewers keep watching. This page covers each one, in the order you're likely to need them.
The commands below are for the one-line install, run from /opt/clipmux,
where clipmux admin runs inside the app container:
cd /opt/clipmux
docker compose exec app clipmux admin list-keys --app my-appBefore you start
- The owner's dashboard sign-in, and shell access to the server.
- Somewhere to put each new secret: your app's environment, your webhook receiver, or your offline backup.
API keys
- Create a new key: in the dashboard, open Apps & API, choose the app, and on API keys choose Create key. It's shown once.
- Put it in your app's backend as
CLIPMUX_API_KEYand deploy. - Revoke the old one: Revoke next to it, or
clipmux admin revoke-key cmx_…. It stops working at once.
Signing keys
docker compose exec app clipmux admin rotate-signing-key --app my-appThis creates a new signing key and prints it once. The app's other keys are
retired when the longest token they may have signed runs out, so viewers
mid-session finish. Meanwhile, switch your backend's CLIPMUX_SIGNING_KID
and CLIPMUX_SIGNING_KEY to the new key.
Revoke on the app's Signing keys tab, or clipmux admin revoke-key
with the key's kid, ends a key at once: every token it signed stops
playing. Use that for a leaked key, not a routine rotation.
Webhook secrets
Rotating takes two steps, so your receiver never sees a delivery it can't verify:
- On the app's Webhooks tab, choose Rotate secret. The new secret is shown once, and deliveries stay signed with the old one.
- Give your receiver the new secret and deploy it.
- Choose Activate new secret. Deliveries are signed with it from the next try.
Over the API, the steps are POST /v1/webhook-endpoints/{id}/secret and
POST /v1/webhook-endpoints/{id}/secret/activate. See
Retries, redelivery and secret rotation.
The content key secret
The content key secret is what every video's encryption key is derived
from. In the dashboard, open Settings, and under
Content encryption key choose Rotate key. Or call
POST /v1/content-keys/rotate as the owner.
- New encodes use the new version. Existing videos keep theirs and keep playing. To move a video to the new version, re-encode it.
- With Cloudflare delivery, the
rotation needs a Cloudflare token, the same kind Connect uses. ClipMux
redeploys the Worker with the new version before any video uses it. If
the redeploy fails, the call answers
502with the steps, and the new version stays unused; rotating again retries. Without a token, it answers409 cloudflare_token_required.
The secrets key
The secrets key seals every secret ClipMux keeps in Postgres. It's
CLIPMUX_SECRETS_KEY, written as v1: and 64 hex digits; the one-line
install keeps it in /opt/clipmux/.env.
Make a new key with the next version
echo "v2:$(openssl rand -hex 32)"Give serve both keys
In .env, move the old value to CLIPMUX_SECRETS_KEY_PREVIOUS and put the
new one in CLIPMUX_SECRETS_KEY. Then restart: docker compose up -d --wait.
Reseal
docker compose exec app clipmux admin reseal-secretsIt reseals every stored secret with the new key, and ends by saying
CLIPMUX_SECRETS_KEY_PREVIOUS can go.
Drop the previous key
Remove CLIPMUX_SECRETS_KEY_PREVIOUS from .env and restart again. Then
back up the new key.
Keep the old key too, in your recovery kit, until the oldest backup made under it has expired: each backup is encrypted to the key that was current when it was taken, and the old key is the only thing that opens it.
serve refuses to start if a sealed value opens with neither key, and names its column, so a mistake here stops the server rather than losing data.
Provider credentials
| Credential | How to replace it |
|---|---|
| Cloudflare delivery token | Delivery, Connect again, with a new token. R2's credentials derive from the token, so revoking the old one cuts off storage until you do. |
| Edge analytics token | Replace token in the Edge analytics card. |
| An R2 bucket added with a token | Storage, Add R2 bucket with the same bucket and a new token renews its keys. |
| S3 storage keys | Rotate keys on the bucket in Storage, or PUT /v1/storage/{id}/credentials. The old keys work until the new ones pass the checks. |
| Modal or RunPod | Connect the provider again on Encoding; it replaces the key. |
| Speech API or chapters LLM key | Connect again on Captions & AI. A failed connect keeps the old connection. |
When a key leaks
- Revoke it at once:
clipmux admin revoke-key IDfor an API key or a signing key, or the dashboard's Revoke. - Rotate whatever it could reach.
- For a leaked content key secret, rotate it and re-encode the affected videos.
- For a stolen Cloudflare token, revoke it in Cloudflare and rotate the content key secret: a token that can deploy a Worker can read Worker secrets.
Check it works
clipmux admin list-keys --app my-appshows the app's API and signing keys, with which are retired or revoked.- After a webhook rotation, the endpoint's deliveries on the Webhooks tab keep succeeding.
- After rotating the secrets key, the server starts without the previous
key, and
clipmux admin setup-test --waitpasses.