Guides

Secrets

Secrets are credentials Moil adds to outbound HTTPS requests at the egress proxy. Code in the box only ever sees a stand-in value, so a prompt-injected agent can use a key without being able to read it.

Store a secret

moil secrets set OPENAI_API_KEY --host api.openai.com
moil secrets set GITHUB_TOKEN --host api.github.com --host github.com
moil secrets ls
moil secrets rm GITHUB_TOKEN

set reads the value from your terminal (or stdin), never from a flag, so it doesn’t end up in your shell history. Each secret names the hosts it may be sent to. Values are encrypted at rest and never printed again — not by the CLI, the API or the dashboard.

Attach it to a box

moil create --name agent --secret OPENAI_API_KEY --secret GITHUB_TOKEN

Inside the box the variable holds a stand-in, not the key:

$ echo $OPENAI_API_KEY
moil-secret:OPENAI_API_KEY

$ curl https://api.openai.com/v1/models -H "Authorization: Bearer $OPENAI_API_KEY"
{ "object": "list", "data": [ … ] }

When a request to an allowed host carries the stand-in in a header, the proxy swaps in the real value on its way out. The same stand-in sent anywhere else goes out unchanged — and is useless to whoever receives it.

Scope

  • Secrets belong to a workspace. On Team, everyone in the workspace can attach them; on other plans they’re yours alone.
  • They are never written to the box’s disks, so they don’t travel with snapshots or forks. A box started from a snapshot gets the secrets you attach to it.
  • Only HTTPS headers are rewritten. A secret that has to sit in a file or a request body isn’t a fit; pass it with --env and treat that box as trusted.

Rotate a key at its provider, then run moil secrets set again with the new value. Boxes pick it up on their next request; nothing needs a restart.