> ## Documentation Index
> Fetch the complete documentation index at: https://docs.wistx.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Re-index Document

> Re-index an existing document with latest processing logic

> Re-index an existing document with latest processing logic

<CodeGroup>
  ```bash cURL theme={null}
  curl --request POST \
    --url https://api.wistx.ai/v1/indexing/documents/res_abc123/reindex \
    --header 'Authorization: Bearer YOUR_API_KEY' \
    --header 'Content-Type: application/json' \
    --data '{
      "force": false
    }'
  ```

  ```python Python theme={null}
  import requests

  api_key = "YOUR_API_KEY"
  resource_id = "res_abc123"

  response = requests.post(
      f"https://api.wistx.ai/v1/indexing/documents/{resource_id}/reindex",
      headers={
          "Authorization": f"Bearer {api_key}",
          "Content-Type": "application/json"
      },
      json={"force": False}
  )

  resource = response.json()
  print(f"Re-indexing started: {resource['status']}")
  ```

  ```javascript JavaScript theme={null}
  const apiKey = "YOUR_API_KEY";
  const resourceId = "res_abc123";

  const response = await fetch(
    `https://api.wistx.ai/v1/indexing/documents/${resourceId}/reindex`,
    {
      method: "POST",
      headers: {
        Authorization: `Bearer ${apiKey}`,
        "Content-Type": "application/json"
      },
      body: JSON.stringify({
        force: false
      })
    }
  );

  const resource = await response.json();
  console.log(`Re-indexing started: ${resource.status}`);
  ```

  ```go Go theme={null}
  package main

  import (
      "bytes"
      "encoding/json"
      "fmt"
      "net/http"
  )

  func main() {
      apiKey := "YOUR_API_KEY"
      resourceID := "res_abc123"
      url := fmt.Sprintf("https://api.wistx.ai/v1/indexing/documents/%s/reindex", resourceID)

      payload := map[string]interface{}{
          "force": false,
      }

      jsonData, _ := json.Marshal(payload)
      req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
      req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", apiKey))
      req.Header.Set("Content-Type", "application/json")

      client := &http.Client{}
      resp, _ := client.Do(req)
      defer resp.Body.Close()

      var resource map[string]interface{}
      json.NewDecoder(resp.Body).Decode(&resource)
      fmt.Printf("Re-indexing started: %v\n", resource["status"])
  }
  ```

  ```ruby Ruby theme={null}
  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}/reindex")

  http = Net::HTTP.new(url.host, url.port)
  http.use_ssl = true

  request = Net::HTTP::Post.new(url)
  request["Authorization"] = "Bearer #{api_key}"
  request["Content-Type"] = "application/json"
  request.body = {
    force: false
  }.to_json

  response = http.request(request)
  resource = JSON.parse(response.body)
  puts "Re-indexing started: #{resource['status']}"
  ```

  ```php PHP theme={null}
  <?php

  $apiKey = "YOUR_API_KEY";
  $resourceId = "res_abc123";
  $url = "https://api.wistx.ai/v1/indexing/documents/" . $resourceId . "/reindex";

  $data = [
      "force" => false
  ];

  $ch = curl_init($url);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_POST, true);
  curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
  curl_setopt($ch, CURLOPT_HTTPHEADER, [
      "Authorization: Bearer " . $apiKey,
      "Content-Type: application/json"
  ]);

  $response = curl_exec($ch);
  curl_close($ch);

  $resource = json_decode($response, true);
  echo "Re-indexing started: " . $resource['status'];
  ```

  ```java Java theme={null}
  import java.net.HttpURLConnection;
  import java.net.URL;
  import java.io.OutputStream;
  import java.io.BufferedReader;
  import java.io.InputStreamReader;
  import com.google.gson.Gson;
  import com.google.gson.JsonObject;

  public class ReindexDocument {
      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 + "/reindex");
          
          HttpURLConnection conn = (HttpURLConnection) url.openConnection();
          conn.setRequestMethod("POST");
          conn.setRequestProperty("Authorization", "Bearer " + apiKey);
          conn.setRequestProperty("Content-Type", "application/json");
          conn.setDoOutput(true);
          
          JsonObject payload = new JsonObject();
          payload.addProperty("force", false);
          
          Gson gson = new Gson();
          try (OutputStream os = conn.getOutputStream()) {
              byte[] input = gson.toJson(payload).getBytes("utf-8");
              os.write(input, 0, input.length);
          }
          
          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());
      }
  }
  ```
</CodeGroup>

## Path Parameters

<ParamField path="resource_id" type="string" required>
  Resource ID of the document to re-index.
</ParamField>

## Request Parameters

<ParamField body="force" type="boolean">
  Force re-indexing even if document hasn't changed.

  **Default:** `false`
</ParamField>

## Response

<ResponseExample>
  ```json 200 Success theme={null}
  {
    "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"
  }
  ```

  ```json 400 Bad Request theme={null}
  {
    "error": {
      "code": "VALIDATION_ERROR",
      "message": "Invalid request parameters",
      "details": null
    },
    "metadata": {
      "request_id": "req_abc123",
      "timestamp": 1704067200.0
    }
  }
  ```

  ```json 401 Unauthorized theme={null}
  {
    "detail": "User ID not found"
  }
  ```

  ```json 404 Not Found theme={null}
  {
    "detail": "Resource not found or access denied"
  }
  ```

  ```json 500 Internal Server Error theme={null}
  {
    "error": {
      "code": "REINDEX_ERROR",
      "message": "Failed to re-index document",
      "details": null
    },
    "metadata": {
      "request_id": "req_abc123",
      "timestamp": 1704067200.0
    }
  }
  ```
</ResponseExample>

## Related Endpoints

* [Update Document Metadata](/api-reference/indexing/update-document-metadata) - Update metadata only
* [Replace Document Content](/api-reference/indexing/replace-document-content) - Replace content
* [Get Resource Status](/api-reference/indexing/resource-status) - Check resource status


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.