Query API
Overview
The Rokt Query API is a comprehensive and flexible API for querying account data, campaigns, and transactions. Check out our interactive documentation here.
Authentication
The Rokt Query API leverages the OAuth 2.0 approach to client integration. See the OAuth 2.0 Credentials Flow for more details. You need to use your Rokt App ID and App Secret to access the Query API.
Generating a Rokt App ID and App Secret
- Sign in to One Platform at my.rokt.com
- Navigate to Profile Settings under your account icon at the bottom left
- Scroll down to the Generate Personal API Credentials section
- Enter the name of your app and click Generate
- Store the App ID and App Secret securely - you will not have access to the App Secret again
Generating an Access Token
Rokt uses OAuth 2.0 for secure authentication to our public APIs. This is to ensure that only authorized users can access their data.
To generate an access token, make the following POST request.
curl -X POST https://api.rokt.com/auth/oauth2/token \
--header "Authorization: Basic $ENCODED_TOKEN" \
--header "Content-Type: application/x-www-form-urlencoded" \
--data "grant_type=client_credentials"
The access token expires after one hour, and must be included as a Bearer token in all API requests.
Step-by-Step Example
Here's a complete example using shell commands:
# Step 1: Set your environment variables. Do not store these in version control
export ROKT_APP_ID="your_app_id"
export ROKT_APP_SECRET="your_secret"
# Step 2: Encode your credentials to generate an auth token
export ENCODED_TOKEN=$(printf '%s' "${ROKT_APP_ID}:${ROKT_APP_SECRET}" | openssl base64 | tr -d '\n')
# Step 3: Request OAuth2/Bearer token using Basic Auth with the encoded token
BEARER_TOKEN=$(curl -s -X POST https://api.rokt.com/auth/oauth2/token \
-H "Authorization: Basic $ENCODED_TOKEN" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=client_credentials" | jq -r '.access_token')
# Step 4: Use the Bearer token in Query API requests
curl -X GET "https://api.rokt.com/v1/query/accounts" \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer $BEARER_TOKEN"
Important Notes
- Always use environment variables for credentials to avoid exposing them in scripts or version control
- The
printf
command withopenssl base64
ensures proper encoding without newline characters - Store the access token securely as it provides full API access until expiration
Rate Limiting
API requests are rate-limited to ensure fair usage and system stability.
Error Handling
The API returns standardized error responses with appropriate HTTP status codes.
Account APIs
Get User Acconuts
Retrieve all accounts associated with the authenticated user.
Description
This endpoint returns a list of all accounts that the authenticated user has access to. The response includes account details such as account ID, name, country, currency, and timezone information.
Request
Path
GET /v1/query/accounts
Authentication
Requires a valid Bearer token from a user's Rokt JWT or encoded OAuth2 token. For more information about authenticating with our API, see the Authentication documentation.
Response
Returns a list of account objects with the following structure:
accountId
: Unique identifier for the accountaccountName
: Display name of the accountcountryCode
: ISO country code for the accountaccountOwner
: Email address of the account owner (optional)accountCurrencyCode
: Currency code for the accountaccountTimezone
: Timezone name for the accountaccountTimezoneOffset
: Timezone offset in minutes
Error Responses
401 Unauthorized
: Failed to authenticate. Invalid token.404 Not Found
: User does not have any accounts500 Internal Server Error
: Server error while retrieving accounts
Example Response
[
{
"accountId": "acc_123456789",
"accountName": "Example Account 1",
"countryCode": "US",
"accountOwner": "user@example.com",
"accountCurrencyCode": "USD",
"accountTimezone": "America/New_York",
"accountTimezoneOffset": -300
},
{
"accountId": "acc_123456790",
"accountName": "Example Account 2",
"countryCode": "AU",
"accountOwner": "user@example.com",
"accountCurrencyCode": "AUD",
"accountTimezone": "Australia/Sydney",
"accountTimezoneOffset": 600
}
]
Get Account
Retrieve detailed information for a specific account.
Description
This endpoint returns detailed information about a specific account identified by the account_id parameter. The user must have access permissions to the specified account.