Issues with rotating pgsodium and Vault root encryption keys
Last edited: 9/11/2026
If you can still decrypt existing Vault secrets after an attempted key rotation, the project is still using the legacy root key. The Supabase Management API /pgsodium endpoint is the correct mechanism for key rotation, but it requires a specific format to trigger the update across the database instance.
How to rotate the root key#
- Generate a new 64-character hexadecimal string to serve as the root key.
- Issue a PUT request to the project's
/pgsodiumManagement API endpoint using a valid Personal Access Token. - Pass the new 64-character hex key in the request body.
- Verify rotation by attempting to decrypt data encrypted with the previous key. After rotation, you can no longer decrypt legacy data.
- Manually re-encrypt or re-store your Vault secrets using the new key configuration.