---
title: "Create an API key"
method: POST
path: "/v1/api-keys"
tags: ["API Keys"]
---

# Create an API key

`POST /v1/api-keys`

## Request

- Base URL: `https://api.mailbeast.ai`
- URL: `https://api.mailbeast.ai/v1/api-keys`
- Auth: HTTP bearer

Mint a new key for your workspace. The full token is returned **once**, so store it immediately. Requested scopes must be a subset of the calling key’s own scopes, and cannot include `apikeys:manage`.

Requires the `apikeys:manage` scope, which no wildcard grants and which can only be created from the dashboard.

## Request body

- CreateApiKeyDto
  - `name` string, required
  - `scopes` string[], required: Granted scopes (least-privilege). Must be a subset of the caller.
  - `environment` 'live' | 'test'
  - `expiresAt` string, date-time: ISO-8601 expiry; omit for a non-expiring key.

## Response `201`

Key created; token returned once.

- CreateApiKeyResponseDto
  - `token` string, required: The full secret token. Store it now - it is never retrievable again.
  - `apiKey` ApiKeySummaryDto, required
    - `id` string, uuid, required
    - `name` string, required
    - `keyPrefix` string, required: Masked prefix - the full secret is only shown once, at creation.
    - `scopes` string[], required
    - `environment` 'live' | 'test', required
    - `lastUsedAt` string, date-time, nullable, required
    - `expiresAt` string, date-time, nullable, required
    - `revokedAt` string, date-time, nullable, required: Always null: a deleted key is removed, not kept as revoked.
    - `createdAt` string, date-time, required

## Other responses

- `400`: The request body or parameters failed validation.
- `401`: Missing or invalid API key.
- `403`: The key lacks a required scope, or the plan does not include API access.
- `429`: Rate limit exceeded - retry after the interval in the Retry-After header.

---

[API](https://skmtc.dev/mailbeast/apis/mailbeast-public-api.md) · [All operations](https://skmtc.dev/mailbeast/apis/mailbeast-public-api/llms.txt) · [OpenAPI document](https://skmtc.dev/mailbeast/apis/mailbeast-public-api/revisions/6440ce0738a4?raw)
