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

> Index a GitHub repository for user-specific search

> Index a GitHub repository for user-specific search

<CodeGroup>
  ```bash cURL theme={null}
  curl --request POST \
    --url https://api.wistx.ai/v1/indexing/repositories \
    --header 'Authorization: Bearer YOUR_API_KEY' \
    --header 'Content-Type: application/json' \
    --data '{
      "repo_url": "https://github.com/owner/repo",
      "branch": "main",
      "name": "My Repository",
      "description": "Production infrastructure repository",
      "tags": ["terraform", "aws"],
      "include_patterns": ["**/*.tf", "**/terraform/**"],
      "exclude_patterns": ["**/node_modules/**", "**/.git/**"]
    }'
  ```

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

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

  response = requests.post(
      url,
      headers={
          "Authorization": f"Bearer {api_key}",
          "Content-Type": "application/json"
      },
      json={
          "repo_url": "https://github.com/owner/repo",
          "branch": "main",
          "name": "My Repository",
          "description": "Production infrastructure repository",
          "tags": ["terraform", "aws"],
          "include_patterns": ["**/*.tf", "**/terraform/**"],
          "exclude_patterns": ["**/node_modules/**", "**/.git/**"]
      }
  )

  data = response.json()
  print(f"Indexing started. Resource ID: {data['resource_id']}")
  ```

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

  const response = await fetch(url, {
    method: "POST",
    headers: {
      "Authorization": `Bearer ${apiKey}`,
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      repo_url: "https://github.com/owner/repo",
      branch: "main",
      name: "My Repository",
      description: "Production infrastructure repository",
      tags: ["terraform", "aws"],
      include_patterns: ["**/*.tf", "**/terraform/**"],
      exclude_patterns: ["**/node_modules/**", "**/.git/**"]
    })
  });

  const data = await response.json();
  console.log(`Indexing started. Resource ID: ${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/repositories"

      payload := map[string]interface{}{
          "repo_url": "https://github.com/owner/repo",
          "branch": "main",
          "name": "My Repository",
          "description": "Production infrastructure repository",
          "tags": []string{"terraform", "aws"},
          "include_patterns": []string{"**/*.tf", "**/terraform/**"},
          "exclude_patterns": []string{"**/node_modules/**", "**/.git/**"},
      }

      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("Indexing started. Resource ID: %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/repositories")

  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 = {
    repo_url: "https://github.com/owner/repo",
    branch: "main",
    name: "My Repository",
    description: "Production infrastructure repository",
    tags: ["terraform", "aws"],
    include_patterns: ["**/*.tf", "**/terraform/**"],
    exclude_patterns: ["**/node_modules/**", "**/.git/**"]
  }.to_json

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

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

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

  $data = [
      "repo_url" => "https://github.com/owner/repo",
      "branch" => "main",
      "name" => "My Repository",
      "description" => "Production infrastructure repository",
      "tags" => ["terraform", "aws"],
      "include_patterns" => ["**/*.tf", "**/terraform/**"],
      "exclude_patterns" => ["**/node_modules/**", "**/.git/**"]
  ];

  $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 "Indexing started. Resource ID: " . $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 IndexRepository {
      public static void main(String[] args) throws Exception {
          String apiKey = "YOUR_API_KEY";
          URL url = new URL("https://api.wistx.ai/v1/indexing/repositories");
          
          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("repo_url", "https://github.com/owner/repo");
          payload.addProperty("branch", "main");
          payload.addProperty("name", "My Repository");
          payload.addProperty("description", "Production infrastructure repository");
          
          Gson gson = new Gson();
          String[] tags = {"terraform", "aws"};
          String[] includePatterns = {"**/*.tf", "**/terraform/**"};
          String[] excludePatterns = {"**/node_modules/**", "**/.git/**"};
          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="repo_url" type="string" required>
  GitHub repository URL in format `https://github.com/owner/repo` or `owner/repo`.
</ParamField>

<ParamField body="branch" type="string">
  Branch to index. Defaults to `main` if not specified.
</ParamField>

<ParamField body="name" type="string">
  Custom name for the resource. If not provided, uses repository name.
</ParamField>

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

<ParamField body="tags" type="array[string]">
  Tags for categorization (e.g., `["terraform", "aws", "production"]`).
</ParamField>

<ParamField body="github_token" type="string">
  GitHub personal access token. Optional if you've connected GitHub OAuth during signup. Required for private repositories.
</ParamField>

<ParamField body="include_patterns" type="array[string]">
  File path patterns to include (glob patterns). Defaults to DevOps-focused paths if not provided.

  **Examples:** `["**/terraform/**", "**/*.tf", "**/*.yaml"]`
</ParamField>

<ParamField body="exclude_patterns" type="array[string]">
  File path patterns to exclude (glob patterns). Defaults to excluding application code paths if not provided.

  **Examples:** `["**/src/**", "**/app/**", "**/node_modules/**"]`
</ParamField>

## Response

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

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

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

  ```json 403 Forbidden theme={null}
  {
    "error": "GITHUB_OAUTH_REQUIRED",
    "message": "GitHub connection is required. Please connect your GitHub account in settings.",
    "authorization_url": "/v1/oauth/github/authorize"
  }
  ```

  ```json 403 Forbidden theme={null}
  {
    "error": "REPOSITORY_ACCESS_DENIED",
    "message": "Access denied to this private repository. Check repository permissions."
  }
  ```

  ```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 repository indexing",
      "details": null
    },
    "metadata": {
      "request_id": "req_abc123",
      "timestamp": 1704067200.0
    }
  }
  ```
</ResponseExample>

## Related Endpoints

* [Index Documentation](/api-reference/indexing/documentation) - Index a documentation website
* [Index Document](/api-reference/indexing/documents) - Index a single document file
* [List Resources](/api-reference/indexing/resources) - List all indexed resources


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