Skip to content

User Management ​

Endpoints for managing user profiles and sessions.

Get Current User ​

Retrieve the authenticated user's information.

Endpoint ​

GET /api/auth/user

Headers ​

Authorization: Bearer YOUR_TOKEN_HERE

Response ​

json
{
  "data": {
    "id": 1,
    "phone": "+1234567890",
    "username": "user123",
    "name": "John Doe",
    "matrix_user_id": "@user123:matrix.server",
    "coins": 100,
    "created_at": "2024-01-01T00:00:00Z",
    "teams": {
      "primary": {
        "id": 1,
        "name": "Team Name",
        "logo": "https://cdn.example.com/team-logo.png"
      },
      "others": [
        {
          "id": 2,
          "name": "Secondary Team"
        }
      ]
    }
  }
}

Verify Authentication ​

Verify if the current authentication token is valid.

Endpoint ​

GET /api/auth/verify

Response ​

json
{
  "authenticated": true,
  "user_id": 1
}

Check Username Setup Status ​

Check if the user has completed username setup.

Endpoint ​

GET /api/auth/username/status

Response ​

json
{
  "setup_complete": false,
  "current_username": null
}

Complete Username Setup ​

Set the user's username for the first time.

Endpoint ​

POST /api/auth/username/setup

Request ​

json
{
  "username": "desired_username"
}

Response ​

json
{
  "message": "Username setup completed successfully",
  "data": {
    "username": "desired_username"
  }
}

Error Responses ​

  • 422 - Username already taken or invalid format
  • 409 - Username already set for this user

Update User Name ​

Update the user's display name.

Endpoint ​

POST /api/auth/user/name

Request ​

json
{
  "name": "John Doe"
}

Response ​

json
{
  "message": "Name updated successfully",
  "data": {
    "name": "John Doe"
  }
}

Logout ​

Invalidate the current authentication token.

Endpoint ​

POST /api/auth/logout

Response ​

json
{
  "message": "Successfully logged out"
}

Notes ​

  • This will revoke the current bearer token
  • Matrix session may need separate logout