Step 2: Get an access token

Now, you must exchange your client ID and client secret for an access token. The access token securely authenticates your upcoming API calls.

In this guide, we'll start by requesting an access token through the Create an access token endpoint. After that, we'll copy the access token to use in Step 3.

1. Request an access token

This guide outlines two methods to request an access token:

  • Using curl: Send HTTP requests directly from your command line interface.
  • Through the API reference portal: Test the endpoint directly in the API reference documentation, with options to select your preferred programming language.

Using curl

  1. Copy the curl example below.
curl --request POST \
     --url your_environment_url/api/v2/oauth2/token \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --data '
{
  "grant_type": "client_credentials",
  "client_id": "your_client_ID",
  "client_secret": "your_client_secret"
}
'
  1. Paste it into a text editor.
  2. In line 2, replace your_environment_url with the URL for your environment:
  3. In line 8, replace your_client_ID with your client ID.
  4. In line 9, replace your_client_secret with your client secret.
  5. Copy the code and paste it into your terminal.
  6. Hit Enter to execute the request.

Through the API reference portal

  1. Go to Create an access token.
  2. Under BODY PARAMS, enter:
    1. client_id: Your client ID.
    2. client_secret: Your client secret.
  3. At the top right, select your preferred programming language.
  4. In the right panel under URL, click Base URL and select the appropriate URL based on your environment:
    1. Production EU
    2. Production US
  5. In the code snippet panel on the right, click Try it! to execute the request.

2. Copy the access token from the response

If successful, the API will return a JSON response containing your access token:

{  
  "token_type": "Bearer",  
  "access_token": "your_access_token",  
  "expires_in": "3600"  
}

Make sure to copy the access token (your_access_token) and store it securely, as you'll need it for the next step.

Token expiration

An access token is valid for 1 hour. After that, you'll need to request a new token to maintain access.

💡

If you encounter any errors while making API calls, please refer to our dedicated Error handling guide for troubleshooting tips and common solutions.