Agents
Restore an agent revision
Restore an earlier revision’s spec as a new revision.
POST
/
api
/
v2
/
agents
/
{agent_name}
/
revisions
/
{number}
/
restore
from hai_agents import Client
client = Client()
agent = client.agents.restore_agent_revision(agent_name="my-research-bot", number=2, if_match='"3"')
print(agent.instructions)
import { HaiAgentsClient } from "hai-agents";
const client = new HaiAgentsClient();
const agent = await client.agents.restoreAgentRevision({ agentName: "my-research-bot", number: 2, ifMatch: '"3"' });
console.log(agent.instructions);
curl -X POST https://agp.eu.hcompany.ai/api/v2/agents/my-research-bot/revisions/2/restore \
-H "Authorization: Bearer $HAI_API_KEY" \
-H 'If-Match: "3"'
{
"name": "my-research-bot",
"description": "Researches a topic and returns a sourced summary.",
"environments": ["wide-browser"],
"model": null,
"reasoning_effort": null,
"instructions": "Always cite the page you took each claim from.",
"subagents": null,
"skills": ["extract-table-data"],
"answer_format": null,
"tools": null,
"memory": null
}
History is never rewritten: the spec of revision
Plus the common errors.
number becomes the agent’s next revision, with the message Restored from vN and restored_from set to N. Later sessions run it, except those pinned to another revision with name:N. Restoring a spec equal to the current one changes nothing.
The restored spec is checked like an update: the environments, skills, and subagents it names must still exist and be visible to you.
Headers
The
ETag you read, for example "3". A stale value fails with 412. Omit it, or send *, to skip the check. See Revisions and concurrency.Path parameters
The revision to restore, from List revisions.
Response
200 with the restored agent object, with its new revision in the ETag header.
from hai_agents import Client
client = Client()
agent = client.agents.restore_agent_revision(agent_name="my-research-bot", number=2, if_match='"3"')
print(agent.instructions)
import { HaiAgentsClient } from "hai-agents";
const client = new HaiAgentsClient();
const agent = await client.agents.restoreAgentRevision({ agentName: "my-research-bot", number: 2, ifMatch: '"3"' });
console.log(agent.instructions);
curl -X POST https://agp.eu.hcompany.ai/api/v2/agents/my-research-bot/revisions/2/restore \
-H "Authorization: Bearer $HAI_API_KEY" \
-H 'If-Match: "3"'
{
"name": "my-research-bot",
"description": "Researches a topic and returns a sourced summary.",
"environments": ["wide-browser"],
"model": null,
"reasoning_effort": null,
"instructions": "Always cite the page you took each claim from.",
"subagents": null,
"skills": ["extract-table-data"],
"answer_format": null,
"tools": null,
"memory": null
}
Errors
| Status | Cause |
|---|---|
400 | If-Match is not a single revision tag. |
403 | The agent is reserved (h/) and read-only. |
404 | Not found, or not in your organization. Also sent for an unknown revision, or when an environment the revision names was deleted. |
410 | The revision’s stored spec fails current validation. |
412 | If-Match names a stale revision. The ETag header has the current one (Revisions and concurrency). |
Was this page helpful?
⌘I
from hai_agents import Client
client = Client()
agent = client.agents.restore_agent_revision(agent_name="my-research-bot", number=2, if_match='"3"')
print(agent.instructions)
import { HaiAgentsClient } from "hai-agents";
const client = new HaiAgentsClient();
const agent = await client.agents.restoreAgentRevision({ agentName: "my-research-bot", number: 2, ifMatch: '"3"' });
console.log(agent.instructions);
curl -X POST https://agp.eu.hcompany.ai/api/v2/agents/my-research-bot/revisions/2/restore \
-H "Authorization: Bearer $HAI_API_KEY" \
-H 'If-Match: "3"'
{
"name": "my-research-bot",
"description": "Researches a topic and returns a sourced summary.",
"environments": ["wide-browser"],
"model": null,
"reasoning_effort": null,
"instructions": "Always cite the page you took each claim from.",
"subagents": null,
"skills": ["extract-table-data"],
"answer_format": null,
"tools": null,
"memory": null
}