---
title: "Create a user API key"
method: POST
path: "/v0/users/{user}/keys"
tags: ["users", "keys"]
---

# Create a user API key

`POST /v0/users/{user}/keys`

Create a new `bencher_user_*` API key for a user. The plaintext key is only returned once in the response. Only the authenticated user themselves and server admins have access to this endpoint. This endpoint cannot be called with a user API key: a key cannot be used to create another key, so revoking a key also cuts off any credentials that could have been derived from it. Authenticate with a JWT (user session token) instead.

## Path parameters

- `user` string, required

## Request body

- JsonNewUserKey
  - `name` string, required
  - `ttl` integer, nullable — The time-to-live (TTL) for the key in seconds. If not provided, the key will not expire for over 128 years.

## Response `201`

successful creation

- JsonUserKeyCreated
  - `creation` string, date-time, required
  - `expiration` string, date-time, required
  - `key` string, required
  - `name` string, required
  - `user` string, uuid, required
  - `uuid` string, uuid, required

## Other responses

- `4XX` — Error
- `5XX` — Error

---

[API](https://skmtc.net/bencherdev/apis/bencher-api.md) · [All operations](https://skmtc.net/bencherdev/apis/bencher-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/bencherdev/bencher-api/revisions/84086e99e6cd/schema)
