Autenticação
A API Handelsregister AI suporta dois métodos de autenticação: Chave API e Token Bearer. Ambos os métodos funcionam em todos os endpoints da API.
Métodos de Autenticação
x-api-key: YOUR_API_KEY |
Chave API via Cabeçalho: Recomendado para integrações servidor-para-servidor e uso em produção |
?api_key=YOUR_API_KEY |
Chave API via Parâmetro de Consulta: Apenas para testes rápidos e compatibilidade retroativa |
Authorization: Bearer YOUR_TOKEN |
Token Bearer: Melhor para aplicações que requerem controle de acesso refinado, expiração de token e segurança aprimorada |
Exemplos de Autenticação por Chave API
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"
Gerenciamento de Token Bearer
Criar um 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"
}'
A resposta incluirá seu token Bearer. Armazene-o com segurança!
Usando um Token Bearer
curl -X GET "https://handelsregister.ai/api/v1/search-organizations?q=company" \
-H "Authorization: Bearer YOUR_API_TOKEN"
Endpoints de Gerenciamento de Token
POST /api/v1/auth/tokens/create |
Criar novo token |
GET /api/v1/auth/tokens |
Listar todos os tokens |
DELETE /api/v1/auth/tokens/{id} |
Revogar token específico |
DELETE /api/v1/auth/tokens |
Revogar todos os tokens |