Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions docusaurus/docs/cms/features/users-permissions/rest-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,12 @@ curl -X POST http://localhost:1337/api/users \

Example response (201): A user object with the populated role.

:::tip
The `role` field accepts both numeric `id` (legacy) and `documentId` (Strapi v5 convention). Examples:
- `"role": 1` — numeric ID
- `"role": "x74detpqybxw0bn6ormua5g2"` — documentId
:::

### Update a user

`PUT /api/users/:id`
Expand Down Expand Up @@ -596,23 +602,27 @@ Possible errors:
| 400 | `"Username already taken"` or `"Email already taken"` | Duplicate value |

:::note Relation inputs support both `documentId` and numeric IDs
When updating a user with custom relations, you can use either `documentId` (recommended for Strapi 5) or numeric `id` in relation payloads:
When updating a user, including the `role` relation, you can use either `documentId` (recommended for Strapi 5) or numeric `id` in relation payloads:
```json
{
"customRelation": {
"connect": ["x74detpqybxw0bn6ormua5g2"] // documentId
}
"role": "x74detpqybxw0bn6ormua5g2" // role documentId (shorthand)
}
```
or
```json
{
"customRelation": {
"connect": [1] // numeric ID (legacy)
"role": {
"connect": ["x74detpqybxw0bn6ormua5g2"] // role documentId (longhand)
}
}
```
Both formats are accepted for backward compatibility.
or
```json
{
"role": 1 // numeric ID (legacy)
}
```
For custom relations, you can also use the longhand format. Both formats are accepted for backward compatibility.
:::

### Delete a user
Expand Down
Loading