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

# Health Check

> Check API health status and system status

> Check API health status and comprehensive system status

## Endpoints

WISTX provides three health and status endpoints:

* **`GET /v1/health`** - Basic health check (simple status)
* **`GET /v1/status`** - Comprehensive system status (all services)
* **`GET /v1/status/uptime`** - Uptime statistics

## Basic Health Check

### `GET /v1/health`

Simple health check endpoint for quick status verification.

<CodeGroup>
  ```bash cURL theme={null}
  curl --request GET \
    --url https://api.wistx.ai/v1/health
  ```

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

  url = "https://api.wistx.ai/v1/health"

  response = requests.get(url)
  print(response.json())
  ```

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

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

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

  import (
      "fmt"
      "net/http"
      "io"
  )

  func main() {
      url := "https://api.wistx.ai/v1/health"

      resp, _ := http.Get(url)
      defer resp.Body.Close()

      body, _ := io.ReadAll(resp.Body)
      fmt.Println(string(body))
  }
  ```

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

  url = URI("https://api.wistx.ai/v1/health")

  http = Net::HTTP.new(url.host, url.port)
  http.use_ssl = true

  response = http.get(url.path)
  puts JSON.parse(response.body)
  ```

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

  $url = "https://api.wistx.ai/v1/health";

  $ch = curl_init($url);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

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

  echo $response;
  ```

  ```java Java theme={null}
  import java.net.HttpURLConnection;
  import java.net.URL;
  import java.io.BufferedReader;
  import java.io.InputStreamReader;

  public class HealthCheck {
      public static void main(String[] args) throws Exception {
          URL url = new URL("https://api.wistx.ai/v1/health");
          
          HttpURLConnection conn = (HttpURLConnection) url.openConnection();
          conn.setRequestMethod("GET");
          
          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>

### Response

<ResponseExample>
  ```json 200 Success theme={null}
  {
    "status": "healthy"
  }
  ```
</ResponseExample>

### Response Fields

<ResponseField name="status" type="string" required>
  Health status of the API. Returns `"healthy"` when the service is operational.
</ResponseField>

## Get System Status

### `GET /v1/status`

Comprehensive status check for all WISTX services including API, Database, Vector Search, Indexing, and Authentication.

<CodeGroup>
  ```bash cURL theme={null}
  curl --request GET \
    --url https://api.wistx.ai/v1/status \
    --header 'Authorization: Bearer YOUR_API_KEY'
  ```

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

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

  response = requests.get(
      url,
      headers={"Authorization": f"Bearer {api_key}"}
  )

  data = response.json()
  print(f"Overall Status: {data['status']}")
  print(f"API Status: {data['services']['api']['status']}")
  print(f"Database Status: {data['services']['database']['status']}")
  ```

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

  const response = await fetch(url, {
    headers: {
      "Authorization": `Bearer ${apiKey}`
    }
  });

  const data = await response.json();
  console.log(`Overall Status: ${data.status}`);
  console.log(`API Status: ${data.services.api.status}`);
  console.log(`Database Status: ${data.services.database.status}`);
  ```

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

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

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

      req, _ := http.NewRequest("GET", url, nil)
      req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", apiKey))

      client := &http.Client{}
      resp, _ := client.Do(req)
      defer resp.Body.Close()

      body, _ := io.ReadAll(resp.Body)
      
      var result map[string]interface{}
      json.Unmarshal(body, &result)
      fmt.Printf("Overall Status: %v\n", result["status"])
  }
  ```

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

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

  http = Net::HTTP.new(url.host, url.port)
  http.use_ssl = true

  request = Net::HTTP::Get.new(url)
  request["Authorization"] = "Bearer #{api_key}"

  response = http.request(request)
  data = JSON.parse(response.body)
  puts "Overall Status: #{data['status']}"
  puts "API Status: #{data['services']['api']['status']}"
  ```

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

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

  $ch = curl_init($url);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_HTTPHEADER, [
      "Authorization: Bearer " . $apiKey
  ]);

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

  $data = json_decode($response, true);
  echo "Overall Status: " . $data['status'] . "\n";
  ```

  ```java Java theme={null}
  import java.net.HttpURLConnection;
  import java.net.URL;
  import java.io.BufferedReader;
  import java.io.InputStreamReader;
  import org.json.JSONObject;

  public class GetStatus {
      public static void main(String[] args) throws Exception {
          String apiKey = "YOUR_API_KEY";
          URL url = new URL("https://api.wistx.ai/v1/status");
          
          HttpURLConnection conn = (HttpURLConnection) url.openConnection();
          conn.setRequestMethod("GET");
          conn.setRequestProperty("Authorization", "Bearer " + apiKey);
          
          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());
          }
          
          JSONObject json = new JSONObject(response.toString());
          System.out.println("Overall Status: " + json.getString("status"));
      }
  }
  ```
