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

# Save a browser profile

> Export the whole browser profile and re-import it into a later runtime

Export the entire browser profile — cookies, storage, cache, extension state, everything in Chromium's user directory — to a tar archive, and import it into a later runtime to resume exactly where the session left off. This is the durable-login primitive when a [storage state](https://docs.gravixlayer.ai/documentation/agentruntime/browser-use/contexts.md) is not enough (IndexedDB, service workers, extension data).

CLI and cURL examples use `$RT` and browser `b1` ([Sessions](https://docs.gravixlayer.ai/documentation/agentruntime/browser-use/browser.md)).

## Export, then import

`profile_export` quiesces the browser and writes a tar of the profile to a
guest path (`dest_path` under the workspace — download it with
`runtime.files`). `profile_import` takes that archive path, unpacks it, and
respawns the browser on the imported profile; existing tabs re-open.

```python Python theme={null}
from gravixlayer import GravixLayer

client = GravixLayer()  # reads GRAVIXLAYER_API_KEY
sandbox = client.runtime.create(template="browser-small")
bid = sandbox.browser.open(url="https://app.example.com/login")["browser_id"]

# …log in here…

r = sandbox.browser.profile_export(bid, dest_path="/workspace/profile.tar")
print(r["path"])

# Later — same or another runtime: upload the tar, then import
bid2 = sandbox.browser.open()["browser_id"]
sandbox.browser.profile_import(bid2, "/workspace/profile.tar")
sandbox.kill()
```

```typescript TypeScript theme={null}
import { GravixLayer } from 'gravixlayer';

const client = new GravixLayer();
const sandbox = await client.runtime.create({ template: 'browser-small' });
const bid = (await sandbox.browser.open({ url: 'https://app.example.com/login' })).browserId;

// …log in here…

const r = await sandbox.browser.profileExport(bid, { destPath: '/workspace/profile.tar' });
console.log(r.path);

// Later — same or another runtime: upload the tar, then import
const bid2 = (await sandbox.browser.open()).browserId;
await sandbox.browser.profileImport(bid2, '/workspace/profile.tar');
await sandbox.kill();
```

```bash CLI theme={null}
gravixlayer runtime browser profile-export "$RT" --browser b1 \
  --dest /workspace/profile.tar

gravixlayer runtime browser profile-import "$RT" --browser b1 \
  /workspace/profile.tar
```

```bash cURL theme={null}
API="https://api.gravixlayer.ai/v1"

curl -sS -X POST "$API/agents/runtime/$RT/browser/b1/profile/export" \
  -H "Authorization: Bearer $GRAVIXLAYER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"dest_path": "/workspace/profile.tar"}'

curl -sS -X POST "$API/agents/runtime/$RT/browser/b1/profile/import" \
  -H "Authorization: Bearer $GRAVIXLAYER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"archive_path": "/workspace/profile.tar"}'
```

> [!WARNING]
>
> An imported profile contains live credentials — cookies, tokens, saved sessions. Treat the archive like a secret: keep it in your own storage, and prefer [storage state](https://docs.gravixlayer.ai/documentation/agentruntime/browser-use/contexts.md) when cookies alone are enough.


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