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

# Create an API key

`POST /api-keys`

## Request

- Base URL: `https://api.eusend.dev`
- URL: `https://api.eusend.dev/api-keys`
- Auth: HTTP bearer

The secret is returned once and never again. A test-mode key may only create further test-mode keys.

## Request body

- CreateApiKeyRequest
  - `name` string, required
  - `test_mode` boolean: Mint an `eu_test_` key. A test key can only mint further test keys.
  - `permission` 'full_access' | 'sending_access': `sending_access` reaches the send paths only; every other resource returns 403.
  - `domain_id` string, uuid: Restrict the key to one sending domain. Valid only with `permission: sending_access`.

## Response `201`

Created. Store `key` now.

- CreateApiKeyResponse
  - `id` string, uuid, required
  - `name` string, required
  - `key` string, required: The secret. Shown once, at creation, and never again.
  - `prefix` string, required: First 12 characters, for identifying the key later.
  - `test_mode` boolean, required
  - `permission` 'full_access' | 'sending_access', required
  - `domain_id` string, uuid, nullable
  - `domain_name` string, nullable
  - `created_at` string, date-time, required

## Other responses

- `400`: The request body or query failed validation (`VALIDATION_ERROR`).
- `401`: Missing, malformed, or revoked API key (`UNAUTHORIZED`).
- `403`: The key exists but may not reach this resource — a `sending_access` key outside the send paths, a test-mode key writing live state, or an account on hold (`FORBIDDEN`, `ACCOUNT_RESTRICTED`).
- `429`: Rate limit exceeded (`RATE_LIMITED`).
- `500`: Unexpected server error (`INTERNAL_ERROR`). Carries `request_id`.

---

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