> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.lakera.ai/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.lakera.ai/_mcp/server.

# Check policy configuration health

POST https://api.lakera.ai/v2/policies/health
Content-Type: application/json

Check the validity of the policy configuration for a given project.
If no project ID is passed then the health of the AI Guardrails Default Policy will be returned.


Reference: https://docs.lakera.ai/api-reference/lakera-api/policies-health/check-policy-health

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication using API key. Generate an API key from the AI Guardrails Dashboard. Example: Bearer sk_123...

## Servers

- `https://api.lakera.ai` (Default, default)
- `https://eu.api.lakera.ai` (Eu)
- `https://us.api.lakera.ai` (Us)
- `https://ap-southeast-1.api.lakera.ai` (ApSoutheast)

## Request

### Body (application/json)

This endpoint expects a PoliciesHealthRequest.

- `project_id` (string, required) — The project_id for which the policy health should be checked,.

## Response

### 200

Policy health check results

- `status` (enum, optional) — Overall health status
  - Allowed values: `ok`, `error`
- `is_default` (boolean, optional) — Whether using the AI Guardrails Default Policy or a custom policy
- `message` (string, optional, nullable) — Human-readable status message
- `lint` (PolicyHealthResponseLint, optional) — Policy validation results

## Types

### PolicyHealthResponseLint

Policy validation results

- `passed` (boolean, optional) — Whether validation passed
- `errors` (list of PolicyHealthResponseLintErrorsItems, optional) — List of validation errors and warnings

### PolicyHealthResponseLintErrorsItems

- `message` (string, optional) — Error or warning message
- `severity` (enum, optional) — Error severity level
  - Allowed values: `error`, `warning`

## Examples

**Request**

```json
{
  "project_id": "string"
}
```

**Response**

```json
{
  "status": "ok",
  "is_default": true,
  "message": "string",
  "lint": {
    "passed": true,
    "errors": [
      {
        "message": "string",
        "severity": "error"
      }
    ]
  }
}
```

**SDK Code**

```python
import requests

url = "https://api.lakera.ai/v2/policies/health"

payload = { "project_id": "string" }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api.lakera.ai/v2/policies/health';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"project_id":"string"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

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

func main() {

	url := "https://api.lakera.ai/v2/policies/health"

	payload := strings.NewReader("{\n  \"project_id\": \"string\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.lakera.ai/v2/policies/health")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"project_id\": \"string\"\n}"

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

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.lakera.ai/v2/policies/health")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"project_id\": \"string\"\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.lakera.ai/v2/policies/health', [
  'body' => '{
  "project_id": "string"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.lakera.ai/v2/policies/health");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"project_id\": \"string\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["project_id": "string"] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.lakera.ai/v2/policies/health")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```