---
title: "E2B"
description: "Let code in E2B sandboxes call Limrun with the sandbox's identity instead of an API key."
canonical_url: "https://docs.limrun.com/docs/access/workload-identity-federation/e2b"
markdown_url: "https://docs.limrun.com/docs/access/workload-identity-federation/e2b.md"
last_updated: "2026-11-26"
x_farming_labs_generated_preamble: true
---

# E2B
URL: /docs/access/workload-identity-federation/e2b
LLM index: /llms.txt
Description: Let code in E2B sandboxes call Limrun with the sandbox's identity instead of an API key.

# Authenticate E2B sandboxes with workload identity federation

E2B gives each sandbox a workload identity JWT but never shows it to code inside the sandbox. Its egress proxy adds the JWT to outbound requests you configure. You set up Limrun to trust E2B's tokens, then create sandboxes whose proxy hands the token to Limrun's token service, so no Limrun API key enters the sandbox.

## Before you start

You need:

- The `admin` role in your Limrun organization.
- Your E2B project ID. Every E2B token's subject has the form `spiffe://id.e2b.dev/<project-id>/<sandbox-id>/<execution-id>`, and the `project_id` claim carries the same ID.
- A [CLI or SDK version](/docs/access/workload-identity-federation#configure-your-workload) with workload identity support in the sandbox.

## Create the provider

E2B signs tokens for all of its customers, so the provider condition must check that a token belongs to your project.

1. Open [console.limrun.com](https://console.limrun.com), go to **Settings**, then **Workload identity federation**, and click the **+** button next to **Identity providers**.
2. In **Issuer**, choose **E2B**. The preset fills in the issuer `https://id.e2b.dev` and its signing keys at `https://id.e2b.dev/.well-known/jwks.json`.
3. Keep **Token audience** as `limrun`. The sandbox requests its token with this audience.
4. In **Provider condition (CEL)**, replace `PROJECT_ID` with your project ID:

   ```text
   assertion.sub.startsWith('spiffe://id.e2b.dev/PROJECT_ID/')
   ```

5. Click **Create provider**. Limrun fetches E2B's signing keys before it saves the provider.

## Create a binding

1. In the provider's card, click the **+** button next to **Bindings**.
2. Enter a name and a **Claim condition (CEL)**. `true` admits every sandbox in your project. E2B's discovery document also lists `sandbox_id`, `execution_id`, and `template_id` claims. Decode a token from one of your sandboxes to see their values before you narrow the condition with them.
3. Enter the permissions the sandboxes need, one per line, such as `xcode:*:all`.
4. Click **Create binding**, expand **Setup**, and copy the binding ID.

## Create a sandbox that sends its token to Limrun

When you create the sandbox, define a workload token with the audience `limrun` and a network rule that adds it to requests for `sts.limrun.com` in the `X-Limrun-Subject-Token` header:

<CodeGroup labels={["TypeScript", "Python"]}>
```ts
import { Sandbox, Secret } from 'e2b';

const sandbox = await Sandbox.create({
  iam: {
    tokens: { limrun: Secret.iamToken({ audience: 'limrun', tokenType: 'JWT-SVID' }) },
  },
  network: {
    allowOut: ({ rules }) => [...rules.keys()],
    rules: {
      'sts.limrun.com': [
        { transform: ({ iam }) => ({ headers: { 'X-Limrun-Subject-Token': iam.tokens.limrun } }) },
      ],
    },
  },
});
```

```python
from e2b import Sandbox, Secret

sandbox = Sandbox.create(
    iam={
        "tokens": {"limrun": Secret.iam_token(audience="limrun", token_type="JWT-SVID")},
    },
    network={
        "allow_out": lambda ctx: list(ctx.rules.keys()),
        "rules": {
            "sts.limrun.com": [
                {"transform": lambda ctx: {"headers": {"X-Limrun-Subject-Token": ctx.iam.tokens["limrun"]}}},
            ],
        },
    },
)
```
</CodeGroup>

`iam.tokens.limrun` is a placeholder. E2B's proxy replaces it with a signed token on the way out, so the value never passes through code in the sandbox. A rule's host must also be allowed in `allowOut`. If the sandbox restricts outbound traffic, also allow the Limrun API and the hosts your instances use.

## Run lim in the sandbox

Inside the sandbox, tell the CLI to rely on the injected token and point Node at the certificate authority E2B's proxy uses:

```bash
export LIMRUN_WORKLOAD_IDENTITY_TOKEN_INJECTED=true
export LIMRUN_WORKLOAD_IDENTITY_BINDING_ID=binding_REPLACE_WITH_BINDING_ID
export NODE_EXTRA_CA_CERTS=/etc/ssl/certs/ca-certificates.crt
lim whoami
```

`lim whoami` prints your organization and the binding's permissions. E2B's proxy decrypts traffic to `sts.limrun.com` with its own certificate authority, which E2B adds to `/etc/ssl/certs/ca-certificates.crt`. Node reads `NODE_EXTRA_CA_CERTS` only at startup, so set it before you start the CLI or your application. For the Python SDK, set `SSL_CERT_FILE` to the same file instead. The Go SDK uses the system bundle.

The same variables configure the SDKs, or pass `workloadTokenInjected`, `workload_token_injected`, or `TokenInjected` explicitly. Each `lim` command, and each SDK renewal, exchanges a token again, and E2B's proxy attaches a valid token each time.

## Troubleshoot

| Error | Cause |
| --- | --- |
| `invalid_request` | The exchange reached Limrun without a token. Check that the rule's host is exactly `sts.limrun.com` and that `allowOut` includes it. |
| `invalid_grant` | Limrun rejected the token or the binding. Check the binding ID, that the token's audience matches the provider's, and that the project ID in the provider condition is correct. |
| A certificate error | Node does not trust E2B's proxy. Set `NODE_EXTRA_CA_CERTS` before the process starts. |

See [E2B workload identity](https://docs.e2b.dev/iam/workload-identity) for the E2B side of the setup.

## Sitemap

See the full [sitemap](/sitemap.md) for all pages.
Docs-scoped sitemap: [/docs/sitemap.md](/docs/sitemap.md).
Well-known sitemap: [/.well-known/sitemap.md](/.well-known/sitemap.md).
