Vaults
Rotate a vault token
Rotate a vault’s stored service account token, keeping its ID and settings.
PUT
/
api
/
v2
/
vaults
/
{vault_id}
/
token
from hai_agents import Client
client = Client()
client.vaults.rotate_vault_token(
vault_id=vault_id,
token="ops_newtoken...",
)
import { HaiAgentsClient } from "hai-agents";
const client = new HaiAgentsClient();
await client.vaults.rotateVaultToken({
vaultId,
token: "ops_newtoken...",
});
curl -X PUT https://agp.eu.hcompany.ai/api/v2/vaults/$VAULT_ID/token \
-H "Authorization: Bearer $HAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"token": "ops_newtoken..."}'
Behavior
The service account token travels in clear text inside the body. Send it only over HTTPS and never log the request. Rotation is not idempotent: a retry after a 5xx may apply twice. The new token is health-checked against the provider before it is written, so a token that cannot reachop_vault_id is rejected and the old one stays in place. An H-hosted vault has no token to rotate.
Path parameters
string
required
The vault config’s
id (UUID).Request body
string
required
The new 1Password service account token. Write-only and never returned.
Response
204 No Content.
from hai_agents import Client
client = Client()
client.vaults.rotate_vault_token(
vault_id=vault_id,
token="ops_newtoken...",
)
import { HaiAgentsClient } from "hai-agents";
const client = new HaiAgentsClient();
await client.vaults.rotateVaultToken({
vaultId,
token: "ops_newtoken...",
});
curl -X PUT https://agp.eu.hcompany.ai/api/v2/vaults/$VAULT_ID/token \
-H "Authorization: Bearer $HAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"token": "ops_newtoken..."}'
Errors
| Status | Cause |
|---|---|
400 | The provider rejected the new token (the stored token is unchanged), or the vault is H-hosted and has no token. |
404 | Not found, or not in your organization. |
422 | Body failed validation. |
Was this page helpful?
⌘I
from hai_agents import Client
client = Client()
client.vaults.rotate_vault_token(
vault_id=vault_id,
token="ops_newtoken...",
)
import { HaiAgentsClient } from "hai-agents";
const client = new HaiAgentsClient();
await client.vaults.rotateVaultToken({
vaultId,
token: "ops_newtoken...",
});
curl -X PUT https://agp.eu.hcompany.ai/api/v2/vaults/$VAULT_ID/token \
-H "Authorization: Bearer $HAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"token": "ops_newtoken..."}'