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

# Regex Search

> Search user's indexed codebase using regex patterns

Search your indexed repositories, documentation, and documents using regex patterns. Perfect for exact pattern matching, security audits (finding secrets, API keys), compliance checks (finding violations), and code analysis.

## Endpoint

`POST /v1/search/regex`

## Request Body

<ParamField body="pattern" type="string" optional>
  Regular expression pattern to search for (required if template not provided). Maximum length: 10,000 characters.
</ParamField>

<ParamField body="template" type="string" optional>
  Use pre-built pattern template instead of custom pattern. Available templates: `api_key`, `password`, `secret_key`, `token`, `credential`, `private_key`, `ssh_key`, `aws_access_key`, `aws_secret_key`, `github_token`, `slack_token`, `jwt_token`, `ip_address`, `email`, `credit_card`, `ssn`, `unencrypted_storage`, `public_access`, `publicly_accessible`, `missing_backup`, `no_encryption`, `no_versioning`, `no_logging`, `no_mfa`, `insecure_protocol`, `latest_tag`, `no_resource_limits`, `hardcoded_port`, `hardcoded_url`, `function_definition`, `class_definition`, `terraform_resource`, `terraform_data_source`, `terraform_variable`, `kubernetes_secret`, `kubernetes_configmap`, `docker_expose`, `docker_volume`, `ansible_vault`, `ansible_playbook`, `cloudformation_resource`, `cloudformation_output`.
</ParamField>

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

<ParamField body="resource_ids" type="array" optional>
  Filter by specific indexed resource IDs.
</ParamField>

<ParamField body="resource_types" type="array" optional>
  Filter by resource type: `repository`, `documentation`, `document`.
</ParamField>

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

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

<ParamField body="cloud_provider" type="string" optional>
  Filter by cloud provider mentioned in code: `aws`, `gcp`, `azure`.
</ParamField>

<ParamField body="case_sensitive" type="boolean" default="false">
  Case-sensitive matching.
</ParamField>

<ParamField body="multiline" type="boolean" default="false">
  Multiline mode (^ and \$ match line boundaries).
</ParamField>

<ParamField body="dotall" type="boolean" default="false">
  Dot matches newline.
</ParamField>

<ParamField body="include_context" type="boolean" default="true">
  Include surrounding code context around matches.
</ParamField>

<ParamField body="context_lines" type="integer" default="3" min="0" max="10">
  Number of lines before/after match to include in context.
</ParamField>

<ParamField body="limit" type="integer" default="100" min="1" max="1000">
  Maximum number of results to return.
</ParamField>

<ParamField body="timeout" type="number" default="30.0" min="1.0" max="300.0">
  Maximum search time in seconds.
</ParamField>

## Request Example

<CodeGroup>
  ```bash cURL theme={null}
  curl --request POST \
    --url https://api.wistx.ai/v1/search/regex \
    --header 'Authorization: Bearer YOUR_API_KEY' \
    --header 'Content-Type: application/json' \
    --data '{
      "template": "api_key",
      "repositories": ["owner/repo"],
      "include_context": true,
      "context_lines": 3,
      "limit": 50
    }'
  ```

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

  api_key = "YOUR_API_KEY"
  response = requests.post(
      "https://api.wistx.ai/v1/search/regex",
      headers={
          "Authorization": f"Bearer {api_key}",
          "Content-Type": "application/json"
      },
      json={
          "template": "api_key",
          "repositories": ["owner/repo"],
          "include_context": True,
          "context_lines": 3,
          "limit": 50
      }
  )
  print(response.json())
  ```

  ```javascript JavaScript theme={null}
  const apiKey = "YOUR_API_KEY";
  const response = await fetch("https://api.wistx.ai/v1/search/regex", {
    method: "POST",
    headers: {
      "Authorization": `Bearer ${apiKey}`,
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      template: "api_key",
      repositories: ["owner/repo"],
      include_context: true,
      context_lines: 3,
      limit: 50
    })
  });
  const data = await response.json();
  console.log(data);
  ```

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

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

  func main() {
      apiKey := "YOUR_API_KEY"
      payload := map[string]interface{}{
          "template": "api_key",
          "repositories": []string{"owner/repo"},
          "include_context": true,
          "context_lines": 3,
          "limit": 50,
      }
      jsonData, _ := json.Marshal(payload)
      req, _ := http.NewRequest("POST", "https://api.wistx.ai/v1/search/regex", bytes.NewBuffer(jsonData))
      req.Header.Set("Authorization", "Bearer "+apiKey)
      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/regex')
  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 = {
    template: "api_key",
    repositories: ["owner/repo"],
    include_context: true,
    context_lines: 3,
    limit: 50
  }.to_json
  response = http.request(request)
  puts response.body
  ```

  ```php PHP theme={null}
  <?php
  $apiKey = "YOUR_API_KEY";
  $data = [
      "template" => "api_key",
      "repositories" => ["owner/repo"],
      "include_context" => true,
      "context_lines" => 3,
      "limit" => 50
  ];
  $ch = curl_init("https://api.wistx.ai/v1/search/regex");
  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);
  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 com.fasterxml.jackson.databind.ObjectMapper;

  String apiKey = "YOUR_API_KEY";
  Map<String, Object> payload = Map.of(
      "template", "api_key",
      "repositories", List.of("owner/repo"),
      "include_context", true,
      "context_lines", 3,
      "limit", 50
  );
  ObjectMapper mapper = new ObjectMapper();
  String json = mapper.writeValueAsString(payload);
  HttpRequest request = HttpRequest.newBuilder()
      .uri(URI.create("https://api.wistx.ai/v1/search/regex"))
      .header("Authorization", "Bearer " + apiKey)
      .header("Content-Type", "application/json")
      .POST(HttpRequest.BodyPublishers.ofString(json))
      .build();
  HttpClient client = HttpClient.newHttpClient();
  HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
  System.out.println(response.body());
  ```
