These guides are primarily for agent readers. They explain how agents use Sails. If you are a person, start at sails.app or Add Sails.

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.

  1. 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.
  2. They paste the key and submit.
  3. 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.

VisibilityWho can use it
owner (default)Creator only
groupCreator + --group NAME
membersAny 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:

  • curl URL (whole-token only), -H values (including Bearer ssec_NAME), and -d / --data bodies
  • MCP server headers / auth and tool --json arguments (destination = MCP server URL)
  • git HTTPS --token / URL userinfo (destination = remote URL)
  • Webhook --secret and 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

TaskExample
OpenAI-compatible APIsecret open --origin https://api.groq.com groq then curl -H "Authorization: Bearer ssec_groq" …
MCP server with API keysecret open --origin https://mcp.exa.ai exa then mcp add exa --url … --header "x-api-key=ssec_exa"
Stripe webhook signing secretsecret open --origin https://api.stripe.com stripe-whsec then webhook add … --secret ssec_stripe-whsec
Outbound hooksecret open --origin https://hooks.example.com hook-token then hook add NAME --url … --secret ssec_hook-token
Foreign Postgres DSNsecret open --origin https://db.example.com app-db then createdb app.db --url ssec_app-db
GitHub HTTPS PATsecret open --origin https://github.com github-pat then git clone … --token ssec_github-pat

Flags

secret help
CommandWhoWhat it does
secret open --origin URL [--note TEXT] [--help-url URL] [LABEL]ownerPrint an intake URL right away; token is ssec_LABEL
secret open --field NAME:ORIGIN:LABEL …ownerOne intake page for several secrets
secret poll INTAKE_IDownerWait for the browser submit; print each ssec_… by name
secret open … --waitownerBlock until submitted. Avoid in bash_exec
secret set --origin URL [--as NAME] VALUEownerStore a value you already have
secret set --origin URL [--as NAME] --stdinownerSame, read from stdin
secret listmemberTokens you can see, with origin and visibility
secret chmod ssec_… --origin URLcreator or ownerSet or replace the allowed origin
secret chmod ssec_… --visibility … [--group NAME]creator or ownerChange who can use it
secret unset ssec_…creator or ownerRevoke

--timeout SECS applies to secret open / secret poll. Only secret help prints help; secret open --help is an unknown flag.

Failure modes

What you seeWhat it meansWhat to do
secret open requires --origin URL or --field NAME:ORIGIN:LABELNo origin givenAdd --origin https://api.example.com
origin must not include a pathYou passed https://host/v1Use scheme + host only
Usage error with several --field flagsA label with spaces was not quotedQuote each --field 'name:origin:Label words'
intake session not foundWrong or expired intake idCopy the id from secret open, or run it again
timed out after Ns waiting for secret submissionNobody submitted yetWait and secret poll again, or secret open a fresh link
Intake page rejects the personIntake needs a repository ownerSign in as an owner on the printed URL
secret open deniedOwner-onlyAn owner runs it, or elevate that goal
curl / MCP fails closed after createDestination host is not the secret originMatch --origin to the real API host, or secret chmod ssec_… --origin …
secret list shows no originCreated before origin bindingsecret chmod ssec_… --origin https://api.example.com
You cannot use that ssec_…Visibility or missing accesssecret list; secret chmod if you should share it
You committed sk- / whsec_ / a DSNWrong storeRotate the leaked value, collect the new one with secret open, put ssec_… in config
You uploaded a .envWorkspace file, not a secretDelete 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.