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

# Create project

POST https://platform.lakera.ai/api/v1-beta/projects
Content-Type: application/json

Create a new project

Reference: https://docs.lakera.ai/api-reference/platform-api/projects/create-project

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

## Request

### Body (application/json)

This endpoint expects a Project.

- `name` (string, required) — A descriptive name for the project
- `policy_id` (string, optional) — ID of the policy to be applied to this project. If not provided, uses default policy.
- `project_metadata` (map from string to string, optional) — Custom metadata tags for analysis and cross referencing
- `action` (enum, optional) — Controls whether Guard enforces flagging on this project. `enforce` (the default) means full enforcement: the top-level `flagged` in a `guard` response is `true` whenever any of the enabled detectors triggers. `detect` surfaces detections in the breakdown but forces the top-level `flagged` to `false`, letting you observe detector behavior without blocking traffic. Always returned when reading a project. Optional when creating — defaults to `enforce`. Optional when updating — omit to keep the existing value. More information in [Project Mode](/docs/projects#project-mode).
  - Allowed values: `detect`, `enforce`

## Response

### 200

Project created

- `name` (string, required) — A descriptive name for the project
- `policy_id` (string, optional) — ID of the policy to be applied to this project. If not provided, uses default policy.
- `project_metadata` (map from string to string, optional) — Custom metadata tags for analysis and cross referencing
- `action` (enum, optional) — Controls whether Guard enforces flagging on this project. `enforce` (the default) means full enforcement: the top-level `flagged` in a `guard` response is `true` whenever any of the enabled detectors triggers. `detect` surfaces detections in the breakdown but forces the top-level `flagged` to `false`, letting you observe detector behavior without blocking traffic. Always returned when reading a project. Optional when creating — defaults to `enforce`. Optional when updating — omit to keep the existing value. More information in [Project Mode](/docs/projects#project-mode).
  - Allowed values: `detect`, `enforce`

## Examples

**Request**

```json
{
  "name": "string"
}
```

**Response**

```json
{
  "name": "string",
  "policy_id": "string",
  "project_metadata": {},
  "action": "detect"
}
```

**SDK Code**

```python
import requests

url = "https://platform.lakera.ai/api/v1-beta/projects"

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

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

print(response.json())
```

```javascript
const url = 'https://platform.lakera.ai/api/v1-beta/projects';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"name":"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://platform.lakera.ai/api/v1-beta/projects"

	payload := strings.NewReader("{\n  \"name\": \"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://platform.lakera.ai/api/v1-beta/projects")

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  \"name\": \"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://platform.lakera.ai/api/v1-beta/projects")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"name\": \"string\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

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

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

```csharp
using RestSharp;

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

```swift
import Foundation

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

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

let request = NSMutableURLRequest(url: NSURL(string: "https://platform.lakera.ai/api/v1-beta/projects")! 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()
```