Skip to content
中文

Credentials and logins

The credentials an agent uses fall into three kinds, and each has one place. This page says where each kind lives, gives five practices that apply to all of them, and walks through one department end to end. The built-in skill manage-credentials makes the calls with your agent.

Where each kind lives

What you keepWhere it livesNotes
Platform identity: who you and your agents areThe platform-managed loginThe platform writes the login onto an agent’s computer and renews it, so the computer needs no API Key. A credential only answers “who”; what that principal may do is decided by its roles, see Security. A vault refuses the names of platform login variables
External-service secrets: a GitHub token, a third-party API Key, an account passwordVaultWrite-only values, see Concepts
Website login state: the cookies and localStorage left after signing inBrowser contextSee Cloud browser. The account and password do not go in the login state; they go in a vault

Five practices

1. One vault per owner

Create one vault per department, not one per application. When an application is replaced or added, the vault stays; when a key rotates, you ask one owner. A vault holds at most 50 active secrets.

An organization rule attaches a whole vault, never a single secret. Keep secrets that different people may use in different vaults.

2. Attach only through organization rules, at the highest unit that needs it

An organization rule (a spec in the API) is a document that the organization, a department, a level, a job, a position or an assignment each writes; every unit inherits the one above it. The grants block of a rule attaches vaults to the holder’s agent, written as grants: [{vault: "vlt_…"}].

  • Attach at the highest unit that needs the vault: if a whole department uses it, write it in the department rule, not in each position.
  • Do not add a vault by hand to one agent. Once a rule writes grants, the platform makes the agent’s vaults match the rule exactly, and a hand-added vault is taken back.
  • Revising a rule takes an organization owner or admin, or the head of the department. An agent’s own session token may read a rule; trying to revise one returns 403 PERMISSION_DENIED.

3. Attach login state through rules too, and separate read from write

The browser block of a rule attaches login state through contexts. Each item has the browser context ID (starting with bsc_) and a mode: read_only or read_write.

  • Positions that only use the login state write read_only.
  • The one position that keeps the login state valid writes read_write.
  • Only one session at a time can write a given login state; another one gets 409 CONTEXT_LOCKED. Only the position that keeps it passes persist: true when it creates a session.

A lower unit that names the same login state again overrides the mode from above: the department rule writes read_only, and the keeping position’s rule writes read_write.

4. Every secret carries four labels; search before you create

Labels are metadata in the API: up to 16 pairs, keys up to 64 and values up to 512 characters.

LabelWhat to writeExample
ownerWho is responsible for the secretsupport-team
purposeWhat it is used forhelpdesk-api
ticketThe ticket that requested or changed itSUP-17
rotate_byThe latest rotation date, YYYY-MM-DD2027-03-01

Before you create a secret, search by domain: list the secrets in the vaults and check whether one already has the domain in its allowed_hosts. The API has no filter by host, so list and compare yourself; an entry such as *.example.com covers its subdomains but not example.com itself. If one exists, reuse it.

5. Enter values only in the Console

Type a secret’s value only on the Vault page of the Console. Never pass it through a conversation, a ticket or a script: each of them keeps a record, and a value written there cannot be taken back. An agent can prepare the name, the allowed_hosts and the four labels, and leave the value for you to fill in on the Console.

Example: the support department’s vault

The support department wants every support position’s agent to call the helpdesk system and to read orders with a shop back-office login.

  1. On the Console’s Vault page, create a vault named “Support” and note its vlt_… ID.
  2. Add the secret HELPDESK_API_KEY to it: allowed host api.helpdesk.example.com, labels owner=support-team, purpose=helpdesk-api, ticket=SUP-17 and rotate_by=2027-03-01. You fill in the value at this step.
  3. On the Console’s Browser › Login states page, create shop-admin and note its bsc_… ID. Open a session with it, take over the browser and sign in once; the login state is saved when the session ends with persist: true. Put the back-office account and password in the same vault as secrets.
  4. On the Console’s Organization page, open the support department and edit its rule. Write the following under 开通 (provision), run the preview, which lists the affected agents and each change, then save:
grants:
- vault: vlt_…
browser:
contexts:
- context: bsc_…
mode: read_only
  1. In the rule of the position that keeps the login state (for example the shop-operations position), write the same context again with mode: read_write.

After you save, every agent in the support department’s positions holds the vault and the read-only login state, and so does every agent that takes up a position later; delete an item from the rule and the platform takes it back from those agents. Only the shop-operations position opens sessions with persist: true to save the login state.

Known gaps and interim practice

  • Applications cannot reference a vault yet. An application’s vault-reference bindings and secret writes with a vault source return 501. Interim: keep a second copy in the application’s own settings, and keep the labeled copy in the vault as the master.
  • The agent can read a secret’s value. A vault secret reaches the agent’s computer as an environment variable, so the agent can read the value; the platform does not yet substitute it at egress. allowed_hosts only governs which domains the platform hands the value to, and does not limit reading by name. A service agent, which talks to many people, does not receive secrets that declare hosts. Interim: put in the vaults an agent can hold only the secrets that agent is allowed to use.
  • There is no inventory. You cannot look up which agents use a secret, and nothing reminds you of an expiry. Interim: the four labels are the inventory. Find the owner by owner, list secrets near their rotate_by date on a regular schedule, and read a secret’s last_used_at to see whether anyone still uses it.

Next