Migrating from Legacy Tokens to API Keysets

Legacy Demandbase API tokens are associated with individual users. If a user is deactivated or their permissions change, integrations that use their token may stop working.

API Key Sets provide authentication credentials that are independent of individual users. Each API Key Set has assigned permissions and supports secure credential rotation.

This article explains how to migrate existing integrations from legacy API tokens to API Key Sets, update authentication, test integrations, and retire legacy tokens.

Important: This article explains how to migrate existing integrations from legacy API tokens to API Key Sets, update authentication, test integrations, and retire legacy tokens.


Understand the Differences Between Legacy Tokens and API Key Sets

The following table compares legacy API tokens with API Key Set authentication.

Legacy API TokensAPI Key Sets
Associated with an individual user.Independent of individual users.
Use a legacy token directly for bearer authentication.Exchange a Client ID and Client Secret for a temporary access token.
Access depends on the user's permissions.Access depends on permissions assigned to the API Key Set.
Integrations may stop working when user access changes.Integrations remain active independently of user changes.

Both authentication methods use the following authorization header:

Authorization: Bearer <access-token>

The primary difference is how you obtain and refresh the access token.


Understand API Key Set Terminology

TermDescription
API Key SetA named collection of API permissions for an integration.
API TokenA Client ID and Client Secret generated within an API Key Set.
Access TokenA temporary JWT returned by the authentication endpoint and used to authenticate API requests.

Important: Do not include the Client Secret in the Authorization header.


Prerequisites to Migrating to API Key Sets

Before you begin, ensure that you have:

  • Demandbase administrator access or permission to manage API Key Sets.
  • A list of applications, integrations, and scheduled jobs that use legacy API tokens.
  • A secure secrets manager for storing the Client ID and Client Secret.
  • Access to a sandbox or controlled testing environment, if available.

Migrate from Legacy API Tokens to API Key Sets

Step 1: Identify Integrations Using Legacy API Tokens

Identify all applications and services that use legacy API tokens, including:

  • Applications and scheduled jobs.
  • CI/CD variables.
  • Cloud secret managers.
  • Postman environments.
  • Middleware and third-party integrations.
  • Production and sandbox environments.

Record the Demandbase APIs and operations each integration uses to determine the permissions required for its new API Key Set.

Step 2: Plan Your API Key Sets

Create separate API Key Sets for independent integrations or workloads when possible.

For example:

  • Production Data Export
  • Production Data Import
  • Salesforce Integration
  • Development Testing

Assign only the permissions each integration requires.

Important: Demandbase supports up to five API Key Sets, with up to five active API tokens per set. Plan your API Key Sets according to these limits.

Step 3: Create an API Key Set

Create an API key set. See Generate and Manage API Key Sets.

Important: The Client Secret appears only once. Copy and store it immediately. Do not store credentials or access tokens in source control, support tickets, email, chat, application logs, or unencrypted configuration files.

Some API permissions, including B2B and Data Export, may require enablement by your Demandbase account team.

Step 4: Generate an Access Token

Use the Client ID and Client Secret to request a JWT access token from the authentication endpoint. See Generate a JWT Token endpoint.

Endpoint

POST https://uapi.demandbase.com/auth/v1/token

Example request

curl --request POST \
  --url https://uapi.demandbase.com/auth/v1/token \
  --header 'Content-Type: application/json' \
  --header 'Accept: application/json' \
  --data '{
    "grantType": "client_credentials",
    "clientId": "YOUR_CLIENT_ID",
    "clientSecret": "YOUR_CLIENT_SECRET"
  }'

Example response

{
  "accessToken": "...",
  "tokenType": "bearer",
  "expiresIn": 3600
}

Use the returned accessToken to authenticate API requests.

The expiresIn field specifies the access token's lifetime in seconds. Use this value to determine when to refresh the token.

Step 5: Update API Authentication

Replace the legacy bearer token with the JWT access token generated using your API Key Set credentials. See Authenticating with the APIs.

Example request

curl --request GET \
  --url 'https://uapi.demandbase.com/<api-path>' \
  --header 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
  --header 'Accept: application/json'

Replace with the appropriate API endpoint and YOUR_ACCESS_TOKEN with the generated JWT.

The API request continues to use the Authorization: Bearer header.

