API Reference Update Preview Status
Update Preview Status
Set the status of a pull-request preview record.
Session token
Set a preview record's status — for example to mark it expired once the pull request closes.
Note
Any workspace member, with a session JWT. API keys are not accepted. Any plan.
Path Parameters
NameDescription
projectIdThe project ID (e.g.,
3f2a9c1e-8b4d-4e7a-9c21-5d6e7f8a9b0c).previewIdThe preview record ID (e.g.,
prv_abc123).Request Body
NameDescription
statusdeployed, failed or expired.Response
Returns { "success": true }. The update only applies to a record of this project. A previewId that does not exist, or belongs to another project, changes nothing and still returns 200. Setting expired also deletes that preview's search index.
Error Responses
| Status | error.code | When |
|---|---|---|
| 400 | validation_error | status is missing or not one of the three values; each problem is in details.issues — see Create Preview |
| 401 | unauthorized | No session JWT, an invalid or expired one, or an API key |
| 401 | session_revoked | The session has been signed out |
| 403 | forbidden | You are not a member of the project's workspace |
| 404 | not_found | The project does not exist or is deleted |
Was this page helpful? Yes No
Previous
Request
cURLJavaScriptPythonGoRubyPHPJavaC#cURL
curl -X PATCH https://api.syntext.dev/v1/projects/3f2a9c1e-8b4d-4e7a-9c21-5d6e7f8a9b0c/previews/prv_abc123 \
-H "Authorization: Bearer $SYNTEXT_JWT" \
-H "Content-Type: application/json" \
-d '{ "status": "expired" }'
// A browser has no environment variables: set these to your values.
const SYNTEXT_JWT = '<SYNTEXT_JWT>';
const response = await fetch('https://api.syntext.dev/v1/projects/3f2a9c1e-8b4d-4e7a-9c21-5d6e7f8a9b0c/previews/prv_abc123', {
method: 'PATCH',
headers: {
'Authorization': `Bearer ${SYNTEXT_JWT}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"status": "expired"
}),
});
const data = await response.json();
console.log(response.status, data);
import os
import requests
url = "https://api.syntext.dev/v1/projects/3f2a9c1e-8b4d-4e7a-9c21-5d6e7f8a9b0c/previews/prv_abc123"
headers = {
"Authorization": f"Bearer {os.environ['SYNTEXT_JWT']}",
}
payload = {
"status": "expired",
}
response = requests.patch(url, headers=headers, json=payload)
print(response.status_code)
print(response.json())
package main
import (
"bytes"
"fmt"
"io"
"net/http"
"os"
)
func main() {
payload := []byte(`{
"status": "expired"
}`)
req, err := http.NewRequest("PATCH", "https://api.syntext.dev/v1/projects/3f2a9c1e-8b4d-4e7a-9c21-5d6e7f8a9b0c/previews/prv_abc123", bytes.NewReader(payload))
if err != nil {
panic(err)
}
req.Header.Set("Authorization", "Bearer "+os.Getenv("SYNTEXT_JWT"))
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/previews/prv_abc123")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"
request = Net::HTTP::Patch.new(uri)
request["Authorization"] = "Bearer #{ENV.fetch("SYNTEXT_JWT")}"
request["Content-Type"] = "application/json"
request.body = JSON.generate({
"status" => "expired",
})
response = http.request(request)
puts response.code
puts response.body
<?php
$payload = [
'status' => 'expired',
];
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => 'https://api.syntext.dev/v1/projects/3f2a9c1e-8b4d-4e7a-9c21-5d6e7f8a9b0c/previews/prv_abc123',
CURLOPT_CUSTOMREQUEST => 'PATCH',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('SYNTEXT_JWT'),
'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 = """
{
"status": "expired"
}
""";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.syntext.dev/v1/projects/3f2a9c1e-8b4d-4e7a-9c21-5d6e7f8a9b0c/previews/prv_abc123"))
.header("Authorization", "Bearer " + System.getenv("SYNTEXT_JWT"))
.header("Content-Type", "application/json")
.method("PATCH", 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.Patch, "https://api.syntext.dev/v1/projects/3f2a9c1e-8b4d-4e7a-9c21-5d6e7f8a9b0c/previews/prv_abc123");
request.Headers.TryAddWithoutValidation("Authorization", "Bearer " + Environment.GetEnvironmentVariable("SYNTEXT_JWT"));
request.Content = new StringContent(
"""
{
"status": "expired"
}
""",
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
{
"success": true
}