You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
We're creating preview branches for development through a script on the command line. I am able to retrieve all the preview branch details, like the jwt secret, but I am not able to retrieve the anon key via the CLI. We need the anon key to spin up a development server
Describe the solution you'd like
Ideally I would like to use a command like supabase branches get-api-keys <branch_id> that returns the api keys that we can use to spin up a development server.
Describe alternatives you've considered
I tried using the jwt secret returned by supabase branches get <branch_id> to create an anon key, but I wasn't able to create a working anon key even though I followed the directions here and was able to create a similar anon key than the one that is exposed on the dashboard: https://stackoverflow.com/questions/74587078/any-way-to-generate-supabase-anon-key-and-jwt-secret-locally
Additional context
We need this to be automated and can't copy the anon key manually from the preview branch dashboard.
Reacted by Han Qiao, bradwithwoz, Jonny Browning, Alex Leonov, Onur Temizkan, Frederik Rajiv, Kevin Alex Nielsen, Michael Gartner, hinrikjosafat, Sawyer W and 6 more
I'm running in to this because I had hoped the Supabase GitHub integration would be smart enough to sync the public url and anon key to the Vercel deployment associated with the Supabase branch created for the GitHub pull request. I was looking for a way I could hack it together myself, but because we are unable to programatically retrieve the public url and anon key, it appears to be impossible to automate.
edit:
after hacking at it for a while, I have Supabase branches and Vercel deployments playing nice together and syncing the appropriate secrets (via the official integrations), but I'll have to examine what exactly I did to get it working. If anyone is interested feel free to ask and I'll see if I can wrangle up some instructions.
Anybody figured this one out? We're not using Vercel so got to integrate somehow ...
Possibly terraform is an option, but having something simpler would be great.
This is a problem to migrate to the new version of keys as we're not supposed to use the SUPABASE_SERVICE_ROLE_KEY anymore.
Did someone managed to get it in clear?
Thanks in advance!
supabase branches get <branch> -o json currently returns the publishable key, but the new secret key is masked. Using projects api-keys --reveal with the preview branch's own project ref returns the full key.
In the JSON output, the default secret key is the entry with:
{
"type": "secret",
"name": "default"
}
and its api_key field contains the full sb_secret_... value.
The same command also returns the publishable keys, so you can select whichever key you need from the output.
The main thing to watch out for is that --project-ref needs to be the preview branch's own project ref, not the parent project ref.
While anon and legacy service_role keys are returned, modern sb_secret_... keys (SUPABASE_DEFAULT_KEY) come back masked as ****** because supabase branches get does not pass reveal: true to the API. supabase projects api-keys already provides a --reveal flag for this purpose.
Proposal:
Add --reveal boolean flag to supabase branches get, matching projects api-keys --reveal.
Keep default output masked (reveal: false).
When --reveal is provided, pass reveal=true to GET /v1/projects/{ref}/api-keys so secret keys are exposed in full for machine formats (-o json, -o env, -o toml, -o yaml).
A 403 on restricted tokens fails with BranchesApiKeysUnexpectedStatusError (no silent fallback to masked values).
Could you please add the open-for-contribution label to this issue? I have the changes and integration tests prepared and will open a PR once labeled.
While anon and legacy service_role keys are returned, modern sb_secret_... keys (SUPABASE_DEFAULT_KEY) come back masked as ****** because supabase branches get does not pass reveal: true to the API. supabase projects api-keys already provides a --reveal flag for this purpose.
Proposal:
Add --reveal boolean flag to supabase branches get, matching projects api-keys --reveal.
Keep default output masked (reveal: false).
When --reveal is provided, pass reveal=true to GET /v1/projects/{ref}/api-keys so secret keys are exposed in full for machine formats (-o json, -o env, -o toml, -o yaml).
A 403 on restricted tokens fails with BranchesApiKeysUnexpectedStatusError (no silent fallback to masked values).
Could you please add the open-for-contribution label to this issue? I have the changes and integration tests prepared and will reopen the PR once labeled.
Activity
cwharris commentedon Nov 25, 2025
I'm running in to this because I had hoped the Supabase GitHub integration would be smart enough to sync the public url and anon key to the Vercel deployment associated with the Supabase branch created for the GitHub pull request. I was looking for a way I could hack it together myself, but because we are unable to programatically retrieve the public url and anon key, it appears to be impossible to automate.
edit:
after hacking at it for a while, I have Supabase branches and Vercel deployments playing nice together and syncing the appropriate secrets (via the official integrations), but I'll have to examine what exactly I did to get it working. If anyone is interested feel free to ask and I'll see if I can wrangle up some instructions.
Siilwyn commentedon Feb 25, 2026
Anybody figured this one out? We're not using Vercel so got to integrate somehow ...
Possibly terraform is an option, but having something simpler would be great.
flyinglimao commentedon Jul 23, 2026
supabase branches get <branch-id> -o jsonoutputs the credentials in JSON format:{
"POSTGRES_URL": "...",
"POSTGRES_URL_NON_POOLING": "...",
"SUPABASE_ANON_KEY": "...",
"SUPABASE_DEFAULT_KEY": "...",
"SUPABASE_JWT_SECRET": "...",
"SUPABASE_PUBLISHABLE_KEY": "...",
"SUPABASE_SERVICE_ROLE_KEY": "...",
"SUPABASE_URL": "..."
}
We've been using this in our workflow for months without any issues. Hope this helps!
celine-m-s commentedon Sep 3, 2026
Hey there! I wanted to do the same thing to retrieve the default key but it's obfuscated.
This is a problem to migrate to the new version of keys as we're not supposed to use the
SUPABASE_SERVICE_ROLE_KEYanymore.Did someone managed to get it in clear?
Thanks in advance!
flyinglimao commentedon Sep 3, 2026
Hi @celine-m-s
We ran into the same issue as well. Our current workaround is to retrieve the keys separately with:
supabase branches get <branch> -o jsoncurrently returns the publishable key, but the new secret key is masked. Usingprojects api-keys --revealwith the preview branch's own project ref returns the full key.In the JSON output, the default secret key is the entry with:
{ "type": "secret", "name": "default" }and its
api_keyfield contains the fullsb_secret_...value.The same command also returns the publishable keys, so you can select whichever key you need from the output.
The main thing to watch out for is that
--project-refneeds to be the preview branch's own project ref, not the parent project ref.Review apps: use the legacy SUPABASE_SERVICE_ROLE_KEY instead of the …
Review apps: retrieve Supabase new service role key
celine-m-s commentedon Sep 9, 2026
Thank you very much @flyinglimao !!
Review apps: retrieve Supabase new service role key
feat(evals): add deploy-database-005-preview-branch-lifecycle CLI eva…
sayandeep0212 commentedon Nov 25, 2026
Hi maintainers,
I'd like to take this on.
While anon and legacy service_role keys are returned, modern
sb_secret_...keys (SUPABASE_DEFAULT_KEY) come back masked as******becausesupabase branches getdoes not passreveal: trueto the API.supabase projects api-keysalready provides a--revealflag for this purpose.Proposal:
--revealboolean flag tosupabase branches get, matchingprojects api-keys --reveal.reveal: false).--revealis provided, passreveal=truetoGET /v1/projects/{ref}/api-keysso secret keys are exposed in full for machine formats (-o json,-o env,-o toml,-o yaml).BranchesApiKeysUnexpectedStatusError(no silent fallback to masked values).Could you please add the
open-for-contributionlabel to this issue? I have the changes and integration tests prepared and will open a PR once labeled.sayandeep0212 commentedon Nov 25, 2026
Hi maintainers,
I'd like to take this on.
While anon and legacy service_role keys are returned, modern
sb_secret_...keys (SUPABASE_DEFAULT_KEY) come back masked as******becausesupabase branches getdoes not passreveal: trueto the API.supabase projects api-keysalready provides a--revealflag for this purpose.Proposal:
--revealboolean flag tosupabase branches get, matchingprojects api-keys --reveal.reveal: false).--revealis provided, passreveal=truetoGET /v1/projects/{ref}/api-keysso secret keys are exposed in full for machine formats (-o json,-o env,-o toml,-o yaml).BranchesApiKeysUnexpectedStatusError(no silent fallback to masked values).Could you please add the
open-for-contributionlabel to this issue? I have the changes and integration tests prepared and will reopen the PR once labeled.