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

# Login vault

> Browsers for AI that stay logged in. The login vault keeps the username, password and two-step (TOTP) secret an end user's profile signs in with, so a profile can sign in again when its session ends without your agent ever seeing the password.

Base URL: `https://api.styne.ai`. Every request carries `Authorization: Bearer $STYNE_API_KEY`.

## Write-only

The vault is write-only. A secret goes in with `POST` or `PATCH` and never comes out: no answer, error, webhook, log line
or audit row carries it, its length or a hash of it. There is no read, export or reveal of a secret, and no call that
answers or checks a two-step code. An item shows its sites, a username hint such as `a•••@e•••.com`, whether it has a
TOTP secret with its public parameters, and when the password last changed.

## Store a login and link it to a profile

[//]: # "smoke: not executed, it stores a credential"

```bash theme={"theme":"css-variables"}
curl -sS -X POST https://api.styne.ai/vault/items -H "Authorization: Bearer $STYNE_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"label":"Acme portal","hosts":["portal.acme.com"],"login_url":"https://portal.acme.com/login",
       "fields":{"username":"'$ACME_USER'","password":"'$ACME_PASSWORD'","totp_secret":"'$ACME_TOTP'"},
       "profiles":["user_123"]}'
```

The answer is the item, without any secret:

```json theme={"theme":"css-variables"}
{"id":"vi_3f9c0a5e7d1b2c4a6e8f","label":"Acme portal","hosts":["portal.acme.com"],
 "login_url":"https://portal.acme.com/login","username_hint":"a•••@e•••.com","has_totp":true,
 "totp":{"digits":6,"period":30,"algorithm":"SHA1"},"profiles":["prof_8d2e..."],"region":"ams","version":1,
 "created_at":1794000000,"updated_at":1794000000,"password_updated_at":1794000000,"last_used_at":null,
 "last_result":null,"disabled_reason":null}
```

* `hosts`: one to five sites the item may be typed into (`*.acme.com` covers the subdomains). The hosts are part of how
  the item is sealed, so they cannot change: make a new item for another site. IP addresses, local names and `*.` on a
  public suffix are refused (`422 host_not_allowed`).
* `login_url`: an `https` address on one of the hosts where the sign-in starts.
* `fields.totp_secret`: the one-time-code secret from the site's two-step setup: the base32 secret, or the
  `otpauth://totp/...`, `otpauth://hotp/...` or `otpauth://steam/...` link. `totp` sets `type` (`totp`, `hotp`, `steam`),
  `digits` (6, 7, 8), `period` (15, 30, 60), `algorithm` (`SHA1`, `SHA256`, `SHA512`) and, for HOTP, the `counter` of the
  first code, when the secret does not carry them.
  * Time-based codes (TOTP) are the default.
  * Counter-based codes (HOTP, RFC 4226): an `otpauth://hotp/...?secret=...&counter=N` link, or the base32 secret with
    `"totp": {"type": "hotp", "counter": N}`. Each code a sign-in types uses the next counter and the item stores it
    advanced, so no counter is sent twice; `hotp_counter` in the item shows the next one. Without a counter the first
    code uses 0.
  * Steam Guard codes (5 characters, 30 s): an `otpauth://steam/...?secret=...` link (or an `otpauth://totp/` link with
    `issuer=Steam` or `encoder=steam`), `steam://<base32 secret>`, or the secret with `"totp": {"type": "steam"}`. With
    `type` `steam` the secret may also be the base64 `shared_secret` of a Steam mobile authenticator file.
* `profiles`: profile ids or end-user names. A profile signs in with one item; linking a profile that already has another
  item answers `409 credential_conflict`. `PATCH /profiles/{id}` with `{"login": {"item": "vi_..."}}` links one profile,
  `{"login": null}` unlinks it. A fork of a profile signs in with the same item unless its body says
  `"copy_credentials": false`.

To change a password or a TOTP secret, `PATCH /vault/items/{id}` with the new value in `fields`; `version` and
`password_updated_at` move. Setting the same password again is no change: `password_updated_at` stays, and so does what
the site made of that password. `{"fields": {"totp_secret": null}}` removes the TOTP secret. A new HOTP secret starts at
its own counter.

## Sign in on its own

Tell the profile what signed in looks like, then let it sign in with its item:

[//]: # "smoke: not executed, it signs in to a site"

```bash theme={"theme":"css-variables"}
curl -sS -X PATCH https://api.styne.ai/profiles/$PROFILE_ID -H "Authorization: Bearer $STYNE_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"login":{"item":"vi_3f9c0a5e7d1b2c4a6e8f","expect":{"selector_exists":"#account"}}}'
curl -sS -X POST https://api.styne.ai/profiles/$PROFILE_ID/login -H "Authorization: Bearer $STYNE_API_KEY"
```

`POST /profiles/{id}/login` answers `202` with the profile at once; the sign-in runs in the background and
`GET /profiles/{id}` shows it under `relogin`: `state` is `running`, then `idle` when it signed in (`last_ok_at`),
`needs_human` with a `reason`, or `failed`. `POST /profiles/{id}/relogin` does the same for a profile that was signed in
before; while a run is going, both answer `200` with the profile and start nothing.

A profile also signs in again on its own when a check (`POST /profiles/{id}/check`) or a step on a browser started from
it (`POST /browsers/{id}/steps`) finds it signed out. `login` sets how:

* `expect`: what signed in looks like (`url_matches`, `selector_exists`, `text_contains`, `cookie`). The first check with
  a `url` and `expect` is remembered, and a check without them uses the remembered ones. On a page where a password is
  typed nothing may test what a field holds: `js_expr` is refused (`422 js_expr_refused`); `selector_exists` takes tags,
  `#ids`, `.classes`, `[data-*]` presence and combinators only (`422 selector_refused`); `url_matches` takes at most 200
  characters, no quantified group such as `(a+)+` or `(a)?`, and at most two unbounded repeats (`*`, `+`, `{n,}`) outside character classes (`422 pattern_refused`).
* `logged_out`: what signed out looks like on a live page, in the same terms. Without it, a page on one of the item's
  hosts with a password field or a sign-in address counts as signed out.
* `url`: where the sign-in starts; the item's `login_url` when unset.
* `auto`: `false` stops the automatic runs; explicit calls still work.

How a run signs in: it starts a copy of the profile's saved browser that only Styne holds (no connect URL, not listed,
no takeover). The copy asks for one field at a time, and gets a value only for a page on one of the item's hosts. Two-step
codes are computed by Styne at the moment the code field shows, so the TOTP secret never enters the browser, and a code is
never sent twice. The signed-in copy is checked against `expect` once more and saved into the profile, unless the profile
was saved by someone else meanwhile.

What protects the site account: one run per profile at a time, and one run per password across all profiles of an
item; at most 3 password submits per hour and 6 per day per profile, and 6 per hour and 20 per day per item across all
its profiles; at most 6 two-step codes per hour and 20 per day per item; after a failed automatic run the next one waits
5, then 15, then 60 minutes. A run that started before you changed the password never sends the old one. A password the
site refuses is submitted once: the item gets `disabled_reason: "bad_credentials"` and is not used again
(`409 credential_rejected`) until you change the password with `PATCH /vault/items/{id}`. A submit with no clear answer
from the site counts as possibly refused: the item gets `disabled_reason: "unverified"` and that password is not sent
again (`409 credential_unverified`) until a person finishes the sign-in link of that run and its `expect` check passes,
or you set a different password.

Events (see [Webhooks](https://docs.styne.ai/webhooks.md)): `relogin.succeeded` when a run signed in, and `relogin.needs_human` with a `reason`
(`captcha`, `otp_unusual`, `new_device`, `bad_credentials`, `timeout`, `no_credential`), an `action` (`open_link` or
`update_credential`) and `signin_link`, a link a person opens to finish on the page where the run stopped, or `null`.
The link's `url` has the form `https://app.styne.ai/signin/<id>#<secret>`: the secret rides in the fragment, which no
server receives. Treat the whole URL as a secret; it opens on one device only, and ends when used or after its `ttl`.
`profile.expired` names in `relogin` whether a run started (`started`, `not_configured`, `limited`, `disabled`).

## Regions

Items are kept per region, in the region whose API received them, and are never copied to the other region. A profile
links only to items of its own region. If you keep profiles in both regions, store the login once per region, through
each region's API host or the SDK's `region` (see [Regions](https://docs.styne.ai/regions.md)).

## How it is protected, and the limits

Each region has its own key-encryption key, kept outside the database. Each account has its own data key per region,
wrapped under it, and every field is sealed on its own (AES-256-GCM) with the account, item, field, sites and region bound
in, so a sealed value copied anywhere else does not open. Values are padded before sealing, so the stored size does not
tell a password's length.

What this does not do: deleting an item or your account removes it at once, but database backups taken before keep the
sealed copy until their retention ends. If a region's key were lost, the items of that region would have to be stored
again.

Limits of a sign-in in a browser, stated plainly:

* The site's own page, and every script it loads, sees the password as it is typed, as in any browser.
* Sign-ins run on Styne's browser image. A browser image you build yourself runs your code next to the typed values, so it
  could capture them.
* Before a browser a password was typed in is saved into a profile, the browser and the process that carried the values
  into it are started afresh, and the free memory is written with zeros. The zeroing covers most free memory, not all:
  about 96 to 112 MiB of free pages are left unwritten. In our test (2026-11-17, a test site, 10 saves, vault filler only),
  no process of a browser started from the saved profile held the password, but a copy was left in the memory of the
  operating system's kernel after 7 of 10 saves. Your own agent runs as root in a browser it starts from that profile, so
  code you run there can read that copy; treat the password as readable by it in most saves. Closing this is ongoing.
* The sign-in-link path (a person types the password into a page you opened for them) was not part of that scan. Whether
  the process that carries the keystrokes outlives the clearing is not measured.

## Audit

`GET /vault/audit?item=<id>` lists what happened to your items, newest first, for 90 days: `item.created`,
`item.updated`, `item.password_rotated`, `item.totp_rotated`, `item.deleted`, `item.linked`, `item.unlinked`, each
sign-in (`relogin.started`, `relogin.succeeded`, `relogin.needs_human`, `relogin.failed`) and each field a sign-in typed
(`fill.username`, `fill.password`, `fill.totp`, with the profile and whether it was given or refused), each with the
time, the API key that did it and the region.

## Limits and errors

An account keeps up to 2,000 items per region; an item links up to 100 profiles. Vault writes are limited to 60 per
minute and reads to 600 per minute per account; a request body is at most 16 KiB.

| Status | `error_code` | When |
| - | - | - |
| 503 | `vault_unavailable` | The vault could not open this account's items; retry later. |
| 404 | `vault_item_not_found` | No such item in this account and region. |
| 404 | `profile_not_found` | A linked profile is not in this account and region. |
| 409 | `credential_conflict` | The profile already signs in with another item. |
| 409 | `no_credential` | `login` on a profile without a vault item. |
| 409 | `credential_rejected` | The site refused the item's password; change it first. |
| 409 | `credential_unverified` | The item's password was sent and the site gave no clear answer; finish the sign-in link or set a different password. |
| 409 | `item_changed` | The item changed while the call ran (a new password or another write); try again. |
| 409 | `link_not_opened` | A sign-in link is ended before the device that ends it opened it. |
| 409 | `link_in_use` | The sign-in link is open on another device. |
| 409 | `profile_empty` | Neither the profile nor its item names where the sign-in starts. |
| 422 | `expect_required` | `login`/`relogin` before the profile knows what signed in looks like. |
| 422 | `host_not_allowed` | A host or `login_url` is not a public `https` site of the item, or the profile's start page (`login.url`, `login.check_url`) is not on one of the item's hosts. |
| 422 | `js_expr_refused` | `login.expect`, `login.logged_out` or a sign-in link's `success_check` names `js_expr`. |
| 422 | `selector_refused` | Their `selector_exists` reads an attribute value or a field's state. |
| 422 | `pattern_refused` | Their `url_matches` is longer than 200 characters or repeats a group. |
| 422 | `invalid_totp_secret` | The one-time-code secret or its parameters cannot be read, a Steam code is given other digits, period or algorithm, `totp.counter` is given for a type other than `hotp`, or it differs from the link's `counter`. |
| 429 | `vault_limit` | The account has 2,000 items in this region. |
| 429 | `rate_limited` | Too many vault calls this minute (`login`/`relogin`: 10 per minute; `PATCH /profiles/{id}`: 60 per minute); retry after `Retry-After` seconds. |
| 429 | `relogin_limited` | The profile or the item used its password submits for now, or another profile's run holds the password; retry after `Retry-After` seconds. |
| 502 | `scrub_failed` | A signed-in browser could not be cleared before it was saved, so it was not saved; try again. |

## Calls

Every path is also served under `/v1` (for example `/v1/vault/items`).

| Method | Path | What it does |
| - | - | - |
| `POST` | `/vault/items` | Store a login (username, password, TOTP secret) for one or more sites |
| `GET` | `/vault/items` | List the account's vault items in this region, newest first, optionally of one profile or host |
| `GET` | `/vault/items/{id}` | Read a vault item (never a secret) |
| `PATCH` | `/vault/items/{id}` | Change a vault item: label, login URL, linked profiles, or a new password or TOTP secret |
| `DELETE` | `/vault/items/{id}` | Delete a vault item and unlink it from its profiles |
| `GET` | `/vault/audit` | List what happened to the account's vault items, newest first |
| `PATCH` | `/profiles/{id}` | Change a profile's label or how it signs in: vault item, start page, signed-in and signed-out pages |
| `POST` | `/profiles/{id}/login` | Sign a profile in with its vault item, in the background (202) |
| `POST` | `/profiles/{id}/relogin` | Sign a profile in again with its vault item (202; 200 when a run is already going) |


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