</CodeGroup>

### Authorization

<ParamField header="Authorization" type="string" required>
  Bearer token for API authentication. Format: `Bearer YOUR_API_KEY`
</ParamField>

### Response

<ResponseExample>
  ```json 200 Success theme={null}
  {
    "status": "operational",
    "timestamp": "2024-12-20T10:30:00.000Z",
    "check_duration_ms": 45.2,
    "services": {
      "api": {
        "status": "operational",
        "version": "1.0.0",
        "title": "WISTX API",
        "uptime_seconds": 86400
      },
      "database": {
        "status": "operational",
        "latency_ms": 12.5,
        "connections": {
          "current": 15,
          "available": 35,
          "max": 50
        },
        "server_version": "7.0.0"
      },
      "vector_search": {
        "status": "operational",
        "index_name": "wistx",
        "total_vectors": 150000,
        "indexes": {}
      },
      "indexing": {
        "status": "operational",
        "recent_jobs_today": 25,
        "active_jobs": 2
      },
      "authentication": {
        "status": "operational",
        "total_users": 1250,
        "active_users": 1180
      }
    }
  }
  ```
</ResponseExample>

### Response Fields

<ResponseField name="status" type="string" required>
  Overall system status. Possible values: `operational`, `degraded`, `down`
</ResponseField>

<ResponseField name="timestamp" type="string" required>
  ISO 8601 timestamp of when the status check was performed
</ResponseField>

<ResponseField name="check_duration_ms" type="number" required>
  Duration of the status check in milliseconds
</ResponseField>

<ResponseField name="services" type="object" required>
  Status of individual services:

  * `api` - API service status
  * `database` - MongoDB database status
  * `vector_search` - Pinecone vector search status
  * `indexing` - Indexing service status
  * `authentication` - Authentication service status
</ResponseField>

## Get Uptime Statistics

### `GET /v1/status/uptime`

Get uptime statistics for WISTX services over a specified period.

