Skip to content

Create Service Key

POST
/internal/admin/service-keys

Create a new service API key.

Creates a service account key that can be used for service-to-service authentication. The plaintext key is only returned in this response and cannot be retrieved later.

Args: request: Key creation parameters (name, multi_tenant, permissions) admin_key: Validated admin API key (from dependency) db: Database session

Returns: CreateServiceKeyResponse with key details including plaintext

Raises: 409: If key with same name already exists

X-API-Key
Any of:
string
CreateServiceKeyRequest

Request schema for creating a service API key (FR-CREATE-001, FR-CREATE-002).

Attributes: name: Human-readable key name (e.g., ‘n8n-integration’) multi_tenant: Enable multi-tenant token requests permissions: Service permissions (e.g., [‘admin:keys’]) business_id: Business context UUID (defaults to system business)

object
name
required
Name

Human-readable key name (e.g., ‘n8n-integration’)

string
>= 1 characters <= 255 characters
multi_tenant
Multi Tenant

Enable multi-tenant token requests

boolean
default: true
permissions
Permissions

Service permissions (e.g., [‘admin:keys’])

Array<string>
business_id
Any of:
string

Service key created successfully

CreateServiceKeyResponse

Response schema for service key creation (FR-CREATE-003).

NOTE: api_key is only returned at creation time and cannot be retrieved later.

Attributes: id: Key UUID name: Key name api_key: Plaintext key (shown once - store securely!) created_at: Creation timestamp multi_tenant: Multi-tenant enabled permissions: Service permissions

object
id
required
Id

Key UUID

string
name
required
Name

Key name

string
api_key
required
Api Key

Plaintext key (shown once - store securely!)

string
created_at
required
Created At

Creation timestamp

string format: date-time
multi_tenant
required
Multi Tenant

Multi-tenant enabled

boolean
permissions
required
Permissions

Service permissions

Array<string>

Invalid API key

AdminAPIError

Standard error response for Admin API.

Attributes: error: Error code (e.g., ‘key_exists’, ‘permission_denied’) message: Human-readable error message

object
error
required
Error

Error code

string
message
required
Message

Human-readable error message

string

Missing admin:keys permission

AdminAPIError

Standard error response for Admin API.

Attributes: error: Error code (e.g., ‘key_exists’, ‘permission_denied’) message: Human-readable error message

object
error
required
Error

Error code

string
message
required
Message

Human-readable error message

string

Key with name already exists

AdminAPIError

Standard error response for Admin API.

Attributes: error: Error code (e.g., ‘key_exists’, ‘permission_denied’) message: Human-readable error message

object
error
required
Error

Error code

string
message
required
Message

Human-readable error message

string

Validation Error

HTTPValidationError
object
detail
Detail
Array<object>
ValidationError
object
loc
required
Location
Array
msg
required
Message
string
type
required
Error Type
string
input
Input
ctx
Context
object

Rate limited

AdminAPIError

Standard error response for Admin API.

Attributes: error: Error code (e.g., ‘key_exists’, ‘permission_denied’) message: Human-readable error message

object
error
required
Error

Error code

string
message
required
Message

Human-readable error message

string