Skip to main content
POST
/
agents
/
{agentId}
/
sources
/
{sourceId}
/
restore
Restore source
curl --request POST \
  --url https://www.chatbase.co/api/v2/agents/{agentId}/sources/{sourceId}/restore \
  --header 'Authorization: Bearer <token>'
import requests

url = "https://www.chatbase.co/api/v2/agents/{agentId}/sources/{sourceId}/restore"

headers = {"Authorization": "Bearer <token>"}

response = requests.post(url, headers=headers)

print(response.text)
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};

fetch('https://www.chatbase.co/api/v2/agents/{agentId}/sources/{sourceId}/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://www.chatbase.co/api/v2/agents/{agentId}/sources/{sourceId}/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://www.chatbase.co/api/v2/agents/{agentId}/sources/{sourceId}/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://www.chatbase.co/api/v2/agents/{agentId}/sources/{sourceId}/restore")
  .header("Authorization", "Bearer <token>")
  .asString();
require 'uri'
require 'net/http'

url = URI("https://www.chatbase.co/api/v2/agents/{agentId}/sources/{sourceId}/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_body
{
  "id": "<string>",
  "name": "<string>",
  "size": 123,
  "createdAt": "<string>",
  "metadata": {
    "type": "individual"
  }
}
{
  "error": {
    "code": "AUTH_MISSING_API_KEY",
    "message": "Authentication required"
  }
}
{
  "error": {
    "code": "SUBSCRIPTION_API_RESTRICTED_PLAN",
    "message": "A Standard plan or higher is required to access the API"
  }
}
{
  "error": {
    "code": "AGENT_NOT_FOUND",
    "message": "Agent not found"
  }
}
{
  "error": {
    "code": "SOURCE_NOT_RESTORABLE",
    "message": "Source is not pending deletion"
  }
}
{
  "error": {
    "code": "SOURCE_LINK_LIMIT_EXCEEDED",
    "message": "Crawl/sitemap link limit reached"
  }
}
{
  "error": {
    "code": "RATE_LIMIT_TOO_MANY_REQUESTS",
    "message": "Too many requests, please try again later"
  }
}
{
  "error": {
    "code": "INTERNAL_SERVER_ERROR",
    "message": "Something went wrong, please try again"
  }
}

Authorizations

Authorization
string
header
required

API key from your account settings

Path Parameters

agentId
string
required

The agent ID

Minimum string length: 1
Example:

"5QHA6VB-DIAbBhxwqxfdi"

sourceId
string
required

The source ID

Minimum string length: 1
Example:

"a63a69a5-e7a9-4757-b73b-2041854d435d"

Response

Source restored to its previous active state

id
string
required

Source ID

type
enum<string>
required

Source type

Available options:
link,
file,
qna,
notionPage,
text
name
string | null
required

Source name or URL

size
number
required

Source size in bytes

createdAt
string
required

ISO 8601 creation timestamp

status
enum<string>
required

Training status of the source

Available options:
untrained,
trained,
toBeDeleted,
updated
metadata
object
required

Link-specific metadata. Present only for type="link".