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

# Troubleshoot Issue

> Diagnose and fix infrastructure/code issues

Diagnose and fix infrastructure and code issues. Analyzes errors, logs, and code to identify root causes, provides fix recommendations, and prevention strategies.

## Endpoint

`POST /v1/troubleshoot/issue`

## Request Body

<ParamField body="issue_description" type="string" required>
  Description of the issue. Minimum length: 10 characters.
</ParamField>

<ParamField body="infrastructure_type" type="string" optional>
  Type of infrastructure: `terraform`, `kubernetes`, `docker`, `cloudformation`, `ansible`.
</ParamField>

<ParamField body="cloud_provider" type="string" optional>
  Cloud provider: `aws`, `gcp`, `azure`.
</ParamField>

<ParamField body="error_messages" type="array" optional>
  List of error messages encountered.
</ParamField>

<ParamField body="configuration_code" type="string" optional>
  Relevant configuration code that may be causing the issue.
</ParamField>

<ParamField body="logs" type="string" optional>
  Log output from the failing system.
</ParamField>

<ParamField body="resource_type" type="string" optional>
  Resource type (RDS, S3, EKS, etc.).
</ParamField>

## Request Example

<CodeGroup>
  ```bash cURL theme={null}
  curl --request POST \
    --url https://api.wistx.ai/v1/troubleshoot/issue \
    --header 'Authorization: Bearer YOUR_API_KEY' \
    --header 'Content-Type: application/json' \
    --data '{
      "issue_description": "Kubernetes pod failing to start with image pull error",
      "infrastructure_type": "kubernetes",
      "cloud_provider": "aws",
      "error_messages": [
        "Error: ImagePullBackOff",
        "Failed to pull image: repository not found"
      ],
      "configuration_code": "apiVersion: v1\nkind: Pod\nspec:\n  containers:\n  - name: app\n    image: myapp:latest",
      "resource_type": "EKS"
    }'
  ```

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

  api_key = "YOUR_API_KEY"
  response = requests.post(
      "https://api.wistx.ai/v1/troubleshoot/issue",
      headers={
          "Authorization": f"Bearer {api_key}",
          "Content-Type": "application/json"
      },
      json={
          "issue_description": "Kubernetes pod failing to start with image pull error",
          "infrastructure_type": "kubernetes",
          "cloud_provider": "aws",
          "error_messages": [
              "Error: ImagePullBackOff",
              "Failed to pull image: repository not found"
          ],
          "configuration_code": "apiVersion: v1\nkind: Pod\nspec:\n  containers:\n  - name: app\n    image: myapp:latest",
          "resource_type": "EKS"
      }
  )
  print(response.json())
  ```

  ```javascript JavaScript theme={null}
  const apiKey = "YOUR_API_KEY";
  const response = await fetch("https://api.wistx.ai/v1/troubleshoot/issue", {
    method: "POST",
    headers: {
      "Authorization": `Bearer ${apiKey}`,
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      issue_description: "Kubernetes pod failing to start with image pull error",
      infrastructure_type: "kubernetes",
      cloud_provider: "aws",
      error_messages: [
        "Error: ImagePullBackOff",
        "Failed to pull image: repository not found"
      ],
      configuration_code: "apiVersion: v1\nkind: Pod\nspec:\n  containers:\n  - name: app\n    image: myapp:latest",
      resource_type: "EKS"
    })
  });
  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{}{
          "issue_description": "Kubernetes pod failing to start with image pull error",
          "infrastructure_type": "kubernetes",
          "cloud_provider": "aws",
          "error_messages": []string{
              "Error: ImagePullBackOff",
              "Failed to pull image: repository not found",
          },
          "configuration_code": "apiVersion: v1\nkind: Pod\nspec:\n  containers:\n  - name: app\n    image: myapp:latest",
          "resource_type": "EKS",
      }
      jsonData, _ := json.Marshal(payload)
      req, _ := http.NewRequest("POST", "https://api.wistx.ai/v1/troubleshoot/issue", 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/troubleshoot/issue')
  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 = {
    issue_description: "Kubernetes pod failing to start with image pull error",
    infrastructure_type: "kubernetes",
    cloud_provider: "aws",
    error_messages: [
      "Error: ImagePullBackOff",
      "Failed to pull image: repository not found"
    ],
    configuration_code: "apiVersion: v1\nkind: Pod\nspec:\n  containers:\n  - name: app\n    image: myapp:latest",
    resource_type: "EKS"
  }.to_json
  response = http.request(request)
  puts response.body
  ```

  ```php PHP theme={null}
  <?php
  $apiKey = "YOUR_API_KEY";
  $data = [
      "issue_description" => "Kubernetes pod failing to start with image pull error",
      "infrastructure_type" => "kubernetes",
      "cloud_provider" => "aws",
      "error_messages" => [
          "Error: ImagePullBackOff",
          "Failed to pull image: repository not found"
      ],
      "configuration_code" => "apiVersion: v1\nkind: Pod\nspec:\n  containers:\n  - name: app\n    image: myapp:latest",
      "resource_type" => "EKS"
  ];
  $ch = curl_init("https://api.wistx.ai/v1/troubleshoot/issue");
  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(
      "issue_description", "Kubernetes pod failing to start with image pull error",
      "infrastructure_type", "kubernetes",
      "cloud_provider", "aws",
      "error_messages", List.of(
          "Error: ImagePullBackOff",
          "Failed to pull image: repository not found"
      ),
      "configuration_code", "apiVersion: v1\nkind: Pod\nspec:\n  containers:\n  - name: app\n    image: myapp:latest",
      "resource_type", "EKS"
  );
  ObjectMapper mapper = new ObjectMapper();
  String json = mapper.writeValueAsString(payload);
  HttpRequest request = HttpRequest.newBuilder()
      .uri(URI.create("https://api.wistx.ai/v1/troubleshoot/issue"))
      .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": {
      "incident_id": "inc_abc123",
      "diagnosis": {
        "root_cause": "Image repository not found or inaccessible",
        "confidence": "high",
        "issues": [
          "Image repository not found or inaccessible",
          "Missing image pull secrets",
          "Incorrect image tag"
        ],
        "error_patterns": ["ImagePullBackOff", "repository not found"],
        "log_analysis": {
          "error_count": 2,
          "error_lines": ["Error: ImagePullBackOff", "Failed to pull image"]
        },
        "configuration_issues": [
          "Image tag 'latest' is not recommended for production",
          "No imagePullSecrets specified"
        ]
      },
      "issues": [
        "Image repository not found or inaccessible",
        "Missing image pull secrets",
        "Incorrect image tag"
      ],
      "fixes": [
        {
          "title": "Fix Image Pull Error",
          "description": "Update the image reference to use a valid repository and tag",
          "code_example": "apiVersion: v1\nkind: Pod\nspec:\n  containers:\n  - name: app\n    image: myregistry.com/myapp:v1.0.0",
          "steps": [
            "Verify image exists in registry",
            "Update image reference with correct tag",
            "Add imagePullSecrets if using private registry"
          ],
          "source": "ai_analysis",
          "confidence": "high"
        }
      ],
      "prevention": [
        "Use specific image tags instead of 'latest'",
        "Configure imagePullSecrets for private registries",
        "Implement image scanning and validation",
        "Use image pull policies appropriately",
        "Monitor pod startup failures"
      ],
      "related_knowledge": [
        {
          "article_id": "kb_123",
          "title": "Kubernetes Image Pull Errors",
          "summary": "Common causes and solutions for image pull errors..."
        }
      ],
      "similar_issues": [],
      "similar_incidents": [
        {
          "incident_id": "inc_xyz789",
          "issue_description": "Pod failing to start",
          "status": "resolved",
          "solution_applied": "Updated image reference"
        }
      ],
      "similar_solutions": [],
      "web_sources": []
    },
    "metadata": {
      "request_id": "req_abc123",
      "timestamp": 1704067200.0,
      "query_time_ms": 3456
    }
  }
  ```

  ```json 400 Bad Request theme={null}
  {
    "error": {
      "code": "VALIDATION_ERROR",
      "message": "Invalid request parameters",
      "details": "issue_description is required"
    },
    "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": "Troubleshooting service unavailable"
    },
    "metadata": {
      "request_id": "req_abc123",
      "timestamp": 1704067200.0
    }
  }
  ```

  ```json 503 Service Unavailable theme={null}
  {
    "error": {
      "code": "DATABASE_ERROR",
      "message": "Database connection failed",
      "details": "MongoDB connection timeout"
    },
    "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.