Skip to main content

User Management

This guide will take you through the journey of managing users within your betting application using our API.

Creating a User

Once you have authenticated, you can create users who will be placing bets on your platform. To create a user, you need to send a POST request to our API with the user's details. The reference field is optional and will be generated if not provided. The preferences field is also optional.

# Using token authentication
curl -X POST "$baseUrl/account/user" \
-H "Authorization: Bearer $token" \
-H "Content-Type: application/json" \
-d '{
"reference": "danny_user", # Optional
"name": "User 3",
"preferences": {} # Optional
}'

# Or using API key authentication
curl -X POST "$baseUrl/account/user" \
-H "Authorization: Basic $base64_encoded" \
-H "Content-Type: application/json" \
-d '{
"reference": "danny_user", # Optional
"name": "User 3",
"preferences": {} # Optional
}'

Upon successful creation, the API will respond with the user's details:

{
"data": {
"id": 2,
"reference": "a2_user_Xhwz442NTj74z6F0",
"created_at": "2025-09-08T12:05:10.000Z"
},
"message": "User created successfully"
}

Flow of Creating a User

Here is a visual representation of the flow for creating a user:

This diagram shows the complete sequence of API calls to create an account, authenticate, and then create a user.

Getting User Details

You can retrieve the details of a specific user by sending a GET request to our API with either the user's ID or reference.

By User ID

# Using token authentication
curl -X GET "$baseUrl/account/user/$userId" \
-H "Authorization: Bearer $token" \
-H "Content-Type: application/json"

# Or using API key authentication
curl -X GET "$baseUrl/account/user/$userId" \
-H "Authorization: Basic $base64_encoded" \
-H "Content-Type: application/json"

By User Reference

# Using token authentication
curl -X GET "$baseUrl/account/user/$reference/reference" \
-H "Authorization: Bearer $token" \
-H "Content-Type: application/json"

# Or using API key authentication
curl -X GET "$baseUrl/account/user/$reference/reference" \
-H "Authorization: Basic $base64_encoded" \
-H "Content-Type: application/json"

Upon successful retrieval, the API will respond with the user's details:

{
"data": {
"id": 1,
"reference": "a1_user_FclirLc2MJecJqsi",
"name": "User 3",
"preferences": {},
"created_at": "2025-09-08T12:00:00.000Z"
},
"message": "User details retrieved successfully"
}

The API will respond with the user's details:

{
"data": {
"id": 1,
"account_id": 2,
"reference": "a2_user_4lH6u7hayvaqs6Ix",
"name": "Jane Dodde",
"role": "user",
"preferences": {
"allow_negative_balance": true
},
"balance": 0,
"exposure": 0,
"created_at": "2025-09-08T12:00:00.000Z"
},
"message": "User fetched successfully"
}

The API will respond with the updated user's preferences:

{
"message": "account preference updated successfully"
}

Get Paginated Users

Retrieve a list of users for your account. Supports pagination, optional search, and sorting.

Parameters (query string):

  • page (default 1) – Page number (min 1)
  • per_page (default 20) – Results per page (1–100)
  • search – Partial match on name or reference (case-insensitive)
  • sort_by (default created_at) – One of: id, name, reference, created_at, balance, exposure
  • sort_order (default desc) – asc or desc
# Using token authentication
curl -X GET "$baseUrl/account/user?page=1&per_page=2" \
-H "Authorization: Bearer $token" \
-H "Content-Type: application/json"

# Or using API key authentication
curl -X GET "$baseUrl/account/user?page=1&per_page=2" \
-H "Authorization: Basic $base64_encoded" \
-H "Content-Type: application/json"

Sample response:

{
"data": {
"items": [
{
"id": 1,
"account_id": 2,
"reference": "a2_user_4lH6u7hayvaqs6Ix",
"name": "Jane Doe",
"role": "user",
"preferences": { "allow_negative_balance": true },
"balance": 0,
"exposure": 0,
"created_at": "2025-09-08T12:00:00.000Z"
},
{
"id": 2,
"account_id": 2,
"reference": "a2_user_Xhwz442NTj74z6F0",
"name": "John Doe",
"role": "user",
"preferences": {},
"balance": 0,
"exposure": 0,
"created_at": "2025-09-08T12:05:10.000Z"
}
],
"page": 1,
"per_page": 2,
"total": 12,
"total_pages": 6
},
"message": "Users fetched successfully"
}