Add an HTTP secret
Let your agent call any HTTP API with a real key that it never sees. Your agent needs the OpenAI API, a Stripe test key, or your internal service’s token. You save the key once as an HTTP secret. The agent gets a placeholder in an environment variable and uses it like the real key. On the way out, Marshal swaps the placeholder for the real value, and only on requests to the hosts you list.
Before you start
- Any member can create an HTTP secret.
- You have the key and you know which hosts it is for, for example
https://api.openai.com.
Create the secret
- In the left rail, open Connections.
- On the HTTP Secret card, click Connect. If you already have one, the button says Add another.
- In New HTTP secret, enter a Name, for example “OpenAI API”.
- Enter the Env var, for example
OPENAI_API_KEY. Use capital letters, digits, and_, starting with a letter. You cannot change it after you create the secret. - Under Secret value, paste the key. If you already saved the value as a credential, choose Saved credential instead of Paste value.
- Under Hosts, enter at least one URL pattern the key is for, for example
https://api.openai.com/**. Click + host to add more. Each pattern starts withhttps://orhttp://, then a host. In the host,*stays within one label and does not cross dots, sohttps://*.example.commatchesapi.example.combut nota.b.example.com.**crosses dots, sohttps://**.example.commatches both. A host with no path, likehttps://example.com, matches only the site root. Add/**to match every path, as inhttps://example.com/**. In the path,*matches one segment and**matches the rest. A port, when you give one, is a number. Marshal checks every pattern when you save, and the message names the pattern to fix, for examplehost "OPENAI_API_KEY": missing scheme. - If an Owner field is shown, choose who owns the secret: Just me, a team, or Everyone in the organization. The owner decides whose spaces can use it.
- Optional: open Advanced to set a Placeholder prefix and Total length. Use them when a tool checks the shape of the key, for example that it starts with
sk-. - Click Create.
Marshal never blocks a save over how wide a pattern is, and it tells you when a pattern matches less than it may look like. After you save, and on every secret in your list, you see a hint under the secret when:
- A host has no path, or only
/: “This host matches only the site root. Usehttps://<host>/**to allow every path.” - A host label is exactly
*: “*matches within one label, not across dots. Use**to match deeper subdomains.”
The same pattern can show both hints. Click Edit, adjust the pattern, and the hint is gone.
Use it in a space
-
Open a running space and open the right panel (Toggle inspector panel in the toolbar).
-
Open the Secrets tab.
-
On your secret, click Add. It changes to Active. The space does not restart. A space can hold one secret per env var. If another secret with the same env var is already Active, Marshal declines the Add and names both secrets. Remove the active one first, then add the other.
-
In a terminal that was already open, reload the environment:
source /run/agent-env
New terminals see the variable at once. The placeholder is also written to ~/workspace/.env.marshal, for tools that read a .env file. To take the secret out of the space, hover over Active and click Remove.
A space keeps the same placeholder for each secret every time it stops and resumes. A tool you registered with the placeholder, for example an MCP server configured with a header, or a CLI that saved the placeholder in its own config, keeps working after a resume with no changes. A secret you add later gets its own placeholder.
Your administrator can set a stack to add HTTP secrets to new spaces on their own.
Change the value
When a key rotates, replace the value and keep everything else. The secret keeps its name, env var, hosts and placeholder, so nothing in your spaces or stacks needs to change.
- In the left rail, open Connections.
- Under HTTP Secrets, find the secret and click Replace value. You can also click Edit and then Replace value in the form.
- Paste the new value under New value.
- Check the summary. It says how many running spaces use the secret. If other secrets use the same value, it lists them too, because they change with it.
- Click Replace value.
Running spaces get the new value at once, with no restart. The agent keeps the same placeholder, so it never notices the change.
The secret’s owner, a lead of the team that owns it, or an org admin can replace the value. For a secret that comes from a vault, change the value in the vault and click Resync on the connection instead. See Connect a vault.
How the swap works
- The agent sees only the placeholder. The real value stays outside its reach.
- Marshal swaps the placeholder in the URL, the query string, the headers, and JSON or form bodies.
- The swap happens only for the hosts you listed. A request that carries the placeholder to any other host is blocked.
What comes back
The swap works in both directions. When a host you listed echoes your key in a reply, for example an API error that quotes the rejected key, Marshal puts the placeholder back before the agent reads it. On those hosts, the real value is replaced in the headers of every reply (including HEAD and bodiless replies), and in JSON and text bodies, streamed replies, and gzip or deflate replies. The plain value is covered, and so are its JSON-escaped, URL-encoded and base64 forms.
- A reply that Marshal changes is delivered in chunks and uncompressed, and a strong
ETagbecomes weak (W/"..."). Replies from other hosts are not touched. - Credentials Marshal adds for package registries, and for tools connected through MCP, are replaced with
[REDACTED:http-secret]if a reply echoes them. - Some replies pass through as they are:
- Large downloads of files (images, archives, container layers) and partial (range) replies.
- Replies compressed with brotli or zstd, and WebSocket traffic. Marshal records the partial and compressed cases in the audit log.
- Replies from a host that has no secret of yours. A value you stored through one host and read back from another is not covered.
- Echoes the host has changed, for example a hashed, truncated or re-cased value.
- Values shorter than 8 bytes. Use a longer key where you can.
- The audit log shows one
http_secret.response_redactedevent for each reply that held a value: the host, the secret names and how many values were replaced, never the value.
What you should see
- The secret on the Connections page under HTTP Secrets.
- In the space’s Secrets tab, the secret marked Active, and the note “Placeholder env vars are written to: ~/workspace/.env.marshal”.
- In the space,
echo $OPENAI_API_KEYprints the placeholder, not your key. A call to the API with it works.
Next
Ask your agent to use the API, for example “Call the OpenAI API with $OPENAI_API_KEY and list the models.”