# Create key

Creates a key.

```http
POST https://api.pozy.ai/v1/api-keys
```

- Area: Workspace / API Keys
- Auth: Authorization: Bearer pz_live_...

## Request body

Content type: `application/json`

- `name`, string, required
- `expiresIn`, integer
- `scope`, string: One of `full`, `profiles`. Default `full`
- `profileIds`, array of string
- `permission`, string: One of `read-write`, `read`. Default `read-write`
- `disabledResourceGroups`, array of string: Each item: one of `publishing`, `engagement`, `messages`, `contacts`, `analytics`, `ads`, `telephony`, `accounts`, `billing`, `webhooks`, `commerce`, `creator_campaigns`, `money`, `calendar`, `files`

## Example request

```bash
curl -X POST "https://api.pozy.ai/v1/api-keys" \
  -H "Authorization: Bearer $POZY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "name": "Acme"
}'
```

```ts
const res = await fetch("https://api.pozy.ai/v1/api-keys", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.POZY_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    name: "Acme"
  }),
});
const data = await res.json();
if (!res.ok) throw new Error(data?.error ?? `Request failed with status ${res.status}`);
console.log(data);
```

```python
import os
import requests

resp = requests.post(
    "https://api.pozy.ai/v1/api-keys",
    headers={"Authorization": f"Bearer {os.environ['POZY_API_KEY']}"},
    json={
        "name": "Acme",
    },
    timeout=30,
)
resp.raise_for_status()
print(resp.json())
```

## Response 201

- `message`, string
- `apiKey`, object
  - `id`, string
  - `name`, string
  - `keyPreview`, string
  - `expiresAt`, string (date-time)
  - `createdAt`, string (date-time)
  - `key`, string
  - `scope`, string: One of `full`, `profiles`. Default `full`
  - `profileIds`, array of object
    - `_id`, string
    - `name`, string
    - `color`, string
  - `permission`, string: One of `read-write`, `read`. Default `read-write`
  - `disabledResourceGroups`, array of string: Each item: one of `publishing`, `engagement`, `messages`, `contacts`, `analytics`, `ads`, `telephony`, `accounts`, `billing`, `webhooks`, `commerce`, `creator_campaigns`, `money`, `calendar`, `files`
  - `createdBy`, object: Can be null
    - `id`, string
    - `email`, string

```json
{
  "message": "Hello from Pozy",
  "apiKey": {
    "id": "6bfebd43ddc270f6d2c56fc5",
    "name": "Acme",
    "keyPreview": "string",
    "expiresAt": "2026-10-02T09:00:00.000Z",
    "createdAt": "2026-10-02T09:00:00.000Z",
    "key": "string",
    "scope": "full",
    "profileIds": [
      {
        "_id": "635d87e261ae344ef27fd1df",
        "name": "Acme",
        "color": "string"
      }
    ],
    "permission": "read-write",
    "disabledResourceGroups": [
      "publishing"
    ],
    "createdBy": {
      "id": "6bfebd43ddc270f6d2c56fc5",
      "email": "alex@example.com"
    }
  }
}
```
