Authentication
Getting Started

Authentication

The API supports two authentication methods: API key and Bearer token. Both work on every endpoint.

Authentication Methods

x-api-key: YOUR_API_KEY API key via header: Recommended for server-to-server integrations and production use.
?api_key=YOUR_API_KEY API key via query parameter: Quick tests and backwards compatibility only — the key is visible in the URL.
Authorization: Bearer YOUR_TOKEN Bearer token: Best when you need fine-grained scopes, expiry dates, or instantly revocable access.

API Key Authentication Examples

Using the x-api-key header (recommended)
curl -X GET "https://handelsregister.ai/api/v1/search-organizations?q=company" \
     -H "x-api-key: YOUR_API_KEY"
# Using query parameter (legacy)
curl "https://handelsregister.ai/api/v1/fetch-organization?api_key=YOUR_API_KEY&q=company"

# Using x-api-key header (recommended)
curl -X GET "https://handelsregister.ai/api/v1/fetch-organization?q=company" \
     -H "x-api-key: YOUR_API_KEY"

Managing Bearer Tokens

Create a token

curl -X POST "https://handelsregister.ai/api/v1/auth/tokens/create" \
     -H "x-api-key: YOUR_API_KEY" \
     -H "Content-Type: application/json" \
     -d '{
       "token_name": "My Application",
       "abilities": ["*"],
       "expires_at": "2026-01-01 00:00:00"
     }'

The response includes your Bearer token — store it securely.

Use a token

curl -X GET "https://handelsregister.ai/api/v1/search-organizations?q=company" \
     -H "Authorization: Bearer YOUR_API_TOKEN"

Token Management Endpoints

POST /api/v1/auth/tokens/create Create a new token
GET /api/v1/auth/tokens List all tokens
DELETE /api/v1/auth/tokens/{id} Revoke a single token
DELETE /api/v1/auth/tokens Revoke all tokens