---
title: "创建 API Key（明文只显示一次；新 Key 附带 3 次免费额度）/ Create a key (shown once; new keys come with 3 free credits)"
method: POST
path: "/v1/api-keys"
tags: ["Keys"]
---

# 创建 API Key（明文只显示一次；新 Key 附带 3 次免费额度）/ Create a key (shown once; new keys come with 3 free credits)

`POST /v1/api-keys`

## Request

- Base URL: `https://api.musicsforyou.com`
- URL: `https://api.musicsforyou.com/v1/api-keys`
- Auth: OAuth 2 (authorization code, authorization URL `https://www.musicsforyou.com/oauth/authorize`, token URL `https://api.musicsforyou.com/oauth/token`, scopes: `music`)

## Request body

- CreateApiKeyRequest
  - `name` string

## Response `201`

已创建 / Created

- CreateApiKeyResponse
  - `success` true, required
  - `key` string, required: 完整 Key，只返回这一次 / Full key, shown only once
  - `apiKey` ApiKey, required
    - `id` string, required
    - `name` string, required
    - `prefix` string, required: 例如 ty_live_ab12cd… / Masked prefix
    - `lastUsedAt` string, date-time, nullable, required
    - `createdAt` string, date-time, required
    - `webhookUrl` string, uri, nullable: 完成回调地址 / Completion webhook URL
  - `note` string

## Other responses

- `401`: 未登录或 Key 无效 / Not authenticated（LOGIN_REQUIRED、INVALID_API_KEY）
- `403`: API Key 不能管理 API Key

---

[API](https://skmtc.dev/musicsforyou/apis/taoyuan-music-api.md) · [All operations](https://skmtc.dev/musicsforyou/apis/taoyuan-music-api/llms.txt) · [OpenAPI document](https://skmtc.dev/musicsforyou/apis/taoyuan-music-api/revisions/65b8919a4d82?raw)
