Skip to main content

tokens

Creates, updates, deletes, gets or lists a tokens resource.

Overview

Nametokens
TypeResource
Idvercel.authentication.tokens

Fields

The following fields are returned by SELECT queries:

Successful response.

NameDatatypeDescription
idstringThe unique identifier of the token. (example: 5d9f2ebd38ddca62e5d51e9c1704c72530bdc8bfdd41e782a6687c48399e8391)
namestringThe human-readable name of the token.
active_atnumberTimestamp (in milliseconds) of when the token was most recently used. (wire: activeAt)
created_atnumberTimestamp (in milliseconds) of when the token was created. (wire: createdAt)
expires_atnumberTimestamp (in milliseconds) of when the token expires. (wire: expiresAt)
leaked_atnumberTimestamp (in milliseconds) of when the token was marked as leaked. (wire: leakedAt)
leaked_urlstringURL where the token was discovered as leaked. (wire: leakedUrl)
originstringThe origin of how the token was created. (example: github)
prefixstringThe token's prefix, for identification purposes. (example: vcp_)
revoked_atnumberTimestamp (in milliseconds) of when the token was revoked. (wire: revokedAt)
scopesarrayThe access scopes granted to the token.
suffixstringThe last few characters of the token, for identification purposes. (example: abc123)
typestringThe type of the token. (example: oauth2-token)

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselecttoken_idRetrieve metadata about an authentication token belonging to the currently authenticated User.
listselectRetrieve a list of the current User's authentication tokens.
createinsertnameteam_id, slugCreates and returns a new authentication token for the currently authenticated User. The bearerToken property is only provided once, in the response body, so be sure to save it on the client for use with API requests.
deletedeletetoken_idInvalidate an authentication token, such that it will no longer be valid for future HTTP requests.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
token_idstringThe identifier of the token to invalidate. The special value "current" may be supplied, which invalidates the token that the HTTP request was authenticated with.
slugstringThe Team slug to perform the request on behalf of.
team_idstringThe Team identifier to perform the request on behalf of. (wire: teamId)

SELECT examples

Retrieve metadata about an authentication token belonging to the currently authenticated User.

SELECT
id,
name,
active_at,
created_at,
expires_at,
leaked_at,
leaked_url,
origin,
prefix,
revoked_at,
scopes,
suffix,
type
FROM vercel.authentication.tokens
WHERE token_id = '{{ token_id }}' -- required
;

INSERT examples

Creates and returns a new authentication token for the currently authenticated User. The bearerToken property is only provided once, in the response body, so be sure to save it on the client for use with API requests.

INSERT INTO vercel.authentication.tokens (
name,
expires_at,
project_id,
team_id,
slug
)
SELECT
'{{ name }}' /* required */,
{{ expires_at }},
'{{ project_id }}',
'{{ team_id }}',
'{{ slug }}'
RETURNING
bearer_token,
token
;

DELETE examples

Invalidate an authentication token, such that it will no longer be valid for future HTTP requests.

DELETE FROM vercel.authentication.tokens
WHERE token_id = '{{ token_id }}' --required
;