Store a secret
API keys, signing secrets, and database URLs belong in encrypted platform storage. You keep an opaque ssec_… token in commands and config. The plaintext never goes in git, in a page, or in chat.
Every secret is bound to a web origin (scheme + host, for example https://api.stripe.com). HTTP substitution decrypts the token only when the request URL matches that origin. The same token sent to a different host fails closed and does not leak the value.
To get a key from a person, always use secret open. It prints a sails.app link where they paste the value. The agent only ever sees the ssec_… token. Do not send people to /admin or Settings to create a secret, and do not ask them to paste a key in chat.
upload / download are the wrong tool. Those links write ordinary workspace files.
Only repository owners can secret open / secret set. Members can secret list tokens they are allowed to see.
Done looks like
secret poll prints a token such as ssec_groq. A later curl or MCP header that contains that exact token succeeds only against the origin you set. secret list shows the token and its allowed origin.
Worked example: one key with a help note
Job: get a Groq API key from the owner without seeing it.
secret open --origin https://api.groq.com \
--note 'Get it from console.groq.com/keys' \
--help-url https://console.groq.com/keys \
groq
Output (intake ids will differ):
Open this URL in your browser to submit the secret (owner only).
Do not paste the value in chat.
https://sails.app/admin/secrets/intake/fBR8Po6NL5TdBImCE8AUaBbcN58D3Hgf
Label: groq
Allowed origin: https://api.groq.com
Token name: ssec_groq
Note: Get it from console.groq.com/keys
Help: https://console.groq.com/keys
Intake session: fBR8Po6NL5TdBImCE8AUaBbcN58D3Hgf
After submitting in the browser, run:
secret poll fBR8Po6NL5TdBImCE8AUaBbcN58D3Hgf
The label becomes the token name, so you know the token (ssec_groq) before anyone submits. --note and --help-url show under the field on the intake page, so the person knows where to find the key.
- Give the person the printed URL. They sign in as a repository owner. A different user is rejected. The link is single-use and expires.
- They paste the key and submit.
- Back in the shell:
secret poll fBR8Po6NL5TdBImCE8AUaBbcN58D3Hgf
# Secret tokens:
# groq ssec_groq
Use the token. The exact ssec_… string is replaced at call time when the destination matches the origin:
curl -s -H "Authorization: Bearer ssec_groq" https://api.groq.com/openai/v1/models
# the same token sent to any other host fails closed
Store ssec_groq in MCP headers, webhook --secret, or a .env line, not the raw key.
Do not pass --wait from bash_exec. Output is buffered until the command ends, so you never see the URL. Print the link, then secret poll INTAKE_ID.
Several keys in one link
Use --field NAME:ORIGIN:LABEL once per secret. One page collects all of them, and secret poll prints each token by name.
Quote each --field when the label has spaces. Unquoted, the shell splits the label and secret open exits with a usage error.
secret open \
--field 'groq:https://api.groq.com:Groq API key' \
--note 'Get it from console.groq.com/keys' \
--help-url https://console.groq.com/keys \
--field 'stripe:https://api.stripe.com:Stripe secret key'
Output (intake ids will differ):
Open this URL in your browser to submit the secret (owner only).
Do not paste the value in chat.
https://sails.app/admin/secrets/intake/nq1hHvD1Fo74WTGCEdAwz4QAU8HBWeSA
Fields:
groq https://api.groq.com Groq API key
note: Get it from console.groq.com/keys
help: https://console.groq.com/keys
stripe https://api.stripe.com Stripe secret key
Intake session: nq1hHvD1Fo74WTGCEdAwz4QAU8HBWeSA
After submitting in the browser, run:
secret poll nq1hHvD1Fo74WTGCEdAwz4QAU8HBWeSA
--note and --help-url attach to the --field right before them. Put them after the field they describe.
secret poll nq1hHvD1Fo74WTGCEdAwz4QAU8HBWeSA
# groq ssec_groq
# stripe ssec_stripe
Scripts: a value you already have
secret set is only for automation that already holds the value, for example a signing secret an API just returned. Never use it to ask a person for a key.
secret set --origin https://api.example.com --as example "$ALREADY_HAVE_THIS"
# prints: ssec_example
# or from stdin
printf '%s' "$VALUE" | secret set --origin https://api.example.com --as example --stdin
Without --as, the token gets a random id. Names are case-sensitive and use letters, digits, ., _, and -.
Who can use the token
Default visibility is owner (the creator only).
secret list
secret chmod ssec_groq --visibility members
secret chmod ssec_groq --visibility group --group writers
secret unset ssec_groq
secret list prints one line per token with its origin= and visibility=. A token with no origin shows that HTTP substitution is blocked for it.
| Visibility | Who can use it |
|---|---|
owner (default) | Creator only |
group | Creator + --group NAME |
members | Any repository member |
secret chmod / secret unset: creator or repo owner.
To rotate the plaintext without changing the token (so MCP headers keep working), the owner can use Set value on that token under Admin, repo Settings, Secrets. That page is a human inventory, not where agents send people to create secrets.
Origin binding
Create always takes --origin (or an origin inside each --field). Use scheme + host, plus a non-default port if any. No path, query, or wildcards: --origin https://api.groq.com/v1 is rejected.
Existing tokens that have no origin cannot be used in HTTP until you set one:
secret chmod ssec_… --origin https://api.example.com
HTTP substitution fails closed when the token is unknown or inaccessible, the destination origin does not match, or the secret has no origin. The literal ssec_… string is never forwarded to the upstream host. Errors never include the secret value.
SSH identity keys (ssh -i ssec_…) and foreign Postgres DSNs (createdb --url ssec_…) decrypt without an HTTP origin check (they never go over curl). The origin still blocks using that same token in HTTP to another host.
Where substitution happens
Exact ssec_… matches are replaced when the platform makes the outbound call:
curlURL (whole-token only),-Hvalues (includingBearer ssec_NAME), and-d/--databodies- MCP server headers / auth and tool
--jsonarguments (destination = MCP server URL) gitHTTPS--token/ URL userinfo (destination = remote URL)- Webhook
--secretand similar config - Inbox push hooks (
inbox hook set --url/--auth), decrypted when posting to the hook URL origin - SSH identity:
ssh user@host -i ssec_… - Foreign Postgres:
createdb app.db --url ssec_…
Handlers also auto-source a folder .env of KEY=ssec_… (or plain values). Tokens stay unsubstituted until an outbound call. Published handlers read the served mount's .env; workspace scripts use the nearest .env walking up to $HOME. repo env secret refs stay as ssec_… in the process environment so curl -H "Authorization: $KEY" still goes through origin checks.
OAuth MCP (mcp connect) and integration connect store their own tokens. You do not need secret open for those.
Common uses
| Task | Example |
|---|---|
| OpenAI-compatible API | secret open --origin https://api.groq.com groq then curl -H "Authorization: Bearer ssec_groq" … |
| MCP server with API key | secret open --origin https://mcp.exa.ai exa then mcp add exa --url … --header "x-api-key=ssec_exa" |
| Stripe webhook signing secret | secret open --origin https://api.stripe.com stripe-whsec then webhook add … --secret ssec_stripe-whsec |
| Outbound hook | secret open --origin https://hooks.example.com hook-token then hook add NAME --url … --secret ssec_hook-token |
| Foreign Postgres DSN | secret open --origin https://db.example.com app-db then createdb app.db --url ssec_app-db |
| GitHub HTTPS PAT | secret open --origin https://github.com github-pat then git clone … --token ssec_github-pat |
Flags
secret help
| Command | Who | What it does |
|---|---|---|
secret open --origin URL [--note TEXT] [--help-url URL] [LABEL] | owner | Print an intake URL right away; token is ssec_LABEL |
secret open --field NAME:ORIGIN:LABEL … | owner | One intake page for several secrets |
secret poll INTAKE_ID | owner | Wait for the browser submit; print each ssec_… by name |
secret open … --wait | owner | Block until submitted. Avoid in bash_exec |
secret set --origin URL [--as NAME] VALUE | owner | Store a value you already have |
secret set --origin URL [--as NAME] --stdin | owner | Same, read from stdin |
secret list | member | Tokens you can see, with origin and visibility |
secret chmod ssec_… --origin URL | creator or owner | Set or replace the allowed origin |
secret chmod ssec_… --visibility … [--group NAME] | creator or owner | Change who can use it |
secret unset ssec_… | creator or owner | Revoke |
--timeout SECS applies to secret open / secret poll. Only secret help prints help; secret open --help is an unknown flag.
Failure modes
| What you see | What it means | What to do |
|---|---|---|
secret open requires --origin URL or --field NAME:ORIGIN:LABEL | No origin given | Add --origin https://api.example.com |
origin must not include a path | You passed https://host/v1 | Use scheme + host only |
Usage error with several --field flags | A label with spaces was not quoted | Quote each --field 'name:origin:Label words' |
intake session not found | Wrong or expired intake id | Copy the id from secret open, or run it again |
timed out after Ns waiting for secret submission | Nobody submitted yet | Wait and secret poll again, or secret open a fresh link |
| Intake page rejects the person | Intake needs a repository owner | Sign in as an owner on the printed URL |
secret open denied | Owner-only | An owner runs it, or elevate that goal |
| curl / MCP fails closed after create | Destination host is not the secret origin | Match --origin to the real API host, or secret chmod ssec_… --origin … |
secret list shows no origin | Created before origin binding | secret chmod ssec_… --origin https://api.example.com |
You cannot use that ssec_… | Visibility or missing access | secret list; secret chmod if you should share it |
You committed sk- / whsec_ / a DSN | Wrong store | Rotate the leaked value, collect the new one with secret open, put ssec_… in config |
You uploaded a .env | Workspace file, not a secret | Delete the file, then secret open --origin … |
See Connect an MCP server for API-key MCP servers, Send a file when the job is a CSV or zip, and SSH to a host when the secret is an SSH identity key.