Skip to main content

Authentication

Every request to a protected endpoint carries a credential in the Authorization header. There are two ways to get one and they are interchangeable: an api key, which does not expire, or an access token from the login, which lives 15 minutes.

Use an api key instead

Logging in with username and password is deprecated for API use. Create an api key in the customer portal and send it as Authorization: Bearer <key>: a key does not expire, so there is no login before a call.

The login endpoint keeps working. Your keys are managed in the portal.

Api key​

Create a key in the customer portal at /portal/, on the page "Api keys". You see the key exactly once, right after creating it: we store only its checksum and cannot show it to you again. You may hold a small number of valid keys at a time, and the page says how many. A key you no longer need is revoked on the same page, which takes effect immediately.

Send it where the token would go:

curl https://api.axro.com/api/v1/product/ \
-H 'Authorization: Bearer axro_your_key_here'

A key does not expire, so there is nothing to refresh and no 401 to handle. It carries the same permissions as the user it belongs to, with one exception: a key may not manage keys. Create and revoke keys in the portal, where you sign in with your e-mail address and password. That way a key that fell into the wrong hands can neither create a second one nor revoke yours.

A key in a browser is a published key

The API answers calls from any origin, so you can call it from JavaScript in a browser. Be aware of what that means: anything your page sends is readable by the person using it. A key that reaches a browser counts as published, and it carries the permissions of the user it belongs to. Keep keys on your server and let your own backend talk to us, unless the data behind the key is meant to be public anyway.

Login with username and password​

Deprecated for API use

This is no longer the recommended way to reach the API. It keeps working and is not switched off. Use an api key for your requests, and the portal to manage your keys.

POST/api/v1/login/

Login with username (e-mail) and password to get an access token

NameTypeRequiredDescription
usernamestring✅Your AXRO account e-mail
passwordstring✅Your AXRO account password

Example Request​

curl -X POST https://api.axro.com/api/v1/login/ \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'username=your_username&password=your_password'

Example Response​

{
"token_type": "Bearer",
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}

Token lifetime​

An access token is valid for 15 minutes (900 seconds). The exact moment it expires is in the exp claim of the token itself, so your client can read it without asking us.

Reuse the token until it expires. Logging in before every request is the most expensive way to use this API: every login verifies your password with bcrypt, which is deliberately slow, so you pay that cost on every single call. One login every 15 minutes is enough, whatever your request volume is.

When a token has expired, the API answers 401 - Unauthorized. That is the signal to log in once more and repeat the request. Two lines in your client, and the login disappears from your hot path.