Skip to main content
PUT
/
api
/
v2
/
vaults
/
{vault_id}
/
token
Rotate the token
curl --request PUT \
  --url https://agp.eu.hcompany.ai/api/v2/vaults/{vault_id}/token \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "token": "<string>"
}
'
import requests

url = "https://agp.eu.hcompany.ai/api/v2/vaults/{vault_id}/token"

payload = { "token": "<string>" }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}

response = requests.put(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({token: '<string>'})
};

fetch('https://agp.eu.hcompany.ai/api/v2/vaults/{vault_id}/token', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://agp.eu.hcompany.ai/api/v2/vaults/{vault_id}/token",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'token' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://agp.eu.hcompany.ai/api/v2/vaults/{vault_id}/token"

payload := strings.NewReader("{\n \"token\": \"<string>\"\n}")

req, _ := http.NewRequest("PUT", url, payload)

req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.put("https://agp.eu.hcompany.ai/api/v2/vaults/{vault_id}/token")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"token\": \"<string>\"\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://agp.eu.hcompany.ai/api/v2/vaults/{vault_id}/token")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"token\": \"<string>\"\n}"

response = http.request(request)
puts response.read_body
Replaces the service account token stored for a vault config. The new token is health-checked against the provider before it is written, so a token that cannot reach op_vault_id is rejected and the old one stays in place. Returns 204 No Content on success.
The request body carries a plaintext service account token. Send it only over HTTPS, never log it, and note that rotation is not idempotent: a retry after a 5xx may apply twice.

Path parameters

vault_id
string
required
The vault config’s id (UUID).

Request body

token
string
required
The new 1Password service account token. Write-only and never returned.

Examples

curl -X PUT https://agp.eu.hcompany.ai/api/v2/vaults/f47ac10b-58cc-4372-a567-0e02b2c3d479/token \
  -H "Authorization: Bearer $HAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"token": "ops_newtoken..."}'
from hai_agents import Client

client = Client()

client.vaults.rotate_vault_token(
    vault_id="f47ac10b-58cc-4372-a567-0e02b2c3d479",
    token="ops_newtoken...",
)
import { HaiAgentsClient } from "hai-agents";

const client = new HaiAgentsClient();

await client.vaults.rotateVaultToken({
  vaultId: "f47ac10b-58cc-4372-a567-0e02b2c3d479",
  token: "ops_newtoken...",
});

Errors

StatusCause
404Vault not found or you don’t have access.
422The provider rejected the new token. The stored token is unchanged.