Skip to content

2. Get the token

You need a valid authorization token to use the API.

To get the token you must have an expert.ai developer account. Visit the developer portal and sign up to get one.

If you are going to make your first call using an interactive tool like curl or Postman, follow the instructions below to get the token by using the same tool.
If, instead, you are going to make the first call using an expert.ai client package, you can go to the next step since the client is able to get the token by itself.

Info

The authorization token has a certain duration and then expires, so if you want to do interactive tests with curl or Postman at a certain distance of time from each other, repeat the procedure below to obtain it.

Get the token with curl

To get the authorization token with curl, run the following command from a shell after replacing yourusername and yourpassword with your account credentials:

curl -X POST https://developer.expert.ai/oauth2/token \
    -H 'Content-Type: application/json; charset=utf-8' \
    -d '{
  "username": "yourusername",
  "password": "yourpassword"
}'

To get the authorization token with curl, open a command prompt in the folder where you installed curl and run the following command after replacing yourusername and yourpassword with your account credentials:

curl -X POST https://developer.expert.ai/oauth2/token -H "Content-Type: application/json; charset=utf-8" -d "{\"username\": \"yourusername\", \"password\": \"yourpassword\"}"

The token is the command output, note it down or copy it to the clipboard.

Get and save the token with Postman

To obtain and save the token with Postman:

  1. Run Postman.
  2. Select the expert.ai Natural Language API collection you previously imported.
  3. Select the Variables tab.
  4. Replace the current value of variables username and password with your account credentials.
  5. Select Save.
  6. Expand the expert.ai Natural Language API collection.
  7. Select token.
  8. Select Send in the right panel. The result is the authorization token, that also gets automatically saved as a collection variable.

The next step

You are now ready to make your first call.