Authentification
Premiers Pas

Authentification

L'API Handelsregister AI prend en charge deux méthodes d'authentification : Clé API et Token Bearer. Les deux méthodes fonctionnent sur tous les endpoints de l'API.

Méthodes d'Authentification

x-api-key: YOUR_API_KEY Clé API via En-tête : Recommandé pour les intégrations serveur à serveur et l'utilisation en production
?api_key=YOUR_API_KEY Clé API via Paramètre de Requête : Uniquement pour les tests rapides et la rétrocompatibilité
Authorization: Bearer YOUR_TOKEN Token Bearer : Idéal pour les applications nécessitant un contrôle d'accès granulaire, l'expiration des tokens et une sécurité renforcée

Exemples d'Authentification par Clé API

Utilisation de l'En-tête x-api-key (Recommandé)
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"

Gestion des Tokens Bearer

Créer un Token API

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"
     }'

La réponse inclura votre token Bearer. Conservez-le en lieu sûr !

Utiliser un Token Bearer

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

Endpoints de Gestion des Tokens

POST /api/v1/auth/tokens/create Créer un nouveau token
GET /api/v1/auth/tokens Lister tous les tokens
DELETE /api/v1/auth/tokens/{id} Révoquer un token spécifique
DELETE /api/v1/auth/tokens Révoquer tous les tokens