---
title: "Issue an API key for an application (key returned once)"
method: POST
path: "/applications/{id}/keys"
tags: ["Applications"]
---

# Issue an API key for an application (key returned once)

`POST /applications/{id}/keys`

## Request

- Base URL: `https://api.customdomain.ai/v1`
- URL: `https://api.customdomain.ai/v1/applications/{id}/keys`
- Auth: one of:
  - HTTP bearer
  - HTTP bearer

## Path parameters

- `id` string, required

## Request body

- object
  - `name` string
  - `environment` 'production' | 'staging' | 'development'

## Response `201`

Created; the full secret is present only in this response

- object
  - `id` string, required
  - `application_id` string, required: The application the key belongs to.
  - `name` string, required
  - `prefix` string, required: The stored, non-secret prefix that identifies the key, for example cd_live_ab12cd34.
  - `environment` 'production' | 'staging' | 'development', required
  - `scopes` string[]
  - `is_default` boolean, required: true on the workspace default key (at most one active per workspace).
  - `last_used_at` string, date-time: When the key last authenticated a request. Absent until it has been used.
  - `created_at` string, date-time, required
  - `revoked_at` string, date-time: When the key was revoked. Absent while the key is active.
  - `key` string: cd_live_… or cd_test_…; shown once, stored hashed

## Other responses

- `401`: Error envelope: {code, title, details}.
- `402`: Refused because of the workspace's billing. `billing_required`: the workspace has no active or trialing subscription (a new workspace that has not started its trial, a Free workspace past its grace period, a comp that ended, or a subscription Stripe marked unpaid or canceled). It stops a new connection, the start of a domain purchase and the first live credential (an application, an API key or a rotated client secret). Domains already connected keep working, and an owner or admin sets up billing in the console; `details` says where. A new workspace's first domain is the exception: while it has fewer pending, propagating or live connections than its free domains (ten, unless an operator set another number: `free_domains`), a connect and the start of a purchase go through (`first_domain_free`), and the next one is refused with a `title` saying a card is needed to connect more domains. Credentials still need the trial. `quota_exceeded` (connections only): a plan that is refused past its quota (Starter, and the retired Free) is at it and the deployment enforces quotas. `connections_unavailable`: what a connect-scoped widget token, the tenant's own end user, gets instead of either, with neutral wording, so the tenant's customers are never told about the tenant's billing. A delegated agent token gets the full wording, and `GET /billing/standing` tells it beforehand whether a new connection would be refused.
- `404`: Error envelope: {code, title, details}.

---

[API](https://skmtc.dev/customdomain/apis/customdomain-control-plane-api.md) · [All operations](https://skmtc.dev/customdomain/apis/customdomain-control-plane-api/llms.txt) · [OpenAPI document](https://skmtc.dev/customdomain/apis/customdomain-control-plane-api/revisions/34d89cb7a7cd?raw)
