API Reference Restore Revision
Restore Revision
Bring back a past revision of a project written in Syntext — every file, or the ones you choose — as a new revision.
API key or session token
Bring files back to how they were at revision {number}. The restore is saved as a new revision (source: "restore"), so history is never rewritten and you can undo a restore by restoring again. Like any save, it's a draft until you publish — or send publish: true.
Note
Any workspace member (session JWT), or an API key bound to this project with the full scope.
Path Parameters
Request Body
NameDescription
pathsOnly these files, 1–500 paths. Omit to restore the whole project: every file goes back to how it was, and files that didn't exist then are deleted. With
paths, a listed file that didn't exist then is deleted too.messageThe revision message, up to 500 characters. Defaults to
Restore <what> to revision N.publishPublish the result right away.
Default
falseResponse — 200 OK
•
revision is null when the files already match revision {number}; nothing is written.•
publish is present when you sent publish: true and a revision was written. When the publish couldn't start, build is null and skipped says why — for example { "code": "USAGE_LIMIT_EXCEEDED", "current": 100, "limit": 100 }. The restore is saved either way.Error Responses
400 Bad Request
validation_error — {number} isn't a positive integer, or the body is invalid.
404 Not Found
not_found — no revision with that number in this project.
409 Conflict
•
save_conflict — a file changed while the restore was being written. Try again.•
content_source_github / content_source_upload — the project isn't written in Syntext.413 Payload Too Large
too_many_files or content_too_large — the result would be over the project's 2,000 files or 200 MB.
Was this page helpful? Yes No
Previous
Next
Request
bashJavaScriptPythonGoRubyPHPJavaC#bash
curl -X POST https://api.syntext.dev/v1/projects/3f2a9c1e-8b4d-4e7a-9c21-5d6e7f8a9b0c/content/revisions/9/restore \
-H "Authorization: Bearer stx_A1b2C3d4_..." \
-H "Content-Type: application/json" \
-d '{ "paths": ["guides/quickstart.mdx"], "publish": true }'
const response = await fetch('https://api.syntext.dev/v1/projects/3f2a9c1e-8b4d-4e7a-9c21-5d6e7f8a9b0c/content/revisions/9/restore', {
method: 'POST',
headers: {
'Authorization': 'Bearer stx_A1b2C3d4_...',
'Content-Type': 'application/json',
},
body: JSON.stringify({
"paths": [
"guides/quickstart.mdx"
],
"publish": true
}),
});
const data = await response.json();
console.log(response.status, data);
import requests
url = "https://api.syntext.dev/v1/projects/3f2a9c1e-8b4d-4e7a-9c21-5d6e7f8a9b0c/content/revisions/9/restore"
headers = {
"Authorization": "Bearer stx_A1b2C3d4_...",
}
payload = {
"paths": [
"guides/quickstart.mdx",
],
"publish": True,
}
response = requests.post(url, headers=headers, json=payload)
print(response.status_code)
print(response.json())
package main
import (
"bytes"
"fmt"
"io"
"net/http"
)
func main() {
payload := []byte(`{
"paths": [
"guides/quickstart.mdx"
],
"publish": true
}`)
req, err := http.NewRequest("POST", "https://api.syntext.dev/v1/projects/3f2a9c1e-8b4d-4e7a-9c21-5d6e7f8a9b0c/content/revisions/9/restore", bytes.NewReader(payload))
if err != nil {
panic(err)
}
req.Header.Set("Authorization", "Bearer stx_A1b2C3d4_...")
req.Header.Set("Content-Type", "application/json")
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 "json"
require "net/http"
require "uri"
uri = URI("https://api.syntext.dev/v1/projects/3f2a9c1e-8b4d-4e7a-9c21-5d6e7f8a9b0c/content/revisions/9/restore")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"
request = Net::HTTP::Post.new(uri)
request["Authorization"] = "Bearer stx_A1b2C3d4_..."
request["Content-Type"] = "application/json"
request.body = JSON.generate({
"paths" => [
"guides/quickstart.mdx",
],
"publish" => true,
})
response = http.request(request)
puts response.code
puts response.body
<?php
$payload = [
'paths' => [
'guides/quickstart.mdx',
],
'publish' => true,
];
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => 'https://api.syntext.dev/v1/projects/3f2a9c1e-8b4d-4e7a-9c21-5d6e7f8a9b0c/content/revisions/9/restore',
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer stx_A1b2C3d4_...',
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode($payload),
]);
$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 {
String payload = """
{
"paths": [
"guides/quickstart.mdx"
],
"publish": true
}
""";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.syntext.dev/v1/projects/3f2a9c1e-8b4d-4e7a-9c21-5d6e7f8a9b0c/content/revisions/9/restore"))
.header("Authorization", "Bearer stx_A1b2C3d4_...")
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString(payload))
.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/3f2a9c1e-8b4d-4e7a-9c21-5d6e7f8a9b0c/content/revisions/9/restore");
request.Headers.TryAddWithoutValidation("Authorization", "Bearer stx_A1b2C3d4_...");
request.Content = new StringContent(
"""
{
"paths": [
"guides/quickstart.mdx"
],
"publish": true
}
""",
Encoding.UTF8,
"application/json");
using var response = await client.SendAsync(request);
Console.WriteLine((int)response.StatusCode);
Console.WriteLine(await response.Content.ReadAsStringAsync());
Responseapplication/json
200OK
{
"data": {
"revision": { "id": "7e3a1b9c-2d4f-4a8e-b6c1-9f0d5e2a7c30", "number": 15 },
"files": [{ "path": "guides/quickstart.mdx", "sha": "3f1c9a7e2b4d6f8a0c1e3b5d7f9a1c3e5b7d9f1a" }],
"publish": { "build": { "id": "b7d2e9a4-1c3f-4b8e-9a6d-2f5c8e1b4a70", "status": "queued" }, "revision": { "id": "7e3a1b9c-2d4f-4a8e-b6c1-9f0d5e2a7c30", "number": 15 } }
}
}