> ## 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.

# Index Document

> Index a single document file for user-specific search

> Index a single document file (PDF, DOCX, Markdown, TXT) for user-specific search

<CodeGroup>
  ```bash cURL theme={null}
  curl --request POST \
    --url https://api.wistx.ai/v1/indexing/documents \
    --header 'Authorization: Bearer YOUR_API_KEY' \
    --header 'Content-Type: application/json' \
    --data '{
      "content_url": "https://docs.example.com",
      "name": "Example Documentation",
      "description": "Product documentation",
      "tags": ["docs", "api"],
      "include_patterns": ["/docs/", "/api/"],
      "exclude_patterns": ["/admin/", "/private/"]
    }'
  ```

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

  api_key = "YOUR_API_KEY"
  url = "https://api.wistx.ai/v1/indexing/documentation"

  response = requests.post(
      url,
      headers={
          "Authorization": f"Bearer {api_key}",
          "Content-Type": "application/json"
      },
      json={
          "content_url": "https://docs.example.com",
          "name": "Example Documentation",
          "description": "Product documentation",
          "tags": ["docs", "api"],
          "include_patterns": ["/docs/", "/api/"],
          "exclude_patterns": ["/admin/", "/private/"]
      }
  )

  data = response.json()
  print(f"Documentation indexing started: {data['resource_id']}")
  ```

  ```javascript JavaScript theme={null}
  const apiKey = "YOUR_API_KEY";
  const url = "https://api.wistx.ai/v1/indexing/documentation";

  const response = await fetch(url, {
    method: "POST",
    headers: {
      "Authorization": `Bearer ${apiKey}`,
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      content_url: "https://docs.example.com",
      name: "Example Documentation",
      description: "Product documentation",
      tags: ["docs", "api"],
      include_patterns: ["/docs/", "/api/"],
      exclude_patterns: ["/admin/", "/private/"]
    })
  });

  const data = await response.json();
  console.log(`Documentation indexing started: ${data.resource_id}`);
  ```

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

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

  func main() {
      apiKey := "YOUR_API_KEY"
      url := "https://api.wistx.ai/v1/indexing/documentation"

      payload := map[string]interface{}{
          "content_url": "https://docs.example.com",
          "name": "Example Documentation",
          "description": "Product documentation",
          "tags": []string{"docs", "api"},
          "include_patterns": []string{"/docs/", "/api/"},
          "exclude_patterns": []string{"/admin/", "/private/"},
      }

      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 result map[string]interface{}
      json.NewDecoder(resp.Body).Decode(&result)
      fmt.Printf("Documentation indexing started: %v\n", result["resource_id"])
  }
  ```

  ```ruby Ruby theme={null}
  require 'net/http'
  require 'json'
  require 'uri'

  api_key = "YOUR_API_KEY"
  url = URI("https://api.wistx.ai/v1/indexing/documentation")

  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 = {
    content_url: "https://docs.example.com",
    name: "Example Documentation",
    description: "Product documentation",
    tags: ["docs", "api"],
    include_patterns: ["/docs/", "/api/"],
    exclude_patterns: ["/admin/", "/private/"]
  }.to_json

  response = http.request(request)
  data = JSON.parse(response.body)
  puts "Documentation indexing started: #{data['resource_id']}"
  ```

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

  $apiKey = "YOUR_API_KEY";
  $url = "https://api.wistx.ai/v1/indexing/documentation";

  $data = [
      "content_url" => "https://docs.example.com",
      "name" => "Example Documentation",
      "description" => "Product documentation",
      "tags" => ["docs", "api"],
      "include_patterns" => ["/docs/", "/api/"],
      "exclude_patterns" => ["/admin/", "/private/"]
  ];

  $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);

  $data = json_decode($response, true);
  echo "Documentation indexing started: " . $data['resource_id'];
  ```

  ```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 IndexDocumentation {
      public static void main(String[] args) throws Exception {
          String apiKey = "YOUR_API_KEY";
          URL url = new URL("https://api.wistx.ai/v1/indexing/documentation");
          
          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("content_url", "https://docs.example.com");
          payload.addProperty("name", "Example Documentation");
          payload.addProperty("description", "Product documentation");
          
          Gson gson = new Gson();
          String[] tags = {"docs", "api"};
          String[] includePatterns = {"/docs/", "/api/"};
          String[] excludePatterns = {"/admin/", "/private/"};
          payload.add("tags", gson.toJsonTree(tags));
          payload.add("include_patterns", gson.toJsonTree(includePatterns));
          payload.add("exclude_patterns", gson.toJsonTree(excludePatterns));
          
          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>

### Request Parameters

<ParamField body="content_url" type="string" required>
  Documentation website URL to crawl and index.
</ParamField>

<ParamField body="name" type="string">
  Custom name for the resource.
</ParamField>

<ParamField body="description" type="string">
  Description of the documentation.
</ParamField>

<ParamField body="tags" type="array[string]">
  Tags for categorization.
</ParamField>

<ParamField body="include_patterns" type="array[string]">
  URL patterns to include (e.g., `["/docs/", "/api/"]`).
</ParamField>

<ParamField body="exclude_patterns" type="array[string]">
  URL patterns to exclude (e.g., `["/admin/", "/private/"]`).
</ParamField>

### Response

<ResponseExample>
  ```json 202 Accepted theme={null}
  {
    "resource_id": "res_abc123",
    "status": "pending",
    "progress": {
      "percentage": 0,
      "stage": "queued",
      "message": "Documentation indexing queued"
    },
    "message": "Documentation indexing started"
  }
  ```

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

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

  ```json 429 Too Many Requests theme={null}
  {
    "error": {
      "code": "QUOTA_EXCEEDED",
      "message": "Indexing quota exceeded",
      "details": {
        "limit_type": "indexes_per_month",
        "current": 3,
        "limit": 3
      }
    },
    "metadata": {
      "request_id": "req_abc123",
      "timestamp": 1704067200.0
    }
  }
  ```

  ```json 500 Internal Server Error theme={null}
  {
    "error": {
      "code": "INDEXING_ERROR",
      "message": "Failed to start documentation indexing",
      "details": null
    },
    "metadata": {
      "request_id": "req_abc123",
      "timestamp": 1704067200.0
    }
  }
  ```
</ResponseExample>


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