メインコンテンツまでスキップ

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:

  1. Token scopes: The access token includes a scope that permits the requested operation.
  2. 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 with 403 Forbidden.
  • Blast-radius containment: A token scoped only to query:campaigns:read cannot 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 への直接リンク

  1. Sign in to One Platform at my.rokt.com.
  2. Click your profile icon in the top-right corner and select Profile Settings (or go to my.rokt.com/profile-settings).
  3. Under Personal access tokens, select Create personal access token.
  4. Enter a descriptive Token name (up to 128 characters, for example Snowflake reporting pipeline).
  5. Choose an Expiration (30 days, 90 days (recommended), 180 days, 1 year, Custom date..., or No expiration).
  6. Under Scopes, select the scopes required for your integration (see Available scopes).
  7. Select Create token.
  8. In the Copy personal access token modal, copy the token secret (rsec_...) and store it in your secrets manager.
  9. 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 -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"

Example response:

{
"access_token": "rsej_eyJhbGciOiJSUzI1NiIs...",
"token_type": "Bearer",
"expires_in": 300
}

Keep these requirements in mind when requesting access tokens:

  • Pass scope explicitly: Include a space-delimited list of the scopes your workload needs (a subset of the scopes assigned to the PAT). If you omit scope, the issued access token carries no scopes and scope-protected endpoints return 403 Forbidden.
  • Cache and reuse access tokens: Each rsej_... access token is valid for 300 seconds (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:

  1. In Profile Settings under Personal access tokens, click the edit icon on an active token.
  2. 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:

  1. In Profile Settings under Personal access tokens, click the revoke icon next to the active token.
  2. 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 への直接リンク

APIScopeDescriptionSupported endpoints
Query APIquery:accounts:readRead account discovery and account detailsGET /v1/query/accounts
GET /v1/query/accounts/{account_id}
Query APIquery:campaigns:readQuery campaign reporting dataPOST /v1/query/accounts/{account_id}/campaigns
GET /v1/query/accounts/{account_id}/campaigns/help
Query APIquery:transactions:readQuery transaction reporting dataPOST /v1/query/accounts/{account_id}/transactions
GET /v1/query/accounts/{account_id}/transactions/help
Reporting APIreporting:accounts:readRead account-level summary, overview, and histogram reportsGET /reporting/accounts/{accountId}/summary
GET /reporting/accounts/{accountId}/overview
GET /reporting/accounts/{accountId}/histogram/*
Reporting APIreporting:campaigns:readRead campaign reporting dataGET /reporting/accounts/{accountId}/campaigns/*
Reporting APIreporting:transactions:readRead transaction and revenue reportsGET /reporting/accounts/{accountId}/transactions/*
Reporting APImetadata:accounts:readList accessible accountsGET /accounts
GET /metadata/accounts
Reporting APImetadata:campaigns:readRead campaign, creative, and audience metadataGET /metadata/accounts/{accountId}/campaigns/{campaignId}
GET /metadata/accounts/{accountId}/campaigns/{campaignId}/creatives/{creativeId}
GET /metadata/accounts/{accountId}/campaigns/{campaignId}/audiences/{audienceId}
Data Deletion APIdata-deletion:requests:readView data deletion requestsGET /data-deletion-requests
GET /data/deletion-requests
Data Deletion APIdata-deletion:requests:writeCreate and cancel data deletion requestsPOST /data/deletion-requests/emails
DELETE /data/deletion-requests/{taskId}

Error referenceError reference への直接リンク

HTTP statusErrorMeaning and resolution
400invalid_scopeOne 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.
400unsupported_grant_typeSet grant_type=client_credentials in the form body.
401invalid_clientThe pat_... Token ID or rsec_... secret is invalid, or the PAT is expired or revoked. Verify your credentials and token status in Profile Settings.
403ForbiddenEither the rsej_... token was requested without the required scope, or your Rokt user account lacks permission on the target account ID.
429Rate limitedThe 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_ID and ROKT_PAT_SECRET in 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.
この記事は役に立ちましたか?