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

# Search Codebase

> Search user's indexed repositories, documentation, and documents

Search your indexed codebase (repositories, documentation, and documents) using natural language queries.

<ParamField body="query" type="string" required>
  Natural language search question (1-10,000 characters)
</ParamField>

<ParamField body="repositories" type="string[]">
  List of repositories to search (owner/repo format, e.g., `["owner/repo", "another/org/repo"]`)
</ParamField>

<ParamField body="resource_ids" type="string[]">
  Filter by specific indexed resources (alternative to repositories)
</ParamField>

<ParamField body="resource_types" type="string[]">
  Filter by resource type: `repository`, `documentation`, `document`
</ParamField>

<ParamField body="file_types" type="string[]">
  Filter by file extensions (e.g., `[".tf", ".yaml", ".py", ".md"]`)
</ParamField>

<ParamField body="code_type" type="string">
  Filter by code type: `terraform`, `kubernetes`, `docker`, `python`
</ParamField>

<ParamField body="cloud_provider" type="string">
  Filter by cloud provider mentioned in code (e.g., `aws`, `gcp`, `azure`)
</ParamField>

<ParamField body="include_sources" type="boolean" default="true">
  Include source code snippets in results
</ParamField>

<ParamField body="include_ai_analysis" type="boolean" default="true">
  Include AI-analyzed results with explanations
</ParamField>

<ParamField body="limit" type="integer" default="1000">
  Maximum number of results (1-1000)
</ParamField>

## Request Example

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST "https://api.wistx.ai/v1/search/codebase" \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "query": "How do we configure RDS database backups?",
      "repositories": ["myorg/infrastructure"],
      "file_types": [".tf", ".yaml"],
      "include_sources": true,
      "include_ai_analysis": true,
      "limit": 1000
    }'
  ```

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

  url = "https://api.wistx.ai/v1/search/codebase"
  headers = {
      "Authorization": "Bearer YOUR_API_KEY",
      "Content-Type": "application/json"
  }
  data = {
      "query": "How do we configure RDS database backups?",
      "repositories": ["myorg/infrastructure"],
      "file_types": [".tf", ".yaml"],
      "include_sources": True,
      "include_ai_analysis": True,
      "limit": 1000
  }

  response = requests.post(url, json=data, headers=headers)
  print(response.json())
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch("https://api.wistx.ai/v1/search/codebase", {
    method: "POST",
    headers: {
      "Authorization": "Bearer YOUR_API_KEY",
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      query: "How do we configure RDS database backups?",
      repositories: ["myorg/infrastructure"],
      file_types: [".tf", ".yaml"],
      include_sources: true,
      include_ai_analysis: true,
      limit: 1000
    })
  });

  const data = await response.json();
  console.log(data);
  ```

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

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

  func main() {
      url := "https://api.wistx.ai/v1/search/codebase"
      data := map[string]interface{}{
          "query": "How do we configure RDS database backups?",
          "repositories": []string{"myorg/infrastructure"},
          "file_types": []string{".tf", ".yaml"},
          "include_sources": true,
          "include_ai_analysis": true,
          "limit": 1000,
      }
      
      jsonData, _ := json.Marshal(data)
      req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
      req.Header.Set("Authorization", "Bearer YOUR_API_KEY")
      req.Header.Set("Content-Type", "application/json")
      
      client := &http.Client{}
      resp, _ := client.Do(req)
      defer resp.Body.Close()
  }
  ```

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

  uri = URI('https://api.wistx.ai/v1/search/codebase')
  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = true

  request = Net::HTTP::Post.new(uri.path)
  request['Authorization'] = 'Bearer YOUR_API_KEY'
  request['Content-Type'] = 'application/json'
  request.body = {
    query: "How do we configure RDS database backups?",
    repositories: ["myorg/infrastructure"],
    file_types: [".tf", ".yaml"],
    include_sources: true,
    include_ai_analysis: true,
    limit: 20
  }.to_json

  response = http.request(request)
  puts response.body
  ```

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

  $url = "https://api.wistx.ai/v1/search/codebase";
  $data = [
      "query" => "How do we configure RDS database backups?",
      "repositories" => ["myorg/infrastructure"],
      "file_types" => [".tf", ".yaml"],
      "include_sources" => true,
      "include_ai_analysis" => true,
      "limit" => 20
  ];

  $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 YOUR_API_KEY",
      "Content-Type: application/json"
  ]);

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

  ```java Java theme={null}
  import java.net.http.HttpClient;
  import java.net.http.HttpRequest;
  import java.net.http.HttpResponse;
  import java.net.URI;
  import java.nio.charset.StandardCharsets;

  HttpClient client = HttpClient.newHttpClient();
  String json = "{\"query\":\"How do we configure RDS database backups?\",\"repositories\":[\"myorg/infrastructure\"],\"file_types\":[\".tf\",\".yaml\"],\"include_sources\":true,\"include_ai_analysis\":true,\"limit\":20}";

  HttpRequest request = HttpRequest.newBuilder()
      .uri(URI.create("https://api.wistx.ai/v1/search/codebase"))
      .header("Authorization", "Bearer YOUR_API_KEY")
      .header("Content-Type", "application/json")
      .POST(HttpRequest.BodyPublishers.ofString(json))
      .build();

  HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
  System.out.println(response.body());
  ```
