User API
This page provides routes for managing users. The following routes are available:
GET /users Retrieve a list of users in the organization. POST /users Create a new user for the organization. GET /users/:userId Retrieve a specific user by ID. PUT /users/:userId Update a specific user by ID. DELETE /users/:userId Delete a specific user by ID. GET /users/profile Retrieve the profile of the authenticated user. POST /users/registerLocalUser Create a new local user in the application database. POST /users/owner Create owner users in the organization. POST /users/registerLocalOwner Create a new local owner in the application database. DELETE /users/owner Delete owner of the organization. Retrieve a list of users in the organization
This endpoint retrieves a list of users for the organization. The list is sorted in descending order of creation date.
GET https://api.token.web3sandpit.com/api/v1/users
INFO
Authentication: Requires ApiKey for authentication.
Permissions: Requires OWNER role with user_management and read permissions.
Parameters
None
Example
{}[
{
"deleted": false,
"email": "gefova6643@edectus.com",
"orgId": "671a3c8db86d5a1d46dff7ee",
"userId": "6731aa0c3d4515af7c561d28",
"walletAddress": "0x9696cf4cd872E6C4B65cdc3Fc1b4da802C0C8cD2",
"credits": [],
"creditsRemaining": 0,
"creditsTotal": 0,
"creditsUsed": 0,
"id": "6731aa2a983d00c9f847ec2f"
}
]HTTP Response Codes
| Status Code | Text | Description |
|---|---|---|
| 200 | OK | With an array of user objects and pagination information. |
| 400 | Bad Request | The request was invalid or cannot be processed. |
| 401 | Unauthorized | Authentication is required or has failed. |
| 403 | Forbidden | The authenticated user is not authorized to perform the requested action. |
| 404 | Not Found | The requested resource could not be found. |
| 500 | Internal Server Error | An unexpected error occurred. |
Create a new user
Creates a new user for the organization.
POST https://api.token.web3sandpit.com/api/v1/users
INFO
Authentication: Requires ApiKey for authentication.
Permissions: Requires OWNER role with user_management, write, and create permissions.
Parameters
None
Example
{
"user": {
"firstName": "John", //First name of the user
"lastName": "Doe", //Last name of the user
"email": "johndoe@example.com" //Email of the user
},
// Organization object keys and values are fixed and cannot be changed
"organization": {
"role": "CUSTOMER", //Role of the user
"accessScope": ["read", "write", "update", "delete", "token_read", "token_send"], //Access scope of the user
"applicationName": "tokenMinter" //application name
},
"hasAccount": false //If the user has a wallet account or not
}{
"localUser": {
"deleted": false,
"email": "johndoe@example.com",
"orgId": "671a3c8db86d5a1d46dff7ee",
"userId": "6731b9bef2191d4ccb071647",
"walletAddress": "0xa4C80648049293C265DAF69915Ea4a25563a5555",
"credits": [],
"creditsRemaining": 0,
"creditsTotal": 0,
"creditsUsed": 0,
"id": "6731b9c334dd3d124c66bb54"
},
"response": {
"data": {
"createdBy": "671b8bad65b5bb889dd83c84",
"deleted": false,
"email": "johndoe@example.com",
"emailVerified": false,
"failedLoginAttempts": 0,
"firstName": "John",
"lastName": "Doe",
"organizations": [
{
"accessScope": ["read", "write", "update", "delete", "token_read", "token_send"],
"applicationName": "token-minter",
"deleted": false,
"orgId": "671a3c8db86d5a1d46dff7ee",
"role": "CUSTOMER",
"wallet": {
"mnemonic": "D7PgGUwYRnm0YN3579ePmg==:AUnsTG4HdxmwpZOdHcanPstNlE2Oao4osdk/nFlKGfbD1d9WKvjeXGkzLa7YvhDkTrd19ZzOGobQyoUBoTyWuUMK/Ojl164kQW99609gXFHoj666",
"privateKey": "D7PgGUwYRnm0YN3579ePmg==:QV6wFnpbLEbmrYOPHsDxL4xbmxvNPZhy4d9p3QQWCraU1ccXe/GDW2FyOKWBtQalFeQoqI6YHY+L3dIR/DTH50NX"
},
"_id": "6731b9bef2191d4ccb071648"
}
],
"profilePicture": {
"original": "",
"thumbnail": ""
},
"twoFactorAuth": false,
"_id": "6731b9bef2191d4ccb071647",
"createdAt": "2024-11-11T08:01:02.714Z",
"updatedAt": "2024-11-11T08:01:02.714Z",
"__v": 0
},
"message": "Registration successful. Verification email sent.",
"status": "success"
}
}HTTP Response Codes
| Status Code | Text | Description |
|---|---|---|
| 200 | OK | With an array of user objects and pagination information. |
| 400 | Bad Request | The request was invalid or cannot be processed. |
| 401 | Unauthorized | Authentication is required or has failed. |
| 403 | Forbidden | The authenticated user is not authorized to perform the requested action. |
| 404 | Not Found | The requested resource could not be found. |
| 500 | Internal Server Error | An unexpected error occurred. |
Retrieve user by ID
This endpoint retrieves a specific user by ID.
GET https://api.token.web3sandpit.com/api/v1/users/:userId
INFO
Authentication: Requires ApiKey for authentication.
Permissions: Requires ADMIN or OWNER role with read permission.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| userId | string | Yes | The ID of the user to retrieve |
Example
{}{
"deleted": false,
"email": "john@example.com",
"orgId": "671a3c8db86d5a1d46dff7ee",
"userId": "667d4f40e99f7b8df036bc87",
"walletAddress": "0xe09C5f717aA39841deC170B0085C9B9953Ef95d2",
"credits": [],
"creditsRemaining": 0,
"creditsTotal": 0,
"creditsUsed": 0,
"id": "67346f7cb7ce96cd7aa6b6d6"
}HTTP Response Codes
| Status Code | Text | Description |
|---|---|---|
| 200 | OK | With an array of user objects and pagination information. |
| 400 | Bad Request | The request was invalid or cannot be processed. |
| 401 | Unauthorized | Authentication is required or has failed. |
| 403 | Forbidden | The authenticated user is not authorized to perform the requested action. |
| 404 | Not Found | The requested resource could not be found. |
| 500 | Internal Server Error | An unexpected error occurred. |
Update user by ID
This endpoint updates a specific user by ID.
PUT https://api.token.web3sandpit.com/api/v1/users/:userId
INFO
Authentication: Requires ApiKey for authentication.
Permissions: Requires ADMIN or OWNER role with user_management and update permissions.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| userId | string | Yes | The ID of the user to retrieve |
Example
{ "walletAddress": "0xe09C5f717aA39841deC170B0085C9B9953Ef95d1" }
//wallet address of the user to be changed{
"deleted": false,
"email": "john@example.com",
"orgId": "671a3c8db86d5a1d46dff7ee",
"userId": "667d4f40e99f7b8df036bc87",
"walletAddress": "0xe09C5f717aA39841deC170B0085C9B9953Ef95d1",
"credits": [],
"creditsRemaining": 0,
"creditsTotal": 0,
"creditsUsed": 0,
"id": "67346f7cb7ce96cd7aa6b6d6"
}HTTP Response Codes
| Status Code | Text | Description |
|---|---|---|
| 200 | OK | With an array of user objects and pagination information. |
| 400 | Bad Request | The request was invalid or cannot be processed. |
| 401 | Unauthorized | Authentication is required or has failed. |
| 403 | Forbidden | The authenticated user is not authorized to perform the requested action. |
| 404 | Not Found | The requested resource could not be found. |
| 500 | Internal Server Error | An unexpected error occurred. |
Delete user by ID
This endpoint soft deletes a specific user by ID.
DELETE https://api.token.web3sandpit.com/api/v1/users/:userId
INFO
Authentication: Requires ApiKey for authentication.
Permissions: Requires ADMIN or OWNER role with user_management and delete permissions.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| userId | string | Yes | The ID of the user to delete |
Example
{}{
"message": "User deleted successfully"
}HTTP Response Codes
| Status Code | Text | Description |
|---|---|---|
| 200 | OK | With an array of user objects and pagination information. |
| 400 | Bad Request | The request was invalid or cannot be processed. |
| 401 | Unauthorized | Authentication is required or has failed. |
| 403 | Forbidden | The authenticated user is not authorized to perform the requested action. |
| 404 | Not Found | The requested resource could not be found. |
| 500 | Internal Server Error | An unexpected error occurred. |
Retrieve user profile
This endpoint retrieves the profile of the authenticated user.
GET https://api.token.web3sandpit.com/api/v1/users/profile
INFO
Authentication: Requires ApiKey for authentication.
Permissions: Requires USER role with read permission.
Parameters
None
Example
{}{
"deleted": false,
"email": "bawehi5026@bulatox.com",
"orgId": "671a3c8db86d5a1d46dff7ee",
"userId": "671b8bad65b5bb889dd83c84",
"walletAddress": "",
"credits": [],
"creditsRemaining": 0,
"creditsTotal": 0,
"creditsUsed": 0,
"id": "671b8bb14b7aeb4512551543"
}HTTP Response Codes
| Status Code | Text | Description |
|---|---|---|
| 200 | OK | With an array of user objects and pagination information. |
| 400 | Bad Request | The request was invalid or cannot be processed. |
| 401 | Unauthorized | Authentication is required or has failed. |
| 500 | Internal Server Error | An unexpected error occurred. |
Create local user
This endpoint creates a local user in the application database.
POST https://api.token.web3sandpit.com/api/v1/users/registerLocalUser |
INFO
Authentication: Requires ApiKey for authentication.
Permissions: Requires OWNER role with user_management, write, and create permissions.
Parameters
None
Example
{
"email": "john@example.com", //Email of the user
"userId": "667d4f40e99f7b8df036bc87", //User ID of the user from microservice
"hasAccount": false //Boolean value indicating whether the user has a wallet account or not
}{
"user": {
"deleted": false,
"email": "john@example.com",
"orgId": "671a3c8db86d5a1d46dff7ee",
"userId": "667d4f40e99f7b8df036bc87",
"walletAddress": "0xe09C5f717aA39841deC170B0085C9B9953Ef95d2",
"credits": [],
"creditsRemaining": 0,
"creditsTotal": 0,
"creditsUsed": 0,
"id": "67346f7cb7ce96cd7aa6b6d6"
},
"wallet": {
"accountAddress": "0xe09C5f717aA39841deC170B0085C9B9953Ef95d2",
"mnemonic": "PWyrnv/+x3My34UnQYLCkQ==:ZK2wiFva+wKiVaxc4BbzYjnUa24BelOJe4mCXsV6SAPjrLCSUrUjTyTbooaDyqZ2xaNeJFHfeCDkW1upr2ZOL+ibyYMw5ixK",
"privateKey": "PWyrnv/+x3My34UnQYLCkQ==:J7TuyBeI4wX7DvRK4FOmJnvCOT9dOUWCOo7ZG5c6RBDjpqbIAqY1E3SfsoTciLMs07MaMl6FJnq2Ghv0omVfcLDQ"
}
}HTTP Response Codes
| Status Code | Text | Description |
|---|---|---|
| 200 | OK | With an array of user objects and pagination information. |
| 400 | Bad Request | The request was invalid or cannot be processed. |
| 401 | Unauthorized | Authentication is required or has failed. |
| 403 | Forbidden | The authenticated user is not authorized to perform the requested action. |
| 404 | Not Found | The requested resource could not be found. |
| 500 | Internal Server Error | An unexpected error occurred. |
Create owner users in the organization
This endpoint creates owner users in the organization.
POST https://api.token.web3sandpit.com/api/v1/users/owner
INFO
Authentication: Requires ApiKey for authentication.
Permissions: Requires OWNER role with user_management and read permissions.
Parameters
None
Example
{
"organization": {
"accessScope": ["read", "write", "update", "create"], //Access scope for the user
"applicationName": "token-minter", //Application name
"orgId": "67036192840366f473a7at65", //Organization ID
"role": "OWNER" //Role of the user(here OWNER)
},
"user": {
"email": "john@example.com", //Email of the user
"firstName": "FirstName", //First name of the user
"lastName": "LastName" //Last name of the user
}
}{
"localUser": {
"deleted": false,
"email": "john@example.com",
"orgId": "67036192840366f473a7ae65",
"userId": "67346b4aafd60b0bb5cffec3",
"walletAddress": "",
"credits": [],
"creditsRemaining": 0,
"creditsTotal": 0,
"creditsUsed": 0,
"id": "67346b4db7ce96cd7aa6b6c7"
},
"response": {
"data": {
"createdBy": "66740a56d434270f2c248db0",
"deleted": false,
"email": "john@example.com",
"emailVerified": false,
"failedLoginAttempts": 0,
"firstName": "FrstName",
"lastName": "LastName",
"organizations": [
{
"accessScope": ["read", "write", "update", "create"],
"applicationName": "token-minter",
"deleted": false,
"orgId": "67036192840366f473a7at65",
"role": "OWNER",
"wallet": {
"accountAddress": "0x138E1837bdA3b58028d77DA93B32eE77cC410fb4",
"mnemonic": "yG31YGIBHtmq8vrSQIHjww==:Mez9evYBoBw9SKrsXLdu3/mwdl4t3K4b8uAJqn6LSLlbwYjZ+5d/xpyXCwKdOxtwhgfENAwZQ58ri227NCmvPmqxq8+Cum0GmW0t6XaEuA=r",
"privateKey": "yG31YGIBHtmq8vrSQIHjww==:ZOz/KrxA5hljGeyqW/Mvzbi/IQBrgbQN5eZO7GrTGL4bgMqaoJZ11I3AXw/aLRczxFXJIFYLEcornXr9NHSgZG40"
},
"_id": "67346b4aafd60b0bb5cffec4"
}
],
"profilePicture": {
"original": "",
"thumbnail": ""
},
"twoFactorAuth": false,
"_id": "67346b4aafd60b0bb5cffec3",
"createdAt": "2024-11-13T09:03:06.014Z",
"updatedAt": "2024-11-13T09:03:06.014Z",
"__v": 0
},
"message": "Registration successful. Verification email sent.",
"status": "success"
}
}HTTP Response Codes
| Status Code | Text | Description |
|---|---|---|
| 200 | OK | With an array of owner user objects and pagination information. |
| 400 | Bad Request | The request was invalid or cannot be processed. |
| 401 | Unauthorized | Authentication is required or has failed. |
| 403 | Forbidden | The authenticated user is not authorized to perform the requested action. |
| 404 | Not Found | The requested resource could not be found. |
| 500 | Internal Server Error | An unexpected error occurred. |
Create local owner
This endpoint creates a local owner in the application database.
POST https://api.token.web3sandpit.com/api/v1/users/registerLocalOwner
INFO
Authentication: Requires ApiKey for authentication.
Permissions: Requires ADMIN role with user_management, write, and create permissions.
Parameters
None
Example
{
"orgId": "67036192840366f473a7ae65", //Organization ID
"email": "john@example.com", //Email of the user
"userId": "667d4f40e99f7b8df036bc87" //user id from microservice
}{
"user": {
"deleted": false,
"email": "john@example.com",
"orgId": "67036192840366f473a7ae65",
"userId": "667d4f40e99f7b8df036bc87",
"walletAddress": "",
"credits": [],
"creditsRemaining": 0,
"creditsTotal": 0,
"creditsUsed": 0,
"id": "67347035b7ce96cd7aa6b77b"
},
"wallet": {
"accountAddress": "0x138E1837bdA3b58028d77DA93B32eE77cC410fb8",
"mnemonic": "yG31YGIBHtmq8vrSQIHjww==:Mez9evYBoBw9SKrsXLdu3/mwdl4t3K4b8uAJqn6LSLlbwYjZ+5d/xpyXCwKdOxtwhgfENAwZQ58ri227NCmvPmqxq8+Cum0GmW0t6XaEuA==",
"privateKey": "yG31YGIBHtmq8vrSQIHjww==:ZOz/KrxA5hljGeyqW/Mvzbi/IQBrgbQN5eZO7GrTGL4bgMqaoJZ11I3AXw/aLRczxFXJIFYLEcornXr9NHSgZG/0"
}
}HTTP Response Codes
| Status Code | Text | Description |
|---|---|---|
| 200 | OK | With an array of user objects and pagination information. |
| 400 | Bad Request | The request was invalid or cannot be processed. |
| 401 | Unauthorized | Authentication is required or has failed. |
| 403 | Forbidden | The authenticated user is not authorized to perform the requested action. |
| 404 | Not Found | The requested resource could not be found. |
| 500 | Internal Server Error | An unexpected error occurred. |
Delete owner user
This endpoint soft deletes an owner user.
DELETE https://api.token.web3sandpit.com/api/v1/users/owner
INFO
Authentication: Requires ApiKey for authentication.
Permissions: Requires ADMIN role with user_management and delete permissions.
Query Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| orgId | string | Yes | The ID of the organization |
| ownerId | string | Yes | The ID of the owner to delete |
Example:/owner?orgId=67036192840366f473a7ae69&&ownerId=673469deafd60b0bb5cffe73
Example
{}{
"message": "User deleted successfully"
}HTTP Response Code
| Status Code | Text | Description |
|---|---|---|
| 200 | OK | if the owner user was successfully deleted. |
| 400 | Bad Request | if the request body is missing required fields or contains invalid data. |
| 401 | Unauthorized | if the user is not authenticated or does not have the required permissions. |
| 404 | Not Found | if the owner user does not exist. |
| 500 | Internal Server Error | if there is an issue deleting the owner user from the database. |