Skip to content

Commit 64015b0

Browse files
mishig25claude
andcommitted
Document token rotation, fine-grained overview, and permission scopes
- Document token rotation API endpoint (POST /api/settings/tokens/{id}/rotate) - Document fine-grained token overview endpoint (GET /api/settings/tokens/{id}/fine-grained-overview) - Add full fine-grained permission scopes reference (40+ scopes) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent e350035 commit 64015b0

File tree

1 file changed

+82
-1
lines changed

1 file changed

+82
-1
lines changed

docs/hub/security-tokens.md

Lines changed: 82 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ To create an access token, go to your settings, then click on the [Access Tokens
3737

3838
Select a role and a name for your token and voilà - you're ready to go!
3939

40-
You can delete and refresh User Access Tokens by clicking on the **Manage** button.
40+
You can delete and rotate User Access Tokens by clicking on the **Manage** button.
4141

4242
<div class="flex justify-center">
4343
<img class="block dark:hidden" width="350" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/delete-token.png"/>
@@ -64,6 +64,87 @@ model = AutoModel.from_pretrained("private/model", token=access_token)
6464
> [!WARNING]
6565
> Try not to leak your token! Though you can always rotate it, anyone will be able to read or write your private repos in the meantime which is 💩
6666
67+
### Token rotation
68+
69+
You can rotate a token to generate a new token value while keeping the same name, permissions, and scopes. This is useful if a token may have been compromised. Rotate a token via the UI in your [Access Tokens settings](https://huggingface.co/settings/tokens), or programmatically via the API:
70+
71+
```
72+
POST https://huggingface.co/api/settings/tokens/{token_id}/rotate
73+
```
74+
75+
For fine-grained tokens, you can also retrieve an overview of the token's permissions and scopes:
76+
77+
```
78+
GET https://huggingface.co/api/settings/tokens/{token_id}/fine-grained-overview
79+
```
80+
81+
### Fine-grained token permission scopes
82+
83+
When creating a fine-grained token, you can select from the following permission scopes:
84+
85+
**Repository permissions** (applied per-repo or per-org):
86+
87+
| Scope | Description |
88+
|-------|-------------|
89+
| `repo.content.read` | Read repository content (files, commits) |
90+
| `repo.content.write` | Push commits, create/delete branches and tags |
91+
| `repo.config.read` | Read repository settings |
92+
| `repo.config.write` | Modify repository settings |
93+
| `repo.config.visibility.write` | Change repository visibility (public/private) |
94+
| `repo.config.variables.write` | Manage Space variables |
95+
| `repo.config.secrets.write` | Manage Space secrets |
96+
| `repo.config.doi.write` | Generate or update DOI |
97+
| `repo.access.read` | Read gated access settings and requests |
98+
| `repo.access.write` | Approve/deny gated access requests |
99+
| `repo.lfs.read` | Read LFS files |
100+
| `repo.devMode.read` | Access VS Code dev mode |
101+
102+
**Discussion & community permissions:**
103+
104+
| Scope | Description |
105+
|-------|-------------|
106+
| `discussion.write` | Create/edit discussions and pull requests |
107+
| `post.write` | Create/edit social posts |
108+
| `collection.read` | Read collections |
109+
| `collection.write` | Create/edit collections |
110+
111+
**User permissions** (applied to your own account):
112+
113+
| Scope | Description |
114+
|-------|-------------|
115+
| `user.tokens.read` | List your tokens |
116+
| `user.tokens.write` | Create/manage tokens |
117+
| `user.billing.read` | View billing information |
118+
| `user.billing.write` | Modify billing settings |
119+
| `user.webhooks.read` | List your webhooks |
120+
| `user.webhooks.write` | Create/manage webhooks |
121+
| `user.inference-providers.write` | Manage inference provider API keys |
122+
123+
**Infrastructure permissions:**
124+
125+
| Scope | Description |
126+
|-------|-------------|
127+
| `inference.endpoints.read` | View Inference Endpoints |
128+
| `inference.endpoints.write` | Create/manage Inference Endpoints |
129+
| `inference.serverless.write` | Use serverless inference |
130+
| `job.read` | View Jobs |
131+
| `job.write` | Create/manage Jobs |
132+
| `sql-console.embed.read` | Read SQL Console embeds |
133+
| `sql-console.embed.write` | Create/manage SQL Console embeds |
134+
135+
**Organization permissions** (applied per-org):
136+
137+
| Scope | Description |
138+
|-------|-------------|
139+
| `org.read` | Read organization info |
140+
| `org.write` | Manage organization settings |
141+
| `org.billing.read` | View organization billing |
142+
| `org.billing.write` | Modify organization billing |
143+
| `resourceGroup.read` | View resource groups |
144+
| `resourceGroup.write` | Manage resource groups |
145+
| `resourceGroup.settings.write` | Manage resource group settings/members |
146+
| `resourceGroup.repos.write` | Add/remove repos in resource groups |
147+
67148
### Best practices
68149

69150
We recommend you create one access token per app or usage. For instance, you could have a separate token for:

0 commit comments

Comments
 (0)