</CodeGroup>

## Response Example

<ResponseExample>
  ```json 200 Success theme={null}
  {
    "data": {
      "results": [
        {
          "article_id": "abc123",
          "resource_id": "res_xyz789",
          "title": "RDS Backup Configuration",
          "content": "resource \"aws_db_instance\" \"main\" {\n  backup_retention_period = 7\n  backup_window = \"03:00-04:00\"\n  ...",
          "source_url": "https://github.com/myorg/infrastructure/blob/main/rds.tf",
          "file_path": "rds.tf",
          "tags": [".tf", "terraform", "rds"],
          "similarity_score": 0.95
        }
      ],
      "resources": [
        {
          "resource_id": "res_xyz789",
          "name": "Infrastructure Repo",
          "resource_type": "repository",
          "repo_url": "https://github.com/myorg/infrastructure"
        }
      ],
      "total": 1,
      "highlights": [
        {
          "article_id": "abc123",
          "highlight": "...backup_retention_period = 7\n  backup_window = \"03:00-04:00\"...",
          "file_path": "rds.tf"
        }
      ],
      "ai_analysis": {
        "summary": "Found RDS backup configuration using Terraform",
        "key_findings": ["Backup retention: 7 days", "Backup window: 03:00-04:00 UTC"]
      }
    },
    "metadata": {
      "request_id": "req_123",
      "timestamp": 1234567890.123,
      "query_time_ms": 245
    }
  }
  ```

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

  ```json 401 Unauthorized theme={null}
  {
    "error": {
      "code": "UNAUTHORIZED",
      "message": "Invalid or expired token"
    },
    "metadata": {
      "request_id": "req_123",
      "timestamp": 1234567890.123
    }
  }
  ```

  ```json 429 Too Many Requests theme={null}
  {
    "error": {
      "code": "QUOTA_EXCEEDED",
      "message": "Query quota exceeded",
      "details": {
        "limit_type": "queries_per_month",
        "current": 1000,
        "limit": 1000
      }
    },
    "metadata": {
      "request_id": "req_123",
      "timestamp": 1234567890.123
    }
  }
  ```

  ```json 500 Internal Server Error theme={null}
  {
    "error": {
      "code": "INTERNAL_ERROR",
      "message": "An unexpected error occurred"
    },
    "metadata": {
      "request_id": "req_123",
      "timestamp": 1234567890.123
    }
  }
  ```

  ```json 503 Service Unavailable theme={null}
  {
    "error": {
      "code": "DATABASE_ERROR",
      "message": "Database connection failed"
    },
    "metadata": {
      "request_id": "req_123",
      "timestamp": 1234567890.123
    }
  }
  ```
</ResponseExample>

## Rate Limits

* **Professional**: 2,000 queries/month
* **Team**: 10,000 queries/month
* **Enterprise**: Unlimited queries/month


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