---
title: "Create API key"
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.cloudraker.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create API key

Path: CloudRaker Paperwork API › Account

`POST /api-keys`

Issues a new API key for the organization. Body: `{ name: string (1-255 chars, required), v1Only?: boolean (default false) }`. The plaintext key value is returned ONCE in this 201 response and is never retrievable again. Authorization: organization administrators only. Returns 400 on an invalid body.

## Authentication

- `bearerAuth`, http, header `Authorization`

## Request body

_Required._

- `name` (`createApiKey.name`; string, required)
  - minLength 1; maxLength 255; example `"CI pipeline"`
- `v1Only` (`createApiKey.v1Only`; boolean, optional) — When true, the key may only call the public /v1 API; every other route answers 403 `api_key_v1_only`.
  - default `false`

## Example request

```json
{
  "name": "CI pipeline",
  "v1Only": false
}
```

## Code samples

### cURL

```bash
curl --request POST \
  --url https://api.cloudraker.com/api-keys \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "name": "CI pipeline",
  "v1Only": false
}
'
```

### TypeScript

```typescript
const url = 'https://api.cloudraker.com/api-keys';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json', Authorization: 'Bearer <token>'},
  body: JSON.stringify({name: 'CI pipeline', v1Only: false})
};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://api.cloudraker.com/api-keys"

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

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

print(response.text)
```

## Responses

### 201

The created API key, including its one-time plaintext value.

#### Example

```json
{
  "id": "key_01H…",
  "name": "CI pipeline",
  "permissions": [
    "string"
  ],
  "v1Only": true,
  "lastUsedAt": "2019-08-24T14:15:22Z",
  "createdAt": "2019-08-24T14:15:22Z",
  "createdBy": {
    "id": "user_01H…",
    "type": "user",
    "name": "Jérôme Lin",
    "email": "string"
  },
  "value": "sk_…"
}
```

- `id` (`createApiKey.response.201.id`; string, required)
  - example `"key_01H…"`
- `name` (`createApiKey.response.201.name`; string, required)
  - example `"CI pipeline"`
- `permissions` (`createApiKey.response.201.permissions`; array<string>, required)
- `v1Only` (`createApiKey.response.201.v1Only`; boolean, required) — Restricted to the public /v1 API — all other routes answer 403.
- `lastUsedAt` (`createApiKey.response.201.lastUsedAt`; any of, required)
  - any of: `string`, `null`
- `createdAt` (`createApiKey.response.201.createdAt`; string, required)
  - format `date-time`; pattern `^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z))$`
- `createdBy` (`createApiKey.response.201.createdBy`; any of, required) — Who created the key, or null when that is not known.
  - any of: `ApiKeyCreator`, `null`
- `value` (`createApiKey.response.201.value`; string, required) — The plaintext key. Returned ONCE, at creation, and never retrievable again.
  - example `"sk_…"`


Source: https://docs.cloudraker.com/paperwork/api/account/create-api-key/index.md
