Personal access tokens
A personal access token (PAT) is a user-owned, revocable OAuth 2.0 client credential (pat_... / rsec_...) for programmatic access to Rokt APIs. Use PATs for non-interactive workloads—such as automated scripts, reporting pipelines, CLI tools, and backend integrations—that act on behalf of your Rokt user account with least-privilege scopes.
How permissions workHow permissions work への直接リンク
A PAT acts as a scoped proxy for the Rokt user who creates it. It never grants permissions that your user account does not already hold.
Every API call made with a PAT passes two checks:
- Token scopes: The access token includes a scope that permits the requested operation.
- User account permissions: Your Rokt user account has permission to access the target Rokt account and resource.
This model provides three security guarantees:
- Scopes are restrictive, never additive: Even if a token holds
reporting:campaigns:read, requests for an account you cannot access fail with403 Forbidden. - Blast-radius containment: A token scoped only to
query:campaigns:readcannot manage data deletion requests, even if your user account has administrator permissions. - Automatic offboarding: If your access to an account is removed or your user account is deactivated, your PATs lose access immediately.
Quickstart: Create and use a PATQuickstart: Create and use a PAT への直接リンク
When you create a PAT in One Platform, you receive a Token ID (pat_...) and a Token secret (rsec_...). Your application exchanges this credential pair for a short-lived bearer access token (rsej_...) before calling Rokt APIs.
1. Create a token in One Platform1. Create a token in One Platform への直接リンク
- Sign in to One Platform at my.rokt.com.
- Click your profile icon in the top-right corner and select Profile Settings (or go to my.rokt.com/profile-settings).
- Under Personal access tokens, select Create personal access token.
- Enter a descriptive Token name (up to 128 characters, for example
Snowflake reporting pipeline). - Choose an Expiration (30 days, 90 days (recommended), 180 days, 1 year, Custom date..., or No expiration).
- Under Scopes, select the scopes required for your integration (see Available scopes).
- Select Create token.
- In the Copy personal access token modal, copy the token secret (
rsec_...) and store it in your secrets manager. - Copy your Token ID (
pat_...) from the Token ID column in the Active tokens table.
Copy the rsec_... token secret before closing the modal. For security reasons, the secret is shown only once and cannot be retrieved again.
2. Exchange credentials for an access token2. Exchange credentials for an access token への直接リンク
Never send the long-lived rsec_... secret directly to Rokt data APIs. Instead, exchange your pat_... Token ID and rsec_... secret at the OAuth 2.0 token endpoint for a 5-minute bearer access token, passing a space-delimited scope list:
POST https://auth.rokt.com/api/v1/oauth/token
The endpoint accepts Content-Type: application/x-www-form-urlencoded with HTTP Basic authentication (client_id:client_secret) or form-body parameters (client_id and client_secret).
- cURL
- Python
- Node.js
curl -X POST "https://auth.rokt.com/api/v1/oauth/token" \
-H "Content-Type: application/x-www-form-urlencoded" \
-u "pat_<token_id>:rsec_<token_secret>" \
-d "grant_type=client_credentials" \
-d "scope=query:accounts:read query:campaigns:read"
import os
import requests
response = requests.post(
"https://auth.rokt.com/api/v1/oauth/token",
auth=(os.environ["ROKT_PAT_ID"], os.environ["ROKT_PAT_SECRET"]),
data={
"grant_type": "client_credentials",
"scope": "query:accounts:read query:campaigns:read",
},
timeout=10,
)
response.raise_for_status()
access_token = response.json()["access_token"]
const credentials = Buffer.from(
`${process.env.ROKT_PAT_ID}:${process.env.ROKT_PAT_SECRET}`
).toString("base64");
const response = await fetch("https://auth.rokt.com/api/v1/oauth/token", {
method: "POST",
headers: {
Authorization: `Basic ${credentials}`,
"Content-Type": "application/x-www-form-urlencoded",
},
body: new URLSearchParams({
grant_type: "client_credentials",
scope: "query:accounts:read query:campaigns:read",
}),
});
if (!response.ok) {
throw new Error(`Token exchange failed: ${response.status}`);
}
const { access_token: accessToken } = await response.json();
Example response:
{
"access_token": "rsej_eyJhbGciOiJSUzI1NiIs...",
"token_type": "Bearer",
"expires_in": 300
}
Keep these requirements in mind when requesting access tokens:
- Pass
scopeexplicitly: Include a space-delimited list of the scopes your workload needs (a subset of the scopes assigned to the PAT). If you omitscope, the issued access token carries no scopes and scope-protected endpoints return403 Forbidden. - Cache and reuse access tokens: Each
rsej_...access token is valid for300seconds (5 minutes). Cache the token in memory and refresh it roughly 30 seconds before expiration rather than requesting a new token on every API call.
3. Call Rokt APIs3. Call Rokt APIs への直接リンク
Include the rsej_... access token in the Authorization: Bearer header when calling supported Rokt APIs:
curl -X GET "https://api.rokt.com/v1/query/accounts" \
-H "Authorization: Bearer rsej_eyJhbGciOiJSUzI1NiIs..." \
-H "Content-Type: application/json"
Manage active tokensManage active tokens への直接リンク
Edit scopes without rotating secretsEdit scopes without rotating secrets への直接リンク
You can adjust a token's permissions without updating credentials in your applications:
- In Profile Settings under Personal access tokens, click the edit icon on an active token.
- Update the Token name or Scopes and select Save.
Your Token ID (pat_...) and Token secret (rsec_...) do not change. Updated scopes take effect on the next token exchange (POST https://auth.rokt.com/api/v1/oauth/token), and any previously issued rsej_... access tokens expire naturally within 5 minutes.
Expiration and rotationExpiration and rotation への直接リンク
A token's expiration date is fixed at creation and cannot be extended. To rotate an expiring token without downtime, create a replacement token, update your secrets manager, verify traffic succeeds with the new token, and revoke the old token.
Revoke a tokenRevoke a token への直接リンク
To permanently disable a PAT in One Platform:
- In Profile Settings under Personal access tokens, click the revoke icon next to the active token.
- Confirm the revocation.
Revoked tokens move to the Revoked tab for auditability and can no longer exchange for new access tokens.
If you also need to invalidate an already-issued rsej_... access token before its 5-minute TTL expires, call the OAuth 2.0 revocation endpoint using the same pat_... and rsec_... credentials that issued it:
curl -X POST "https://auth.rokt.com/api/v1/oauth/revoke" \
-H "Content-Type: application/x-www-form-urlencoded" \
-u "pat_<token_id>:rsec_<token_secret>" \
-d "token=rsej_eyJhbGciOiJSUzI1NiIs..."
Available scopesAvailable scopes への直接リンク
| API | Scope | Description | Supported endpoints |
|---|---|---|---|
| Query API | query:accounts:read | Read account discovery and account details | GET /v1/query/accountsGET /v1/query/accounts/{account_id} |
| Query API | query:campaigns:read | Query campaign reporting data | POST /v1/query/accounts/{account_id}/campaignsGET /v1/query/accounts/{account_id}/campaigns/help |
| Query API | query:transactions:read | Query transaction reporting data | POST /v1/query/accounts/{account_id}/transactionsGET /v1/query/accounts/{account_id}/transactions/help |
| Reporting API | reporting:accounts:read | Read account-level summary, overview, and histogram reports | GET /reporting/accounts/{accountId}/summaryGET /reporting/accounts/{accountId}/overviewGET /reporting/accounts/{accountId}/histogram/* |
| Reporting API | reporting:campaigns:read | Read campaign reporting data | GET /reporting/accounts/{accountId}/campaigns/* |
| Reporting API | reporting:transactions:read | Read transaction and revenue reports | GET /reporting/accounts/{accountId}/transactions/* |
| Reporting API | metadata:accounts:read | List accessible accounts | GET /accountsGET /metadata/accounts |
| Reporting API | metadata:campaigns:read | Read campaign, creative, and audience metadata | GET /metadata/accounts/{accountId}/campaigns/{campaignId}GET /metadata/accounts/{accountId}/campaigns/{campaignId}/creatives/{creativeId}GET /metadata/accounts/{accountId}/campaigns/{campaignId}/audiences/{audienceId} |
| Data Deletion API | data-deletion:requests:read | View data deletion requests | GET /data-deletion-requestsGET /data/deletion-requests |
| Data Deletion API | data-deletion:requests:write | Create and cancel data deletion requests | POST /data/deletion-requests/emailsDELETE /data/deletion-requests/{taskId} |
Error referenceError reference への直接リンク
| HTTP status | Error | Meaning and resolution |
|---|---|---|
400 | invalid_scope | One or more requested scopes in scope are not assigned to this PAT. Edit the token's scopes in Profile Settings or narrow the scope parameter. |
400 | unsupported_grant_type | Set grant_type=client_credentials in the form body. |
401 | invalid_client | The pat_... Token ID or rsec_... secret is invalid, or the PAT is expired or revoked. Verify your credentials and token status in Profile Settings. |
403 | Forbidden | Either the rsej_... token was requested without the required scope, or your Rokt user account lacks permission on the target account ID. |
429 | Rate limited | The token endpoint is rate-limited. Cache and reuse rsej_... access tokens for their 5-minute lifetime instead of exchanging credentials on every request. |
Security best practicesSecurity best practices への直接リンク
- Never commit credentials: Store
ROKT_PAT_IDandROKT_PAT_SECRETin environment variables or a secrets manager, never in source control or client-side browser code. - Follow least privilege: Select only the scopes each workload requires.
- Use expiration dates: Prefer 90 days (recommended) or another finite expiration and rotate tokens on a schedule.
- Isolate integrations: Create separate PATs per pipeline or tool so you can edit scopes or revoke access without disrupting other workloads.