---
title: "Create Key"
method: POST
path: "/v1/admin/keys"
tags: ["Admin"]
---

# Create Key

`POST /v1/admin/keys`

Create a new key for a user.

## Request body

- CreateKeyBody
  - `name` string, required — Name of the key.
  - `user` integer, required — User ID to create the token for another user (by default, the current user). Required CREATE_USER permission.
  - `expires` integer, nullable — Expiration time, as Unix timestamp. If None, the key never expires.

## Response `201`

Successful Response

- KeyResponse
  - `object` 'key' — Type of the object.
  - `id` integer, required — ID of the key.
  - `name` string, required — Name of the key.
  - `value` string, required — Value of the key.
  - `user` integer, required — ID of the user that owns the key.
  - `expires` integer, nullable — Time of expiration, as Unix timestamp. If None, the key never expires.
  - `created` integer, required — Time of creation, as Unix timestamp.

## Other responses

- `401` — Invalid authentication scheme.<br>Invalid API key.
- `403` — User has no admin rights.<br>Your account has expired. Please contact support to renew your account.
- `404` — User {user_id} not found.
- `409` — Key {name} already exists.
- `422` — Validation Error

---

[API](https://skmtc.net/betagouv/apis/opengatellm.md) · [All operations](https://skmtc.net/betagouv/apis/opengatellm/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/betagouv/opengatellm/revisions/f2624a610e5a/schema)
