Ruby
Python
PHP
Java
Node.js
Go
.NET
Authentification and JWT Token
To explore further than the root endpoint /, you will need a valid account.
Generally speaking, the Crossing Minds API uses the JWT standard to authenticate the requests. The Authentication documentation explains these mechanisms in more detail.
Before creating any database or receiving any recommendation, you will need to authenticate using the root account. Let’s assume the correct values are found in the following environment variables:
Your first JWT token will be obtained from the endpoint POST login/individual/ using the root email/password combination.
Once you get a token, you won’t need to use a password to authenticate.
In the Authentication documentation you may also read about refresh tokens, which provides a mechanism to renew the short-lived JWT token automatically without having to enter your password again. This is particularly helpful to implement frontend clients without having to expose your API key publicly.
Using JWT and Refresh Tokens
Authenticating Requests with JWT
Once you get a JWT, you can use it in the Authorization HTTP header (see RFC6750), using the syntax:
Authorization: Bearer <JWT_TOKEN>
If you are using an official client, this is done automatically.
Renewing the JWT with a Refresh Token
For security reasons, the JWT is short lived. In order to automatically re-login when the token expires, you can use the refresh token.
This is done by calling POST login/refresh-token/, which returns a new short-lived JWT, and eventually a new refresh token as well if it was about to expire.
You can also change the selected database when renewing a JWT.
If you are using an official client, this is also done automatically.
New Account Creation
You may want to create multiple accounts instead of using only the root account. For instance to create accounts with less permissive roles than root. The necessary steps are as follows:
- use POST accounts/individual/ or POST accounts/service/ from an account with root or manager role
- for individual accounts, verify the email address using GET accounts/verify/ to enter the code that has been sent to your email address
- the new account can be used to login and select your database with POST login/individual/ or POST login/service/ as before