---
title: "Save API key for user (saveApiKey)"
method: POST
path: "/api/apiKey"
tags: ["api-key-controller"]
---

# Save API key for user (saveApiKey)

`POST /api/apiKey`

Creates an API key for the given user and returns the token ONCE as 'ApiKey <value>'.

Available for any authorized user.

## Request body

- ApiKeyInfo — A JSON value representing the Api Key token.
  - `id` ApiKeyId
    - `id` string, uuid, required — ID of the entity, time-based UUID v1
    - `entityType` 'API_KEY', required — string
  - `createdTime` integer — Entity creation timestamp in milliseconds since Unix epoch
  - `tenantId` TenantId
    - `id` string, uuid, required — ID of the entity, time-based UUID v1
    - `entityType` 'TENANT', required — string
  - `userId` UserId
    - `id` string, uuid, required — ID of the entity, time-based UUID v1
    - `entityType` 'USER', required — string
  - `expirationTime` integer — Expiration time of the API key.
  - `description` string, required — API Key description.
  - `enabled` boolean — Enabled/disabled API key.
  - `expired` boolean — Indicates if the API key is expired based on current time. Returns false if expirationTime is 0 (no expiry).

## Response `200`

OK

- ApiKey
  - `id` ApiKeyId
    - `id` string, uuid, required — ID of the entity, time-based UUID v1
    - `entityType` 'API_KEY', required — string
  - `createdTime` integer — Entity creation timestamp in milliseconds since Unix epoch
  - `tenantId` TenantId
    - `id` string, uuid, required — ID of the entity, time-based UUID v1
    - `entityType` 'TENANT', required — string
  - `userId` UserId
    - `id` string, uuid, required — ID of the entity, time-based UUID v1
    - `entityType` 'USER', required — string
  - `expirationTime` integer — Expiration time of the API key.
  - `description` string, required — API Key description.
  - `enabled` boolean — Enabled/disabled API key.
  - `value` string, required — API key value
  - `expired` boolean — Indicates if the API key is expired based on current time. Returns false if expirationTime is 0 (no expiry).

---

[API](https://skmtc.net/thingsboard/apis/thingsboard-rest-api.md) · [All operations](https://skmtc.net/thingsboard/apis/thingsboard-rest-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/thingsboard/thingsboard-rest-api/revisions/40169ccdec5c/schema)
