Environments
Restore an environment revision
Restore an earlier revision’s spec as a new revision.
POST
/
api
/
v2
/
environments
/
{id}
/
revisions
/
{number}
/
restore
from hai_agents import Client
client = Client()
environment = client.environments.restore_environment_revision("wide-browser", number=1, if_match='"2"')
print(environment.start_url)
import { HaiAgentsClient } from "hai-agents";
const client = new HaiAgentsClient();
const environment = await client.environments.restoreEnvironmentRevision({ id: "wide-browser", number: 1, ifMatch: '"2"' });
if (environment.kind === "web") {
console.log(environment.startUrl);
}
curl -X POST https://agp.eu.hcompany.ai/api/v2/environments/wide-browser/revisions/1/restore \
-H "Authorization: Bearer $HAI_API_KEY" \
-H 'If-Match: "2"'
{
"id": "wide-browser",
"kind": "web",
"host": "cloud",
"start_url": "https://www.google.com",
"headless": false,
"session_id": null,
"mode": {"type": "visual", "width": 1920, "height": 1080, "markdown": false},
"lazy": false,
"settle_s": 1.0,
"vault_id": null,
"browser_profile_id": null,
"use_default_browser_profile": false,
"persist_browser_profile": false,
"network": null
}
Behavior
History is never rewritten: the spec of revisionnumber becomes the environment’s next revision, with the message Restored from vN and restored_from set to N. Agents use it from their next session, except those pinned to another revision with id:N. Restoring a spec equal to the current one changes nothing.
The restored spec is checked like an update.
Headers
string
The
ETag of the revision you based this rollback on, for example "2". If the environment has moved past it, the restore fails with 412. Omit it, or send *, to restore regardless.Path parameters
string
required
The environment’s
id, for example wide-browser or myorg/wide-browser.integer
required
The revision to restore, from List revisions.
Response
200 with the restored environment object, with its new revision in the ETag header.
from hai_agents import Client
client = Client()
environment = client.environments.restore_environment_revision("wide-browser", number=1, if_match='"2"')
print(environment.start_url)
import { HaiAgentsClient } from "hai-agents";
const client = new HaiAgentsClient();
const environment = await client.environments.restoreEnvironmentRevision({ id: "wide-browser", number: 1, ifMatch: '"2"' });
if (environment.kind === "web") {
console.log(environment.startUrl);
}
curl -X POST https://agp.eu.hcompany.ai/api/v2/environments/wide-browser/revisions/1/restore \
-H "Authorization: Bearer $HAI_API_KEY" \
-H 'If-Match: "2"'
{
"id": "wide-browser",
"kind": "web",
"host": "cloud",
"start_url": "https://www.google.com",
"headless": false,
"session_id": null,
"mode": {"type": "visual", "width": 1920, "height": 1080, "markdown": false},
"lazy": false,
"settle_s": 1.0,
"vault_id": null,
"browser_profile_id": null,
"use_default_browser_profile": false,
"persist_browser_profile": false,
"network": null
}
Errors
| Status | Cause |
|---|---|
400 | The path carries an id:N pin, or If-Match is not a single revision tag. |
403 | The environment is reserved (h/) and read-only, or in preview (environment_not_public). |
404 | Not found, or not in your organization. Also sent for an unknown revision. |
410 | The revision’s stored spec fails current validation. |
412 | If-Match names a revision that isn’t the current one. The ETag header has the current one. |
Was this page helpful?
⌘I
from hai_agents import Client
client = Client()
environment = client.environments.restore_environment_revision("wide-browser", number=1, if_match='"2"')
print(environment.start_url)
import { HaiAgentsClient } from "hai-agents";
const client = new HaiAgentsClient();
const environment = await client.environments.restoreEnvironmentRevision({ id: "wide-browser", number: 1, ifMatch: '"2"' });
if (environment.kind === "web") {
console.log(environment.startUrl);
}
curl -X POST https://agp.eu.hcompany.ai/api/v2/environments/wide-browser/revisions/1/restore \
-H "Authorization: Bearer $HAI_API_KEY" \
-H 'If-Match: "2"'
{
"id": "wide-browser",
"kind": "web",
"host": "cloud",
"start_url": "https://www.google.com",
"headless": false,
"session_id": null,
"mode": {"type": "visual", "width": 1920, "height": 1080, "markdown": false},
"lazy": false,
"settle_s": 1.0,
"vault_id": null,
"browser_profile_id": null,
"use_default_browser_profile": false,
"persist_browser_profile": false,
"network": null
}