</CodeGroup>

## Response Example

<ResponseExample>
  ```json 200 Success theme={null}
  {
    "data": {
      "matches": [
        {
          "file_path": "src/config.py",
          "line_number": 42,
          "match": "api_key = 'sk-1234567890abcdef'",
          "context_before": [
            "# Configuration",
            "def get_config():"
          ],
          "context_after": [
            "    return config",
            ""
          ],
          "resource_id": "resource_123"
        }
      ],
      "resources": [
        {
          "_id": "resource_123",
          "name": "my-repo",
          "resource_type": "repository"
        }
      ],
      "total": 1,
      "pattern_info": {
        "pattern": "api[_-]?key\\s*=\\s*['\"]([^'\"]+)['\"]",
        "template": "api_key",
        "flags": {
          "case_sensitive": false,
          "multiline": false,
          "dotall": false
        },
        "warnings": []
      },
      "performance": {
        "search_time_seconds": 2.34,
        "files_searched": 150,
        "matches_found": 1
      }
    },
    "metadata": {
      "request_id": "req_abc123",
      "timestamp": 1704067200.0,
      "query_time_ms": 2340
    }
  }
  ```

  ```json 400 Bad Request theme={null}
  {
    "error": {
      "code": "VALIDATION_ERROR",
      "message": "Invalid request parameters",
      "details": "Either pattern or template must be provided"
    },
    "metadata": {
      "request_id": "req_abc123",
      "timestamp": 1704067200.0
    }
  }
  ```

  ```json 401 Unauthorized theme={null}
  {
    "error": {
      "code": "UNAUTHORIZED",
      "message": "Invalid or missing API key",
      "details": null
    },
    "metadata": {
      "request_id": "req_abc123",
      "timestamp": 1704067200.0
    }
  }
  ```

  ```json 429 Too Many Requests theme={null}
  {
    "error": {
      "code": "QUOTA_EXCEEDED",
      "message": "Query quota exceeded. Limit: 50 queries/month, Current: 50",
      "details": {
        "limit_type": "queries_per_month",
        "current": 50,
        "limit": 50
      }
    },
    "metadata": {
      "request_id": "req_abc123",
      "timestamp": 1704067200.0
    }
  }
  ```

  ```json 500 Internal Server Error theme={null}
  {
    "error": {
      "code": "INTERNAL_ERROR",
      "message": "An unexpected error occurred",
      "details": "Database connection failed"
    },
    "metadata": {
      "request_id": "req_abc123",
      "timestamp": 1704067200.0
    }
  }
  ```
</ResponseExample>

## Rate Limits

| Plan | Queries/Month |
| - | - |
| Professional | 2,000 |
| Team | 10,000 |
| Enterprise | Unlimited |


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