For programmatic access to the Data Activation REST API, you can use a combination of an API key, refresh token, and access tokens. The API key is linked to your account, and with the API key, you can create a new refresh token. With the refresh token, you can create the actual access tokens.
This article describes how to set up the API key and the tokens.
Before you begin
You need a Data activation account with API permissions.
Instructions
Create API key
On the Data Activation platform, click your username and go to User settings.
Select the API Authentication tab.
Click New API Key.
Give the key a unique name, and press enter to save.
Click the eye icon to view the API Key. Copy the key to generate the tokens.
Note
For each platform and use case, create a unique API key with a name that describes the API key's purpose. For example, you can create separate keys for mobile, call center, or CRM.
Generate tokens
To generate the refresh token, use the following API request, which you can configure in any general-purpose programming language. Replace the
$apiKeywith your API key.curl --location --request POST 'https://api.relay42.com/users/authenticate' \--header 'Content-Type: application/json' \--data-raw '{"apiKey" : "$apikey"}'The HTTP request returns a refresh token, such as the following example:
{"refreshToken": "$refreshToken","expiresInSeconds": 172800}Use the token received to generate the access token with the following HTTP call. Replace the
$refreshTokenwith your own refresh token generated in the previous step.curl --location --request POST 'https://api.relay42.com/users/token' \--header 'Content-Type: application/json' \--data-raw '{"refreshToken" : "$refreshToken"}'The HTTP call returns the access token, such as the following example:
{"token": "$accessToken","tokenType": "Bearer","expiresInSeconds": 86400}Use the access token to access the REST APIs. For example, to access profile facts for a given
partnerType, pass the access token as a bearer token to the REST API:curl --location --request GET 'https://api.relay42.com/v1/site-1496/profiles/42/facts?partnerId=2f47e027-f186-4014-b7f0-1fc6eb744746' \--header 'Content-Type: application/json' \--header 'Authorization: Bearer $token'
Delete API key
On the Data Activation platform, click your username and go to User settings.
Select the API Authentication tab
Click the delete icon to delete the API key.
Troubleshooting
It says my account is administratively blocked. What does this mean?
Contact our support team at support@relay42.com to reactivate your account.
When generating an access token, I see a 401 message. What do I need to do?
There are two options here:
The API key is incorrect. Go back to the API authentication menu and try copying it again.
If you pass other authentication methods, such as a bearer token in the header, you will also receive this error.
How do I set API access for a specific token?
The API access is linked to the account. This means that all API keys created from one account will have the same access.