UserUser API Tokens

Create Token

POST
Create a new access token.

Request

This endpoint expects an object.
name
stringRequired
Token name.
policies
list of objectsRequired
List of access policies assigned to the token.
condition
objectOptional
expires_on
datetimeOptional
The expiration time on or after which the JWT MUST NOT be accepted for processing.
not_before
datetimeOptional
The time before which the token MUST NOT be accepted for processing.

Response

This endpoint returns an object
result
objectOptional
POST
1curl -X POST https://api.cloudflare.com/client/v4/user/tokens \
2 -H "Authorization: Bearer <token>" \
3 -H "Content-Type: application/json" \
4 -d '{
5 "name": "readonly token",
6 "policies": [
7 {
8 "effect": "allow",
9 "id": "f267e341f3dd4697bd3b9f71dd96247f",
10 "permission_groups": [
11 {
12 "id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1",
13 "name": "Load Balancers Write"
14 }
15 ],
16 "resources": {
17 "string": "string"
18 }
19 }
20 ],
21 "condition": {
22 "request.ip": {
23 "in": [
24 "199.27.128.0/21"
25 ],
26 "not_in": [
27 "199.27.128.0/21"
28 ]
29 }
30 },
31 "expires_on": "2020-01-01T00:00:00Z",
32 "not_before": "2018-07-01T05:20:00Z"
33}'
200Successful
1{
2 "result": {
3 "value": "8M7wS6hCpXVc-DoRnPPY_UCWPgy8aea4Wy6kCe5T"
4 }
5}