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

# Save a login

> Save a site's cookies for use in later sessions on your account.

Sign in through a browser session, then save that site's cookies. The session's current page must be on the site you specify. Set `TILION_API_KEY`, `TILION_SESSION_ID`, and `LOGIN_DOMAIN` to your key, session ID, and the site's registrable domain, such as `example.com`.

```python Python theme={"dark"}
import os
import requests

sid = os.environ["TILION_SESSION_ID"]
response = requests.post(
    f"https://back.tilion.dev/v1/session/{sid}/save-auth",
    headers={"Authorization": f"Bearer {os.environ['TILION_API_KEY']}"},
    json={"domain": os.environ["LOGIN_DOMAIN"]}, timeout=30,
)
response.raise_for_status()
result = response.json()
if not result.get("ok"):
    raise RuntimeError(result)
print("Cookies saved:", result["cookies_saved"])
```

```javascript Node.js theme={"dark"}
const sid = process.env.TILION_SESSION_ID;
const response = await fetch(`https://back.tilion.dev/v1/session/${sid}/save-auth`, {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.TILION_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ domain: process.env.LOGIN_DOMAIN }),
  signal: AbortSignal.timeout(30_000),
});
if (!response.ok) throw new Error(await response.text());
const result = await response.json();
if (!result.ok) throw new Error(JSON.stringify(result));
console.log("Cookies saved:", result.cookies_saved);
```

```bash curl theme={"dark"}
# Requires jq.
curl --fail-with-body \
  "https://back.tilion.dev/v1/session/$TILION_SESSION_ID/save-auth" \
  -H "Authorization: Bearer $TILION_API_KEY" \
  -H "Content-Type: application/json" \
  -d "$(jq -n --arg domain "$LOGIN_DOMAIN" '{domain: $domain}')"
```

A successful response includes `ok: true`, `domain`, `cookies_saved`, and `entry_id`. Later sessions on the same account load the saved cookies for that site. Authentication still depends on the site accepting those cookies.

> [!NOTE]
>
> The API encrypts saved cookies at rest and does not return their values. `GET /v1/auth` lists connected domains and update times.

To remove a saved login, call `DELETE /v1/auth/{domain}`. Close the original session when finished. See [Saved logins](https://docs.tilion.dev/sessions/saved-logins.md) for importing cookies from another browser and domain-matching errors.


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