<CodeGroup>
  ```bash cURL theme={null}
  curl --request GET \
    --url "https://api.wistx.ai/v1/status/uptime?days=30" \
    --header 'Authorization: Bearer YOUR_API_KEY'
  ```

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

  api_key = "YOUR_API_KEY"
  url = "https://api.wistx.ai/v1/status/uptime"

  response = requests.get(
      url,
      params={"days": 30},
      headers={"Authorization": f"Bearer {api_key}"}
  )

  data = response.json()
  print(f"Uptime: {data['uptime_percentage']}%")
  print(f"Total Checks: {data['total_checks']}")
  ```

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

  const response = await fetch(`${url}?days=30`, {
    headers: {
      "Authorization": `Bearer ${apiKey}`
    }
  });

  const data = await response.json();
  console.log(`Uptime: ${data.uptime_percentage}%`);
  console.log(`Total Checks: ${data.total_checks}`);
  ```

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

  import (
      "encoding/json"
      "fmt"
      "net/http"
      "io"
      "net/url"
  )

  func main() {
      apiKey := "YOUR_API_KEY"
      baseURL := "https://api.wistx.ai/v1/status/uptime"
      
      params := url.Values{}
      params.Add("days", "30")
      fullURL := fmt.Sprintf("%s?%s", baseURL, params.Encode())

      req, _ := http.NewRequest("GET", fullURL, nil)
      req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", apiKey))

      client := &http.Client{}
      resp, _ := client.Do(req)
      defer resp.Body.Close()

      body, _ := io.ReadAll(resp.Body)
      
      var result map[string]interface{}
      json.Unmarshal(body, &result)
      fmt.Printf("Uptime: %.2f%%\n", result["uptime_percentage"])
  }
  ```

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

  api_key = "YOUR_API_KEY"
  url = URI("https://api.wistx.ai/v1/status/uptime")
  url.query = URI.encode_www_form({ days: 30 })

  http = Net::HTTP.new(url.host, url.port)
  http.use_ssl = true

  request = Net::HTTP::Get.new(url)
  request["Authorization"] = "Bearer #{api_key}"

  response = http.request(request)
  data = JSON.parse(response.body)
  puts "Uptime: #{data['uptime_percentage']}%"
  ```

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

  $apiKey = "YOUR_API_KEY";
  $url = "https://api.wistx.ai/v1/status/uptime?days=30";

  $ch = curl_init($url);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_HTTPHEADER, [
      "Authorization: Bearer " . $apiKey
  ]);

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

  $data = json_decode($response, true);
  echo "Uptime: " . $data['uptime_percentage'] . "%\n";
  ```

  ```java Java theme={null}
  import java.net.HttpURLConnection;
  import java.net.URL;
  import java.io.BufferedReader;
  import java.io.InputStreamReader;
  import org.json.JSONObject;

  public class GetUptime {
      public static void main(String[] args) throws Exception {
          String apiKey = "YOUR_API_KEY";
          URL url = new URL("https://api.wistx.ai/v1/status/uptime?days=30");
          
          HttpURLConnection conn = (HttpURLConnection) url.openConnection();
          conn.setRequestMethod("GET");
          conn.setRequestProperty("Authorization", "Bearer " + apiKey);
          
          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());
          }
          
          JSONObject json = new JSONObject(response.toString());
          System.out.println("Uptime: " + json.getDouble("uptime_percentage") + "%");
      }
  }
  ```
</CodeGroup>

### Query Parameters

<ParamField query="days" type="integer" optional>
  Number of days to calculate uptime for. Range: 1-365. Default: 30
</ParamField>

### Authorization

<ParamField header="Authorization" type="string" required>
  Bearer token for API authentication. Format: `Bearer YOUR_API_KEY`
</ParamField>

### Response

<ResponseExample>
  ```json 200 Success theme={null}
  {
    "period_days": 30,
    "total_checks": 43200,
    "operational_checks": 43164,
    "uptime_percentage": 99.92
  }
  ```

  ```json 200 Success (No Historical Data) theme={null}
  {
    "period_days": 30,
    "total_checks": 0,
    "operational_checks": 0,
    "uptime_percentage": 0.0,
    "message": "No historical status data available. Historical uptime statistics require periodic status checks to be stored."
  }
  ```
</ResponseExample>

### Response Fields

<ResponseField name="period_days" type="integer" required>
  Number of days for uptime calculation
</ResponseField>

<ResponseField name="total_checks" type="integer" required>
  Total number of status checks performed in the period
</ResponseField>

<ResponseField name="operational_checks" type="integer" required>
  Number of checks where status was operational
</ResponseField>

<ResponseField name="uptime_percentage" type="number" required>
  Uptime percentage calculated as (operational\_checks / total\_checks) \* 100. Returns 0.0 if no historical data is available.
</ResponseField>

<ResponseField name="message" type="string" optional>
  Informational message about uptime statistics. Present when no historical data is available or when there are issues retrieving statistics.
</ResponseField>

<Note>
  **Historical Data Requirement**: Uptime statistics require periodic status checks to be stored in the database. If no historical data exists, the endpoint will return `total_checks: 0` and `uptime_percentage: 0.0` with an explanatory message. For real-time status, use `/v1/status` instead.
</Note>

## Use Cases

* **Monitoring**: Use `/v1/status` to monitor all WISTX services
* **Load Balancer Health Checks**: Use `/v1/health` for simple health checks
* **Status Pages**: Display comprehensive status using `/v1/status`
* **Uptime Tracking**: Track service reliability using `/v1/status/uptime`
* **Alerting**: Set up alerts based on status endpoint responses

## Related Documentation

* [Status Page](/resources/status) - Visual status dashboard
* [API Reference](/api-reference/introduction) - Overview of all API endpoints


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