# Create API Key

> Create an API key (web session)

**Endpoint:** `POST /v1/api-keys`  
**Access:** Account required

Bound to the current environment. The token is shown once.

## cURL example

```bash
curl -X POST "https://api.verifiedinbox.ai/v1/api-keys" \
  -H "Authorization: Bearer vi_live_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Acme Inc.",
    "scopes": [
      "applications:read"
    ]
  }'
```

## Parameters

| Parameter | Type | Description |
|---|---|---|
| `VI-Environment` (header) | `string` | `live` (default) or `test`. Used for anonymous callers and OAuth access tokens; API keys and web sessions carry their own environment. |

## Request body

| Field | Type | Description |
|---|---|---|
| `name` *(required)* | `string` | — |
| `scopes` | `string[]` | Default: all scopes. |

```json
{
  "name": "Acme Inc.",
  "scopes": [
    "applications:read"
  ]
}
```

## Responses

### 201 OK

Created.

```json
{
  "api_key": {
    "created_at": "2026-10-31T12:00:00Z",
    "environment": "live",
    "id": "0192a5e0-1234-7000-8000-000000000001",
    "last_used_at": "2026-10-31T12:00:00Z",
    "name": "Acme Inc.",
    "prefix": "string",
    "revoked_at": "2026-10-31T12:00:00Z",
    "scopes": []
  },
  "token": "string"
}
```

### 400 (invalid_request)

`invalid_request` — the request is malformed.

```json
{
  "error": {
    "code": "invalid_request",
    "message": "Please provide a valid domain name."
  }
}
```

### 401 (unauthenticated)

`unauthenticated` — sign in / send a valid credential. `next_action.kind = sign_in`.

```json
{
  "error": {
    "code": "unauthenticated",
    "message": "Sign in or provide an API key to continue.",
    "next_action": {
      "kind": "sign_in",
      "title": "Sign in or create an account",
      "url": "/login"
    }
  }
}
```

### 422 (unprocessable)

`unprocessable` / `blocked_provider` — understood but can't be done (plain-English reason).

```json
{
  "error": {
    "code": "unprocessable",
    "message": "Shared mailbox providers like gmail.com cannot be verified."
  }
}
```

### 429 (rate_limited)

`rate_limited` — retry after `Retry-After` seconds (`details.retry_after_seconds`). `limit_reached` — a quota is used up; `details.limit` names it and `next_action` offers support.

```json
{
  "error": {
    "code": "rate_limited",
    "message": "Too many requests. Please wait a moment and try again."
  }
}
```
