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

# List custom guardrails

GET https://platform.lakera.ai/api/v1/custom-guardrails

List the custom guardrails of your organization. Use the returned `id` values in `custom_guardrail_ids` when you create or update a policy.

The response contains the ID, name, description and last edit time of each guardrail, not its rules. Create and edit guardrails in the AI Guardrails Dashboard.


Reference: https://docs.lakera.ai/api-reference/platform-api/custom-guardrails/list-custom-guardrails

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication using API key. Generate an API key from the AI Guardrails Dashboard. Example: Bearer sk_123... Keys carry one of two access scopes, chosen when the key is created: - **Read and write** — may call every endpoint. This is the default, and the scope of every key created before scopes were introduced. - **Read only** — may call read endpoints such as `/v1-beta/logs`, `/v1-beta/analytics` and the `GET` endpoints. Write endpoints return `403`. Issue a read-only key to anything that only needs to retrieve data, such as a log-shipping job or a dashboard, so that it cannot modify your policies or projects.

## Response

### 200

The custom guardrails of your organization, sorted by name

- `custom_guardrails` (list of CustomGuardrailSummary, required) — The custom guardrails of your organization, sorted by name

## Errors

### 400 Bad Request Error

The API key is not tied to an organization

- `status` (enum, optional) — Response status
  - Allowed values: `error`
- `error` (string, optional) — Short machine-readable error identifier
- `message` (string, optional) — Human-readable error message
- `code` (integer, optional) — HTTP status code
- `request_id` (string, optional) — Unique identifier for the request

### 403 Forbidden Error

Custom guardrails are not enabled in this deployment

- `status` (enum, optional) — Response status
  - Allowed values: `error`
- `error` (string, optional) — Short machine-readable error identifier
- `message` (string, optional) — Human-readable error message
- `code` (integer, optional) — HTTP status code
- `request_id` (string, optional) — Unique identifier for the request

## Types

### CustomGuardrailSummary

A custom guardrail, without its rules

- `id` (string, required) — ID to pass in `custom_guardrail_ids` when you create a policy
- `name` (string, required) — Display name of the guardrail
- `description` (string, required) — Description of the guardrail
- `last_edited_at` (string, required, nullable) — When the guardrail was last changed

## Examples

**Response**

```json
{
  "custom_guardrails": [
    {
      "id": "custom-guardrail-1234567890",
      "name": "string",
      "description": "string",
      "last_edited_at": "2024-01-15T09:30:00Z"
    }
  ]
}
```

**SDK Code**

```python
import requests

url = "https://platform.lakera.ai/api/v1/custom-guardrails"

headers = {"Authorization": "Bearer <token>"}

response = requests.get(url, headers=headers)

print(response.json())
```

```javascript
const url = 'https://platform.lakera.ai/api/v1/custom-guardrails';
const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};

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"
	"net/http"
	"io"
)

func main() {

	url := "https://platform.lakera.ai/api/v1/custom-guardrails"

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("Authorization", "Bearer <token>")

	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://platform.lakera.ai/api/v1/custom-guardrails")

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

request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'

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.get("https://platform.lakera.ai/api/v1/custom-guardrails")
  .header("Authorization", "Bearer <token>")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://platform.lakera.ai/api/v1/custom-guardrails', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://platform.lakera.ai/api/v1/custom-guardrails");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <token>");
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Authorization": "Bearer <token>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://platform.lakera.ai/api/v1/custom-guardrails")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

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()
```