# createApiKey

> Part of the MAP Audio Music API docs. Index of every page: https://map.audio/developers/music-api/llms.txt. OpenAPI document: https://map.audio/developers/music-api/openapi.json.

`POST https://api.map.audio/v1/api-keys`

Create an API key

Create an API key; its secret is in this response only, so store it now. Needs a map.audio sign-in on MAP Audio's own pages (https://map.audio/music), not an API key or another app's token, so a leaked key cannot mint more. `mode` picks the `sk_test_` or `sk_live_` prefix: both modes spend the same render-minutes and see the same jobs and files. An account holds at most 10 active keys. Send `acceptTerms` to accept the terms in the same call. Free.

Auth: `Authorization: Bearer` with an API key or a map.audio access token. Not an MCP tool: API keys are created, listed and revoked signed in at https://map.audio/music, so a connected app never holds or handles credentials.

## Body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `name` | string | no | A label you choose, to tell keys apart. At most 80 characters. |
| `mode` | "test" \| "live" | no | `test` or `live`. Both draw on the same render-minutes; the prefix separates Idempotency-Key namespaces and marks test renders' provenance. Default `"test"`. |
| `acceptTerms` | string | no | The prototype terms version being accepted, required until the account has accepted it. |

## Example

```sh
curl -sS "https://api.map.audio/v1/api-keys" \
  -H "Authorization: Bearer $MAP_API_KEY" \
  -H "Map-Version: 2026-11-01" \
  -H "Content-Type: application/json" \
  -d '{"name":"Production server","mode":"live"}'
```

### Request: A live key for a server

```json
{
  "name": "Production server",
  "mode": "live"
}
```

### Request: A first test key, accepting the terms

```json
{
  "name": "Laptop",
  "mode": "test",
  "acceptTerms": "2026-11-01-prototype"
}
```

### 201: Created

```json
{
  "object": "api_key",
  "id": "key_01M6BPRAQ0QXZ93APJ3C3FRWXZ",
  "name": "Production server",
  "mode": "live",
  "prefix": "sk_live_Qm4T",
  "createdAt": "2026-11-01T14:10:05.311Z",
  "lastUsedAt": null,
  "revokedAt": null,
  "secret": "sk_live_Qm4Tz8VbN2rYp6KcW1sXe9JhL3dGa7FuR5o"
}
```

### 403: Needs the account owner's sign-in

```json
{
  "error": {
    "type": "entitlement",
    "code": "oauth_required",
    "message": "Only the account owner, signed in at https://map.audio/music, can create or revoke API keys. This request used an API key.",
    "param": null,
    "retryable": false,
    "jobId": null,
    "docUrl": "https://map.audio/developers/music-api/errors#oauth_required",
    "requestId": "9a3f7c2e5b1d8f40-LHR"
  }
}
```

### 403: Key limit reached

```json
{
  "error": {
    "type": "entitlement",
    "code": "too_many_keys",
    "message": "An account may hold 10 active keys; revoke one (DELETE /v1/api-keys/{id}) first.",
    "param": null,
    "retryable": false,
    "jobId": null,
    "docUrl": "https://map.audio/developers/music-api/errors#too_many_keys",
    "requestId": "9a3f7c2e5b1d8f40-LHR"
  }
}
```

## Responses

- `201`: The key, with its secret.
- `403`: Needs the account owner's sign-in; Key limit reached
- `default`: Any other error: `error.code` names it, `error.param` the field at fault, and `error.docUrl` its entry in the error catalogue.

## Errors

- [`oauth_required`](https://map.audio/developers/music-api/errors#oauth_required)
- [`terms_version_mismatch`](https://map.audio/developers/music-api/errors#terms_version_mismatch)
- [`too_many_keys`](https://map.audio/developers/music-api/errors#too_many_keys)
- [`invalid_request`](https://map.audio/developers/music-api/errors#invalid_request)
- [`unsupported_media_type`](https://map.audio/developers/music-api/errors#unsupported_media_type)
- [`payload_too_large`](https://map.audio/developers/music-api/errors#payload_too_large)
- [`idempotency_key_unsupported`](https://map.audio/developers/music-api/errors#idempotency_key_unsupported)