Step 6: Configure Access Token Refresh

Access tokens expire and must be refreshed to maintain authentication.

Configure your integration to:

  1. Cache the access token while it remains valid.
  2. Use the returned expiresIn value to determine its expiration.
  3. Request a new token shortly before the existing token expires.
  4. If an API request returns 401 Unauthorized, obtain a new access token and retry the request once.
  5. If an API request returns 403 Forbidden, verify the API Key Set permissions before retrying.

Avoid requesting a new access token for every API call. Where practical, coordinate token refreshes across application instances to prevent simultaneous requests.

Important: Never log Client Secrets or complete access tokens.

If you use the Demandbase Python SDK, it can manage authentication and token refresh using the DEMANDBASE_CLIENT_ID and DEMANDBASE_CLIENT_SECRET environment variables.

Step 7: Test Your Integration

Before switching production traffic to API Key Set authentication, verify that the integration works as expected.

  • Confirm that the authentication endpoint returns 200.
  • Test representative API read operations.
  • Test write operations in a controlled environment, if applicable.
  • Complete a full job lifecycle for Data Import or Data Export integrations.
  • Verify that the integration refreshes expired access tokens.
  • Confirm that requests without sufficient permissions return 403.
  • Monitor 401, 403, 429, and 5xx responses.

Important: Avoid submitting the same write operation through both legacy and API Key Set authentication during testing to prevent duplicate operations.

Step 8: Switch to API Key Set Authentication

After successfully testing your integration:

  1. Deploy the new API Key Set credentials alongside the existing legacy authentication configuration.
  2. Enable API Key Set authentication for a limited workload.
  3. Monitor the integration to confirm that API requests and scheduled jobs complete successfully.
  4. Move the remaining traffic to API Key Set authentication.
  5. Keep legacy authentication available only during the agreed rollback period.

Step 9: Retire Legacy API Tokens

After confirming that the integration works with API Key Set authentication:

  1. Remove legacy tokens from applications and scheduled jobs.
  2. Remove legacy tokens from secret managers, CI/CD variables, and Postman environments.
  3. Confirm that no integrations continue to use legacy tokens.
  4. Revoke legacy tokens through the supported tenant process or Demandbase Support.
  5. Document API Key Set ownership and credential rotation procedures.

Roll Back to Legacy Authentication

If the integration experiences authentication failures during migration, temporarily restore legacy authentication.

  1. Switch the affected integration back to its legacy authentication configuration.
  2. Keep the new API Key Set available for troubleshooting.
  3. Record the affected endpoint, request time, HTTP status, and diagnostic ID.
  4. Resolve credential, entitlement, or permission issues.
  5. Repeat validation before switching back to API Key Set authentication.

Important: Rollback is available only while the legacy token remains valid and has not been revoked.


Troubleshoot API Key Set Authentication

IssuePossible CauseRecommended Action
400 Bad Request from authentication endpointInvalid request format or JSON fields.Verify grantType, clientId, and clientSecret and use Content-Type: application/json.
401 Unauthorized from authentication endpointInvalid, deleted, or deactivated credentials.Verify the Client ID, Client Secret, token status, and environment.
401 Unauthorized from API endpointMissing or expired access token.Generate a new access token and retry once.
403 Forbidden from API endpointMissing API permissions or entitlement.Review API Key Set permissions and API enablement.
Legacy authentication works, but API Key Set authentication failsPermission or endpoint-support differences.Record the endpoint, timestamp, HTTP status, and diagnostic ID. Contact Demandbase Support.
429 Too Many RequestsAPI rate limit exceeded.Follow response headers and retry using exponential backoff.

Important: Do not include Client IDs, Client Secrets, or complete access tokens in support requests.


Migration Checklist

Use this checklist to confirm that you have completed the migration.

  • Identify all integrations using legacy API tokens.
  • Determine the required API permissions for each integration.
  • Create and configure API Key Sets.
  • Store Client IDs and Client Secrets securely.
  • Implement access token generation and caching.
  • Configure token expiration handling and refresh.
  • Test API requests and integration workflows.
  • Switch production traffic to API Key Set authentication.
  • Remove and revoke legacy API tokens.
  • Document credential ownership and rotation procedures.

Additional Resources


Did this page help you?