Token API

The Token API allows users to create, list, and revoke tokens that can be used to authenticate and access Databricks REST APIs. See Authentication for more information.

Table of Contents


Create

Endpoint HTTP Method
2.0/token/create POST

Creates and returns a token for a user. This call returns the error QUOTA_EXCEEDED if the user exceeds their token quota.

This API is available to all users.

Request example:

{
  "lifetime_seconds": 100,
  "comment": "this is an example token"
}

Response example:

{
  "token_value":"dapi6ae4581e3ad7da8ee5ca8ead95e9bf9c",
  "token_info": {
    "token_id":"5715498424f15ee0213be729257b53fc35a47d5953e3bdfd8ed22a0b93b339f4",
    "creation_time":1513120516294,
    "expiry_time":1513120616294,
    "comment":"this is an example token"
  }
}

Request Structure

Field Name Type Description
lifetime_seconds LONG The lifetime of the token, in seconds. If no lifetime is specified, this token remains valid indefinitely.
comment STRING Optional description to attach to the token.

Response Structure

Field Name Type Description
token_value STRING The value of the newly-created token.
token_info Public Token Info The public metadata of the newly-created token.

List

Endpoint HTTP Method
2.0/token/list GET

Lists all the valid tokens for a user-workspace pair.

This API is available to all users.

Response example:

{
  "token_infos: [
    {
      "token_id":"5715498424f15ee0213be729257b53fc35a47d5953e3bdfd8ed22a0b93b339f4",
      "creation_time":1513120516294,
      "expiry_time":1513120616294,
      "comment":"this is an example token"
    },
    {
      "token_id":"902eb9ac42c9bef80d0097a2d1746533103c88593add482a331500187946ceb5",
      "creation_time":1512684023036,
      "expiry_time":-1,
      "comment":"this is another example token"
    }
  ]
}

Response Structure

Field Name Type Description
token_infos An array of Public Token Info A list of token information for a user-workspace pair.

Revoke

Endpoint HTTP Method
2.0/token/delete POST

Revokes an access token. This call returns the error RESOURCE_DOES_NOT_EXIST if a token with the given ID is not valid.

This API is available to all users.

Request example:

{
  "token_infos: [
    {
      "token_id":"5715498424f15ee0213be729257b53fc35a47d5953e3bdfd8ed22a0b93b339f4",
      "creation_time":1513120516294,
      "expiry_time":1513120616294,
      "comment":"this is an example token"
    },
    {
      "token_id":"902eb9ac42c9bef80d0097a2d1746533103c88593add482a331500187946ceb5",
      "creation_time":1512684023036,
      "expiry_time":-1,
      "comment":"this is another example token"
    }
  ]
}

Request Structure

Field Name Type Description
token_id STRING The ID of the token to be revoked.

Data Structures

Public Token Info

A data structure that describes the public metadata of an access token.

Field Name Type Description
token_id STRING The ID of this token
creation_time LONG Server time (in epoch milliseconds) when the token was created.
expiry_time LONG Server time (in epoch milliseconds) when the token will expire, or -1 if not applicable.
comment STRING Comment the token was created with, if applicable.