User Management API¶
Create User¶
Endpoint¶
URLs:
- Development:
https://api.rex.fit/[org-id]/dev/v1/create-user - Production:
https://api.rex.fit/[org-id]/prod/v1/create-user
Method: POST
Content-Type: application/json
Required Fields¶
| Field | Type | Description | Example |
|---|---|---|---|
from_id |
string | Unique identifier for the user in your system |
"user_abc123" |
first_name |
string | User's first name | "Ahmad" |
last_name |
string | User's last name | "Smith" |
birthdate |
string | User's birthdate in YYYY-MM-DD format |
"1997-01-25" |
gender |
string | Must be "male" or "female" |
"male" |
language |
string | Must be one of: ["en", "de", "es", "bg", "uk", "ru", "ar"] |
"en" |
goal |
string | Must be: "lose weight", "gain muscle", or "maintain" |
"maintain" |
timezone |
string | User's timezone with location and UTC offset |
"Zurich, Switzerland (UTC+01:00)" |
Measurement Fields (Choose One System)¶
Option A - Metric:
height_cm(number): Height in centimeters |181weight_kg(number): Weight in kilograms |83
Option B - Imperial:
height_ft(string): Height in feet and inches |"5'10"weight_lbs(number): Weight in pounds |183
Optional Fields¶
| Field | Type | Description | Example |
|---|---|---|---|
display_name |
string | User's display name | "Ahmad" |
Example Request (Metric)¶
{
"from_id": "user_abc123",
"first_name": "Ahmad",
"last_name": "Smith",
"birthdate": "1997-01-25",
"gender": "male",
"language": "en",
"goal": "maintain",
"timezone": "Zurich, Switzerland (UTC+01:00)",
"height_cm": 181,
"weight_kg": 83,
"display_name": "Ahmad"
}
Example Request (Imperial)¶
{
"from_id": "user_xyz789",
"first_name": "John",
"last_name": "Doe",
"birthdate": "1985-09-10",
"gender": "female",
"language": "es",
"goal": "lose weight",
"timezone": "New York, USA (UTC-05:00)",
"height_ft": "5'10",
"weight_lbs": 183,
"display_name": "JohnD"
}
Response¶
Success (201 Created):
{
"message": "User created successfully",
"user_id": "abc123xyz",
"visualization_url": "<progress_visualization_url>"
}
Error Responses¶
| Code | Description | Example |
|---|---|---|
| 400 Bad Request | Missing or invalid fields | {"error": "Invalid timezone format"} |
| 401 Unauthorized | Invalid or missing API key | {"error": "Invalid API key"} |
| 404 Not Found | User not found | {"error": "User with from_id user_abc123 not found"} |
| 500 Internal Server Error | Server error | {"error": "Internal server error"} |
Edit User¶
Endpoint¶
URLs:
- Development:
https://api.rex.fit/[org-id]/dev/v1/edit-user - Production:
https://api.rex.fit/[org-id]/prod/v1/edit-user
Method: POST
Content-Type: application/json
Authorization: Bearer <api_key>
Required Field¶
| Field | Type | Description | Example |
|---|---|---|---|
from_id |
string | Unique identifier for the user | "user_abc123" |
Editable Fields¶
| Field | Type | Description | Example |
|---|---|---|---|
timezone |
string | User's timezone with location and UTC offset |
"London, UK (UTC+00:00)" |
language |
string | Must be one of: ["en", "de", "es", "bg", "uk", "ru", "ar"] |
"en" |
goal |
string | Must be: "lose weight", "gain muscle", or "maintain" |
"gain muscle" |
birthdate |
string | User's birthdate inYYYY-MM-DD format |
"1990-05-15" |
reminders_active |
boolean | Whether reminders are active | true |
subscription_status |
string | User's subscription status:"active", "trial", or "trial_end" |
"active" |
Measurement Updates (Choose One System)¶
Metric:
height_cm(number): Height in centimeters |182weight_kg(number): Weight in kilograms |78
Imperial:
height_ft(string): Height in feet and inches |"5'11"weight_lbs(number): Weight in pounds |175
Example Request¶
{
"from_id": "user_abc123",
"timezone": "London, UK (UTC+00:00)",
"language": "en",
"goal": "gain muscle",
"subscription_status": "active"
}
Response¶
Success (200 OK):
Example Error Response:
{
"error": "Invalid timezone format. Must be in format: 'City, Country (UTC[+-]HH:MM)'. Example: 'Zurich, Switzerland (UTC+01:00)'"
}
Error Responses¶
| Code | Description | Example |
|---|---|---|
| 400 Bad Request | Missing or invalid fields | {"error": "Invalid timezone format"} |
| 401 Unauthorized | Invalid or missing API key | {"error": "Invalid API key"} |
| 404 Not Found | User not found | {"error": "User with from_id user_abc123 not found"} |
| 500 Internal Server Error | Server error | {"error": "Internal server error"} |
Notes¶
-
At least one editable field must be provided in the request.
-
If weight, height, or goal is updated, the system will automatically recalculate the user's targets.
-
The API will validate all field formats and return appropriate error messages for invalid inputs.
- You cannot provide both metric and imperial measurements in the same request.
Get User Profile¶
Endpoint¶
URLs:
- Development:
https://api.rex.fit/[org-id]/dev/v1/get-user-profile - Production:
https://api.rex.fit/[org-id]/prod/v1/get-user-profile
Method: GET
Authorization: Bearer <api_key>
Query Parameters¶
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
from_id |
string | Yes | Unique identifier for the user | ?from_id=user_abc123 |
Response Fields¶
| Field | Type | Description | Example |
|---|---|---|---|
from_id |
string | The user's unique identifier | "user_abc123" |
first_name |
string | User's first name | "John" |
last_name |
string | User's last name | "Doe" |
display_name |
string | User's display name | "JohnD" |
birthdate |
string | User's birthdate in YYYY-MM-DD format | "1990-01-01" |
gender |
string | User's gender | "male" |
language |
string | User's preferred language | "en" |
goal |
string | User's fitness goal | "lose weight" |
timezone |
string | User's timezone with location and UTC offset | "London, UK (UTC+00:00)" |
height_cm |
number | User's height in centimeters | 180 |
weight_kg |
number | User's weight in kilograms | 80 |
subscription_status |
string | Current subscription status | "active" |
reminders_active |
boolean | Whether reminders are active for the user | true |
created_at |
string | When the user account was created | "2023-01-15T12:00:00Z" |
last_request |
string | Timestamp of the user's last request | "2023-05-20T14:30:00Z" |
Optional Response Fields¶
| Field | Type | Description | Example |
|---|---|---|---|
target_calories |
number | User's daily calorie target | 2000 |
target_protein |
number | User's daily protein target in grams | 150 |
target_fat |
number | User's daily fat target in grams | 65 |
target_carbs |
number | User's daily carbohydrate target in grams | 200 |
target_weight |
number | Target weight in user's preferred unit (kg or lb) | 75 |
target_weight_kg |
number | Target weight in kilograms | 75 |
Response¶
Success (200 OK):
{
"status": "success",
"profile": {
"from_id": "user_abc123",
"first_name": "John",
"last_name": "Doe",
"display_name": "JohnD",
"birthdate": "1990-01-01",
"gender": "male",
"language": "en",
"goal": "lose weight",
"timezone": "London, UK (UTC+00:00)",
"height_cm": 180,
"weight_kg": 80,
"subscription_status": "active",
"reminders_active": true,
"created_at": "2023-01-15T12:00:00Z",
"last_request": "2023-05-20T14:30:00Z",
"target_calories": 2000,
"target_protein": 150,
"target_fat": 65,
"target_carbs": 200,
"target_weight": 75,
"target_weight_kg": 75
}
}
Error Responses¶
| Code | Description | Example |
|---|---|---|
| 400 Bad Request | Missing or invalid fields | {"error": "Missing required parameter: from_id"} |
| 401 Unauthorized | Invalid or missing API key | {"error": "Invalid API key"} |
| 404 Not Found | User not found | {"error": "User with from_id user_abc123 not found"} |
| 500 Internal Server Error | Server error | {"error": "Internal server error"} |