Skip to main content
The admin page used here is available for self-hosted Business plan and above
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 follow SECRET_KEY.
Setting the other dedicated variables (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.
A later version will refuse to start while SECRET_KEY is unset or still its public default. If your instance runs that way, switch to your own SECRET_KEY before upgrading to that version.
Later versions will also remove some of the other dedicated variables, together with the code that reads them. No date is set. If you plan to upgrade, do it soon and finish this guide on a version that still reads them: an instance that jumps straight to a version without them can no longer read what was stored under them.

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 lists SECRET_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:
A value copied from documentation or an example file is as public as a built-in default, but the page cannot tell. The template on the Docker deployment page contains SECRET_KEY=replace_this_secret_key: if the instance still runs on that value, treat SECRET_KEY as public and follow Switch to your own SECRET_KEY.

Remove the dedicated variables

For each row whose Value from reads Own variable, other than SECRET_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 _OLD appended (for example BACKEND_AI_CONFIG_ENCRYPTION_SECRET_OLD), then delete the variable itself. _OLD only verifies or decrypts existing data; everything new uses SECRET_KEY. For a key and iv pair, set both _OLD variables 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).
Each _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:
  1. Stop the instance, edit the environment variables as described above, then start every replica.
  2. Open the Stored ciphertexts tab and click Dry-run. The Undecryptable column should be 0 everywhere. If it is not, an _OLD value is missing: add it before you continue.
  3. 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.
  4. 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.
  5. Spot-check sign-in, a personal access token call, AI features, third-party credentials in automations, and published apps.
  6. Remove each _OLD variable 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.
Never put a public or leaked value in BACKEND_JWT_SECRET_OLD or BACKEND_SESSION_SECRET_OLD. A value in _OLD is still accepted, so the instance would keep accepting tokens and sessions anyone can forge with it. Switch outright in that case and let users sign in again.

Switch to your own SECRET_KEY

When SECRET_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.
  1. Generate the new root secret:
  2. Prepare the _OLD variables. 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 with SECRET_KEY: The values “derived from the old SECRET_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 _OLD variables in the first three rows and BACKEND_DATA_DB_URL_ENCRYPTION_SECRET_OLD, you can set BACKEND_STORED_CREDENTIAL_ENCRYPTION_SECRET_OLD alone: defaultSecretKey if SECRET_KEY was never set, the old SECRET_KEY otherwise. That one variable reads all of that data.
  3. Stop the instance, set the new SECRET_KEY and the _OLD variables above, and make sure SANDBOX_JWT_SECRET is set (the backend and the sandbox service share one value). Then start every replica.
  4. 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 _OLD when its time comes. Without BACKEND_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.
For a routine change, where the old value is neither public nor leaked, run this next to keep users signed in:

After the switch

Once the new SECRET_KEY is in place:
  • Without BACKEND_JWT_SECRET_OLD and BACKEND_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 with SECRET_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.
If the page lists dedicated variables besides 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:
  1. Generate a value with openssl rand -base64 32.
  2. Stop the instance, set BACKEND_STORED_CREDENTIAL_ENCRYPTION_SECRET, then start every replica. Data stored under SECRET_KEY stays readable without any _OLD: SECRET_KEY keeps decrypting it.
  3. Run the dry-run and the re-encryption as in steps 2 and 3 of Remove the dedicated variables.
If you cannot stop every replica at once, first set 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

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.
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.
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.
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.
Last modified on November 27, 2026