---
title: "Mint a workspace API key"
method: POST
path: "/api/workspaces/{wid}/api-keys"
tags: ["Workspace API Keys"]
---

# Mint a workspace API key

`POST /api/workspaces/{wid}/api-keys`

Returns the secret ONCE in the response body. At least one Available scope must be provided.

## Path parameters

- `wid` string, required

## Request body

- WorkspaceAPIKeyMintRequest
  - `expires_at` string
  - `name` string, required
  - `scopes` string[], required

## Response `201`

Created

- WorkspaceAPIKeyMintResponse
  - `created_at` string, required
  - `expires_at` string, required
  - `id` string, required
  - `name` string, required
  - `prefix` string, required
  - `scopes` string[], required
  - `secret` string, required

## Other responses

- `400` — name required / scope not available / at least one scope required
- `403` — owner or maintainer required
- `422` — expires_at invalid (bad RFC3339 / in past / >365d in future)
- `500` — internal error

---

[API](https://skmtc.dev/agentserver/apis/agentserver-api.md) · [All operations](https://skmtc.dev/agentserver/apis/agentserver-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/agentserver/agentserver-api/revisions/e8c329825b4e/schema)
