Join our Newsletter — 33% off our NHI Course
Home› Guides› How to Audit Databricks Personal Access Tokens: Token…
Guide Identity & Access Management (IAM)

How to Audit Databricks Personal Access Tokens: Token APIs, Owners and Expiry

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, under the editorial direction of Lalit Choda Updated 27 November 2026 15 min read
On this page

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_id is the identity the token authenticates as; created_by_id and created_by_username record 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 accounts service in system.access.audit (generateDbToken, revokeDbToken, tokenLogin and 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

SourceScopeWho can use itWhat it gives youBest use
Account console: Security > Token reportAll workspaces in the accountAccount adminsFilters by owner, workspace, created, expiration and last-used date; quick filters for inactive principals and tokens with no expiry; CSV export; revoke buttonQuarterly account-wide review and evidence export
Token Management API: GET /api/2.0/token-management/tokensOne workspacePrincipals with CAN MANAGE on tokens (workspace admins)Full token_info list, filterable by created_by_id or created_by_usernameAutomated weekly inventory, joins to identity data
CLI: databricks token-management listOne workspaceAs aboveSame data from the command lineAd hoc checks and small estates
Python SDK: w.token_management.list()One workspaceAs aboveSame data as objects, easy to load into a Spark viewNotebook-based audits that join with system tables
system.access.audit (service accounts)Account, per workspaceUsers granted access to system tablesCreation, revocation, scope, ACL and login eventsDetection and proof of use between audits
Settings > Developer > Access tokens > ManageOne user's own tokensEach userAuto-scoping status and scopes per tokenOwner 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.

FieldMeaningAudit question it answers
token_idIdentifier of the token (not the secret)Which record to revoke with DELETE /api/2.0/token-management/tokens/{token_id}
owner_idUser ID the token authenticates asWhose permissions does this token carry? Is that identity still active and still entitled?
created_by_id, created_by_usernameWho created the tokenWho is accountable for it? For on-behalf-of tokens this is the human or automation that minted a token for a service principal
creation_timeCreation timestampHow old is it? Was it created before the lifetime cap was set?
expiry_timeExpiry timestampHow long is left? A missing or far-future value is the first thing to flag
last_used_dayApproximate last use, accurate to within one dayIs it live? Pair with audit logs before deciding it is unused
commentPurpose text set by the creatorDoes it name a system and an owner team? Empty comments are an ownership gap
scopesScopes the token was created with, if anyIs it an all-APIs token or limited to what the workload needs?
workspace_idWorkspace where it was createdWhich 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

  1. 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.
  2. 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.
  3. 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_time and last_used_day to dates.
  4. Resolve owners. Join owner_id and created_by_id to 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.
  5. 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.
  6. Corroborate use from logs. Before revoking anything marked unused, query system.access.audit for tokenLogin events and requests from the owner over the last 30 to 90 days. last_used_day is approximate, and the logs show source IPs and user agents that identify the calling system.
  7. 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.
  8. Revoke in waves. Revoke orphaned and no-expiry tokens first, then over-lifetime tokens, using databricks token-management delete TOKEN_ID or 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.
  9. Tighten the controls that let the problem grow. Set maxTokenLifetimeDays through the workspace configuration API (PATCH /api/2.0/workspace-conf) or databricks 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.
  10. 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

FindingHow to detect itDefault action
No expiryexpiry_time empty or the Token report "no expiration date" filterRevoke after owner notice; replace with a token under the lifetime cap or OAuth
Lifetime above policyexpiry_time minus run date greater than the policy (for example 90 days)Shorten: issue a replacement, then revoke
Owner deactivated or deletedowner_id not matched to an active identityRevoke; investigate any use after the owner left
Admin-owned tokenOwner is in the admins groupHighest priority review; move automation to a service principal with least privilege
Human token used by automationSteady daily tokenLogin from a server IP or tool user agentMove the workload to a service principal with OAuth machine-to-machine authentication
Service principal token with no owning teamNo owner recorded in the inventory or commentAssign an owner or revoke; admins receive the expiry emails for these tokens
All-APIs tokenscopes empty for an all-APIs tokenReplace with a scoped token where the workload allows
Empty commentcomment blankAsk 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 admins group 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 nameKey request parametersWhy monitor it
generateDbTokentokenExpirationTime, tokenCreatedBy, tokenHash, userIdNew token; alert on far-future expiry or creation for an admin or service principal
revokeDbTokenuserId, tokenHashEvidence that clean-up happened
garbageCollectDbTokentokenExpirationTime, tokenCreationTime, tokenFirstAccessed, tokenHashAutomatic removal by the platform
changeDbTokenAcltargetUserId, aclPermissionSetSomeone changed who may create or use tokens
changeDbTokenStatetokenHash, tokenState, userIdToken state change outside the normal flow
updateOnBehalfOfTokentoken.owner_id, token.created_by_id, token.scopesA service principal token was altered
tokenLogintokenId, user, authenticationMethodActual 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_day alone: the field is approximate. Confirm with tokenLogin events 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

FrameworkReferenceHow the PAT audit supports it
NIST SP 800-53 Rev 5IA-5 Authenticator ManagementLifetime limits, revocation and replacement of token authenticators
NIST SP 800-53 Rev 5AC-2 Account Management, AC-2(3) Disable AccountsOwner resolution, orphaned token removal, idle token handling
NIST SP 800-53 Rev 5AC-6 Least PrivilegeRestricting CAN USE, scoped tokens, moving admin-owned automation
NIST SP 800-53 Rev 5AU-2 Event Logging, AU-6 Audit Record ReviewToken events in system.access.audit and periodic review
NIST CSF 2.0PR.AA-01, PR.AA-05, DE.CM-03Credential management, permission review and monitoring of token use
CIS Controls v8.15.1 account inventory, 5.3 disable dormant accounts, 6.2 access revoking processToken inventory, idle token revocation, revocation procedure
ISO/IEC 27001:2022 Annex A5.16, 5.17, 5.18, 8.15Identity management, authentication information, access rights, logging
MITRE ATT&CKT1528, T1550.001, T1078.004Token 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_info from the Token Management API in every workspace, including those with PATs disabled.
  • Resolve owner_id and created_by_id to active identities and owning teams.
  • Classify each token as keep, shorten, revoke or investigate using written rules.
  • Confirm use with tokenLogin events before revoking any token marked idle.
  • Revoke orphaned and no-expiry tokens first, then over-lifetime tokens.
  • Set maxTokenLifetimeDays to the policy value in every workspace and check none is set to 0.
  • Remove CAN USE from the users group and grant it to named groups and service principals only.
  • Alert on generateDbToken with 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

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

PDF for subscribers

Take this guide with you

Every section, table and checklist in one PDF, with links to the sources and related guides. Subscribe to our weekly NHI & AI Identity Journal and we’ll email you a download link.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

PDF Downloads for Newsletter Subscribers

Get the guide

Enter your details and we’ll email you a download link.

The full guide is free to read online. The PDF is a thank you for subscribing.

Fill in all fields marked * and tick both boxes to continue.