# Signing keys

URL: https://docs.folkways.io/docs/console/signing-keys

Add, rotate and delete the key pairs your backend signs user and service tokens with.

Your backend signs a short-lived token for each user with a **signing key**: a key pair, Ed25519 (EdDSA) or P-256
(ES256). Folkways keeps only the public key and checks every token's signature with it. Until a segment has a
signing key, it refuses every signed token.

Manage keys on the segment's **Signing keys** tab. Owners and admins add and delete keys.

## Add a key [#add-a-key]

1. Choose **Add key** and enter a **Key ID** (`kid`), e.g. `backend-2026-12`. Your backend puts it in each
   token's header.
2. Either:
   - **Generate a key pair.** Pick Ed25519 (the default) or P-256. The Console shows the private key **once**, to
     copy or download. We never keep a copy.
   - **Use my own public key.** Create the pair yourself, with OpenSSL, `ssh-keygen`, your key management service
     or a JWT library, and paste only the public key: a PEM, a JWK, or an `ssh-ed25519` line.
3. Save. The key works within seconds.

Store the private key in your backend's secrets manager, never in an app or a repository. The segment's **Connect**
tab shows how to load it in Node.js, Python and Go.

## Rotate a key [#rotate-a-key]

Keys coexist, so rotation has no downtime:

1. Add a new key with a new ID.
2. Switch your backend to sign with it.
3. Wait until tokens signed with the old key have expired (at most 15 minutes), then delete the old key.

## Delete a key [#delete-a-key]

Deleting a key ends every connection whose token it signed, and its tokens stop working. If a private key leaks,
add a new key, switch your backend, and delete the leaked one at once.

## Lost a private key? [#lost-a-private-key]

We can't show a generated private key again. Generate a new pair, switch your backend to it, and delete the old
key.

See [Identities and tokens](/docs/concepts/authentication) for what goes in a token, and
[Realtime API authentication](/docs/realtime-api/authentication) for signing one in any language.
