Replace Document Content
curl --request PUT \
--url https://api.wistx.ai/v1/indexing/documents/{resource_id}/content \
--header 'Content-Type: application/json' \
--data '
{
"document_url": "<string>",
"re_index": true
}
'import requests
url = "https://api.wistx.ai/v1/indexing/documents/{resource_id}/content"
payload = {
"document_url": "<string>",
"re_index": True
}
headers = {"Content-Type": "application/json"}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({document_url: '<string>', re_index: true})
};
fetch('https://api.wistx.ai/v1/indexing/documents/{resource_id}/content', 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://api.wistx.ai/v1/indexing/documents/{resource_id}/content",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'document_url' => '<string>',
're_index' => true
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.wistx.ai/v1/indexing/documents/{resource_id}/content"
payload := strings.NewReader("{\n \"document_url\": \"<string>\",\n \"re_index\": true\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.put("https://api.wistx.ai/v1/indexing/documents/{resource_id}/content")
.header("Content-Type", "application/json")
.body("{\n \"document_url\": \"<string>\",\n \"re_index\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.wistx.ai/v1/indexing/documents/{resource_id}/content")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"document_url\": \"<string>\",\n \"re_index\": true\n}"
response = http.request(request)
puts response.read_body{
"resource_id": "res_abc123",
"resource_type": "document",
"status": "indexing",
"progress": {
"percentage": 0,
"stage": "queued",
"message": "Document re-indexing queued"
},
"updated_at": "2024-01-15T10:30:00Z"
}
{
"error": {
"code": "VALIDATION_ERROR",
"message": "Either 'file' or 'document_url' must be provided",
"details": null
},
"metadata": {
"request_id": "req_abc123",
"timestamp": 1704067200.0
}
}
{
"error": {
"code": "VALIDATION_ERROR",
"message": "Cannot provide both 'file' and 'document_url'",
"details": null
},
"metadata": {
"request_id": "req_abc123",
"timestamp": 1704067200.0
}
}
{
"detail": "User ID not found"
}
{
"error": {
"code": "FILE_NOT_FOUND",
"message": "File not found: /path/to/document.pdf",
"details": null
},
"metadata": {
"request_id": "req_abc123",
"timestamp": 1704067200.0
}
}
{
"detail": "Resource not found or access denied"
}
{
"error": {
"code": "REPLACE_ERROR",
"message": "Failed to replace document content",
"details": null
},
"metadata": {
"request_id": "req_abc123",
"timestamp": 1704067200.0
}
}
Indexing
Replace Document Content
Replace document content and optionally re-index
PUT
/
v1
/
indexing
/
documents
/
{resource_id}
/
content
Replace Document Content
curl --request PUT \
--url https://api.wistx.ai/v1/indexing/documents/{resource_id}/content \
--header 'Content-Type: application/json' \
--data '
{
"document_url": "<string>",
"re_index": true
}
'import requests
url = "https://api.wistx.ai/v1/indexing/documents/{resource_id}/content"
payload = {
"document_url": "<string>",
"re_index": True
}
headers = {"Content-Type": "application/json"}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({document_url: '<string>', re_index: true})
};
fetch('https://api.wistx.ai/v1/indexing/documents/{resource_id}/content', 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://api.wistx.ai/v1/indexing/documents/{resource_id}/content",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'document_url' => '<string>',
're_index' => true
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.wistx.ai/v1/indexing/documents/{resource_id}/content"
payload := strings.NewReader("{\n \"document_url\": \"<string>\",\n \"re_index\": true\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.put("https://api.wistx.ai/v1/indexing/documents/{resource_id}/content")
.header("Content-Type", "application/json")
.body("{\n \"document_url\": \"<string>\",\n \"re_index\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.wistx.ai/v1/indexing/documents/{resource_id}/content")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"document_url\": \"<string>\",\n \"re_index\": true\n}"
response = http.request(request)
puts response.read_body{
"resource_id": "res_abc123",
"resource_type": "document",
"status": "indexing",
"progress": {
"percentage": 0,
"stage": "queued",
"message": "Document re-indexing queued"
},
"updated_at": "2024-01-15T10:30:00Z"
}
{
"error": {
"code": "VALIDATION_ERROR",
"message": "Either 'file' or 'document_url' must be provided",
"details": null
},
"metadata": {
"request_id": "req_abc123",
"timestamp": 1704067200.0
}
}
{
"error": {
"code": "VALIDATION_ERROR",
"message": "Cannot provide both 'file' and 'document_url'",
"details": null
},
"metadata": {
"request_id": "req_abc123",
"timestamp": 1704067200.0
}
}
{
"detail": "User ID not found"
}
{
"error": {
"code": "FILE_NOT_FOUND",
"message": "File not found: /path/to/document.pdf",
"details": null
},
"metadata": {
"request_id": "req_abc123",
"timestamp": 1704067200.0
}
}
{
"detail": "Resource not found or access denied"
}
{
"error": {
"code": "REPLACE_ERROR",
"message": "Failed to replace document content",
"details": null
},
"metadata": {
"request_id": "req_abc123",
"timestamp": 1704067200.0
}
}
Replace document content and optionally re-index
curl --request PUT \
--url https://api.wistx.ai/v1/indexing/documents/res_abc123/content \
--header 'Authorization: Bearer YOUR_API_KEY' \
--form 'file=@/path/to/new-document.pdf' \
--form 're_index=true'
import requests
api_key = "YOUR_API_KEY"
resource_id = "res_abc123"
with open("new-document.pdf", "rb") as f:
response = requests.put(
f"https://api.wistx.ai/v1/indexing/documents/{resource_id}/content",
headers={"Authorization": f"Bearer {api_key}"},
files={"file": f},
data={"re_index": "true"}
)
resource = response.json()
print(f"Content replaced: {resource['status']}")
const apiKey = "YOUR_API_KEY";
const resourceId = "res_abc123";
const formData = new FormData();
formData.append("file", fileInput.files[0]);
formData.append("re_index", "true");
const response = await fetch(
`https://api.wistx.ai/v1/indexing/documents/${resourceId}/content`,
{
method: "PUT",
headers: {
Authorization: `Bearer ${apiKey}`
},
body: formData
}
);
const resource = await response.json();
console.log(`Content replaced: ${resource.status}`);
package main
import (
"bytes"
"fmt"
"io"
"mime/multipart"
"net/http"
"os"
)
func main() {
apiKey := "YOUR_API_KEY"
resourceID := "res_abc123"
url := fmt.Sprintf("https://api.wistx.ai/v1/indexing/documents/%s/content", resourceID)
file, _ := os.Open("new-document.pdf")
defer file.Close()
body := &bytes.Buffer{}
writer := multipart.NewWriter(body)
part, _ := writer.CreateFormFile("file", "new-document.pdf")
io.Copy(part, file)
writer.WriteField("re_index", "true")
writer.Close()
req, _ := http.NewRequest("PUT", url, body)
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", apiKey))
req.Header.Set("Content-Type", writer.FormDataContentType())
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
var resource map[string]interface{}
json.NewDecoder(resp.Body).Decode(&resource)
fmt.Printf("Content replaced: %v\n", resource["status"])
}
require 'net/http'
require 'json'
require 'uri'
api_key = "YOUR_API_KEY"
resource_id = "res_abc123"
url = URI("https://api.wistx.ai/v1/indexing/documents/#{resource_id}/content")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = "Bearer #{api_key}"
form_data = [
['file', File.open('new-document.pdf')],
['re_index', 'true']
]
request.set_form(form_data, 'multipart/form-data')
response = http.request(request)
resource = JSON.parse(response.body)
puts "Content replaced: #{resource['status']}"
<?php
$apiKey = "YOUR_API_KEY";
$resourceId = "res_abc123";
$url = "https://api.wistx.ai/v1/indexing/documents/" . $resourceId . "/content";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer " . $apiKey
]);
$file = new CURLFile('new-document.pdf', 'application/pdf', 'new-document.pdf');
curl_setopt($ch, CURLOPT_POSTFIELDS, [
'file' => $file,
're_index' => 'true'
]);
$response = curl_exec($ch);
curl_close($ch);
$resource = json_decode($response, true);
echo "Content replaced: " . $resource['status'];
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Paths;
public class ReplaceDocumentContent {
public static void main(String[] args) throws Exception {
String apiKey = "YOUR_API_KEY";
String resourceId = "res_abc123";
URL url = new URL("https://api.wistx.ai/v1/indexing/documents/" + resourceId + "/content");
String boundary = "----WebKitFormBoundary" + System.currentTimeMillis();
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("PUT");
conn.setRequestProperty("Authorization", "Bearer " + apiKey);
conn.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + boundary);
conn.setDoOutput(true);
try (OutputStream os = conn.getOutputStream();
PrintWriter writer = new PrintWriter(new OutputStreamWriter(os, "UTF-8"), true)) {
writer.append("--" + boundary).append("\r\n");
writer.append("Content-Disposition: form-data; name=\"file\"; filename=\"new-document.pdf\"").append("\r\n");
writer.append("Content-Type: application/pdf").append("\r\n");
writer.append("\r\n").flush();
Files.copy(Paths.get("new-document.pdf"), os);
os.flush();
writer.append("\r\n").flush();
writer.append("--" + boundary).append("\r\n");
writer.append("Content-Disposition: form-data; name=\"re_index\"").append("\r\n");
writer.append("\r\n");
writer.append("true").append("\r\n").flush();
writer.append("--" + boundary + "--").append("\r\n").flush();
}
BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream(), "utf-8"));
StringBuilder response = new StringBuilder();
String responseLine;
while ((responseLine = br.readLine()) != null) {
response.append(responseLine.trim());
}
System.out.println(response.toString());
}
}
Path Parameters
string
required
Resource ID of the document to replace.
Request Parameters
file
New file to upload. Either
file or document_url is required.string
New document URL (http/https). Either
file or document_url is required.boolean
Whether to re-index after replacement.Default:
trueResponse
{
"resource_id": "res_abc123",
"resource_type": "document",
"status": "indexing",
"progress": {
"percentage": 0,
"stage": "queued",
"message": "Document re-indexing queued"
},
"updated_at": "2024-01-15T10:30:00Z"
}
{
"error": {
"code": "VALIDATION_ERROR",
"message": "Either 'file' or 'document_url' must be provided",
"details": null
},
"metadata": {
"request_id": "req_abc123",
"timestamp": 1704067200.0
}
}
{
"error": {
"code": "VALIDATION_ERROR",
"message": "Cannot provide both 'file' and 'document_url'",
"details": null
},
"metadata": {
"request_id": "req_abc123",
"timestamp": 1704067200.0
}
}
{
"detail": "User ID not found"
}
{
"error": {
"code": "FILE_NOT_FOUND",
"message": "File not found: /path/to/document.pdf",
"details": null
},
"metadata": {
"request_id": "req_abc123",
"timestamp": 1704067200.0
}
}
{
"detail": "Resource not found or access denied"
}
{
"error": {
"code": "REPLACE_ERROR",
"message": "Failed to replace document content",
"details": null
},
"metadata": {
"request_id": "req_abc123",
"timestamp": 1704067200.0
}
}
Related Endpoints
- Update Document Metadata - Update metadata only
- Re-index Document - Re-index existing document
- Get Resource Status - Check resource status