Skip to main content
Version: v0.1.0

Users API

API for user management.

Overview

The Users API allows you to create, retrieve, update, and delete D.Hub users. Admin privileges are required.

Endpoints

GET /api/v1/users/

Retrieves a list of all users.

Query Parameters

ParameterTypeDefaultDescription
limitinteger100Maximum number of items to retrieve
tokenstring-Pagination token

Response

200 OK

{
"items": {
"user-abc123": "{\"id\":\"user-abc123\",\"email\":\"user@example.com\",...}",
"user-xyz789": "{\"id\":\"user-xyz789\",\"email\":\"admin@example.com\",...}"
},
"token": "next-page-token"
}
note

The password_hash field is excluded from responses for security.


GET /api/v1/users/{user_id}/versions

Retrieves the version history of a user.

Path Parameters

ParameterTypeRequiredDescription
user_idstringYesUser ID

Response

200 OK

[
{
"version_id": "v2",
"last_modified": "2024-01-20T10:30:00Z",
"size": 512
}
]

GET /api/v1/users/{user_id}

Retrieves a specific user.

Path Parameters

ParameterTypeRequiredDescription
user_idstringYesUser ID

Query Parameters

ParameterTypeRequiredDescription
user_versionstringNoRetrieve a specific version

Response

200 OK

{
"id": "user-abc123",
"email": "user@example.com",
"name": "John Doe",
"alias": "john",
"type": "user",
"groups": ["developers"],
"tags": [],
"provider": "local",
"is_active": true,
"roles": ["user"],
"created_at": "2024-01-01T00:00:00Z",
"updated_at": "2024-01-15T09:00:00Z"
}

Error Responses

Status CodeDescription
404 Not FoundUser not found

POST /api/v1/users/

Creates a new user.

Request Body

{
"email": "newuser@example.com",
"name": "New User",
"password": "secure-password",
"groups": ["developers"],
"tags": []
}
FieldTypeRequiredDescription
emailstringYesEmail (unique)
namestringYesUser name
passwordstringYesPassword
aliasstringNoAlias
groupsarrayNoAffiliated groups
tagsarrayNoTags

Response

200 OK

{
"item": "user-newid123"
}

Error Responses

Status CodeDescription
409 ConflictEmail already exists

PUT /api/v1/users/{user_id}

Updates user information.

Path Parameters

ParameterTypeRequiredDescription
user_idstringYesUser ID

Request Body

Include only the fields to be modified.

{
"name": "Updated Name",
"email": "newemail@example.com",
"groups": ["developers", "admins"]
}
FieldTypeDescription
namestringUser name
aliasstringAlias
typestringUser type
emailstringEmail (duplicate check on change)
groupsarrayAffiliated groups
tagsarrayTags
commentstringModification comment

Response

200 OK

{
"message": "User updated successfully"
}

Error Responses

Status CodeDescription
404 Not FoundUser not found
409 ConflictEmail already exists

DELETE /api/v1/users/{user_id}

Deletes a user.

Path Parameters

ParameterTypeRequiredDescription
user_idstringYesUser ID

Response

200 OK

{
"message": "User deleted successfully"
}

Error Responses

Status CodeDescription
404 Not FoundUser not found

User Object

FieldTypeDescription
idstringUser unique ID
emailstringEmail address
namestringUser name
aliasstringAlias
typestringUser type (user, admin, etc.)
groupsarrayAffiliated group list
tagsarrayTag list
providerstringAuth provider (local, ldap, oidc)
is_activebooleanActive status
rolesarrayRole list
created_atstringCreation time
updated_atstringUpdate time

Usage Examples

cURL

# List users
curl https://api.dhub.io/api/v1/users/ \
-H "Authorization: Bearer <access_token>"

# Create a user
curl -X POST https://api.dhub.io/api/v1/users/ \
-H "Authorization: Bearer <access_token>" \
-H "Content-Type: application/json" \
-d '{
"email": "newuser@example.com",
"name": "New User",
"password": "secure-password"
}'

# Update a user
curl -X PUT https://api.dhub.io/api/v1/users/user-abc123 \
-H "Authorization: Bearer <access_token>" \
-H "Content-Type: application/json" \
-d '{"name": "Updated Name"}'

# Delete a user
curl -X DELETE https://api.dhub.io/api/v1/users/user-abc123 \
-H "Authorization: Bearer <access_token>"