> ## 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.

# End-user credentials

> Store a sign-in for each of your own users, and let an agent sign in as that user without ever seeing the password.

An end-user credential is one of your users' accounts on one site, for example the LinkedIn account of the user you know as `acme-user-4471`. Your backend creates it with no secret in the request. Tilion returns a single-use link, your product sends the signed-in user to it, and the user types the username and password on a page served by Tilion. From then on, a session opened for that user can sign in to the site with the stored sign-in. Neither your code nor the agent ever receives the password, the authenticator seed, or the site's session cookies.

Org-level credentials ([Credentials and approvals](https://docs.tilion.dev/automation/credentials.md)) hold your organisation's own logins. End-user credentials hold your users' logins and are kept apart: the `/v1/credentials` routes never return an end-user credential, and the routes on this page never return an org-level one.

## How it works

1. Your backend calls `POST /v1/credentials/end-users` with your id for the user (`end_user_ref`) and the site (`host`). The response has a `connect_url`.
2. Your product shows that link to the signed-in user, inside your own app. The link works once, for 15 minutes.
3. The user enters the sign-in on the Tilion page. The credential becomes `active`, and your webhook receives `end_user_credential.active` if you have one set up.
4. When an agent needs to act for that user, open a session with `end_user_ref` and run the `login` task. Tilion types the password itself, in a browser tab the caller cannot reach, then saves the site's cookies to the credential so the next sign-in can usually skip the password.
5. When the user disconnects the site in your product, call `DELETE /v1/credentials/end-users/{id}`. Running sessions are signed out of the site.

A session opened with `end_user_ref` is a protected session for its whole life. See [Protected sessions](#protected-sessions) for what that changes.

## Scopes

These routes check their scope strictly: a key with no scope record is refused. Ask for the scopes when you create the key in the dashboard. A key with `admin` has all three.

| Scope | Allows |
| - | - |
| `end_user_credentials:write` | Create, new link, revoke |
| `end_user_credentials:read` | List and read |
| `end_user_credentials:use` | Open a session with `end_user_ref` |

A key without the scope gets 403 with `{"detail": "this API key lacks the 'end_user_credentials:write' scope"}`.

## Conventions

| Topic | Rule |
| - | - |
| Ids | UUIDs with no prefix |
| Error body | `{"detail": {"error": "<code>", "message": "<text>"}}`. `error` is stable; `message` is for people and may change. Missing or wrongly typed fields answer 422 with a plain `detail` string. |
| Not found | An unknown id and another organisation's id both answer 404 `{"detail": {"error": "not_found", "message": "end-user credential not found"}}` |
| Not available | 501 `not_available` when end-user credentials are not switched on for the deployment |
| Rate limit | Create, new link and revoke by `end_user_ref` have a count of their own, at your account's drive rate limit, and can answer 429 |
| Site names | `host` is reduced to its registrable domain: `www.linkedin.com` is stored as `linkedin.com` |

## The end-user credential object

No field ever holds a secret.

| Field | Type | Meaning |
| - | - | - |
| `id` | string | the end-user credential id |
| `end_user_ref` | string | your id for the user, 1 to 128 characters |
| `host` | string | the site, as a registrable domain |
| `sign_in_hosts` | string\[] | other sites recorded for the sign-in, such as an identity provider. They limit where `login_url` may point. |
| `login_url` | string or null | the page the sign-in starts from |
| `status` | string | `pending`, `active`, `needs_auth` or `revoked` |
| `approval` | string | `none`, or `required` when a member must approve each session's first sign-in. Set from `risk_tier` (`required` for `high` and `critical`); the caller cannot set it. |
| `risk_tier` | string | `low`, `medium`, `high` or `critical`, given to the site at creation |
| `has` | string\[] | what is stored: `password`, `totp`, `cookie` |
| `needs_auth_reason` | string or null | why the stored sign-in needs replacing |
| `last_used_at` | string or null | ISO timestamp of the last sign-in attempt, successful or not |
| `created_at` | string | ISO timestamp |
| `revoked_at` | string or null | ISO timestamp |
| `connect_expires_at` | string or null | expiry time of the newest link, even one already used or voided. Null only when no link was made. |

Statuses:

| Status | Meaning | Can sign in |
| - | - | - |
| `pending` | Created; the user has not completed the link yet | No |
| `active` | A sign-in is stored | Yes |
| `needs_auth` | Reserved for a stored sign-in that needs replacing. Nothing moves a credential to it today: treat repeated `login_not_verified` results as the signal to send the user a new link. | No |
| `revoked` | Withdrawn. Its secrets are deleted. Final. | No |

The site, the user and the approval setting never change. To change them, revoke the credential and create a new one.

## POST /v1/credentials/end-users

Create an end-user credential and its first connect link.

Auth: Bearer API key with `end_user_credentials:write`.

Request:

| Field | Type | Default | Meaning |
| - | - | - | - |
| `end_user_ref` | string | required | your id for the user, 1 to 128 characters, with no leading or trailing spaces and no control characters. Use an opaque id, not an email address. |
| `host` | string | required | the site, for example `linkedin.com` |
| `sign_in_hosts` | string\[] | `[]` | up to 8 identity providers, for example `accounts.google.com`. Fixed at creation. They are recorded and limit where `login_url` may point. The password is typed only on `host` and its subdomains, so a site that sends the user to an identity provider to enter the password ends `credential_host_mismatch`. |
| `login_url` | https URL | `https://<host>/` | where the sign-in starts. Must be on `host` or one of `sign_in_hosts`. At most 2000 characters. |
| `kinds` | string\[] | `["password"]` | what the page asks for: `password`, `totp`, or both |
| `return_url` | https URL | none | the page shows a link back to it when the user is done. Any https address, at most 2000 characters. |
| `reason` | string | none | shown to the user on the connect page, cut to 200 characters |

The body never carries a secret. A request with any of `username`, `password`, `secret`, `totp`, `otp`, `cookie`, `cookies` or `token` is refused with 400 `plain_secret_refused`.

```bash theme={"dark"}
curl -X POST https://back.tilion.dev/v1/credentials/end-users \
  -H "Authorization: Bearer ph_live_..." \
  -H "Content-Type: application/json" \
  -d '{"end_user_ref": "acme-user-4471", "host": "linkedin.com",
       "return_url": "https://app.acme.com/connected",
       "reason": "So Acme can post on your behalf"}'
```

Response (201):

```json theme={"dark"}
{
  "id": "5d0c1c1e-8f1e-4c43-9a43-2f1b7d0d6a11",
  "end_user_ref": "acme-user-4471",
  "host": "linkedin.com",
  "sign_in_hosts": [],
  "login_url": null,
  "status": "pending",
  "approval": "none",
  "risk_tier": "medium",
  "needs_auth_reason": null,
  "last_used_at": null,
  "created_at": "2026-12-01T10:00:00Z",
  "revoked_at": null,
  "has": [],
  "connect_url": "https://back.tilion.dev/connect/<token>",
  "connect_expires_at": "2026-12-01T10:15:00Z"
}
```

`connect_url` is returned once. The token is stored hashed, and no route returns it again. If you lose it, mint a new link.

Errors:

| Status | `error` | When |
| - | - | - |
| 401 | none | missing or wrong key |
| 403 | none | the key lacks `end_user_credentials:write` |
| 422 | none | `end_user_ref` or `host` missing or not a string, `end_user_ref` not 1 to 128 characters, more than 8 `sign_in_hosts`, or `kinds` empty or not a list of `password` and `totp` |
| 400 | `plain_secret_refused` | the body carries a secret field |
| 400 | `host_invalid` | `host` or a `sign_in_hosts` entry is not a public site name, `login_url` is not an https address on `host` or one of `sign_in_hosts`, or `return_url` is not an https address |
| 409 | `end_user_credential_exists` | the user already has a credential for this site that is not revoked. The error object carries its `id`. |

A revoked credential does not block a new one for the same user and site.

## GET /v1/credentials/end-users

List end-user credentials, newest first.

Auth: Bearer API key with `end_user_credentials:read`.

Query:

| Parameter | Default | Meaning |
| - | - | - |
| `end_user_ref` | none | one user only |
| `host` | none | one site only, reduced to its registrable domain |
| `status` | none | one status. Revoked credentials are listed only with `status=revoked`. |
| `limit` | 100 | page size, at most 500 (a larger value is read as 500) |
| `cursor` | none | the `next_cursor` of the previous page |

Response: `{"end_user_credentials": [...], "next_cursor": "..."}`. `next_cursor` is null on the last page.

Errors: 422 for an unknown `status` or a `limit` below 1; 400 `cursor_invalid` for a cursor this API did not return; 400 `host_invalid`.

## GET /v1/credentials/end-users/\{id}

One end-user credential. A revoked one is still readable.

Auth: Bearer API key with `end_user_credentials:read`.

Errors: 404 `not_found`.

## POST /v1/credentials/end-users/\{id}/link

Mint a new connect link for an existing credential. Use it when a `pending` credential's link expired, when a credential is `needs_auth`, or when the user wants to change the stored sign-in. Any earlier open link stops working. Completing a link from this route replaces the stored sign-in; a link from the create route never overwrites one.

Auth: Bearer API key with `end_user_credentials:write`.

Request (optional): `kinds`, `return_url` and `reason`, as for create.

Response: `{"id", "status", "connect_url", "connect_expires_at"}`.

Errors: 404 `not_found`; 409 `end_user_credential_revoked` (create a new credential instead); 400 `plain_secret_refused`; 400 `host_invalid` for a bad `return_url`; 422 for bad `kinds`.

## DELETE /v1/credentials/end-users/\{id}

Revoke one end-user credential. The status becomes `revoked` first, so no new sign-in can start. Then the password, seed and cookies are deleted, any open link is voided, and every running session that signed in with the credential has the site's cookies deleted. Tokens the site keeps in page storage are not cleared. A protected session also re-checks its credentials every 30 seconds, so it signs itself out even if it missed the revoke.

Auth: Bearer API key with `end_user_credentials:write`.

Response: `{"ok": true, "id": "...", "status": "revoked", "sessions_reached": 2}`. `sessions_reached` is the number of sessions recorded as using the credential, each told to sign out; a session that already ended can be in the count. Repeating the call answers 200 with `sessions_reached: 0`, and so does revoking a `pending` credential.

Errors: 404 `not_found`.

## DELETE /v1/credentials/end-users?end\_user\_ref=

Revoke every credential of one user, for example when the user deletes their account or makes a privacy request.

Auth: Bearer API key with `end_user_credentials:write`.

Response: `{"ok": true, "end_user_ref": "acme-user-4471", "revoked": 3}`.

Errors: 422 when `end_user_ref` is missing. An `end_user_ref` with no credentials answers 200 with `revoked: 0`.

## The connect page

`GET /connect/{token}` and `POST /connect/{token}` are the page the user opens. They need no API key and are plain HTML that loads nothing from another origin.

| Case | Behavior |
| - | - |
| Valid link | The page names your organisation, the site and the `reason`, and shows only the fields in `kinds` |
| Submit | A password needs a username. The link is claimed, so two submissions cannot both write. The credential becomes `active`, and the page shows a done message with a link to `return_url`. |
| Wrong, expired or voided link, or a revoked credential | 404 with one message for every case, so the page does not reveal which |
| Link already used, or a second submission that lost | 409, with the same visible page |
| A field is missing, or the link does not accept what was entered | 400 with a message on the page. The link stays usable. |
| The sign-in could not be saved | 500. The link is released so the user can try again. |

Who can complete a link: whoever opens it first. Hand it only to the signed-in user inside your product, never by email or chat. Open `connect_url` as a top-level page (a redirect or a new tab): it cannot be shown in an iframe.

The authenticator key is optional on the page and may be an `otpauth://` address or the setup key. Use `kinds: ["totp"]` alone only on `/link`, to add a key to a credential that already has a password. Completing a new link clears the saved cookies, so the next sign-in types the password.

## Signing in

### Open a protected session

Add `end_user_ref` to `POST /v1/session`. The key needs `end_user_credentials:use` as well as `sessions:write`.

```bash theme={"dark"}
curl -X POST https://back.tilion.dev/v1/session \
  -H "Authorization: Bearer ph_live_..." \
  -H "Content-Type: application/json" \
  -d '{"end_user_ref": "acme-user-4471"}'
```

The response carries `"end_user_ref": "acme-user-4471"` and `"protected": true` next to the usual session fields, and `GET /v1/session/{id}` returns both too. The user need not have a credential yet.

| Status | `error` | When |
| - | - | - |
| 422 | none | `end_user_ref` is not 1 to 128 characters |
| 403 | none | the key lacks `end_user_credentials:use` |
| 400 | `proxy_not_allowed` | the request also sets `proxy`. A protected session always leaves through a Tilion exit, so your own proxy never sees the sign-in. |
| 501 | `not_available` | end-user credentials are not switched on |

### Run the login task

```bash theme={"dark"}
curl -X POST https://back.tilion.dev/v1/agent \
  -H "Authorization: Bearer ph_live_..." \
  -H "Content-Type: application/json" \
  -d '{"session_id": "sess_...", "task": "login", "async_mode": true,
       "params": {"end_user_credential_id": "5d0c1c1e-8f1e-4c43-9a43-2f1b7d0d6a11"}}'
```

`end_user_credential_id` is optional. Without it, the credential is found from the session's `end_user_ref` and the site of the page the browser is on. Tilion opens the credential's `login_url` (or the site's home page) itself, so the caller does not choose where a secret is typed. On a new session, whose page is still blank, pass `end_user_credential_id` or navigate to the site first; otherwise the result is `no_credential_for_host`.

The task first restores the saved cookies. If the site shows a signed-in state, the sign-in is done without typing anything. Otherwise it types the stored username and password, and a code from the stored authenticator seed if the site asks for one. With no seed, the task does not enter a code: if the site asks for one, the result is `login_not_verified`. Ask for the authenticator key on the connect page with `kinds: ["password", "totp"]`. After a successful sign-in, the site's cookies are saved to the credential.

```json theme={"dark"}
{"ok": true, "task": "login",
 "data": {"logged_in": true, "method": "restored", "end_user_credential_id": "5d0c1c1e-..."}}
```

`method` is `restored` when the saved cookies worked, or `typed`. A typed sign-in that fails still reports `typed`.

A typed sign-in on a real site takes 25 to 45 seconds, close to the 57 second limit for a synchronous call. Run it with `"async_mode": true` and poll `GET /v1/job/{job_id}`.

Refusals are HTTP 200 with `ok: false` and an `error` code. Nothing is decrypted before every check passes.

A credential with `approval: required` answers `ok: false` with no `error`, `status: "awaiting_approval"` and an `approval_id`. Call again with the `approval_id` once a member approves (see [Credentials and approvals](https://docs.tilion.dev/automation/credentials.md)).

| `error` | Meaning |
| - | - |
| `no_credential_for_host` | nothing stored for this user and site, or the id is unknown or belongs to another organisation |
| `end_user_mismatch` | the credential belongs to another user, or the session was not opened with `end_user_ref` |
| `end_user_credential_not_active` | the credential is `pending`, `needs_auth` or `revoked`; `data.status` says which |
| `login_in_progress` | another sign-in holds this credential |
| `credential_audit` | the audit record could not be written, so the sign-in did not start |
| `credential_host_mismatch` | the sign-in page is not on the credential's site, for example because `login_url` led to an identity provider |
| `credential_unresolved` | the stored sign-in could not be read, so nothing was typed |
| `approval_required_gate_unavailable` | the credential needs approval and approvals cannot be taken right now |
| `signin_lock_unavailable` | the sign-in could not be isolated, so nothing was typed. Also returned while a browser trace or `Security.setIgnoreCertificateErrors` is on. |
| `login_form_not_found` | no sign-in form on the page |
| `login_not_verified` | typed, with no sign of success. A wrong password ends here. |
| `login_failed: <detail>` | the task hit an unexpected error. Match on the prefix. |

In a protected session, `login` refuses the parameters `username`, `password`, `totp`, `credential`, `cred` and `allow_hosts` with HTTP 400 `literal_credentials_refused` (with `async_mode`, the job ends in `status: "error"` carrying that code). It ignores `url`, the selector parameters and `success_text`, so the caller cannot choose the fields a password is typed into.

## Protected sessions

A protected session still supports every way of driving the browser, including [Playwright and raw CDP](https://docs.tilion.dev/sessions/playwright-cdp.md), so existing automation runs unchanged. A connected site is the site of any credential of the session's user that is not revoked, `pending` ones included, with its subdomains. What changes:

| Surface | Behavior |
| - | - |
| Navigate, click, type, read, screenshot, agent tasks | Allowed |
| Raw CDP, Playwright and tunnel connections | Allowed, and not paused during a sign-in. The sign-in runs in a separate browser context those connections cannot list or attach to; a command that names it answers a CDP error. |
| `Target.exposeDevToolsProtocol` | Refused with a CDP error. Playwright and Puppeteer do not send it. |
| Raw CDP cookie listings | Cookies of the user's connected sites are left out |
| Raw CDP network events and intercepted requests | `Cookie`, `Set-Cookie` and `Authorization` values and request bodies are replaced with `<withheld>` for connected sites |
| Raw CDP storage and body reads: `DOMStorage.getDOMStorageItems`, `IndexedDB.requestData`, `Network.getResponseBody`, `Network.getRequestPostData`, `Fetch.getResponseBody` | Come back empty for connected sites |
| Browser traces and `Security.setIgnoreCertificateErrors` | A sign-in is refused while either is on, and neither can be switched on while a sign-in runs |
| `GET /v1/session/{id}/context` | Leaves out the connected sites' cookies, and their local and session storage |
| `POST /v1/session/{id}/save-auth` and profile save | Refused with 409 `protected_session`, since both would copy the user's cookies into storage your organisation can export. A session that starts from a profile does not save to it when it closes. |
| Page text and task results | In JSON answers of the REST API, any typed username, password or code is replaced with a placeholder such as `<linkedin.com:password>`. Raw CDP and Playwright output, screenshots and recordings are not rewritten. |
| Session recording | Paused for the whole `login` task |
| Live view | Read-only, and blanked while a secret is typed |
| Full-browser view (noVNC) | Refused. The whole window would show and drive the sign-in tab with no blanking, so `POST /v1/session/{id}/vnc-token` answers 403 and the `vnc-ws` socket closes with code 1008. Use the live view instead. |
| `vault://` references | A reference to an end user's secret works only inside the server's own sign-in for that credential. In any other task or session it does not resolve. |

If Tilion cannot read the user's connected sites when a raw CDP connection opens, the connection is closed with code 1013 and `GET /context` answers 503 `protected_state_unavailable`. Retry after a moment.

What this promises: the password and authenticator seed are never readable by your code or the agent. Session cookies and stored tokens are left out of the REST answers and of the raw CDP cookie listings, network events, storage reads and body reads named in the table above. Other CDP commands are not filtered.

The limit: a script you run on a connected site's page, with `Runtime.evaluate` or Playwright's `page.evaluate`, runs as that page. It can use the signed-in session, as it must for the agent to work, and it can read what the site keeps where page scripts can reach it, such as a cookie not marked HttpOnly or a token in localStorage. Tilion does not filter script results. A site that keeps its session in HttpOnly cookies is fully covered.

## Webhooks

Status changes are sent to your organisation's webhook: `end_user_credential.active` when the user completes a link, `end_user_credential.revoked`, and `end_user_credential.needs_auth` (reserved, not sent today). They are sent only when the webhook has a signing secret, so an unsigned webhook never receives them. Ask Tilion support to set the secret for your organisation.

```
X-Tilion-Event: end_user_credential.active
X-Tilion-Signature: t=<timestamp>,v1=<hex HMAC-SHA256 of "<timestamp>.<body>">
```

```json theme={"dark"}
{"event": "end_user_credential.active", "at": "2026-12-01T10:03:12Z",
 "end_user_credential_id": "5d0c1c1e-...", "end_user_ref": "acme-user-4471",
 "host": "linkedin.com", "status": "active", "reason": null}
```

`reason` is set only for `needs_auth`. A payload never carries a password, a cookie or the webhook address.

Check the signature over the raw body before parsing it, and refuse a timestamp more than five minutes old:

```python theme={"dark"}
import hashlib, hmac, time

def verify(secret: str, header: str, body: bytes, tolerance: int = 300) -> bool:
    parts = dict(p.split("=", 1) for p in header.split(",") if "=" in p)
    ts, sig = parts.get("t", ""), parts.get("v1", "")
    if not ts.isdigit() or abs(time.time() - int(ts)) > tolerance:
        return False
    want = hmac.new(secret.encode(), ts.encode() + b"." + body, hashlib.sha256).hexdigest()
    return hmac.compare_digest(want, sig)
```

Each event is tried a few times within a few seconds and then dropped. A 4xx answer other than 408 or 429 is not retried, and redirects are not followed. Events are not stored, so reconcile with `GET /v1/credentials/end-users`.

Treat the webhook as a hint: read the credential with `GET /v1/credentials/end-users/{id}` before acting on it.

## MCP tools

The hosted [MCP server](https://docs.tilion.dev/mcp/server.md)'s credential tools take an optional `end_user_ref`:

| Tool | With `end_user_ref` |
| - | - |
| `credential_list` | lists that user's credentials (`id`, `host`, `status`, `has`, `approval`, `risk_tier`, `needs_auth_reason`) |
| `credential_connect` | creates the user's credential for `host` and returns the link. If one exists, returns a new link for it with `already_existed: true`. |
| `credential_wait` | with `end_user_credential_id` (both arguments are required together): waits for the credential to become `active`. `revoked` ends the wait as a failure. |

The MCP tools can list, connect and wait for an end user's credential. They cannot open a session with `end_user_ref`: do that with `POST /v1/session`. `credential_connect` always asks for a password and cannot set `kinds`, `return_url`, `login_url` or `sign_in_hosts`. `credential_wait` returns at once when the credential is already `active`.

The key behind the MCP connection needs the three `end_user_credentials` scopes. The `cdp` scope that the MCP OAuth flow issues does not include them, so connect with an API key that has them.


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