Authentication
How your requests identify themselves.
API key
Every request identifies itself with your API key. Send it in the header x-api-key. The request then runs on your account and is billed to your balance.
When you create your account, we create the first key for you. You find it under Account › API keys. There you create more keys and delete them again.
Use a separate key for each application or integration. Then you can delete one without touching the others. The API rejects requests with a deleted key right away.
curl -G "https://handelsregister.ai/api/v1/fetch-organization" \ -H "x-api-key: YOUR_API_KEY" \ --data-urlencode 'q=Hetzner Online GmbH'
import requests response = requests.get( "https://handelsregister.ai/api/v1/fetch-organization", headers={"x-api-key": "YOUR_API_KEY"}, params={ "q": "Hetzner Online GmbH", }, ) data = response.json()
const url = new URL("https://handelsregister.ai/api/v1/fetch-organization"); url.searchParams.append("q", "Hetzner Online GmbH"); const response = await fetch(url, { headers: { "x-api-key": "YOUR_API_KEY" }, }); const data = await response.json();
403.
Three ways to authenticate
The API accepts credentials in three ways. For your own code, the header x-api-key is the simplest and safest.
| Way | What it looks like | Works for |
|---|---|---|
| API key in the header (recommended) |
x-api-key: YOUR_API_KEY |
All endpoints |
Bearer token: a token from /v1/auth/tokens or an AI agent's OAuth token
|
Authorization: Bearer YOUR_TOKEN |
All endpoints except /v1/auth/tokens
|
| API key as a parameter in the URL |
?api_key=YOUR_API_KEY |
Data endpoints and /v1/auth/tokens; /v1/account/* rejects it with 400
|
The parameter api_key still works on the data endpoints. But URLs easily end up in logs, browser histories and proxies. So send the key in the header.
curl -G "https://handelsregister.ai/api/v1/fetch-organization" \ -H "Authorization: Bearer YOUR_TOKEN" \ --data-urlencode "q=Hetzner Online GmbH"
Create a bearer token
A bearer token is an additional credential. You give it a name, abilities and an expiry date yourself. You create it with your API key via POST /v1/auth/tokens/create. The endpoints under /v1/auth/tokens accept only the API key, not a bearer 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": "CRM-Abgleich", "abilities": [ "api:data", "account:read" ], "expires_at": "2027-12-31" }'
import requests response = requests.post( "https://handelsregister.ai/api/v1/auth/tokens/create", headers={"x-api-key": "YOUR_API_KEY"}, json={ "token_name": "CRM-Abgleich", "abilities": [ "api:data", "account:read" ], "expires_at": "2027-12-31" }, ) data = response.json()
const url = new URL("https://handelsregister.ai/api/v1/auth/tokens/create"); const response = await fetch(url, { method: "POST", headers: { "x-api-key": "YOUR_API_KEY", "Content-Type": "application/json" }, body: JSON.stringify({ "token_name": "CRM-Abgleich", "abilities": [ "api:data", "account:read" ], "expires_at": "2027-12-31" }), }); const data = await response.json();
| Name | Type | Description | Example |
|---|---|---|---|
| token_nameBody | stringrequired | A name you recognize the token by, such as the name of your application.Limits: at most 255 characters |
CRM-Abgleich |
| abilitiesBody | list of stringoptional |
The abilities as a list. If omitted, the token gets api:data for the data endpoints and account:read for the account endpoints. monitoring:manage allows changes to monitors.Default: ["*"] |
["api:data","account:read"] |
| expires_atBody | string (date-time)optional | Expiry date in the future. If omitted, the token is valid until you revoke it. |
2027-12-31 |
The response contains the token in the field token, plus name, abilities, expires_at and created_at. You see the token only this once. Store it right away.
Without expires_at, the token is valid until you revoke it.
A token can have these abilities:
| Ability | Meaning |
|---|---|
| api:data | Query data: company profiles, person profiles, Search & Export, documents and Signals. These endpoints accept any valid token. |
| account:read | Read the account: balance, usage, credit subscription, API keys, monitors and webhook endpoints. |
| monitoring:manage | Create, update, pause, resume and archive monitors, verify and test webhook endpoints, resend deliveries. |
| account:keys | Manage API keys and webhook endpoints. Only the admin token has this ability. |
GET /v1/auth/tokens lists your tokens. DELETE /v1/auth/tokens/{id} revokes one, DELETE /v1/auth/tokens revokes all of them, including the admin token.
These endpoints have a limit of 10 requests per minute. They cost no credits.
Admin token
To manage credentials, you need more than an API key. Only with the admin token can you create and delete keys and set up webhook endpoints via the API.
You create the admin token under Account › API keys, in the area “For developers: manage keys via the API”. It is valid for one year. A new admin token replaces the old one. You can also revoke it there at any time.
You send it as a bearer token: Authorization: Bearer YOUR_ADMIN_TOKEN. It has the abilities account:read, account:keys and monitoring:manage.
| Action | API key | Bearer token needs |
|---|---|---|
Read the account (every GET under /v1/account)
|
yes |
account:read |
| Manage monitors, verify and test webhook endpoints, resend deliveries | yes |
account:read, monitoring:manage |
| Create and delete API keys | no, only with the admin token |
account:keys |
| Create webhook endpoints, rotate the secret, enable, disable and archive them | no, only with the admin token |
account:read, account:keys |
OAuth for AI agents
ChatGPT, Claude and other AI agents sign in with OAuth 2.1. You only enter the server URL, sign in to handelsregister.ai and give consent. You don't need to copy an API key.
The URL of the MCP server is https://mcp.handelsregister.ai/mcp. How to set up ChatGPT, Claude and other clients is described under ChatGPT plugin and MCP.
If you build your own client, it finds everything it needs in the discovery documents:
| What | URL |
|---|---|
| Metadata of the MCP server (protected resource) |
https://mcp.handelsregister.ai/.well-known/oauth-protected-resource |
| Metadata of the authorization server |
https://handelsregister.ai/.well-known/oauth-authorization-server |
| Register a client (Dynamic Client Registration) |
POST https://handelsregister.ai/oauth/register |
| Sign-in and consent |
https://handelsregister.ai/oauth/authorize |
| Get and refresh tokens |
POST https://handelsregister.ai/oauth/token |
| Revoke a token |
POST https://handelsregister.ai/oauth/revoke |
The flow is the Authorization Code Flow with PKCE, preferably with the method S256. Clients register themselves via Dynamic Client Registration.
The access token is short-lived; expires_in tells you for how long. With the scope offline_access, the client gets a refresh token and renews access on its own.
| Scope | Meaning |
|---|---|
| mcp | Use the tools of the MCP server. The token also works for the API's data endpoints. |
| api | Use the API on your behalf: query data and read the account. |
| offline_access | Stay connected while you are away (refresh token). |
If a client requests no scopes, it gets mcp and offline_access.
You send an OAuth token like any bearer token in the header Authorization. Every request with it runs on your account and your balance, at the same prices as with an API key.
Protect your keys
Anyone who knows your API key can fetch data at your expense. Treat it like a password.
- Use it only on your server, never in the browser or in an app you distribute. Anyone can read it there.
- Keep it in an environment variable or a secret store, not in source code and not in Git.
- Send it in the header, not in the URL.
- Rotate keys regularly: create a new key, swap it in your application, delete the old one.
Authentication errors
These responses show that something is wrong with the credentials. They never cost credits.
| Status | Cause | What you can do |
|---|---|---|
| 400 |
api_key in the URL of a request to /v1/account/*.
|
Send the key in the header x-api-key.
|
| 401 | No credentials sent, or the key or token is invalid, deleted or expired. | Check the header, compare the key under Account › API keys. |
| 403 | The account's email address is not confirmed yet. | Open the confirmation link in the email. |
| 403 | The token lacks an ability, or an API key tries to manage credentials. | Use a token with the right ability; for credentials, the admin token. |
1{2 "error": "Unauthorized: Missing or invalid authentication. Please provide a valid API key (via x-api-key header or api_key parameter) or Bearer token."3}