---
title: "Create a key"
method: POST
path: "/keys"
tags: ["Keys"]
---

# Create a key

`POST /keys`

## Request

- Base URL: `https://api.warplink.app/v1`
- URL: `https://api.warplink.app/v1/keys`
- Auth: HTTP bearer

## Request body

- object
  - `type` 'api' | 'sdk': `sdk` creates a mobile SDK key with fixed scopes that never expires. `api` is the default.
  - `name` string, required
  - `app_id` string, uuid, nullable: Only for `sdk` keys. Ties the key to one app of your organization, so it works only with the SDK and only for that app. Omit or send null for a key that works for any app. An `api` key cannot be tied to an app. An id that is not an app of your organization is a validation error.
  - `scopes` string[]: Required for `api` keys. Ignored for `sdk` keys, whose scopes are fixed.
  - `expires_at` string, date-time: Must be in the future.

## Response `201`

Key created. The `raw_key` field is only returned once.

- object
  - `id` string, uuid
  - `type` 'api' | 'sdk'
  - `key_prefix` string
  - `name` string
  - `app_id` string, uuid, nullable: The app an `sdk` key is tied to. Null for `api` keys and for `sdk` keys that work for any app.
  - `scopes` string[]
  - `last_used_at` string, date-time, nullable
  - `expires_at` string, date-time, nullable
  - `created_at` string, date-time
  - `updated_at` string, date-time
  - `raw_key` string

## Other responses

- `400`: Validation error
- `401`: Unauthorized
- `403`: Forbidden

---

[API](https://skmtc.dev/warplink/apis/warplink-api.md) · [All operations](https://skmtc.dev/warplink/apis/warplink-api/llms.txt) · [OpenAPI document](https://skmtc.dev/warplink/apis/warplink-api/revisions/2a90ae8c44e8?raw)
