Server Keys: Creating, Rotating and Revoking
Learn how to create a server key for your backend, keep it safe, rotate it without downtime and revoke it.
2 min read
A server key lets your backend use the Pertento server SDK and the server-side HTTP API for one website. With it, your backend can read the website's server-side experiment setup and report conversions. Keep it on your server, never in a page.
Keys start with psk_live_.
Creating a key
- 1Go to Websites and click Server keys on the website's row.
- 2Name the key after where it runs, such as production or staging. A name is at most 64 characters, and no two active keys on a website can share one.
- 3Create the key and copy it straight into your server's secrets. It is shown once and cannot be shown again.
A new key becomes active within about 30 seconds. The SDK retries a refused key for 2 minutes, so a server started straight after creating a key still connects.
Only Owners and Admins can create and revoke keys, and the website's visitor ID has to be on before a key can be created.
What a key gives access to
Besides deciding and reporting, a key gives access to the website's bucketing salt, the secret Pertento uses to turn an ID into a variant. Treat the key like a password. If an experiment buckets on a customer ID, send opaque IDs rather than sequential ones such as database row numbers, because someone holding the key could otherwise work out the enrolment ID of a customer whose ID they can guess. See Attribute rules and bucketing on a customer ID.
Rotating a key
A website can have up to 10 active keys at once, so you can rotate a key without downtime:
- 1Create a new key.
- 2Put it on your servers and check they use it. The Last used column shows when each key was last used.
- 3Revoke the old key.
Revoking a key
Click Revoke on the key's row. Code using it stops working within about 30 seconds, and this cannot be undone. Revoked keys stay in the list, marked with when they were revoked.
Notifications
Creating or revoking a key notifies the account's Owners and Admins, in the dashboard and by default also by email and Slack, because a key nobody expected is a security matter. See Notifications in Pertento.
If the visitor ID is turned off
Existing keys keep working until you revoke them, but no new key can be created until the visitor ID is on again.