Token API 2.0
The Token API allows you to create, list, and revoke tokens that can be used to authenticate and access Databricks REST APIs.
Important
To access Databricks REST APIs, you must authenticate.
Create
Endpoint |
HTTP Method |
---|---|
|
|
Create and return a token. This call returns the error QUOTA_EXCEEDED
if the current number of non-expired tokens exceeds the token quota. The token quota for a user is 600.
Example
Request
curl --netrc --request POST \
https://<databricks-instance>/api/2.0/token/create \
--data '{ "comment": "This is an example token", "lifetime_seconds": 7776000 }' \
| jq .
Replace:
<databricks-instance>
with the Databricks workspace instance name, for example1234567890123456.7.gcp.databricks.com
.This is an example token
with a description to attach to the token.7776000
with the lifetime of the token, in seconds. This example specifies 90 days.
Request structure
Field Name |
Type |
Description |
---|---|---|
lifetime_seconds |
|
The lifetime of the token, in seconds. If no lifetime is specified, the token remains valid indefinitely. |
comment |
|
Optional description to attach to the token. |
List
Endpoint |
HTTP Method |
---|---|
|
|
List all the valid tokens for a user-workspace pair.
Example
Request
curl --netrc --request GET \
https://<databricks-instance>/api/2.0/token/list \
| jq .
Replace <databricks-instance>
with the Databricks workspace instance name, for example 1234567890123456.7.gcp.databricks.com
.
Response
{
"token_infos": [
{
"token_id": "1234567890a12bc3456de789012f34ab56c78d9012e3fabc4de56f7a89b012c3",
"creation_time": 1626286601651,
"expiry_time": 1634062601651,
"comment": "This is an example token"
},
{
"token_id": "2345678901a12bc3456de789012f34ab56c78d9012e3fabc4de56f7a89b012c4",
"creation_time": 1626286906596,
"expiry_time": 1634062906596,
"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 |
---|---|
|
|
Revoke an access token. This call returns the error RESOURCE_DOES_NOT_EXIST
if a token with
the specified ID is not valid.
Example
curl --netrc --request POST \
https://<databricks-instance>/api/2.0/token/delete \
--data '{ "token_id": "<token-id>" }'
This example uses a .netrc file.
Replace:
<databricks-instance>
with the Databricks workspace instance name, for example1234567890123456.7.gcp.databricks.com
.<token-id>
with the ID of the token, for example1234567890a12bc3456de789012f34ab56c78d9012e3fabc4de56f7a89b012c3
.
Data structures
In this section:
Public token info
A data structure that describes the public metadata of an access token.
Field Name |
Type |
Description |
---|---|---|
token_id |
|
The ID of the token. |
creation_time |
|
Server time (in epoch milliseconds) when the token was created. |
expiry_time |
|
Server time (in epoch milliseconds) when the token will expire, or -1 if not applicable. |
comment |
|
Comment the token was created with, if applicable. |