Most Databricks workspaces hold personal access tokens that nobody has looked at since the day they were created, some with lifetimes of two years and some with no expiry at all. This guide is a working procedure for auditing them: which APIs and reports return the inventory, how to read the owner and creator fields, how to find long-lived, unused and orphaned tokens, and how to revoke them without breaking pipelines. It is written for platform engineers, workspace and account admins, and identity teams who need a defensible token inventory. Service principal design and OAuth migration are covered in the Databricks service principal guide; this page stays on the audit itself.
This is an independent guide from NHI Mgmt Group, based on Databricks' public documentation as of November 2026. It is not sponsored or reviewed by Databricks. Product features change, so confirm settings against Databricks' current documentation.
Key takeaways
- Two inventory views exist. The account console Token report covers every workspace in the account; the workspace Token Management API (
GET /api/2.0/token-management/tokens) covers one workspace and is the one to automate. - Owner and creator are different fields.
owner_idis the identity the token authenticates as;created_by_idandcreated_by_usernamerecord who minted it. On-behalf-of tokens for service principals are where the two diverge. - The lifetime cap only touches new tokens.
maxTokenLifetimeDays(default ceiling 730 days) does not shorten tokens that already exist, so the audit has to find and revoke the long-lived ones. - Idle tokens die at 90 days, busy ones do not. Databricks revokes tokens unused for 90 days or more, which means the riskiest tokens are the long-lived ones in daily use by scripts.
- Audit logs close the loop. Token events sit under the
accountsservice insystem.access.audit(generateDbToken,revokeDbToken,tokenLoginand others), which gives creation, revocation and use evidence between audits.
Why a separate PAT audit is needed
A Databricks personal access token is a bearer credential: anyone holding the string can call the REST API, the CLI or a SQL endpoint as the token's owner, with that owner's full permissions unless the token was created with scopes. Databricks itself recommends OAuth over PATs and asks admins to keep new token lifetimes under 90 days and revoke long-lived ones. In practice, PATs persist because they are easy: notebooks, BI tools, partner integrations and scheduled scripts were built on them, and Partner Connect and some partner integrations still require them.
Three properties make a periodic audit necessary rather than optional:
- Lifetime limits are not retroactive: the workspace setting caps new tokens only. A token created before the cap was set keeps its original expiry, which may be years away or none.
- Auto-revocation targets the wrong tokens: the 90-day unused rule removes abandoned tokens, but a token embedded in a nightly job is used every day and never qualifies.
- Tokens outlive context: a token created for a proof of concept, a departed contractor or a retired integration looks identical to one in active, sanctioned use. Only the audit fields and the logs tell them apart.
The attacker interest is direct. Stolen application access tokens map to MITRE ATT&CK T1528 Steal Application Access Token and their reuse to T1550.001 Application Access Token; a token belonging to a workspace admin gives control of clusters, jobs, secrets scopes and data.
Where token data lives
| Source | Scope | Who can use it | What it gives you | Best use |
|---|---|---|---|---|
| Account console: Security > Token report | All workspaces in the account | Account admins | Filters by owner, workspace, created, expiration and last-used date; quick filters for inactive principals and tokens with no expiry; CSV export; revoke button | Quarterly account-wide review and evidence export |
Token Management API: GET /api/2.0/token-management/tokens | One workspace | Principals with CAN MANAGE on tokens (workspace admins) | Full token_info list, filterable by created_by_id or created_by_username | Automated weekly inventory, joins to identity data |
CLI: databricks token-management list | One workspace | As above | Same data from the command line | Ad hoc checks and small estates |
Python SDK: w.token_management.list() | One workspace | As above | Same data as objects, easy to load into a Spark view | Notebook-based audits that join with system tables |
system.access.audit (service accounts) | Account, per workspace | Users granted access to system tables | Creation, revocation, scope, ACL and login events | Detection and proof of use between audits |
| Settings > Developer > Access tokens > Manage | One user's own tokens | Each user | Auto-scoping status and scopes per token | Owner self-attestation during clean-up |
The account console report runs its token queries only when an account admin opens the page, so treat each export as a point-in-time snapshot and keep it with the audit record. Managing tokens at workspace level needs the Premium plan or above.
Reading the token_info fields
Each token returned by the Token Management API carries the fields below. Getting their meaning right is most of the audit.
| Field | Meaning | Audit question it answers |
|---|---|---|
token_id | Identifier of the token (not the secret) | Which record to revoke with DELETE /api/2.0/token-management/tokens/{token_id} |
owner_id | User ID the token authenticates as | Whose permissions does this token carry? Is that identity still active and still entitled? |
created_by_id, created_by_username | Who created the token | Who is accountable for it? For on-behalf-of tokens this is the human or automation that minted a token for a service principal |
creation_time | Creation timestamp | How old is it? Was it created before the lifetime cap was set? |
expiry_time | Expiry timestamp | How long is left? A missing or far-future value is the first thing to flag |
last_used_day | Approximate last use, accurate to within one day | Is it live? Pair with audit logs before deciding it is unused |
comment | Purpose text set by the creator | Does it name a system and an owner team? Empty comments are an ownership gap |
scopes | Scopes the token was created with, if any | Is it an all-APIs token or limited to what the workload needs? |
workspace_id | Workspace where it was created | Which workspace's admins own the remediation? |
Owners versus creators: service principals can hold tokens created through POST /api/2.0/token-management/on-behalf-of/tokens, which takes the service principal's application_id and an optional lifetime_seconds. In that case owner_id is the service principal and created_by_* is whoever called the endpoint. Record both: the owner tells you the blast radius, the creator tells you who to ask. The audit log event updateOnBehalfOfToken records token.owner_id and token.created_by_id when such a token is changed.
Scopes and auto-scoping: the API also returns auto-scoping fields such as autoscope_state, inferred_scopes and backfill_scopes (scopes inferred from historical use for existing tokens). These are useful evidence when deciding what a narrower replacement token or OAuth grant needs. Treat the feature as subject to change and confirm current behaviour in the documentation before relying on it.
Step-by-step audit procedure
- Confirm access and scope. List every workspace in the account. Confirm the auditor has account admin for the Token report and CAN MANAGE (workspace admin) in each workspace for the API. Record which workspaces have PATs disabled on the Advanced settings tab: disabled tokens are not deleted and become usable again if PATs are re-enabled, so they still belong in the inventory.
- Export the account view. Open Security > Token report, use the quick filters for tokens with no expiration date and for inactive principals, then export the full CSV. Save it with the date as audit evidence.
- Pull the workspace inventory. For each workspace, call the Token Management API (or the SDK in a notebook) and load the results into a table with the run date. Convert
creation_time,expiry_timeandlast_used_dayto dates. - Resolve owners. Join
owner_idandcreated_by_idto the workspace's users and service principals (SCIM or the identity system of record). Mark each owner as active user, deactivated or deleted user, service principal with a named owning team, or service principal with no owner. - Classify every token. Apply the risk rules in the next section and give each token one status: keep, shorten (replace with a shorter token or OAuth), revoke, or investigate.
- Corroborate use from logs. Before revoking anything marked unused, query
system.access.auditfortokenLoginevents and requests from the owner over the last 30 to 90 days.last_used_dayis approximate, and the logs show source IPs and user agents that identify the calling system. - Notify owners with a deadline. Send each owner or creator the token IDs, comments and last-use dates, and ask them to confirm purpose, replace or accept revocation. Two weeks is a workable window for most estates.
- Revoke in waves. Revoke orphaned and no-expiry tokens first, then over-lifetime tokens, using
databricks token-management delete TOKEN_IDor the Revoke button in the Token report. Keep the export so a broken integration can be traced; the fix is a new, shorter token or an OAuth credential, never restoring the old secret. - Tighten the controls that let the problem grow. Set
maxTokenLifetimeDaysthrough the workspace configuration API (PATCH /api/2.0/workspace-conf) ordatabricks workspace-conf set-status, for example to 90. Setting it to 0 removes the custom limit and returns to the 730-day default, so check the value is not 0. Review token permissions (below) and disable PATs entirely in workspaces with no remaining need. - Record and schedule. Store the inventory, decisions, exceptions with expiry dates and revocation evidence. Repeat the API inventory weekly and the full review quarterly.
Risk rules for classifying tokens
| Finding | How to detect it | Default action |
|---|---|---|
| No expiry | expiry_time empty or the Token report "no expiration date" filter | Revoke after owner notice; replace with a token under the lifetime cap or OAuth |
| Lifetime above policy | expiry_time minus run date greater than the policy (for example 90 days) | Shorten: issue a replacement, then revoke |
| Owner deactivated or deleted | owner_id not matched to an active identity | Revoke; investigate any use after the owner left |
| Admin-owned token | Owner is in the admins group | Highest priority review; move automation to a service principal with least privilege |
| Human token used by automation | Steady daily tokenLogin from a server IP or tool user agent | Move the workload to a service principal with OAuth machine-to-machine authentication |
| Service principal token with no owning team | No owner recorded in the inventory or comment | Assign an owner or revoke; admins receive the expiry emails for these tokens |
| All-APIs token | scopes empty for an all-APIs token | Replace with a scoped token where the workload allows |
| Empty comment | comment blank | Ask the creator to attest purpose or accept revocation |
Expiry emails help but do not replace the audit. Users get an email about seven days before a token expires, and only if their username is an email address. For service principal tokens the email goes to workspace admins, and only for tokens with a lifetime over seven days that have been used at least once. Service principal OAuth secrets get no expiry notice at all, so track those separately.
Who can create and use tokens
An inventory fixes today's tokens; token permissions decide how many appear next quarter. Workspace token permissions have three levels:
- NO PERMISSIONS: the principal cannot create or use personal access tokens.
- CAN USE: the principal can create a token and authenticate with it.
- CAN MANAGE: held by the
adminsgroup by default, cannot be revoked from it and cannot be granted to anyone else. Only CAN MANAGE holders can list all tokens, revoke other principals' tokens or change token permissions.
If the users group holds CAN USE, every workspace user can mint tokens. Remove it from the group and grant CAN USE to named groups and service principals that have a documented need. The setting is on the admin settings Advanced tab next to Personal Access Tokens (the Permissions button appears only after at least one token exists), or through the Permissions API or Terraform. Removing CAN USE makes that principal's existing tokens unusable, and restoring it makes them work again, which makes permission removal a quick, reversible containment step during an incident.
Detection between audits
Token management events are logged under service name accounts. The ones that matter for an audit programme:
| Action name | Key request parameters | Why monitor it |
|---|---|---|
generateDbToken | tokenExpirationTime, tokenCreatedBy, tokenHash, userId | New token; alert on far-future expiry or creation for an admin or service principal |
revokeDbToken | userId, tokenHash | Evidence that clean-up happened |
garbageCollectDbToken | tokenExpirationTime, tokenCreationTime, tokenFirstAccessed, tokenHash | Automatic removal by the platform |
changeDbTokenAcl | targetUserId, aclPermissionSet | Someone changed who may create or use tokens |
changeDbTokenState | tokenHash, tokenState, userId | Token state change outside the normal flow |
updateOnBehalfOfToken | token.owner_id, token.created_by_id, token.scopes | A service principal token was altered |
tokenLogin | tokenId, user, authenticationMethod | Actual use; baseline source IP and user agent per token |
A starting query filters system.access.audit on service_name = 'accounts' and the action names above, and returns event_time, workspace_id, user_identity, source_ip_address, user_agent and request_params. Confirm the exact action names in your own account with a distinct list of action_name values, because the audit schema is still evolving and the system table is in Public Preview. Useful alerts: a token used from a new country or network for its owner, tokenLogin for a deactivated user, and generateDbToken outside change windows. See the Databricks Audit Logs and System Tables guide for enabling and querying system tables.
Metrics that show the audit is working
- Token count by owner type: human, service principal, orphaned. The orphaned count should reach zero and stay there.
- Maximum remaining lifetime: the longest time to expiry across all tokens; it should fall to the policy value after the first wave.
- Tokens with no expiry: target zero.
- Share of workspaces with PATs disabled or restricted to named groups.
- Human-owned tokens used by automation: a falling count shows migration to service principals and OAuth.
- Exceptions past their expiry date: target zero.
Common failure patterns
- Setting the lifetime cap and calling it done: the cap applies to new tokens only, so a two-year token created last month keeps working until the audit removes it.
- Trusting auto-revocation: the 90-day unused rule cleans up abandoned tokens, not the high-value ones used every day by scripts.
- Auditing one workspace: the API is per workspace. Without the account Token report or a loop over every workspace, development and sandbox workspaces, where tokens are often created most freely, are missed.
- Revoking on
last_used_dayalone: the field is approximate. Confirm withtokenLoginevents before revoking a token that drives a weekly or monthly job. - Ignoring disabled workspaces: disabling PATs does not delete tokens; re-enabling brings every unexpired one back.
- Treating service principal tokens as someone else's problem: their expiry emails go to workspace admins, so without a recorded owning team nobody acts on them. See the Orphaned and Dormant Accounts guide for ownership patterns.
Framework mapping
| Framework | Reference | How the PAT audit supports it |
|---|---|---|
| NIST SP 800-53 Rev 5 | IA-5 Authenticator Management | Lifetime limits, revocation and replacement of token authenticators |
| NIST SP 800-53 Rev 5 | AC-2 Account Management, AC-2(3) Disable Accounts | Owner resolution, orphaned token removal, idle token handling |
| NIST SP 800-53 Rev 5 | AC-6 Least Privilege | Restricting CAN USE, scoped tokens, moving admin-owned automation |
| NIST SP 800-53 Rev 5 | AU-2 Event Logging, AU-6 Audit Record Review | Token events in system.access.audit and periodic review |
| NIST CSF 2.0 | PR.AA-01, PR.AA-05, DE.CM-03 | Credential management, permission review and monitoring of token use |
| CIS Controls v8.1 | 5.1 account inventory, 5.3 disable dormant accounts, 6.2 access revoking process | Token inventory, idle token revocation, revocation procedure |
| ISO/IEC 27001:2022 Annex A | 5.16, 5.17, 5.18, 8.15 | Identity management, authentication information, access rights, logging |
| MITRE ATT&CK | T1528, T1550.001, T1078.004 | Token theft, token reuse and abuse of valid cloud accounts |
Where the PAT audit fits in the wider programme
Run the audit as one feed into the organisation's non-human identity inventory rather than as a Databricks-only spreadsheet, so token owners, service principals and secrets in other platforms are reviewed against the same rules. See the NHI Inventory Reconciliation guide for matching sources, and the Token Lifetime Policy Design Guide for choosing the lifetime value you enforce. Where the audit shows automation running on human tokens, the fix is a service principal with OAuth: see the Databricks Service Principals and Token Security Guide.
Practitioner checklist
- Export the account Token report (no-expiry and inactive filters) and keep it as dated evidence.
- Pull
token_infofrom the Token Management API in every workspace, including those with PATs disabled. - Resolve
owner_idandcreated_by_idto active identities and owning teams. - Classify each token as keep, shorten, revoke or investigate using written rules.
- Confirm use with
tokenLoginevents before revoking any token marked idle. - Revoke orphaned and no-expiry tokens first, then over-lifetime tokens.
- Set
maxTokenLifetimeDaysto the policy value in every workspace and check none is set to 0. - Remove CAN USE from the
usersgroup and grant it to named groups and service principals only. - Alert on
generateDbTokenwith far-future expiry and on token use by deactivated identities. - Re-run the inventory weekly and the full review quarterly, tracking the metrics above.
Standards and references
- Databricks: Monitor and revoke personal access tokens
- Databricks: Token Management API reference
- Databricks: Manage personal access token permissions
- Databricks: Audit log reference
- Databricks: Audit log system table reference
- NIST: SP 800-53 Rev. 5 Security and Privacy Controls
- MITRE ATT&CK: T1528 Steal Application Access Token
Related NHI Mgmt Group resources: Databricks Service Principals and Token Security Guide · Databricks Audit Logs and System Tables · Databricks Security Guide · Orphaned and Dormant Accounts · Token Lifetime Policy Design Guide