Profile API Documentation
These routes handle user profile management, notifications, vault operations, and user settings.
Base Path: /profile
Endpoints
1. GET /profile/notifications
Get all notifications for the authenticated user.
Authentication: Required
Response
Returns an array of notification objects.
Array<{
title: string;
message: string;
date: number;
}>;Success Response (200):
[
{
"title": "Welcome",
"message": "Welcome to Casino!",
"date": 1703001234567
}
]Error Responses:
401 Unauthorized: User is not authenticated400 Bad Request: User not found500 Internal Server Error: Server error
2. DELETE /profile/notifications
Clear all notifications for the authenticated user.
Authentication: Required
Response
Success Response (200):
Error Responses:
401 Unauthorized: User is not authenticated400 Bad Request: User not found500 Internal Server Error: Server error
3. GET /profile/user/:id
Get public user data by Steam ID.
Authentication: Not required (public endpoint)
Parameters
id(path parameter): Steam ID of the user
Response
Success Response (200):
Error Responses:
404 Not Found: User not found
500 Internal Server Error: Server error
4. POST /profile/avatar
Upload or replace the authenticated user's profile picture.
Authentication: Required
Request Body: multipart/form-data
avatar
File
Yes
Image file (jpeg, png, webp, gif). Max size: 2MB.
Response
Success Response (200):
avatarUrl: Full avatar URL, This is also saved as the user'savatarfield in the database.
Error Responses:
401 Unauthorized: User is not authenticated400 Bad Request: No file provided, wrong file type, or file too large
500 Internal Server Error: Server error
5. POST /profile/vault/lock
Lock coins in the vault with a deadline. This moves coins from the user's balance to their vault balance and sets a lock deadline.
Authentication: Required
Request Body
amount(number, required): Amount of coins to lock (must be positive)deadline(number, required): Unix timestamp in milliseconds when the vault will unlock (must be in the future)
Response
Success Response (200):
Error Responses:
401 Unauthorized: User is not authenticated400 Bad Request: Invalid parameters
500 Internal Server Error: Server error
6. POST /profile/vault/unlock
Unlock coins from the vault. This moves coins from the vault balance back to the user's regular balance.
Authentication: Required
Request Body
No body required.
Response
Success Response (200):
Error Responses:
401 Unauthorized: User is not authenticated400 Bad Request: Cannot unlock vault
500 Internal Server Error: Server error
7. PUT /profile/trade-url
Set or update the user's Steam trade URL.
Authentication: Required
Request Body
url(string, required): Steam trade URL (must start withhttps://steamcommunity.com/tradeoffer/new/?partner)
Response
Success Response (200):
Error Responses:
401 Unauthorized: User is not authenticated400 Bad Request: Invalid trade URL
500 Internal Server Error: Server error
8. PUT /profile/email
Update the user's email address.
Authentication: Required
Status: Not implemented (returns 501)
Request Body
Response
Error Response (501):
9. PUT /profile/client-seed
Update the user's Provably Fair client seed.
Authentication: Required
Validation Constraints:
Min Length: 4 characters
Max Length: 64 characters
Allowed: Alphanumeric,
-, and_
Request Body
Response
Success Response (200):
Error Responses:
401 Unauthorized400 Bad Request: Validation error
10. GET /profile/details
Get extended profile information, including personal info and shipping address.
Authentication: Required
Response
Success Response (200):
11. PUT /profile/details
Update profile details and shipping address. All fields are optional.
Authentication: Required
Request Body
Logic:
Username: If provided and different from the current one, it checks for uniqueness.
Partial Updates: You can provide only the fields you wish to change.
Response
Success Response (200):
12. GET /profile/2fa/status
Check if 2FA is enabled for the authenticated user.
Authentication: Required
Response
Success Response (200):
13. POST /profile/2fa/setup
Initiate 2FA setup. Generates a secret and a QR code.
Authentication: Required
Response
Success Response (200):
14. POST /profile/2fa/enable
Verify and enable 2FA using a code from the authenticator app.
Authentication: Required
Request Body
Response
Success Response (200):
Error Responses:
400 Bad Request: Invalid code or setup not initiated.
15. POST /profile/2fa/disable
Disable 2FA after verifying a code.
Authentication: Required
Request Body
Response
Success Response (200):
Error Responses:
400 Bad Request: Invalid code or 2FA not enabled.
2FA Login Flow
The login flow changes when 2FA is enabled for a user. It becomes a two-step process to ensure security.
Step 1: Initial Login
A. Email/Password Login
Call POST /auth/login with email and password.
If 2FA is enabled, the server returns:
preAuthToken: A short-lived (5 min) JWT token required for the second step.
B. OAuth Login (Steam, Google, Discord)
If a user with 2FA enabled logs in via an OAuth provider, the backend will redirect them to the home page with query parameters:
${MAIN_URL}?required2fa=true&token=${preAuthToken}
The frontend should detect required2fa=true, extract the token, and proceed to Step 2.
Step 2: 2FA Verification
Call POST /auth/login/2fa with the preAuthToken and the 6-digit TOTP code.
Request Body
Response
Success Response (200):
Returns the user object and sets the session cookie, completing the login.
Usage Examples
Frontend Integration
Get Notifications
Clear Notifications
Get Public User
Lock Coins in Vault
Unlock Coins from Vault
Set Trade URL
Upload Profile Picture
Update Client Seed
Update Profile Details
2FA Setup Flow
2FA Login Flow
Notes
The vault feature allows users to lock their coins for a specified period, preventing them from being used until the deadline passes.
The email update feature is currently disabled and will return a 501 status code.
Timestamps are in Unix milliseconds format.
Profile picture uploads are stored on the server under
uploads/avatars/. The returnedavatarUrlis an absolute URL constructed from theAPI_URLenvironment variable (e.g.,https://api.example.com/uploads/avatars/filename.jpg).Only
jpeg,png,webp, andgifimage types are accepted for avatar uploads. Maximum file size is 2MB.
Last updated