tokens
Creates, updates, deletes, gets or lists a tokens resource.
Overview
| Name | tokens |
| Type | Resource |
| Id | cloudflare.user.tokens |
Fields
The following fields are returned by SELECT queries:
- get
Token Details response
| Name | Datatype | Description |
|---|---|---|
id | string | Token identifier tag. (example: ed17574386854bf78a67040be0a770b0) |
name | string | Token name. (example: readonly token) |
condition | object | |
expires_on | string (date-time) | The expiration time on or after which the JWT MUST NOT be accepted for processing. (example: 2020-01-01T00:00:00Z) |
issued_on | string (date-time) | The time on which the token was created. (example: 2018-07-01T05:20:00Z) |
last_used_on | string (date-time) | Last time the token was used. (example: 2020-01-02T12:34:00Z) |
modified_on | string (date-time) | Last time the token was modified. (example: 2018-07-02T05:20:00Z) |
not_before | string (date-time) | The time before which the token MUST NOT be accepted for processing. (example: 2018-07-01T05:20:00Z) |
policies | array | List of access policies assigned to the token. |
status | string | Status of the token. (active, disabled, expired) (example: active, x-stainless-terraform-configurability: computed_optional) |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
get | select | token_id | Get information about a specific token. | |
create | insert | name, policies | Create a new access token. | |
update | replace | token_id | Update an existing token. | |
delete | delete | token_id | Destroy a token. | |
update_value | exec | token_id | Roll the 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.
| Name | Datatype | Description |
|---|---|---|
token_id | string | The API token ID. |
SELECT examples
- get
Get information about a specific token.
SELECT
id,
name,
condition,
expires_on,
issued_on,
last_used_on,
modified_on,
not_before,
policies,
status
FROM cloudflare.user.tokens
WHERE token_id = '{{ token_id }}' -- required
;
INSERT examples
- create
- Manifest
Create a new access token.
INSERT INTO cloudflare.user.tokens (
condition,
expires_on,
name,
not_before,
policies
)
SELECT
'{{ condition }}',
'{{ expires_on }}',
'{{ name }}' /* required */,
'{{ not_before }}',
'{{ policies }}' /* required */
RETURNING
errors,
messages,
result,
success
;
# Description fields are for documentation purposes
- name: tokens
props:
- name: condition
value:
request_ip:
in:
- "{{ in }}"
not_in:
- "{{ not_in }}"
- name: expires_on
value: "{{ expires_on }}"
description: |
The expiration time on or after which the JWT MUST NOT be accepted for processing.
- name: name
value: "{{ name }}"
description: |
Token name.
- name: not_before
value: "{{ not_before }}"
description: |
The time before which the token MUST NOT be accepted for processing.
- name: policies
description: |
List of access policies assigned to the token.
value:
- effect: "{{ effect }}"
id: "{{ id }}"
permission_groups: "{{ permission_groups }}"
resources: "{{ resources }}"
REPLACE examples
- update
Update an existing token.
REPLACE cloudflare.user.tokens
SET
condition = '{{ condition }}',
expires_on = '{{ expires_on }}',
name = '{{ name }}',
not_before = '{{ not_before }}',
policies = '{{ policies }}',
status = '{{ status }}'
WHERE
token_id = '{{ token_id }}' --required
RETURNING
errors,
messages,
result,
success;
DELETE examples
- delete
Destroy a token.
DELETE FROM cloudflare.user.tokens
WHERE token_id = '{{ token_id }}' --required
;
Lifecycle Methods
- update_value
Roll the token secret.
EXEC cloudflare.user.tokens.update_value
@token_id='{{ token_id }}' --required
;