Skip to main content
A vault in Kimi Hosted Agents stores access credentials for third-party services. When you bind a vault at session creation, Hosted Agents supplies credentials during the session according to each credential’s type and matching rules. Once written, credential secret values are never returned in API responses. This page is organized into two workflows:
  • Initial setup: Choose a credential type, create a vault, add credentials, and bind the vault when creating a session.
  • Ongoing management: Inspect credentials, complete OAuth authorization, rotate credential values, and archive or delete resources.

Initial setup

Choose a credential type

Select type based on how the third-party service authenticates: mcp_oauth and static_bearer match MCP servers by mcp_server_url. environment_variable matches environment variable names by secret_name. Active credentials within the same vault must have unique matching field values. Each vault can contain at most 20 active credentials. A credential’s type and identifying fields cannot be modified after creation. To change the authentication type or matching field, archive the existing credential first and create a new one. For environment_variable, the environment variable inside the sandbox holds a placeholder rather than the real secret. This credential type is designed for injecting credentials into outbound requests—not for validating the secret locally or computing request signatures with it.

Create a vault

The request below creates a vault to hold access credentials for a single user or business workflow:
id in a successful response is the vault ID. Save it as VAULT_ID for adding credentials and binding the vault to sessions. If jq is not installed in your environment, extract id from the response JSON and set VAULT_ID manually.

Add a credential

Write an access credential to the vault you just created. The example below adds a static Bearer credential:
Replace your-token with the real credential value. Save id from the response as CREDENTIAL_ID so you can inspect, update, or archive this credential later. A successful response returns the credential id and non-sensitive configuration, without secret values for token, access_token, refresh_token, client_secret, or secret_value.

Add an OAuth credential

When an MCP server uses OAuth 2.0, set type to mcp_oauth and supply mcp_server_url and access_token. For automatic token refresh, also provide refresh with token_endpoint, client_id, and token_endpoint_auth_type configured together.

Add an environment variable credential

To pass credentials via an environment variable, provide secret_name and secret_value. You can use networking to restrict which target hosts receive the substituted credential, and injection_location to restrict where substitution takes place. Omitting networking defaults to limited with an empty allowlist, meaning the credential is not substituted for any host; you must explicitly configure allowed_hosts or set type to unrestricted for substitution to occur.
Omitting injection_location altogether at creation time enables substitution in both request headers and request bodies. If you provide the object and omit one of its fields, the omitted field defaults to false—for example, passing {"header": true} does not substitute in the request body. At least one location must be enabled. networking.allowed_hosts only controls which target hosts can receive the substituted credential; it does not replace the execution environment’s network policy. Credential substitution is available only when both the target host configuration and the execution environment permit the request.

Add credentials in batch

To write multiple credentials in a single request, call the batch creation endpoint and pass 1 to 20 credentials in items, each using the same fields as single-credential creation:
Batch creation is atomic: if validation fails for any item, none of the credentials are created. Matching field values within items (such as mcp_server_url) must be unique; duplicate values cause the endpoint to return HTTP 400. the batch also counts toward the vault’s limit of 20 active credentials. In a successful response, items returns the created credentials in request order, without credential secret values.

Complete OAuth authorization

You can also add an mcp_oauth credential via browser authorization without manually filling in access_token; completing authorization creates the credential automatically. Starting authorization when the vault already has an active credential for the same MCP server returns HTTP 409—archive the old credential first. After creating an authorization session, direct the user to open the returned authorize_url.
From the response, extract authorize_url for the user to open in a browser and save oauth_session_id as OAUTH_SESSION_ID. If client is omitted, the platform registers an OAuth client automatically; to use an existing client, provide client_id along with any other client fields required by the authorization server. Once the user completes authorization in the browser, poll the authorization session status:
Continue polling while the status is pending. When the status becomes authorized, the response includes credential_id for the new credential—save it as CREDENTIAL_ID. When the status is failed, the response includes error; address the cause and start a new authorization session. There is no synchronous endpoint to finalize authorization; you must poll to obtain the result.

Check credential coverage

The credential precheck endpoint checks active credential coverage across vaults for a set of MCP server URLs. For example, running a precheck before starting OAuth authorization lets you detect whether an active credential already exists for the same server and avoid a 409 response:
Pass 1 to 50 unique MCP server URLs in mcp_server_urls; vault_ids is optional and accepts up to 16 vault IDs; when omitted, the endpoint searches all vaults visible to the caller. In the response, coverage reports coverage for each URL in request order: mcp_server_url is the original URL from the request, and matching_vault_ids lists the IDs of vaults containing an active credential for that URL (an empty array means no coverage). Each URL is normalized before matching, and URLs that cannot be normalized match no credentials. Only mcp_oauth and static_bearer credentials count toward coverage; environment_variable credentials do not appear in the results.

Bind a vault when creating a session

Vaults can only be bound when creating a session and cannot be added afterward via the session resources endpoints. Replace agent_id and environment_id with the ID of an agent you have access to and the ID of an execution environment whose build is ready.
After creation succeeds, resources on the session contains a binding with type set to vault. You can bind at most 16 vaults to a session. If multiple bound vaults hold an active credential for the same MCP server, the platform uses the first match according to the vault order in resources.

Ongoing management

Inspect vaults and credentials

Inspect a vault and its credentials to verify current names, matching fields, and archive status. Credential lists exclude archived credentials by default; pass include_archived=true to include archived credentials as well. List endpoints paginate with page_size and an opaque page_token: pass next_page_token from the response as page_token on the next request; when next_page_token is omitted, there are no more results.
Retrieve a single credential:
A successful response returns the resource record and non-sensitive configuration, without credential secret values.

Update a vault

Updating a vault allows modifying only display_name or metadata:

Rotate credential values

When rotating a credential value, submit only the fields that need updating. The credential type and identifying fields—such as type, mcp_server_url, secret_name, token_endpoint, and client_id—cannot be modified. type in the request must match the existing credential. The request below rotates the token for a static Bearer credential. mcp_server_url is the credential’s existing value and cannot be changed to another URL:
A successful response returns the updated non-sensitive configuration, without the new credential value.

Archive or delete

Archiving and deleting are two distinct operations:
  • Archive: Retains the resource record while wiping its secret values. Archived credentials or vaults cannot be used in new sessions.
  • Delete: Permanently removes the resource record.
Choose the endpoint corresponding to the resource you want to manage. Deletion applies only to archived vaults or credentials; to delete permanently, archive first and then delete. Archiving a vault also archives its active credentials and wipes their secret values. Deleting a vault deletes its credential records at the same time—you do not need to delete each credential separately. Archive a single credential while keeping its record:
Permanently delete a vault and its credential records. Archive the vault first:
Delete the vault after archiving completes:

Security boundaries

Credential values are write-only and never appear in create, retrieve, list, or update responses. Never include credential values in client logs, prompts, or any other content that enters the model context. MCP credentials match by mcp_server_url, and environment variable credentials match by secret_name. For environment_variable, the platform substitutes the placeholder only when both the target host configuration and the execution environment’s network policy allow the request.