---
title: "Creates a new API key for the tenant. IMPORTANT: The full API key is only returned once during creation. Store it securely - you cannot retrieve it again."
method: POST
path: "/api/tenants/{tenantId}/api-keys"
tags: ["ApiKeys"]
---

# Creates a new API key for the tenant. IMPORTANT: The full API key is only returned once during creation. Store it securely - you cannot retrieve it again.

`POST /api/tenants/{tenantId}/api-keys`

## Request

- Base URL: `https://api.clinicos.vet/backend/business`
- URL: `https://api.clinicos.vet/backend/business/api/tenants/{tenantId}/api-keys`
- Auth: HTTP bearer
- TypeScript: <https://skmtc.dev/clinicos/apis/pawthosx-business-api-v1/docs/api/tenants/:tenantId/api-keys/post.ts> (a function with typed inputs; its response is checked against the schema)

## Path parameters

- `tenantId` string, required

## Request body

- CreateApiKeyRequestDto: Request DTO for creating an API key. TenantId is taken from the route parameter.
  - `name` string, required: Human-readable name for the API key.
  - `description` string, nullable: Optional description of what this key is used for.
  - `scopes` string[], nullable: Scopes to grant. Defaults to ["read", "write"] if not specified.
  - `expiresAt` string, date-time, nullable: Optional expiration date.
  - `allowedIpAddresses` string[], nullable: Optional IP allowlist. If set, only requests from these IPs are allowed.
  - `metadata` object, nullable: Additional metadata.

## Response `201`

Created

- CreateApiKeyResponse
  - `apiKey` string, required
  - `keyHash` string, required
  - `keyPrefix` string, required
  - `tenantId` string, required
  - `name` string, required
  - `scopes` string[], required
  - `createdAt` string, date-time, required

## Other responses

- `400`: Bad Request

---

[API](https://skmtc.dev/clinicos/apis/pawthosx-business-api-v1.md) - [All operations](https://skmtc.dev/clinicos/apis/pawthosx-business-api-v1/llms.txt) - [OpenAPI document](https://skmtc.dev/clinicos/apis/pawthosx-business-api-v1/revisions/099cf36186e0?raw)
