Skip to main content

Users

User management endpoints handle user profiles, credit balance, admin operations, transaction history, and other user-related functionality.

User Profile

Get All Users

GET /users

Get all users (admin only)

Response

{
  "records": [
    {
      "id": "user-uuid",
      "name": "John",
      "lastName": "Doe",
      "email": "[email protected]",
      "organisation": "Research Institute",
      "location": "New York",
      "isActive": true,
      "createdOn": "2024-01-01T00:00:00Z",
      "userStatus": "Active",
      "creditBalance": 100,
      "avatar": "avatar-url"
    }
  ],
  "start": 0,
  "limit": 50,
  "totalRecords": 1
}

Get User by ID

GET /users/{userId}

Get user information by ID

Parameters

  • userId (path): User ID

Response

{
  "id": "user-uuid",
  "name": "John",
  "lastName": "Doe",
  "email": "[email protected]",
  "organisation": "Research Institute",
  "location": "New York",
  "isActive": true
}

Get User by Email

GET /users/email/{email}

Get user information by email

Parameters

  • email (path): User email address

Response

{
  "id": "user-uuid",
  "name": "John",
  "lastName": "Doe",
  "email": "[email protected]",
  "organisation": "Research Institute",
  "location": "New York",
  "isActive": true
}

Update User

PATCH /users/{userId}

Update user information

Parameters

  • userId (path): User ID

Request Body

{
  "name": "Updated Name",
  "lastName": "Updated LastName",
  "organisation": "New Organisation",
  "location": "New Location"
}

Response

{
  "info": {
    "statusCode": 200,
    "responseMessage": "User updated"
  }
}

User Avatar

Upload Avatar

POST /users/{userId}/avatar

Upload a user avatar image

Parameters

  • userId (path): User ID

Request Body (multipart/form-data)

avatar: [File] - Image file for avatar

Response

{
  "info": {
    "statusCode": 200,
    "responseMessage": "User avatar added!"
  }
}

Get Avatar

GET /users/{userId}/avatar

Get user avatar

Parameters

  • userId (path): User ID

Response

{
  "avatar": "base64-encoded-image-data"
}

User Blockchain Address

Get User Public Key

GET /users/{userId}/pubkey

Get user’s blockchain public key address

Parameters

  • userId (path): User ID

Response

{
  "pubKey": "ALGORAND_PUBLIC_KEY_ADDRESS"
}

Credit Balance

Get Credit Balance

GET /users/{userId}/credit-balance

Get user’s credit balance

Parameters

  • userId (path): User ID

Response

{
  "creditBalance": 150
}

Update Credit Balance (Admin Only)

POST /users/{adminId}/credit-balance/{userId}

Update user’s credit balance (admin only)

Parameters

  • adminId (path): Admin user ID
  • userId (path): Target user ID

Request Body

{
  "amount": 100,
  "operationType": "add"
}

Response

{
  "info": {
    "statusCode": 200,
    "responseMessage": "User credits correctly updated!"
  }
}

Transaction History

Download Transaction History

GET /users/{userId}/transactions/{from}/{to}/download

Download user’s transaction history

Parameters

  • userId (path): User ID
  • from (path): Start date (YYYY-MM-DD format)
  • to (path): End date (YYYY-MM-DD format)

Response

{
  "txs": [
    {
      "id": "tx-uuid",
      "createdAt": "2024-01-15T10:30:00Z",
      "amount": -50,
      "type": "PROJECT_CREATION"
    },
    {
      "id": "tx-uuid-2",
      "createdAt": "2024-01-16T14:20:00Z",
      "amount": -10,
      "type": "PROJECT_INVITATION"
    }
  ]
}

User Permissions

Check Project Creation Permission

GET /users/{userId}/can-create-project

Check if user can create projects

Parameters

  • userId (path): User ID

Response

{
  "info": {
    "statusCode": 200,
    "responseMessage": "User can create project"
  }
}

Check Member Invitation Permission

GET /users/{userId}/can-invite-member

Check if user can invite members to projects

Parameters

  • userId (path): User ID

Response

{
  "info": {
    "statusCode": 200,
    "responseMessage": "User can invite members"
  }
}

Check Admin Status

GET /users/{userId}/is-admin

Check if user has admin privileges

Parameters

  • userId (path): User ID

Response

{
  "isAdmin": true
}

Admin Operations

Suspend User

POST /users/{adminId}/suspend/{userEmail}

Suspend a user account (admin only)

Parameters

  • adminId (path): Admin user ID
  • userEmail (path): Email of user to suspend

Request Body

{
  "reason": "Violation of terms of service"
}

Response

{
  "info": {
    "statusCode": 200,
    "responseMessage": "User correctly suspended!"
  }
}

Revoke User Suspension

POST /users/{adminId}/revoke-suspension/{userEmail}

Revoke user suspension (admin only)

Parameters

  • adminId (path): Admin user ID
  • userEmail (path): Email of user to unsuspend

Response

{
  "info": {
    "statusCode": 200,
    "responseMessage": "User suspension correctly revoked!"
  }
}

User Status

Users can have the following statuses:
  • Active: User is active and can use the platform
  • On-hold: User registration is pending activation
  • Suspended: User account is suspended by admin

Tags Management

Get All Tags

GET /tags

Get all available tags

Response

{
  "records": {
    "id": "tag-uuid",
    "name": "research"
  },
  "start": 0,
  "limit": 50,
  "totalRecords": 1
}

Create Tag

POST /tags

Create a new tag

Request Body

{
  "name": "new-tag"
}

Response

{
  "info": {
    "statusCode": 201,
    "responseMessage": "Tag has been successfully added."
  }
}

Search Tags

GET /tags/search

Search for tags

Query Parameters

  • tag (query): Search term for tag names

Response

{
  "records": [
    {
      "id": "tag-uuid",
      "name": "research"
    }
  ],
  "start": 0,
  "limit": 50,
  "totalRecords": 1
}

Example

curl -X GET "https://api.labtrace.io/tags/search?tag=research" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"

Credit System

Credit Costs

Different operations have different credit costs:
  • Project Creation: 50 credits
  • Project Invitation: 10 credits
  • File Upload: 1 credit (private files) or file size in MB (public files)
  • File Deletion: 1 credit

Credit Balance Management

  • Users start with an initial credit balance
  • Admins can add or subtract credits from user accounts
  • Credits are automatically deducted for blockchain operations
  • Users can view their transaction history

Error Responses

400 Bad Request

{
  "error": {
    "statusCode": 400,
    "message": "Invalid request parameters"
  }
}

401 Unauthorized

{
  "error": {
    "statusCode": 401,
    "message": "Authentication required"
  }
}

403 Forbidden

{
  "error": {
    "statusCode": 403,
    "message": "Insufficient permissions"
  }
}

404 Not Found

{
  "error": {
    "statusCode": 404,
    "message": "User not found"
  }
}

User Management Best Practices

Profile Management

  • Keep user information up to date
  • Use meaningful organisation and location data
  • Regularly update avatars for better user experience

Credit Management

  • Monitor credit balance regularly
  • Plan operations based on available credits
  • Contact admin for credit refills when needed

Security

  • Use strong passwords and change them regularly
  • Report suspicious activity immediately
  • Keep personal information secure

Admin Operations

  • Only suspend users when necessary
  • Provide clear reasons for suspensions
  • Monitor user activity for policy violations
  • Regularly audit user permissions and access