Restore an agent revision
curl --request POST \
--url https://agp.eu.hcompany.ai/api/v2/agents/{agent_name}/revisions/{number}/restore \
--header 'Authorization: Bearer <token>'import requests
url = "https://agp.eu.hcompany.ai/api/v2/agents/{agent_name}/revisions/{number}/restore"
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch('https://agp.eu.hcompany.ai/api/v2/agents/{agent_name}/revisions/{number}/restore', 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/agents/{agent_name}/revisions/{number}/restore",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
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/agents/{agent_name}/revisions/{number}/restore"
req, _ := http.NewRequest("POST", 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.post("https://agp.eu.hcompany.ai/api/v2/agents/{agent_name}/revisions/{number}/restore")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://agp.eu.hcompany.ai/api/v2/agents/{agent_name}/revisions/{number}/restore")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_bodyAgents
Restore an agent revision
Roll an agent back: make an earlier revision’s spec current again, as a new revision.
POST
/
api
/
v2
/
agents
/
{agent_name}
/
revisions
/
{number}
/
restore
Restore an agent revision
curl --request POST \
--url https://agp.eu.hcompany.ai/api/v2/agents/{agent_name}/revisions/{number}/restore \
--header 'Authorization: Bearer <token>'import requests
url = "https://agp.eu.hcompany.ai/api/v2/agents/{agent_name}/revisions/{number}/restore"
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch('https://agp.eu.hcompany.ai/api/v2/agents/{agent_name}/revisions/{number}/restore', 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/agents/{agent_name}/revisions/{number}/restore",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
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/agents/{agent_name}/revisions/{number}/restore"
req, _ := http.NewRequest("POST", 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.post("https://agp.eu.hcompany.ai/api/v2/agents/{agent_name}/revisions/{number}/restore")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://agp.eu.hcompany.ai/api/v2/agents/{agent_name}/revisions/{number}/restore")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_bodyMakes revision
number’s spec current again. History is never rewritten: the restored spec 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.
Returns the restored agent object, with its new revision in the ETag header.
Headers
string
The
ETag of the revision you based this rollback on, for example "5". If the agent has moved past it, the restore fails with 412. Omit it, or send *, to restore regardless.Path parameters
string
required
The agent’s
name (e.g. my-research-bot or myorg/web-helper). Slash-containing names are supported.integer
required
The revision to restore. See List revisions.
Examples
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: "5"'
from hai_agents import Client
client = Client()
agent = client.agents.restore_agent_revision(agent_name="my-research-bot", number=2, if_match='"5"')
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: '"5"' });
console.log(agent.instructions);
Response
{
"name": "my-research-bot",
"description": "Researches a topic and returns a sourced summary.",
"environments": ["h/browser"],
"model": null,
"reasoning_effort": null,
"instructions": "Cite a source for every claim.",
"subagents": null,
"skills": null,
"answer_format": null,
"tools": null
}
Errors
| Status | Cause |
|---|---|
400 | If-Match is not a single revision tag. |
403 | The agent is reserved (h/) and read-only. |
404 | Agent or revision not found, or you don’t have access. |
410 | The revision no longer validates, for example because an environment it names was deleted. |
412 | If-Match names a revision that is no longer current. The ETag header has the current one. |
Was this page helpful?