Environments
Patch an environment
Patch some fields of an environment and keep the rest.
PATCH
/
api
/
v2
/
environments
/
{id}
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",
});
if (environment.kind === "web") {
console.log(environment.vaultId);
}
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"}'
Behavior
Sendnull to clear an optional field, for example vault_id: null to unbind a vault. Fields with a default, like host, mode, settle_s, lazy, or headless, can’t be null: send the value you want instead. The merged result is validated like a full update.
Path parameters
string
required
The environment’s
id, for example wide-browser or myorg/wide-browser.Request body
Any subset of these environment fields:host, start_url, headless, session_id, mode, lazy, settle_s, vault_id, browser_profile_id, use_default_browser_profile, persist_browser_profile, network, and screenshot_max_width (desktop environments only). id and kind can’t change.
Response
200 with the updated environment object.
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",
});
if (environment.kind === "web") {
console.log(environment.vaultId);
}
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"}'
Errors
| Status | Cause |
|---|---|
403 | The environment is reserved (h/) and read-only. |
404 | Not found, or not in your organization. |
422 | The merged spec fails validation, for example an invalid mode, or null for a field that can’t be null. |
Was this page helpful?
⌘I
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",
});
if (environment.kind === "web") {
console.log(environment.vaultId);
}
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"}'