Patch an environment
curl --request PATCH \
--url https://agp.eu.hcompany.ai/api/v2/environments/{id} \
--header 'Authorization: Bearer <token>'import requests
url = "https://agp.eu.hcompany.ai/api/v2/environments/{id}"
headers = {"Authorization": "Bearer <token>"}
response = requests.patch(url, headers=headers)
print(response.text)const options = {method: 'PATCH', headers: {Authorization: 'Bearer <token>'}};
fetch('https://agp.eu.hcompany.ai/api/v2/environments/{id}', 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/environments/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://agp.eu.hcompany.ai/api/v2/environments/{id}"
req, _ := http.NewRequest("PATCH", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("https://agp.eu.hcompany.ai/api/v2/environments/{id}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://agp.eu.hcompany.ai/api/v2/environments/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_bodyEnvironments
Patch an environment
Change individual fields of an environment without resending the full spec.
PATCH
/
api
/
v2
/
environments
/
{id}
Patch an environment
curl --request PATCH \
--url https://agp.eu.hcompany.ai/api/v2/environments/{id} \
--header 'Authorization: Bearer <token>'import requests
url = "https://agp.eu.hcompany.ai/api/v2/environments/{id}"
headers = {"Authorization": "Bearer <token>"}
response = requests.patch(url, headers=headers)
print(response.text)const options = {method: 'PATCH', headers: {Authorization: 'Bearer <token>'}};
fetch('https://agp.eu.hcompany.ai/api/v2/environments/{id}', 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/environments/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://agp.eu.hcompany.ai/api/v2/environments/{id}"
req, _ := http.NewRequest("PATCH", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("https://agp.eu.hcompany.ai/api/v2/environments/{id}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://agp.eu.hcompany.ai/api/v2/environments/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_bodyPartial update: only the fields you send change, everything else is preserved. Send a field as
null to clear it, for example vault_id: null to unbind a vault. The merged result is validated like a full update, and id and kind are not patchable.
This makes binding a vault to an existing environment a one-liner, with no need to resend the full spec.
Returns the updated Environment object.
Path parameters
string
required
The environment’s
id (e.g. wide-browser or myorg/wide-browser). Slash-containing identifiers are supported.Request body
Any subset of the Browser spec’s fields exceptid and kind: start_url, headless, mode, vault_id, browser_profile_id, use_default_browser_profile, persist_browser_profile, network.
Examples
Bind a vault, leaving the rest of the spec untouched:curl -X PATCH https://agp.eu.hcompany.ai/api/v2/environments/wide-browser \
-H "Authorization: Bearer $HAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"vault_id": "f47ac10b-58cc-4372-a567-0e02b2c3d479"}'
from hai_agents import Client
client = Client()
environment = client.environments.patch_environment(
"wide-browser",
vault_id="f47ac10b-58cc-4372-a567-0e02b2c3d479",
)
print(environment.vault_id)
import { HaiAgentsClient } from "hai-agents";
const client = new HaiAgentsClient();
const environment = await client.environments.patchEnvironment({
id: "wide-browser",
vaultId: "f47ac10b-58cc-4372-a567-0e02b2c3d479",
});
console.log(environment.vaultId);
Errors
| Status | Cause |
|---|---|
403 | The environment is reserved (h/) and read-only. |
404 | Environment not found or you don’t have access. |
422 | The merged spec fails validation, for example an invalid mode. |
Last modified on September 11, 2026
Was this page helpful?