> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tokenlab.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# Crear API Key

> Crea una nueva API Key de usuario para la organización actual.

## Resumen

Este endpoint crea una nueva API Key de tipo `type=user` en la organización asociada al token de gestión actual.

## Cuerpo de la solicitud

| Campo           | Tipo           | Valor predeterminado / límites                           | Notas                                                                                                                                                     |
| --------------- | -------------- | -------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `name`          | string         | requerido, predeterminado `Default Key`, longitud `1-50` | Nombre visible, recortado en el servidor                                                                                                                  |
| `limitAmount`   | number \| null | mínimo `0`, máximo de entrada `1000000`                  | `null` o omitido = ilimitado, `0` = cuota cero. Los valores positivos se normalizan a un límite almacenado que no puede superar `100000` USD equivalente. |
| `limitCurrency` | enum           | default `USD`                                            | Solo USD. Enviar `CNY` devuelve `400 currency_retired`.                                                                                                   |
| `models`        | string\[]      | predeterminado `[]`                                      | Lista opcional de modelos lógicos permitidos                                                                                                              |
| `expiresAt`     | string \| null | datetime RFC3339                                         | `null` significa sin caducidad                                                                                                                            |

## Notas

* El valor completo de la API key solo se muestra una vez en la respuesta.
* `models: []` significa que la clave no tiene restricciones adicionales de modelo más allá de la política de la organización.
* `limitAmount: 0` crea una clave válida pero sin cuota utilizable hasta que se actualice.

## Ejemplo

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "https://api.tokenlab.sh/v1/management/api-keys" \
    -H "Authorization: Bearer mt-your-management-token" \
    -H "Content-Type: application/json" \
    -d '{
      "name": "Backend Worker",
      "limitAmount": 500,
      "models": ["veo3.1", "kling-3.0-video"],
      "expiresAt": "2026-12-31T23:59:59Z"
    }'
  ```
</RequestExample>

## Solicitud / Respuesta

Usa el panel OpenAPI interactivo de arriba para ver el esquema exacto y los campos de respuesta.

## Response example

<ResponseExample>
  ```json 201 Created theme={null}
  {
    "id": "key_abc123def456",
    "name": "Backend Worker",
    "key": "sk-live-redacted",
    "key_prefix": "sk-live...",
    "status": "active",
    "limit_amount": 500,
    "limit_amount_decimal": "500",
    "used_amount": 0,
    "used_amount_decimal": "0",
    "models": [
      "veo3.1",
      "kling-3.0-video"
    ],
    "expires_at": "2026-12-31T23:59:59.000Z",
    "last_used_at": null,
    "created_at": "2026-07-08T03:00:00.000Z"
  }
  ```
</ResponseExample>

## Important fields

<ResponseField name="key" type="string">Full secret API key value. It is returned only once on creation.</ResponseField>
<ResponseField name="id" type="string">API key identifier used in follow-up Management API calls.</ResponseField>
<ResponseField name="name" type="string">Display name for the API key.</ResponseField>
<ResponseField name="key_prefix" type="string">Non-secret key prefix for display and support.</ResponseField>
<ResponseField name="status" type="string">One of `active`, `inactive`, or `revoked`.</ResponseField>
<ResponseField name="limit_amount" type="number | null">Spending cap in USD as a JSON number for display. `null` means unlimited.</ResponseField>
<ResponseField name="limit_amount_decimal" type="string | null">Exact spending cap in USD as a decimal string. `null` means unlimited.</ResponseField>
<ResponseField name="used_amount" type="number">Accumulated usage in USD as a JSON number for display.</ResponseField>
<ResponseField name="used_amount_decimal" type="string">Exact accumulated usage in USD as a decimal string.</ResponseField>
<ResponseField name="models" type="string[]">Per-key model allowlist. Empty array means no additional key-level model restriction.</ResponseField>
<ResponseField name="expires_at" type="string | null">ISO timestamp when the key expires, or `null` for no expiry.</ResponseField>
<ResponseField name="last_used_at" type="string | null">ISO timestamp for the most recent use, or `null` when unused.</ResponseField>
<ResponseField name="created_at" type="string">ISO creation timestamp.</ResponseField>
