Skip to content

Commit 8adc3a0

Browse files
committed
service token API example
1 parent 582f2c0 commit 8adc3a0

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

src/content/partials/cloudflare-one/access/create-service-token.mdx

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
---
55

6-
import { Tabs, TabItem, Details } from '~/components';
6+
import { Tabs, TabItem, Details, APIRequest } from '~/components';
77

88
<Tabs syncKey="dashPlusAPI"> <TabItem label="Dashboard">
99

@@ -23,6 +23,40 @@ import { Tabs, TabItem, Details } from '~/components';
2323
This is the only time Cloudflare Access will display the Client Secret. If you lose the Client Secret, you must generate a new service token.
2424
:::
2525

26+
</TabItem> <TabItem label="API">
27+
28+
1. Make a `POST` request to the [Access Service Tokens](/api/resources/zero_trust/subresources/access/subresources/service_tokens/methods/create/) endpoint:
29+
30+
<APIRequest
31+
path="/accounts/{account_id}/access/service_tokens"
32+
method="POST"
33+
json={{
34+
name: "CI/CD token",
35+
duration: "8760h"
36+
}}
37+
/>
38+
39+
2. Copy the `client_id` and `client_secret` values returned in the response.
40+
41+
42+
```json title="Response" {2-3}
43+
"result": {
44+
"client_id": "88bf3b6d86161464f6509f7219099e57.access",
45+
"client_secret": "bdd31cbc4dec990953e39163fbbb194c93313ca9f0a6e420346af9d326b1d2a5",
46+
"created_at": "2025-09-25T22:26:26Z",
47+
"expires_at": "2026-09-25T22:26:26Z",
48+
"id": "3537a672-e4d8-4d89-aab9-26cb622918a1",
49+
"name": "CI/CD token",
50+
"updated_at": "2025-09-25T22:26:26Z",
51+
"duration": "8760h",
52+
"client_secret_version": 1
53+
}
54+
```
55+
56+
:::caution
57+
This is the only time Cloudflare Access will display the Client Secret. If you lose the Client Secret, you must generate a new service token.
58+
:::
59+
2660
</TabItem> <TabItem label="Terraform (v5)">
2761

2862
1. Add the following permission to your [`cloudflare_api_token`](https://registry.terraform.io/providers/cloudflare/cloudflare/latest/docs/resources/api_token):

0 commit comments

Comments
 (0)