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

# Create an API key

POST https://api.withverifa.com/api/v1/organizations/{org_id}/keys
Content-Type: application/json

Reference: https://docs.withverifa.com/api-reference/organizations/create-api-key

## Authentication

- `Authorization` header (bearer token, required) — Admin JWT token via `Authorization: Bearer <token>`.

## Request

### Path parameters

- `org_id` (string, required) — Organization ID (`org_*`).

### Headers

- `Verifa-Version` (date, optional) — API version date string (e.g. `2026-02-01`). If omitted, the version pinned to your API key is used.

### Body (application/json)

This endpoint expects a CreateApiKeyRequest.

- `label` (string, required) — Human-readable label for the key.
- `environment` (enum, required) — Environment the key is scoped to.
  - Allowed values: `live`, `sandbox`

## Response

### 201

API key created. The full key is only returned once.

- `id` (string, required)
- `key` (string, required) — Full API key value. Only returned at creation time — store it securely as it cannot be retrieved again.
- `label` (string, required)
- `environment` (enum, required)
  - Allowed values: `live`, `sandbox`
- `created_at` (datetime, required)

## Errors

### 400 Bad Request Error

Invalid request parameters.

- `error` (string, required) — Short error code.
- `status_code` (integer, required) — HTTP status code.
- `detail` (string, optional) — Human-readable error description.

### 401 Unauthorized Error

Missing or invalid API key.

- `error` (string, required) — Short error code.
- `status_code` (integer, required) — HTTP status code.
- `detail` (string, optional) — Human-readable error description.

## Examples

**Request**

```json
{
  "label": "Production key",
  "environment": "live"
}
```

**Response**

```json
{
  "id": "string",
  "key": "vk_live_abc123...",
  "label": "string",
  "environment": "live",
  "created_at": "2024-01-15T09:30:00Z"
}
```

**SDK Code**

```python
import requests

url = "https://api.withverifa.com/api/v1/organizations/org_id/keys"

payload = {
    "label": "Production key",
    "environment": "live"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript
const url = 'https://api.withverifa.com/api/v1/organizations/org_id/keys';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"label":"Production key","environment":"live"}'
};

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.withverifa.com/api/v1/organizations/org_id/keys"

	payload := strings.NewReader("{\n  \"label\": \"Production key\",\n  \"environment\": \"live\"\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.withverifa.com/api/v1/organizations/org_id/keys")

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  \"label\": \"Production key\",\n  \"environment\": \"live\"\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.withverifa.com/api/v1/organizations/org_id/keys")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"label\": \"Production key\",\n  \"environment\": \"live\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.withverifa.com/api/v1/organizations/org_id/keys', [
  'body' => '{
  "label": "Production key",
  "environment": "live"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.withverifa.com/api/v1/organizations/org_id/keys");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"label\": \"Production key\",\n  \"environment\": \"live\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "label": "Production key",
  "environment": "live"
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.withverifa.com/api/v1/organizations/org_id/keys")! 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()
```