Skip to main content

tokens

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

Overview

Nametokens
TypeResource
Idcloudflare.accounts.tokens

Fields

The following fields are returned by SELECT queries:

Token Details response

NameDatatypeDescription
idstringToken identifier tag. (example: ed17574386854bf78a67040be0a770b0)
namestringToken name. (example: readonly token)
conditionobject
expires_onstring (date-time)The expiration time on or after which the JWT MUST NOT be accepted for processing. (example: 2020-01-01T00:00:00Z)
issued_onstring (date-time)The time on which the token was created. (example: 2018-07-01T05:20:00Z)
last_used_onstring (date-time)Last time the token was used. (example: 2020-01-02T12:34:00Z)
modified_onstring (date-time)Last time the token was modified. (example: 2018-07-02T05:20:00Z)
not_beforestring (date-time)The time before which the token MUST NOT be accepted for processing. (example: 2018-07-01T05:20:00Z)
policiesarrayList of access policies assigned to the token.
statusstringStatus of the token. (active, disabled, expired) (example: active, x-stainless-terraform-configurability: computed_optional)

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectaccount_id, token_idGet information about a specific Account Owned API token.
createinsertaccount_id, name, policiesCreate a new Account Owned API token.
updatereplaceaccount_id, token_idUpdate an existing token.
deletedeleteaccount_id, token_idDestroy an Account Owned API token.
roll_tokenexecaccount_id, token_idRoll the Account Owned API token secret.

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
account_idstringThe Cloudflare account ID.
token_idstringThe API token ID.

SELECT examples

Get information about a specific Account Owned API token.

SELECT
id,
name,
condition,
expires_on,
issued_on,
last_used_on,
modified_on,
not_before,
policies,
status
FROM cloudflare.accounts.tokens
WHERE account_id = '{{ account_id }}' -- required
AND token_id = '{{ token_id }}' -- required
;

INSERT examples

Create a new Account Owned API token.

INSERT INTO cloudflare.accounts.tokens (
condition,
expires_on,
name,
not_before,
policies,
account_id
)
SELECT
'{{ condition }}',
'{{ expires_on }}',
'{{ name }}' /* required */,
'{{ not_before }}',
'{{ policies }}' /* required */,
'{{ account_id }}'
RETURNING
errors,
messages,
result,
success
;

REPLACE examples

Update an existing token.

REPLACE cloudflare.accounts.tokens
SET
condition = '{{ condition }}',
expires_on = '{{ expires_on }}',
name = '{{ name }}',
not_before = '{{ not_before }}',
policies = '{{ policies }}',
status = '{{ status }}'
WHERE
account_id = '{{ account_id }}' --required
AND token_id = '{{ token_id }}' --required
RETURNING
errors,
messages,
result,
success;

DELETE examples

Destroy an Account Owned API token.

DELETE FROM cloudflare.accounts.tokens
WHERE account_id = '{{ account_id }}' --required
AND token_id = '{{ token_id }}' --required
;

Lifecycle Methods

Roll the Account Owned API token secret.

EXEC cloudflare.accounts.tokens.roll_token
@account_id='{{ account_id }}' --required,
@token_id='{{ token_id }}' --required
;