> ## Documentation Index
> Fetch the complete documentation index at: https://docs.formal.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Keep Credentials Away from Agents

> Inject API keys on a Connector and seal tokens on the device so agents and laptops never hold a usable secret

## Overview

An agent that can read a secret can leak it.
Formal keeps the real credential out of the agent's environment and adds it to the request in the proxy.

## How Formal helps

| Technique | How it works | Use it for |
| - | - | - |
| Credential injection | The [Connector](https://docs.formal.ai/docs/guides/core-concepts/connectors/introduction.md) stores the key as a [native user](https://docs.formal.ai/docs/guides/core-concepts/resources/native-users.md) and adds it to each request. The client sends no key. | API keys for services such as Stripe |
| Token sealing | The Endpoint or Connector encrypts OAuth tokens and session cookies in transit. The device stores a sealed value that does not work directly against the provider. | Tokens that the user obtains by signing in |
| Keyless machine login | Workloads sign in to Formal with an [OIDC](https://docs.formal.ai/docs/guides/integrations/oidc.md) token instead of a long-lived API key. | CI jobs and agent sandboxes |

## Roll it out

**1. Deploy a Connector**

See [Deploy a Connector](https://docs.formal.ai/docs/guides/core-concepts/connectors/deployment.md). The Connector holds the credential.

**2. Create the resource and native user**

Add an [HTTP resource](https://docs.formal.ai/docs/guides/core-concepts/resources/http.md) and a [native user](https://docs.formal.ai/docs/guides/core-concepts/resources/native-users.md) with the API key.

**3. Route traffic to the Connector**

Install the [Endpoint](https://docs.formal.ai/docs/guides/client-apps/desktop-app.md) and write a [network rule](https://docs.formal.ai/docs/guides/network-rules.md) with `forward_to_connector`.

**4. Remove the key from the client**

Delete the key from laptops and sandbox secrets. Confirm that calls still succeed, then check [Logs](https://docs.formal.ai/docs/guides/observability/logs.md).

## Guides

> [card] [Keep Stripe API keys off laptops](https://docs.formal.ai/docs/guides/example-use-cases/keep-stripe-api-keys-off-laptops.md)
>
> Inject the key into Stripe API calls

> [card] [Keep API keys out of cloud agent sandboxes](https://docs.formal.ai/docs/guides/example-use-cases/cloud-agent-credential-forwarding.md)
>
> Cursor and Devin cloud agents

> [card] [Daytona sandboxes](https://docs.formal.ai/docs/guides/example-use-cases/sandbox-credential-injection/daytona.md)
>
> Inject keys outside a Daytona sandbox

> [card] [E2B sandboxes](https://docs.formal.ai/docs/guides/example-use-cases/sandbox-credential-injection/e2b.md)
>
> Inject keys outside an E2B sandbox

> [card] [Modal sandboxes](https://docs.formal.ai/docs/guides/example-use-cases/sandbox-credential-injection/modal.md)
>
> Run the Endpoint in a Modal Sidecar with Modal OIDC

> [card] [Seal Claude Code OAuth tokens](https://docs.formal.ai/docs/guides/example-use-cases/seal-claude-code-oauth-tokens.md)
>
> Keep tokens encrypted on the device

> [card] [Seal Claude Desktop session cookies](https://docs.formal.ai/docs/guides/example-use-cases/seal-claude-desktop-session-cookies.md)
>
> Replace cookies with sealed values

> [card] [Encrypt MCP OAuth tokens](https://docs.formal.ai/docs/guides/example-use-cases/encrypt-mcp-oauth-tokens.md)
>
> Encrypt Notion MCP OAuth tokens

## Next Steps

> [card] [Token Encryption](https://docs.formal.ai/docs/guides/core-concepts/connectors/token_encryption.md)
>
> Encrypt HTTP tokens with your own KMS key

> [card] [OAuth and Linked Accounts](https://docs.formal.ai/docs/guides/core-concepts/resources/oauth.md)
>
> Send each user's own upstream account


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.