Users
Manage user accounts and their roles. All endpoints require admin authentication.
User Object
{
"id": "clxyz123456789abcdef",
"username": "john_doe",
"role": {
"id": "clxyz123456789abcdef",
"name": "admin"
}
}| Field | Type | Description |
|---|---|---|
id | string | Unique identifier (CUID) |
username | string | User’s username |
role.id | string | Role identifier |
role.name | string | Role name (e.g. admin, operator) |
GET /v1/users
Retrieve all users.
Authentication: Bearer token (admin)
Response 200 OK
[
{
"id": "clxyz123456789abcdef",
"username": "john_doe",
"role": {
"id": "clxyz123456789abcdef",
"name": "admin"
}
}
]Errors
| Status | Description |
|---|---|
401 | Unauthorized |
403 | Forbidden |
GET /v1/users/{id}
Retrieve a single user by ID.
Authentication: Bearer token (admin)
Path Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | User ID (CUID) |
Response 200 OK
Returns a User Object.
Errors
| Status | Description |
|---|---|
400 | Invalid user ID |
401 | Unauthorized |
403 | Forbidden |
404 | User not found |
POST /v1/users
Create a new user.
Authentication: Bearer token (admin)
Request Body
{
"username": "john_doe",
"password": "password123",
"roleId": "clxyz123456789abcdef"
}| Field | Type | Required | Description |
|---|---|---|---|
username | string | Yes | Username (min 6 characters) |
password | string | Yes | Password (min 8 characters) |
roleId | string | Yes | Role ID to assign |
Response 201 Created
Returns the created User Object.
Errors
| Status | Description |
|---|---|
400 | Invalid request body |
401 | Unauthorized |
403 | Forbidden |
409 | Username already exists |
PUT /v1/users/{id}
Update an existing user.
Authentication: Bearer token (admin)
Path Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | User ID (CUID) |
Request Body
{
"username": "john_doe",
"password": "newpassword123",
"roleId": "clxyz123456789abcdef"
}| Field | Type | Required | Description |
|---|---|---|---|
username | string | Yes | Username (min 6 characters) |
password | string | Yes | Password (min 8 characters) |
roleId | string | Yes | Role ID to assign |
Response 200 OK
Returns the updated User Object.
Errors
| Status | Description |
|---|---|
400 | Invalid request body |
401 | Unauthorized |
403 | Forbidden |
404 | User not found |
DELETE /v1/users/{id}
Delete a user.
Authentication: Bearer token (admin)
Path Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | User ID (CUID) |
Response 204 No Content
Errors
| Status | Description |
|---|---|
400 | Invalid user ID |
401 | Unauthorized |
403 | Forbidden |
404 | User not found |
Last updated on