API Reference Retrain the AI
Retrain the AI
Rebuild the AI assistant's knowledge index from the latest deployed docs.
Session token
Rebuilds the AI assistant's knowledge index. Every page from your latest deployed docs is re-read, so answers immediately reflect current content.
Note
Retraining happens automatically on every deploy — you normally never need this endpoint. Use it only to force a rebuild (e.g. after a partial index or unexpected answer quality issues).
Note
Session JWT and org membership required (any role). API keys get 401.
Path Parameters
NameDescription
projectIdThe project ID.
Response
Returns 202 Accepted — retraining runs in the background.
Errors
| Status | Code | Meaning |
|---|---|---|
| 409 | already_running | A retrain is already in progress for this project. |
| 400 | no_deployed_build | No deployed build with source available — deploy your docs first. For a project deployed with stx deploy, only the newest production upload counts: preview uploads are never used to retrain. |
Poll Retrain Status
GET
/v1/projects/{projectId}/ai/retrainbash
curl "https://api.syntext.dev/v1/projects/$PROJECT_ID/ai/retrain" \
-H "Authorization: Bearer $SYNTEXT_JWT"
Response
pageCount is how many pages were read; chunkCount is how many sections of them the assistant can answer from.
status is one of idle, running, completed, or failed (failures include an error message).
Was this page helpful? Yes No
Previous
Request
bashJavaScriptPythonGoRubyPHPJavaC#bash
curl -X POST "https://api.syntext.dev/v1/projects/$PROJECT_ID/ai/retrain" \
-H "Authorization: Bearer $SYNTEXT_JWT"
// A browser has no environment variables: set these to your values.
const PROJECT_ID = '<PROJECT_ID>';
const SYNTEXT_JWT = '<SYNTEXT_JWT>';
const response = await fetch(`https://api.syntext.dev/v1/projects/${PROJECT_ID}/ai/retrain`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${SYNTEXT_JWT}`,
},
});
const data = await response.json();
console.log(response.status, data);
import os
import requests
url = f"https://api.syntext.dev/v1/projects/{os.environ['PROJECT_ID']}/ai/retrain"
headers = {
"Authorization": f"Bearer {os.environ['SYNTEXT_JWT']}",
}
response = requests.post(url, headers=headers)
print(response.status_code)
print(response.json())
package main
import (
"fmt"
"io"
"net/http"
"os"
)
func main() {
req, err := http.NewRequest("POST", "https://api.syntext.dev/v1/projects/"+os.Getenv("PROJECT_ID")+"/ai/retrain", nil)
if err != nil {
panic(err)
}
req.Header.Set("Authorization", "Bearer "+os.Getenv("SYNTEXT_JWT"))
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
body, err := io.ReadAll(res.Body)
if err != nil {
panic(err)
}
fmt.Println(res.Status)
fmt.Println(string(body))
}
require "net/http"
require "uri"
uri = URI("https://api.syntext.dev/v1/projects/#{ENV.fetch("PROJECT_ID")}/ai/retrain")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"
request = Net::HTTP::Post.new(uri)
request["Authorization"] = "Bearer #{ENV.fetch("SYNTEXT_JWT")}"
response = http.request(request)
puts response.code
puts response.body
<?php
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => 'https://api.syntext.dev/v1/projects/' . getenv('PROJECT_ID') . '/ai/retrain',
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('SYNTEXT_JWT'),
],
]);
$response = curl_exec($ch);
if ($response === false) {
throw new RuntimeException(curl_error($ch));
}
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
curl_close($ch);
echo $status, PHP_EOL, $response, PHP_EOL;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) throws Exception {
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.syntext.dev/v1/projects/" + System.getenv("PROJECT_ID") + "/ai/retrain"))
.header("Authorization", "Bearer " + System.getenv("SYNTEXT_JWT"))
.method("POST", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse<String> response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode());
System.out.println(response.body());
}
}
using System.Net.Http;
using System.Text;
using var client = new HttpClient();
using var request = new HttpRequestMessage(HttpMethod.Post, "https://api.syntext.dev/v1/projects/" + Environment.GetEnvironmentVariable("PROJECT_ID") + "/ai/retrain");
request.Headers.TryAddWithoutValidation("Authorization", "Bearer " + Environment.GetEnvironmentVariable("SYNTEXT_JWT"));
using var response = await client.SendAsync(request);
Console.WriteLine((int)response.StatusCode);
Console.WriteLine(await response.Content.ReadAsStringAsync());
Responseapplication/json
json
{
"data": {
"status": "running",
"startedAt": "2025-01-15T10:30:00.000Z"
}
}
Responseapplication/json
json
{
"data": {
"status": "completed",
"startedAt": "2025-01-15T10:30:00.000Z",
"finishedAt": "2025-01-15T10:30:42.000Z",
"pageCount": 38,
"chunkCount": 214
}
}