---
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

## Changes

> 20 revisions in range; 1 could not be searched.

- **2026-05-22** `7ddccc8c8dd1` — 3 info
  - added the new optional request property `expires_at`
  - added the non-success response with the status `422`
  - added the required property `expires_at` to the response with the `201` status
- **2026-05-22** `2329d95e1b7f` — 1 info
  - endpoint added
- **2026-05-22** `1ba39f384b63` — 1 breaking
  - api path removed without deprecation

[Change history](https://skmtc.dev/agentserver/apis/agentserver-api/changes/api/workspaces/:wid/api-keys/post.md)

---

[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)
