API Token Rotation Overview
API token rotation is a security best practice that involves periodically replacing existing tokens with new ones to minimize the risk of compromised credentials. This scenario demonstrates a complete token rotation workflow that can be performed without service interruption. Key benefits of token rotation:- Reduces the impact of potentially leaked or compromised tokens
- Enforces time-limited access even for long-lived integrations
- Helps maintain compliance with security policies and regulations
- Can be performed without downtime for your integrations
Token rotation should be performed as part of a regular security maintenance schedule. The frequency depends on your security requirements - monthly, quarterly, or annually are common intervals.
This scenario assumes you already have an active API token that will be rotated. See our other scenario to learn how to generate your first API token.
Step 1 - List active API tokens to identify rotation candidates (Optional)
Retrieves a list of all active API tokens for your account. This optional step helps you identify tokens that need rotation based on age or usage patterns.- Identify tokens that are approaching your organization’s maximum age policy
- Note token IDs and descriptions to ensure you’re rotating the correct tokens
- Check creation dates to prioritize rotation of older tokens first
- Review last usage timestamps to identify potentially unused or stale tokens
This endpoint is called using your existing API token - the same one you’ll be rotating in the subsequent steps.
Step 2 - Generate a new replacement API token
Creates a new API token that will replace your existing one. This is the first active step in the rotation process and requires no additional authentication beyond your current token.- The new token will have the same permissions as the user who owns the existing token
- Include a descriptive name in the “description” field to track the token’s purpose
- The new token will be valid for 10 years by default, but can be rotated again at any time
It’s important to create the new token before revoking the old one to ensure continuous service availability during the transition. This approach allows you to perform the complete rotation using only your existing API token.
- newApiToken - Located at
idin the response.- The unique identifier for the newly created API token that will replace your existing token. This new token has the same permissions as the user who owns the existing token and is valid for 10 years.
- Example value:
H4BobG6Zt2yQparQZH2nEdcmdx68JeprKFhDgF2h4imxOGmXv8NI3EjLlW8FhAvh
- Update your integration systems with the new token before deactivating the old one
- Allow for a transition period where both tokens are valid
- Monitor your systems to confirm they’re successfully using the new token
- Once confirmed, proceed to revoke the old token
Step 3 - Revoke the old API token to complete the rotation process
Permanently invalidates the old API token after confirming that all integrations are successfully using the new token. This completes the rotation process.- Only revoke the old token after confirming all systems are using the new token
- This action cannot be undone - the old token will immediately stop working
- Consider implementing monitoring to detect any authentication failures after revocation
In a real-world scenario, you would typically wait a period of time (hours or days) between creating the new token and revoking the old one to ensure all systems have been updated.
API Token Rotation Best Practices
Implementing a regular token rotation schedule is an essential security practice:- Establish a consistent rotation schedule based on your security requirements
- Automate the rotation process where possible to minimize human error
- Maintain a transition period where both old and new tokens are valid
- Consider using shorter rotation intervals for tokens with higher privileges
Example Token Rotation Implementation
See our OpenAPI documentation to learn about the full set of API endpoints and parameters.
Please use proper exception handling and function decomposition in your own code. The code is provided for illustrative purposes only and is not intended for production use.