Skip to main content

Users API

API for user management.

Overview

Through the Users API, you can create, retrieve, update, and delete D.Hub users. This API requires administrator privileges.

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

For security, the password_hash field is excluded from the response.


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 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
groupsarrayNoBelonging 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 updated.

{
"name": "Updated Name",
"email": "newemail@example.com",
"groups": ["developers", "admins"]
}
FieldTypeDescription
namestringUser name
aliasstringAlias
typestringUser type
emailstringEmail (duplicate check on change)
groupsarrayBelonging 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.)
groupsarrayList of belonging groups
tagsarrayList of tags
providerstringAuthentication provider (local, ldap, oidc)
is_activebooleanActive status
rolesarrayList of roles
created_atstringCreation time
updated_atstringModification time

Usage Examples

cURL

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

# Create 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 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 user
curl -X DELETE https://api.dhub.io/api/v1/users/user-abc123 \
-H "Authorization: Bearer <access_token>"