SECRET_KEY can supply every server secret Teable needs. JWTs, sessions and the various encryption keys use it directly, or a key derived from it, whenever they have no variable of their own. The app needs two secrets of its own:
SECRET_KEY: the root secret.SANDBOX_JWT_SECRET: signs the sandbox’s execution tokens. The sandbox runs your users’ scripts and never holds the root secret, so this one does not followSECRET_KEY.
BACKEND_JWT_SECRET, BACKEND_SESSION_SECRET, the *_ENCRYPTION_* ones and so on) is no longer recommended, and a later version may stop reading most of them. This page shows how to move an existing instance to these two secrets without losing the data it already holds.
One optional variable is the exception: BACKEND_STORED_CREDENTIAL_ENCRYPTION_SECRET gives the credentials encrypted in the database a root of their own. See A separate root for stored credentials.
A new deployment needs none of this: generate the two secrets as described under Environment Variables and leave the rest unset.
Before you start
- Upgrade first. Bring the instance to the latest version before you begin, at least
release.2026-11-26T23-38-15Z.4093, the first release with everything this guide uses. The steps use the Key rotation page in System Admin; if System Admin does not show it, the version is too old or the plan is below Business. - Back up. Back up the database and every environment variable. After a re-encryption, the data only opens with the current key.
- Plan a maintenance window. The instance restarts along the way, and users sign in again when the session secret changes.
- Change every replica together. All replicas and workers must restart on the same new configuration before you re-encrypt. A replica still on the old configuration cannot read the rewritten data.
Step 1: check what is set
While an instance still runs on the public built-in defaults, the startup log lists the missing secrets, and instance admins see a Server secrets item under System Admin → Instance settings, in the Pending configuration panel. The startup log also prints a block of variables that pins the current values. This guide does not need it; on an instance that already added the block, those variables appear on the page as dedicated variables marked Public value. For the full picture, open System Admin → Key rotation → Server secrets as an instance admin. It listsSECRET_KEY, SANDBOX_JWT_SECRET, and each secret that still has its own variable or an _OLD variable set. A secret that is not listed follows SECRET_KEY and needs nothing. Key rotation explains the columns.
Use what the page shows to tell which cases apply; there can be more than one:
Remove the dedicated variables
For each row whose Value from reads Own variable, other thanSECRET_KEY and SANDBOX_JWT_SECRET themselves, look at the last column, Same as SECRET_KEY alone:
- Same: delete the variable. The value does not change and no data is affected.
- Different: move its current value to the variable of the same name with
_OLDappended (for exampleBACKEND_AI_CONFIG_ENCRYPTION_SECRET_OLD), then delete the variable itself._OLDonly verifies or decrypts existing data; everything new usesSECRET_KEY. For a key and iv pair, set both_OLDvariables together. A variable that the table below does not list has no_OLD: delete it as it is, unless the page labels it Deprecated (see the note under the table).
_OLD variable holds one previous value only. If the environment already has _OLD variables, for example from an earlier change, finish the re-encryption and remove them before you start another round. Otherwise data still encrypted under the older value becomes unreadable and has to be entered again.
You can handle every variable in one change:
- Stop the instance, edit the environment variables as described above, then start every replica.
- Open the Stored ciphertexts tab and click Dry-run. The Undecryptable column should be 0 everywhere. If it is not, an
_OLDvalue is missing: add it before you continue. - Click Re-encrypt, then run the dry-run once more. When Needs re-encryption and Undecryptable are both 0, all stored ciphertext is under
SECRET_KEY. - If the JWT signing secret changed and the instance has App Builder apps, open JWT credentials and refresh the credentials of every app under Needs attention.
- Spot-check sign-in, a personal access token call, AI features, third-party credentials in automations, and published apps.
- Remove each
_OLDvariable when the table below allows, restarting after each removal.
How long each old value stays
Live automations run from a copy of their steps that the re-encryption does not rewrite. An automation that keeps a mail password or a webhook secret in the step itself still reads it under the old value. Before you remove
BACKEND_THIRD_PARTY_CREDENTIAL_ENCRYPTION_SECRET_OLD or BACKEND_STORED_CREDENTIAL_ENCRYPTION_SECRET_OLD, edit each of those automations and click Update, so that it runs from the re-encrypted steps. This matters only when the old value was private: under a public value these credentials were stored unencrypted.
Instead of editing each automation, you can click Check and migrate under Automation credentials on the Stored ciphertexts tab. It moves these credentials out of the steps and of every published version; each mail password becomes a secret owned by a member and granted to the automation. Remove the _OLD variable once that block finds nothing left and another dry-run of the re-encryption shows 0 in both columns.
BACKEND_DATA_DB_URL_ENCRYPTION_KEY / IV carry a Deprecated label on the page. They only serve database tenant connection strings stored in the older format. Finish the re-encryption above first, which rewrites those connection strings into the format protected by SECRET_KEY, then delete the two variables. They need no _OLD.
BACKEND_ENV_VARIABLE_SECRET, BACKEND_AI_CONFIG_ENCRYPTION_SECRET, BACKEND_THIRD_PARTY_CREDENTIAL_ENCRYPTION_SECRET and BACKEND_DATA_DB_URL_ENCRYPTION_SECRET carry the Deprecated label too: BACKEND_STORED_CREDENTIAL_ENCRYPTION_SECRET supersedes them. Each still takes effect while it is set, and its _OLD still works. Do not set them on a new deployment, and remove the ones you have as described above: a later version may stop reading them.
Switch to your own SECRET_KEY
WhenSECRET_KEY is not set, or is still the public default, every secret that follows it uses a public value. Putting in your own SECRET_KEY changes all of them at once, so the old values go into _OLD first to keep existing data readable.
-
Generate the new root secret:
-
Prepare the
_OLDvariables. Pick the column that matches where the instance starts from, and skip a row when the page lists a dedicated variable for that secret, because its value does not change withSECRET_KEY:The values “derived from the oldSECRET_KEY” in the last column are the first 16 hex characters of a SHA-256. The Docker Compose examples below show how to compute them. Instead of the_OLDvariables in the first three rows andBACKEND_DATA_DB_URL_ENCRYPTION_SECRET_OLD, you can setBACKEND_STORED_CREDENTIAL_ENCRYPTION_SECRET_OLDalone:defaultSecretKeyifSECRET_KEYwas never set, the oldSECRET_KEYotherwise. That one variable reads all of that data. -
Stop the instance, set the new
SECRET_KEYand the_OLDvariables above, and make sureSANDBOX_JWT_SECRETis set (the backend and the sandbox service share one value). Then start every replica. -
From here on, follow steps 2 to 6 of Remove the dedicated variables: dry-run, re-encrypt, refresh app credentials, spot-check, and remove each
_OLDwhen its time comes. WithoutBACKEND_JWT_SECRET_OLD, apps cannot reach Teable until their credentials are refreshed, so do that in JWT credentials right after the instance is up.
Docker Compose .env examples
On a Docker Compose deployment, one of the blocks below writes the new SECRET_KEY and the _OLD variables of steps 2 and 3 into .env in the deployment directory. Stop the instance and back up .env first, and start it again with docker compose up -d afterwards. A block that finds .env in a state it does not expect, for example with _OLD variables already in it, says so and changes nothing. The blocks write every _OLD of the table: if the page lists a dedicated variable for one of those secrets, delete that secret’s _OLD line from .env before you start the instance. For any other setup, add the same variables to the Teable app’s environment. If you deployed with the full-featured deployment kit, the variables live elsewhere and are generated differently: follow the “App secrets” section of the kit’s Docker or Helm README instead.
Example: SECRET_KEY was never set
Example: SECRET_KEY was never set
Example: SECRET_KEY was set and is being replaced
Example: SECRET_KEY was set and is being replaced
After the switch
Once the newSECRET_KEY is in place:
- Without
BACKEND_JWT_SECRET_OLDandBACKEND_SESSION_SECRET_OLD, everyone signs in again, and visitors re-enter the password for password-protected share links. - Without
BACKEND_INVITATION_SECRET_OLD, pending email invitations and existing invitation links stop working: invite those people again and create new links. - With local storage, attachment links copied earlier stop working. Previews work again once the page is refreshed.
- If you used the MinIO variant on the Docker deployment page (
MINIO_SECRET_KEY=${SECRET_KEY}), the MinIO root password changes along withSECRET_KEY. Existing files and buckets are not affected; attachment links issued earlier stop working until the page is refreshed. - Personal access tokens, unsubscribe links, database tenant connections, AI configuration and app environment variables keep working.
SECRET_KEY, deal with them afterwards as described in Remove the dedicated variables. A variable with a value of its own does not change with SECRET_KEY, which is why its _OLD is left out above: you will need that _OLD for the variable’s own value when you remove it.
Optional: a separate root for stored credentials
BACKEND_STORED_CREDENTIAL_ENCRYPTION_SECRET gives the credentials encrypted in the database a root of their own, in place of SECRET_KEY: app environment variables, AI configuration, third-party credentials and database tenant connection strings. Once that data is under it, changing SECRET_KEY no longer affects it. The variable is optional: SECRET_KEY alone is enough.
It supersedes BACKEND_ENV_VARIABLE_SECRET, BACKEND_AI_CONFIG_ENCRYPTION_SECRET, BACKEND_THIRD_PARTY_CREDENTIAL_ENCRYPTION_SECRET and BACKEND_DATA_DB_URL_ENCRYPTION_SECRET, which each covered one kind of that data and are now deprecated. While one of them is still set, it takes precedence for its kind of data. Remove it as described in Remove the dedicated variables; the re-encryption then moves its data under the new root.
To turn it on, SECRET_KEY must already be your own value:
- Generate a value with
openssl rand -base64 32. - Stop the instance, set
BACKEND_STORED_CREDENTIAL_ENCRYPTION_SECRET, then start every replica. Data stored underSECRET_KEYstays readable without any_OLD:SECRET_KEYkeeps decrypting it. - Run the dry-run and the re-encryption as in steps 2 and 3 of Remove the dedicated variables.
BACKEND_STORED_CREDENTIAL_ENCRYPTION_SECRET_OLD to the new value on all of them, and set the variable itself only after they have all restarted. _OLD encrypts nothing: it lets each replica read what the others write during the switch, and you can remove it once the variable is set everywhere.
To change the value later, put the new value in the variable and the current one in BACKEND_STORED_CREDENTIAL_ENCRYPTION_SECRET_OLD, then re-encrypt. That one _OLD reads every kind of data listed above.
Rolling back
- Before the re-encryption: put the environment variables back as they were and restart. What was saved in between (credentials, AI keys, app variables, new tokens and sessions) was written under the new configuration and cannot be read under the old one; it is readable again once you switch forward.
- After the re-encryption: do not roll back the environment variables or move to an older image. The rewritten data only opens with the current key. If you really have to go back, restore the database and the environment variables from the backup taken before the change.
FAQ
How do I confirm a variable follows SECRET_KEY after I delete it?
How do I confirm a variable follows SECRET_KEY after I delete it?
Look at the Server secrets tab again after the restart. The count of dedicated variables at the top has dropped. If the variable has an
_OLD set, its row stays until that is removed, and Value from now reads Falls back to SECRET_KEY or Derived from SECRET_KEY; otherwise the row is gone.What if the dry-run shows undecryptable rows?
What if the dry-run shows undecryptable rows?
Neither the current key nor any configured
_OLD opens those rows, so the re-encryption skips them and leaves them as they are. Usually an old value is missing: use the table name and row IDs the page gives, put the value those rows were encrypted with into the matching _OLD variable, restart, and run the dry-run again.I want to keep a dedicated variable and only change its value. How?
I want to keep a dedicated variable and only change its value. How?
Put the new value in the variable and move the current one to the same name with
_OLD appended. Change a key and its iv together and set both _OLD variables: the server refuses to start with only one. Generate these 16-character values with openssl rand -hex 8 and everything else with openssl rand -base64 32. If a value has leaked, do not put it in _OLD; replace it outright.What if the instance does not have the Key rotation page?
What if the instance does not have the Key rotation page?
The community edition and plans below Business do not have it. A new deployment is not affected. When an existing instance changes a secret, keep the old value in the matching
_OLD variable and the existing data stays readable. Without the re-encryption, stored data stays under the old value until it is saved again, so leave the _OLD variables for stored data in place. Apps built with App Builder are the one thing to do by hand: after the JWT signing secret changes with no BACKEND_JWT_SECRET_OLD, rotate each app’s credentials in the app itself, as described under Teable Access Token.
