---
title: "Create an api key, the plaintext is returned once"
method: POST
path: "/api/v1/projects/{projectId}/api-keys"
tags: ["API keys"]
---

# Create an api key, the plaintext is returned once

`POST /api/v1/projects/{projectId}/api-keys`

## Request

- Base URL: `https://otprun.com`
- URL: `https://otprun.com/api/v1/projects/{projectId}/api-keys`
- Auth: HTTP bearer

## Path parameters

- `projectId` integer, required

## Request body

- CreateInputBody2
  - `chat_access` 'all' | 'own': all (default): read every chat; own: only chats this key wrote to
  - `ip_allowlist` string[], nullable: IP addresses or CIDR ranges, empty allows any
  - `name` string, required
  - `scopes` string[], nullable, required

## Response `201`

Created

- CreatedKeyBody
  - `chat_access` 'all' | 'own', required: all: the key reads every WhatsApp chat of the workspace; own: only chats it wrote to itself
  - `created_at` string, date-time, required
  - `id` integer, required
  - `ip_allowlist` string[], nullable, required
  - `key` string, required: Plaintext key, shown only once
  - `last_used_at` string, date-time, nullable, required
  - `name` string, required
  - `prefix` string, required
  - `project_id` integer, required
  - `revoked_at` string, date-time, nullable, required
  - `scopes` string[], nullable, required

## Other responses

- `403`: Forbidden
- `404`: Not Found
- `422`: Unprocessable Entity
- `500`: Internal Server Error

---

[API](https://skmtc.dev/otprun/apis/otp-run-api.md) · [All operations](https://skmtc.dev/otprun/apis/otp-run-api/llms.txt) · [OpenAPI document](https://skmtc.dev/otprun/apis/otp-run-api/revisions/43d40d5f4050?raw)
