Skip to content

Commit 6099750

Browse files
ranbelpedrosousa
andauthored
[Fundamentals] API token permission ID (#23973)
* use permission ID instead of name * Update src/content/docs/fundamentals/api/how-to/create-via-api.mdx Co-authored-by: Pedro Sousa <[email protected]> --------- Co-authored-by: Pedro Sousa <[email protected]>
1 parent 8bbfc9d commit 6099750

File tree

1 file changed

+35
-2
lines changed

1 file changed

+35
-2
lines changed

src/content/docs/fundamentals/api/how-to/create-via-api.mdx

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ sidebar:
77

88
---
99

10-
import { Render, Tabs, TabItem } from "~/components"
10+
import { Render, Tabs, TabItem, APIRequest } from "~/components"
1111

1212
Generate new API tokens on the fly via the API. Before you can do this, you must create an API token in the Cloudflare dashboard that can create subsequent tokens.
1313

@@ -100,7 +100,40 @@ For user resources, you can only reference yourself, which is denoted as:`"com.c
100100

101101
#### Permission groups
102102

103-
Determine what permission groups should be applied. Refer to the full list of permission groups either in [the documentation](/fundamentals/api/reference/permissions/) or fetch the permission groups [via the API](/api/resources/user/subresources/tokens/subresources/permission_groups/methods/list/). It is only required to pass the `id` of the permission group in the policy. Permission groups are scoped to specific resources, so a permission group in a policy will only apply to the resource type it is scoped for.
103+
Add permission groups to the API token by specifying their `id` values. We recommend using `id` as the key for interacting with Cloudflare APIs; the permission `name` is cosmetic and subject to change. Permission groups are scoped to specific resources (user, account, or zone), so a permission group in a policy will only apply to the resource type it is scoped for.
104+
105+
To fetch all available permission groups and their IDs, use the [List permission groups](/api/resources/user/subresources/tokens/subresources/permission_groups/methods/list/) endpoint:
106+
107+
<APIRequest
108+
path="/user/tokens/permission_groups"
109+
method="GET"
110+
/>
111+
112+
```json output
113+
{
114+
"result": [
115+
{
116+
"id": "19637fbb73d242c0a92845d8db0b95b1",
117+
"name": "AI Audit Read",
118+
"description": "Grants access to reading AI Audit",
119+
"scopes": [
120+
"com.cloudflare.api.account.zone"
121+
]
122+
},
123+
{
124+
"id": "1ba6ab4cacdb454b913bbb93e1b8cb8c",
125+
"name": "AI Audit Write",
126+
"description": "Grants access to reading and editing AI Audit",
127+
"scopes": [
128+
"com.cloudflare.api.account.zone"
129+
]
130+
},
131+
// (...)
132+
]
133+
}
134+
```
135+
136+
104137

105138
### 2. Define the restrictions
106139

0 commit comments

Comments
 (0)