Query API
OverviewDirect link to Overview
The Rokt Query API is a comprehensive and flexible API for querying account data, campaigns, and transactions. Check out our interactive documentation here.
AuthenticationDirect link to 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 SecretDirect link to 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 TokenDirect link to 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 ExampleDirect link to 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 NotesDirect link to Important Notes
- Always use environment variables for credentials to avoid exposing them in scripts or version control
- The
printfcommand withopenssl base64ensures proper encoding without newline characters - Store the access token securely as it provides full API access until expiration
Rate LimitingDirect link to Rate Limiting
API requests are rate-limited to ensure fair usage and system stability.
Error HandlingDirect link to Error Handling
The API returns standardized error responses with appropriate HTTP status codes.
Account APIsDirect link to Account APIs
Get User AcconutsDirect link to Get User Acconuts
Retrieve all accounts associated with the authenticated user.
DescriptionDirect link to 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.
RequestDirect link to Request
PathDirect link to Path
GET /v1/query/accounts
AuthenticationDirect link to 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.
ResponseDirect link to 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 ResponsesDirect link to 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 ResponseDirect link to 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 AccountDirect link to Get Account
Retrieve detailed information for a specific account.
DescriptionDirect link to 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.
RequestDirect link to Request
PathDirect link to Path
GET /v1/query/accounts/{account_id}
ParametersDirect link to Parameters
accountId(path): The unique identifier of the account to retrieve
AuthenticationDirect link to 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. The user must have access permissions to the specified account and campaign data.
ResponseDirect link to Response
Returns a single account object 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 ResponsesDirect link to Error Responses
401 Unauthorized: Failed to authenticate. Invalid token.403 Forbidden: User does not have access to the specified account404 Not Found: Account with the specified ID does not exist500 Internal Server Error: Server error while retrieving account
Example ResponseDirect link to Example Response
{
"accountId": "1234567891011",
"accountName": "Example Account 1",
"countryCode": "US",
"accountOwner": "user@example.com",
"accountCurrencyCode": "USD",
"accountTimezone": "America/New_York",
"accountTimezoneOffset": -300
}
Advertiser APIsDirect link to Advertiser APIs
Get Advertiser ReportDirect link to Get Advertiser Report
Generate a comprehensive campaign report for the specified account.
DescriptionDirect link to Description
This endpoint allows you to query campaign performance data with flexible filtering, metrics selection, and date range specification. The response includes aggregated campaign data based on your specified criteria.
RequestDirect link to Request
PathDirect link to Path
POST /v1/query/accounts/{account_id}/campaigns/
ParametersDirect link to Parameters
account_id(path): The unique identifier of the account for which to generate the report
Request BodyDirect link to Request Body
The request body should contain a ReportingRequestExternal object
with the following fields:
| Parameter | Type | Required | Description | Default |
|---|---|---|---|---|
timezoneVariation | string | optional | Timezone for the report data | "America/New_York" |
currencyCode | string | optional | Currency code for the report data | "USD" |
interval | string | optional | Time interval for the report data. Options: "day", "week", "month", "year" | |
startDate | string | required | Start date for the report period in ISO format (inclusive). Accepts YYYY-MM-DD or YYYY-MM-DD HH:MM:SS | |
endDate | string | required | End date for the report period in ISO format (exclusive). Accepts YYYY-MM-DD or YYYY-MM-DD HH:MM:SS | |
dimensionFilters | object | optional | Filters to apply to specific dimensions | |
metrics | array | required | List of metrics to include in the report. Use slugs from get_help endpoint | |
dimensions | array | optional | Dimensions to group the data by. Use slugs from get_help endpoint | |
orderBys | array | optional | Sorting criteria for the results. Accepts both "column" and "direction" keys | |
limit | integer | optional | Maximum number of results to return |
Example RequestDirect link to Example Request
{
"timezoneVariation": "America/New_York",
"currencyCode": "USD",
"interval": "day",
"startDate": "2025-03-04",
"endDate": "2025-03-05",
"dimensionFilters": {
"campaign_id": ["3427232771076128951"]
},
"metrics": ["impressions", "referrals", "gross_cost"],
"dimensions": ["campaign_id", "creative_id", "age_group"],
"orderBys": [
{
"column": "referrals",
"direction": "desc"
}
]
}
AuthenticationDirect link to Authentication
Requires either a valid JWT Bearer token or Cognito token in the request headers. For more information about authenticating with our API, see the Authentication documentation. The user must have access permissions to the specified account and campaign data.
ResponseDirect link to Response
Returns a ReportingResponseExternal object containing:
data: Array of requested campaign metrics and dimensions. If interval is provided, each object will contain adatetimefield denoting the start of the provided interval.accountId: The account ID for which the report was generatedqueryTimeMs: Query execution time in milliseconds
Error ResponsesDirect link to Error Responses
400 Bad Request: Invalid request parameters or filters401 Unauthorized: Failed to authenticate. Invalid token.403 Forbidden: User does not have access to the specified account404 Not Found: The requested resource was not found. Please validate your request is correct and try again.500 Internal Server Error: Server error while generating report
Example ResponseDirect link to Example Response
{
"data": [
{
"datetime": "2025-03-04T00:00:00Z",
"impressions": 1501.0,
"referrals": 205.0,
"gross_cost": 410.05,
"campaign_id": "3427232771076128951",
"creative_id": "3427232968644886703",
"age_group": "26-35"
},
{
"datetime": "2025-03-04T00:00:00Z",
"impressions": 1220.0,
"referrals": 180.0,
"gross_cost": 300.00,
"campaign_id": "3401676908203081730",
"creative_id": "3404563830614458492",
"age_group": "36-45"
}
],
"accountId": "3286272607917027328",
"queryTimeMs": 206
}
Get HelpDirect link to Get Help
Retrieve available metrics and dimensions for campaign reporting.
DescriptionDirect link to Description
This endpoint returns metadata about the available reporting options, including which metrics and dimensions can be used together, their display names, and any additional configuration options.
RequestDirect link to Request
PathDirect link to Path
GET /v1/query/accounts/{account_id}/campaigns/help
ParametersDirect link to Parameters
account_id(path): The unique identifier of the account (used for access validation)
AuthenticationDirect link to 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. The user must have access permissions to the specified account and campaign data.
ResponseDirect link to Response
Returns a ReportingMetadataExternal object containing:
dimensions: List of dimensions with their slugs and descriptionsmetrics: List of metrics with their slugs and descriptions
Error ResponsesDirect link to Error Responses
401 Unauthorized: Failed to authenticate. Invalid token.403 Forbidden: User does not have access to the specified account404 Not Found: The requested resource was not found. Please validate your request is correct and try again.500 Internal Server Error: Server error while retrieving metadata
Example ResponseDirect link to Example Response
{
"dimensions": [
{
"slug": "age_range",
"description": "The age range of the user"
},
{
"slug": "campaign_id",
"description": "The ID of the campaign"
},
{
"slug": "creative_id",
"description": "The ID of the creative"
},
{
"slug": "device",
"description": "The device of the user"
},
],
"metrics": [
{
"slug": "impressions",
"description": "The number of ad impressions"
},
{
"slug": "referrals",
"description": "The number of positive engagements with the ad"
},
{
"slug": "clickthru_acquisitions",
"description": "The number of click-thru acquisitions for the ad. An acquisition represents the first conversion following an engagement event."
},
{
"slug": "cpa",
"description": "The Cost per Acquisition for the ad"
},
{
"slug": "gross_cost",
"description": "The gross cost (spend) for the ad"
},
]
}
Partner APIsDirect link to Partner APIs
Get Partner ReportDirect link to Get Partner Report
Generate a comprehensive transaction report for the specified account.
DescriptionDirect link to Description
This endpoint allows you to query transaction data with flexible filtering, metrics selection, and date range specification. The response includes aggregated transaction data based on your specified criteria.
RequestDirect link to Request
PathDirect link to Path
POST /v1/query/accounts/{account_id}/transactions
ParametersDirect link to Parameters
account_id(path): The unique identifier of the account for which to generate the report
Request BodyDirect link to Request Body
The request body should contain a ReportingRequestExternal object
with the following fields:
| Parameter | Type | Required | Description | Default |
|---|---|---|---|---|
timezoneVariation | string | optional | Timezone for the report data | "America/New_York" |
currencyCode | string | optional | Currency code for the report data | "USD" |
interval | string | optional | Time interval for the report data. Options: "day", "week", "month", "year" | |
startDate | string | required | Start date for the report period in ISO format (inclusive). Accepts YYYY-MM-DD or YYYY-MM-DD HH:MM:SS | |
endDate | string | required | End date for the report period in ISO format (exclusive). Accepts YYYY-MM-DD or YYYY-MM-DD HH:MM:SS | |
dimensionFilters | object | optional | Filters to apply to specific dimensions | |
metrics | array | required | List of metrics to include in the report. Use slugs from get_help endpoint | |
dimensions | array | optional | Dimensions to group the data by. Use slugs from get_help endpoint | |
orderBys | array | optional | Sorting criteria for the results. Accepts both "column" and "direction" keys | |
limit | integer | optional | Maximum number of results to return |
Example RequestDirect link to Example Request
{
"timezoneVariation": "America/New_York",
"currencyCode": "USD",
"interval": "day",
"startDate": "2025-03-04",
"endDate": "2025-03-05",
"dimensionFilters": {
"page_type": ["confirmation"]
},
"metrics": ["impressions", "referrals", "total_page_transactions"],
"dimensions": ["display_type", "page_type", "age_range"],
"orderBys": [
{
"column": "referrals",
"direction": "desc"
}
]
}
AuthenticationDirect link to Authentication
Requires either a valid JWT Bearer token or Cognito token in the request headers. For more information about authenticating with our API, see the Authentication documentation. The user must have access permissions to the specified account and transaction data.
ResponseDirect link to Response
Returns a ReportingResponseExternal object containing:
data: Array of requested transaction metrics and dimensions. If interval is provided, each object will contain adatetimefield denoting the start of the provided interval.accountId: The account ID for which the report was generatedqueryTimeMs: Query execution time in milliseconds
Error ResponsesDirect link to Error Responses
400 Bad Request: Invalid request parameters or filters401 Unauthorized: Failed to authenticate. Invalid token.403 Forbidden: User does not have access to the specified account404 Not Found: The requested resource was not found. Please validate your request is correct and try again.500 Internal Server Error: Server error while generating report
Example ResponseDirect link to Example Response
{
"data": [
{
"datetime": "2025-03-04T00:00:00Z",
"impressions": 1501.0,
"referrals": 205.0,
"total_page_transactions": 1600.0,
"display_type": "desktop",
"page_type": "confirmation",
"age_range": "26-35"
},
{
"datetime": "2025-03-04T00:00:00Z",
"impressions": 1220.0,
"referrals": 180.0,
"total_page_transactions": 1400.0,
"display_type": "mobile",
"page_type": "confirmation",
"age_range": "36-45"
}
],
"accountId": "3286272607917027328",
"queryTimeMs": 206
}
Get HelpDirect link to Get Help
Retrieve available metrics and dimensions for transaction reporting.
DescriptionDirect link to Description
This endpoint returns metadata about the available reporting options, including which metrics and dimensions can be used together, their display names, and any additional configuration options.
RequestDirect link to Request
PathDirect link to Path
GET /v1/query/accounts/{account_id}/transactions/help
ParametersDirect link to Parameters
account_id(path): The unique identifier of the account (used for access validation)
AuthenticationDirect link to 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. The user must have access permissions to the specified account and transaction data.
ResponseDirect link to Response
Returns a ReportingMetadataExternal object containing:
dimensions: List of dimensions with their slugs and definitionsmetrics: List of metrics with their slugs and definitions
Error ResponsesDirect link to Error Responses
401 Unauthorized: Failed to authenticate. Invalid token.403 Forbidden: User does not have access to the specified account404 Not Found: The requested resource was not found. Please validate your request is correct and try again.500 Internal Server Error: Server error while retrieving metadata
Example ResponseDirect link to Example Response
{
"dimensions": [
{
"slug": "age_range",
"description": "The age range of the user"
},
{
"slug": "display_type",
"description": "The type of display the ad was shown on"
},
{
"slug": "page_type",
"description": "The type of page the user was on"
},
{
"slug": "device",
"description": "The device of the user"
},
],
"metrics": [
{
"slug": "transactions",
"description": "Total number of transactions"
},
{
"slug": "rokt_transactions_per_transaction",
"description": "Total number of transactions processed by Rokt per transaction"
},
{
"slug": "impressions",
"description": "Total number of advertisement impressions"
},
{
"slug": "page_transactions",
"description": "Total number of transactions processed by page"
},
{
"slug": "layout_impressions",
"description": "Total number of advertisement impressions processed by layout"
},
]
}
Available Data PointsDirect link to Available Data Points
The following dimensions and metrics are available for use with the Query API. Use the Get Help endpoints for campaigns or transactions to retrieve the exact list available for your account. The slugs below are used in request bodies for dimensions, metrics, dimensionFilters, and orderBys.
DimensionsDirect link to Dimensions
| Slug | Description |
|---|---|
age_range | Age range of the user |
audience_name | Name of the audience |
advertiser_id | ID of the advertiser |
campaign_id | ID of the campaign |
campaign_name | Name of the campaign |
campaign_objective | Objective of the campaign |
campaign_country | Country of the campaign |
creative_id | ID of the creative |
creative_name | Name of the creative |
device | Device of the user |
gender | Gender of the user |
partner_sub_vertical | Sub-vertical of the partner |
partner_vertical | Vertical of the partner |
rank | Rank of the ad placement |
user_country | Country of the user |
country | Country the user is located in |
state | State the user is located in |
population_density | Population density (metropolitan, micropolitan, rural, unknown) |
dma | DMA the user is located in |
dma_code | DMA code the user is located in |
zcta | ZCTA the user is located in |
zip_code | Zip code the user is located in |
operating_system | Operating system of the user (Android, iOS, Windows, Mac OS X, etc.) |
position | Position of the placement |
contains_lookalike_audience | Whether the campaign contains a lookalike audience |
customer_interactivity | Customer interactivity segment |
platform_type | Application environment through which a Rokt Layout is rendered |
MetricsDirect link to Metrics
| Slug | Description |
|---|---|
impressions | Total number of advertisement impressions |
referral_rate | Total number of referrals per impression |
referrals | Total number of positive engagements on advertisements |
click_thru_acquisitions | Click-thru acquisitions grouped by campaign time (first conversion after engagement) |
click_thru_acquisitions_by_conversion_time | Click-thru acquisitions grouped by conversion time |
view_thru_acquisitions_by_conversion_time | View-thru acquisitions grouped by conversion time |
acquisitions_by_conversion_time | All acquisitions grouped by conversion time |
conversion_amount_fill_rate | Average fill rate of conversion amount for conversions |
click_thru_conversion_rate | Average conversion rate for click-thru conversions |
view_thru_conversion_rate | Average conversion rate for view-thru conversions |
conversion_rate | Average conversion rate for all conversions |
click_thru_conversions | Total number of click-thru conversions |
click_thru_conversions_by_conversion_time | Click-thru conversions grouped by conversion time |
view_thru_conversions_by_conversion_time | View-thru conversions grouped by conversion time |
click_thru_copi | Average click-thru conversions per ad impression |
click_thru_cpa | Average cost per acquisition for click-thru acquisitions |
view_thru_cpa | Average cost per acquisition for view-thru acquisitions |
cpa | Average cost per acquisition (all) |
cpr | Average cost per referral |
gross_cost | Total ad spend on the Rokt platform |
net_cost | Total ad spend minus scrub rate |
click_thru_acquisition_roas | ROAS for click-thru acquisitions |
view_thru_acquisition_roas | ROAS for view-thru acquisitions |
acquisition_roas | ROAS for all acquisitions |
click_thru_conversion_roas | ROAS for click-thru conversions |
view_thru_conversion_roas | ROAS for view-thru conversions |
conversion_roas | ROAS for all conversions |
view_thru_acquisitions | Total number of view-thru acquisitions |
view_thru_conversions | Total number of view-thru conversions |
acquisitions | Total number of acquisitions |
conversions | Total number of conversions |
conversions_by_conversion_time | All conversions grouped by conversion time |
copi | Average conversions per impression for acquisitions |
view_thru_copi | Average conversions per impression for view-thru acquisitions |
click_thru_cpa_by_conversion_time | Average CPA for click-thru acquisitions grouped by conversion time |
cost_per_impression | Average cost per impression |
custom_click_thru_conversion_rate_conversions | Average conversion rate for click-thru conversions |
unique_creatives | Count of unique creatives |
unique_campaigns | Count of unique campaigns |
unique_audiences | Count of unique audiences |
unique_campaign_countries | Count of unique campaign countries |
click_thru_conversion_aov | Average order value of click-thru conversions (USD) |
click_thru_conversion_value | Total value of click-thru conversions (USD) |
acquisitions_value | Total value of acquisitions (USD) |
acquisition_aov | Average order value of acquisitions (USD) |
conversion_value | Total value of all conversions (USD) |
conversion_aov | Average order value of conversions (USD) |
view_thru_acquisitions_value | Total value of view-thru acquisitions (USD) |
view_thru_acquisition_aov | Average order value of view-thru acquisitions (USD) |
view_thru_conversion_value | Total value of view-thru conversions (USD) |
view_thru_conversion_aov | Average order value of view-thru conversions (USD) |
click_thru_acquisition_value | Total value of click-thru acquisitions (USD) |
click_thru_acquisition_aov | Average order value of click-thru acquisitions (USD) |