Authentication APIs
Creating an Account
To create an account, you need to send a POST request to our API with the account details. This will register a new account for your betting business.
Request
| Property | Value |
|---|---|
| method | POST |
| url | $baseUrl/auth/register/account |
| Content-Type | application/json |
Body
| Property | Type | Required | Default | Description |
|---|---|---|---|---|
| name | string | Yes | - | Name of the betting business |
| string | Yes | - | Business email address | |
| password | string | Yes | - | Account password |
- cURL
- JavaScript
- Python
- Rust
curl -X POST "$baseUrl/auth/register/account" \
-H "Content-Type: application/json" \
-d '{
"name": "My Betting Business",
"email": "business@example.com",
"password": "securepassword"
}'
const createAccount = async () => {
try {
const response = await fetch(`${baseUrl}/auth/register/account`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
name: "My Betting Business",
email: "business@example.com",
password: "securepassword",
}),
});
const data = await response.json();
console.log("Account created:", data);
} catch (error) {
console.error("Error creating account:", error);
}
};
// Usage
createAccount();
import requests
import json
def create_account():
url = f"{baseUrl}/auth/register/account"
headers = {
'Content-Type': 'application/json'
}
payload = {
"name": "My Betting Business",
"email": "business@example.com",
"password": "securepassword"
}
response = requests.post(url, headers=headers, data=json.dumps(payload))
if response.status_code == 200:
print('Account created:', response.json())
else:
print('Error creating account:', response.text)
# Usage
create_account()
use reqwest::Client;
use serde::{Deserialize, Serialize};
#[derive(Serialize)]
struct AccountRequest {
name: String,
email: String,
password: String,
}
async fn create_account(client: &Client, base_url: &str)
-> Result<serde_json::Value, Box<dyn std::error::Error>> {
let account_request = AccountRequest {
name: "My Betting Business".to_string(),
email: "business@example.com".to_string(),
password: "securepassword".to_string(),
};
let response = client
.post(&format!("{}/auth/register/account", base_url))
.header("Content-Type", "application/json")
.json(&account_request)
.send()
.await?;
let account_data = response.json::<serde_json::Value>().await?;
println!("Account created: {:?}", account_data);
Ok(account_data)
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new();
// Create account
let account_data = create_account(&client, base_url).await?;
Ok(())
}
Response
- Success
- Error
Http Code: 201
{
"message": "Account created successfully"
}
Record already exists
Http Code: 400
{
"status": 400,
"error": "Account with email \"first@email.com\" already exists"
}
Error with body
Http Code: 400
{
"message": [
"name should not be empty",
"email should not be empty",
"email must be an email",
"password must be longer than or equal to 8 characters",
"password should not be empty"
],
"error": "Bad Request",
"statusCode": 400
}
Logging In
To log in to your account, you need to send a POST request to our API with your email and password. This will authenticate your account and return a token.
Request
| Property | Value |
|---|---|
| method | POST |
| url | $baseUrl/auth/login/account |
| Content-Type | application/json |
Body
| Property | Type | Required | Default | Description |
|---|---|---|---|---|
| string | Yes | - | Business email address | |
| password | string | Yes | - | Account password |
- cURL
- JavaScript
- Python
- Rust
curl -X POST "$baseUrl/auth/login/account" \
-H "Content-Type: application/json" \
-d '{
"email": "business@example.com",
"password": "securepassword"
}'
const login = async () => {
try {
const response = await fetch(`${baseUrl}/auth/login/account`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
email: "business@example.com",
password: "securepassword",
}),
});
const data = await response.json();
console.log("Logged in:", data);
} catch (error) {
console.error("Error logging in:", error);
}
};
// Usage
login();
import requests
import json
def login():
url = f"{baseUrl}/auth/login/account"
headers = {
'Content-Type': 'application/json'
}
payload = {
"email": "business@example.com",
"password": "securepassword"
}
response = requests.post(url, headers=headers, data=json.dumps(payload))
if response.status_code == 200:
print('Logged in:', response.json())
else:
print('Error logging in:', response.text)
# Usage
login()
use reqwest::Client;
use serde::{Deserialize, Serialize};
#[derive(Serialize)]
struct LoginRequest {
email: String,
password: String,
}
async fn login(client: &Client, base_url: &str)
-> Result<serde_json::Value, Box<dyn std::error::Error>> {
let login_request = LoginRequest {
email: "business@example.com".to_string(),
password: "securepassword".to_string(),
};
let response = client
.post(&format!("{}/auth/login/account", base_url))
.header("Content-Type", "application/json")
.json(&login_request)
.send()
.await?;
let login_data = response.json::<serde_json::Value>().await?;
println!("Logged in: {:?}", login_data);
Ok(login_data)
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new();
// Log in
let login_data = login(&client, base_url).await?;
Ok(())
}
Response
- Success
- Error
Http Code: 201
{
"data": {
"token": "OCFUBbMIX4PGXb4ROw5xKVC8kW8tGSBh"
},
"message": "Logged into account successfully"
}
Email or password incorrect
Http Code: 400
{
"status": 400,
"error": "Email or password incorrect"
}
Error with body
Http Code: 400
{
"message": [
"email should not be empty",
"email must be an email",
"password should not be empty"
],
"error": "Bad Request",
"statusCode": 400
}
Logging Out
To log out from your account, you need to send a POST request to our API. This will invalidate your authentication token.
Request
| Property | Value |
|---|---|
| method | POST |
| url | $baseUrl/auth/logout/account |
Headers
| Property | Required | Value |
|---|---|---|
| Authorization | Yes | Bearer ${token} |
Params
| Property | Required | Default | Value |
|---|---|---|---|
| logout_all | No | false | If the value is true all tokens associated with the account is logged out |
- cURL
- JavaScript
- Python
- Rust
curl -X POST "$baseUrl/auth/logout/account?logout_all=true" \
-H "Authorization: Bearer $token" \
-H "Content-Type: application/json"
const logout = async (token, logoutAll = false) => {
try {
const url = `${baseUrl}/auth/logout/account?logout_all=${logoutAll}`;
const response = await fetch(url, {
method: "POST",
headers: {
Authorization: `Bearer ${token}`,
"Content-Type": "application/json",
},
});
const data = await response.json();
console.log("Logged out:", data);
} catch (error) {
console.error("Error logging out:", error);
}
};
// Usage
const token = "your_auth_token"; // Replace with actual token
logout(token, true); // Set to true to log out from all sessions
import requests
def logout(token, logout_all=False):
url = f"{baseUrl}/auth/logout/account?logout_all={logout_all}"
headers = {
'Authorization': f"Bearer {token}",
'Content-Type': 'application/json'
}
response = requests.post(url, headers=headers)
if response.status_code == 200:
print('Logged out:', response.json())
else:
print('Error logging out:', response.text)
# Usage
token = 'your_auth_token' # Replace with actual token
logout(token, True) # Set to True to log out from all sessions
use reqwest::Client;
use serde_json::Value;
async fn logout(client: &Client, base_url: &str, token: &str, logout_all: bool) -> Result<Value, Box<dyn std::error::Error>> {
let url = format!("{}/auth/logout/account?logout_all={}", base_url, logout_all);
let response = client
.post(&url)
.header("Authorization", format!("Bearer {}", token))
.header("Content-Type", "application/json")
.send()
.await?;
if response.status().is_success() {
let data = response.json::<Value>().await?;
println!("Logged out: {:?}", data);
Ok(data)
} else {
let error_text = response.text().await?;
println!("Error logging out: {}", error_text);
Err(Box::new(std::io::Error::new(std::io::ErrorKind::Other, error_text)))
}
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new();
let base_url = "your_base_url"; // Replace with actual base URL
let token = "your_auth_token"; // Replace with actual token
// Log out
logout(&client, base_url, token, true).await?;
Ok(())
}
Response
- Success
- Error
Http Code: 201
{
"message": "Logged out successfully"
}
Unauthorized
Http Code: 401
{
"message": "Unauthorized",
"statusCode": 401
}
Generate API Keys
To generate API keys for your account, you need to send a POST request to our API. This will generate a new API key and secret for your account.
Request
For this request, the request must be authorized using the Authorization header. The token is the data.token from the login response.
| Property | Value |
|---|---|
| method | POST |
| url | $baseUrl/auth/account/generate-keys |
| Content-Type | application/json |
Headers
| Property | Required | Value |
|---|---|---|
| Authorization | Yes | Bearer ${token} |
- cURL
- JavaScript
- Python
- Rust
curl -X POST "$baseUrl/auth/account/generate-keys" \
-H "Authorization: Bearer $token" \
-H "Content-Type: application/json"
const generateApiKeys = async (token) => {
try {
const response = await fetch(`${baseUrl}/auth/account/generate-keys`, {
method: "POST",
headers: {
Authorization: `Bearer ${token}`,
"Content-Type": "application/json",
},
});
const data = await response.json();
console.log("API keys generated:", data);
} catch (error) {
console.error("Error generating API keys:", error);
}
};
// Usage
const token = "your_auth_token"; // Replace with actual token
generateApiKeys(token);
import requests
def generate_api_keys(token):
url = f"{baseUrl}/auth/account/generate-keys"
headers = {
'Authorization': f"Bearer {token}",
'Content-Type': 'application/json'
}
response = requests.post(url, headers=headers)
if response.status_code == 200:
print('API keys generated:', response.json())
else:
print('Error generating API keys:', response.text)
# Usage
token = 'your_auth_token' # Replace with actual token
generate_api_keys(token)
use reqwest::Client;
use serde_json::Value;
async fn generate_api_keys(client: &Client, base_url: &str, token: &str)
-> Result<Value, Box<dyn std::error::Error>> {
let response = client
.post(&format!("{}/auth/account/generate-keys", base_url))
.header("Authorization", format!("Bearer {}", token))
.header("Content-Type", "application/json")
.send()
.await?;
let api_keys_data = response.json::<Value>().await?;
println!("API keys generated: {:?}", api_keys_data);
Ok(api_keys_data)
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new();
// Generate API keys
let token = "your_auth_token"; // Replace with actual token
let api_keys_data = generate_api_keys(&client, base_url, token).await?;
Ok(())
}
Response
- Success
- Error
Http Code: 201
{
"data": {
"api_key": "api_key_k4rBSsfzj6SyJbsKOT3YXRXsmKRZuYT4",
"api_secret": "api_secret_80d6bx3NNRsqELP6in2eVS56jSGyVNhiUtRMeImnUoJWc8DQYgLnwm1gH45PISQN",
"base64_encoded": "YXBpX2tleV9rNHJCU3Nmemo2U3lKYnNLT1QzWVhSWHNtS1JadVlUNDphcGlfc2VjcmV0XzgwZDZieDNOTlJzcUVMUDZpbjJlVlM1NmpTR3lWTmhpVXRSTWVJbW5Vb0pXYzhEUVlnTG53bTFnSDQ1UElTUU4="
},
"message": "Api keys generated successfully"
}
Unauthorized
Http Code: 401
{
"message": "Unauthorized",
"statusCode": 401
}
Email not verified
Http Code: 403
{
"status": 403,
"error": "Email not verified"
}
Verify Account Email
To verify an account email, you need to send a GET request to our API with the verification token that was sent to the email address.
Request
| Property | Value |
|---|---|
| method | GET |
| url | $baseUrl/auth/account/verify-email?token=${token} |
Params
| Property | Required | Description |
|---|---|---|
| token | Yes | The verification token sent to the email address |
- cURL
- JavaScript
- Python
- Rust
curl -X GET "$baseUrl/auth/account/verify-email?token=your_verification_token"
const verifyEmail = async (verificationToken) => {
try {
const response = await fetch(`${baseUrl}/auth/account/verify-email?token=${verificationToken}`, {
method: "GET"
});
const data = await response.json();
console.log("Email verification response:", data);
} catch (error) {
console.error("Error verifying email:", error);
}
};
// Usage
const verificationToken = "your_verification_token"; // Token from the email
verifyEmail(verificationToken);
import requests
def verify_email(verification_token):
url = f"{baseUrl}/auth/account/verify-email?token={verification_token}"
response = requests.get(url)
if response.status_code == 200:
print('Email verified:', response.json())
else:
print('Error verifying email:', response.text)
# Usage
verification_token = 'your_verification_token' # Token from the email
verify_email(verification_token)
use reqwest::Client;
use serde_json::Value;
async fn verify_email(client: &Client, base_url: &str, verification_token: &str)
-> Result<Value, Box<dyn std::error::Error>> {
let url = format!("{}/auth/account/verify-email?token={}", base_url, verification_token);
let response = client
.get(&url)
.send()
.await?;
let verification_data = response.json::<Value>().await?;
println!("Email verification response: {:?}", verification_data);
Ok(verification_data)
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new();
let base_url = "your_base_url"; // Replace with actual base URL
let verification_token = "your_verification_token"; // Token from the email
// Verify email
verify_email(&client, base_url, verification_token).await?;
Ok(())
}
Response
- Success
- Error
Http Code: 200
{
"message": "Email verified successfully"
}
Invalid or expired token
Http Code: 400
{
"status": 400,
"error": "Invalid or expired verification token"
}
Resend Verification Email
To resend a verification email, you need to send a POST request to our API. This will generate a new verification token and send it to the associated email address.
Request
For this request, the request must be authorized using the Authorization header.
| Property | Value |
|---|---|
| method | POST |
| url | $baseUrl/auth/account/resend-verification-email |
| Content-Type | application/json |
Headers
| Property | Required | Value |
|---|---|---|
| Authorization | Yes | Bearer ${token} |
- cURL
- JavaScript
- Python
- Rust
curl -X POST "$baseUrl/auth/account/resend-verification-email" \
-H "Authorization: Bearer $token" \
-H "Content-Type: application/json"
const resendVerificationEmail = async (token) => {
try {
const response = await fetch(`${baseUrl}/auth/account/resend-verification-email`, {
method: "POST",
headers: {
Authorization: `Bearer ${token}`,
"Content-Type": "application/json",
}
});
const data = await response.json();
console.log("Verification email response:", data);
} catch (error) {
console.error("Error resending verification email:", error);
}
};
// Usage
const token = "your_auth_token"; // Replace with actual token
resendVerificationEmail(token);
import requests
def resend_verification_email(token):
url = f"{baseUrl}/auth/account/resend-verification-email"
headers = {
'Authorization': f"Bearer {token}",
'Content-Type': 'application/json'
}
response = requests.post(url, headers=headers)
if response.status_code == 200:
print('Verification email sent:', response.json())
else:
print('Error sending verification email:', response.text)
# Usage
token = 'your_auth_token' # Replace with actual token
resend_verification_email(token)
use reqwest::Client;
use serde_json::Value;
async fn resend_verification_email(client: &Client, base_url: &str, token: &str)
-> Result<Value, Box<dyn std::error::Error>> {
let url = format!("{}/auth/account/resend-verification-email", base_url);
let response = client
.post(&url)
.header("Authorization", format!("Bearer {}", token))
.header("Content-Type", "application/json")
.send()
.await?;
let result = response.json::<Value>().await?;
println!("Verification email response: {:?}", result);
Ok(result)
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new();
let base_url = "your_base_url"; // Replace with actual base URL
let token = "your_auth_token"; // Replace with actual token
// Resend verification email
resend_verification_email(&client, base_url, token).await?;
Ok(())
}
Response
- Success
- Error
Http Code: 200
{
"message": "Verification email sent successfully"
}
Unauthorized
Http Code: 401
{
"message": "Unauthorized",
"statusCode": 401
}
Reset Password
Allows authenticated account users to reset their current password by providing their current password and a new password. This endpoint supports both Bearer token and API key authentication methods.
Request
| Property | Value |
|---|---|
| method | POST |
| url | $baseUrl/auth/account/reset-password |
| Content-Type | application/json |
Headers
| Property | Required | Value |
|---|---|---|
| Authorization | Yes | Bearer ${token} or Basic ${base64(api_key:api_secret)} |
Body
| Property | Type | Required | Default | Description |
|---|---|---|---|---|
| password | string | Yes | - | Current account password |
| new_password | string | Yes | - | New password (minimum 8 characters) |
| password_confirmation | string | Yes | - | Confirmation of new password (must match) |
- cURL
- JavaScript
- Python
- Rust
# Using Bearer Token
curl -X POST "$baseUrl/auth/account/reset-password" \
-H "Authorization: Bearer $token" \
-H "Content-Type: application/json" \
-d '{
"password": "current_password",
"new_password": "new_password_min_8_chars",
"password_confirmation": "new_password_min_8_chars"
}'
# Using API Key Authentication
curl -X POST "$baseUrl/auth/account/reset-password" \
-u "api_key:api_secret" \
-H "Content-Type: application/json" \
-d '{
"password": "current_password",
"new_password": "new_password_min_8_chars",
"password_confirmation": "new_password_min_8_chars"
}'
// Using Bearer Token
const resetPasswordWithToken = async (token, currentPassword, newPassword) => {
try {
const response = await fetch(`${baseUrl}/auth/account/reset-password`, {
method: "POST",
headers: {
Authorization: `Bearer ${token}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
password: currentPassword,
new_password: newPassword,
password_confirmation: newPassword,
}),
});
const data = await response.json();
console.log("Password reset response:", data);
} catch (error) {
console.error("Error resetting password:", error);
}
};
// Using API Key Authentication
const resetPasswordWithApiKey = async (apiKey, apiSecret, currentPassword, newPassword) => {
try {
const response = await fetch(`${baseUrl}/auth/account/reset-password`, {
method: "POST",
headers: {
Authorization: `Basic ${btoa(`${apiKey}:${apiSecret}`)}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
password: currentPassword,
new_password: newPassword,
password_confirmation: newPassword,
}),
});
const data = await response.json();
console.log("Password reset response:", data);
} catch (error) {
console.error("Error resetting password:", error);
}
};
// Usage
const token = "your_auth_token"; // Replace with actual token
const apiKey = "your_api_key"; // Replace with actual API key
const apiSecret = "your_api_secret"; // Replace with actual API secret
resetPasswordWithToken(token, "current_password", "new_secure_password123");
resetPasswordWithApiKey(apiKey, apiSecret, "current_password", "new_secure_password123");
import requests
import json
from requests.auth import HTTPBasicAuth
def reset_password_with_token(token, current_password, new_password):
url = f"{baseUrl}/auth/account/reset-password"
headers = {
'Authorization': f"Bearer {token}",
'Content-Type': 'application/json'
}
payload = {
"password": current_password,
"new_password": new_password,
"password_confirmation": new_password
}
response = requests.post(url, headers=headers, data=json.dumps(payload))
if response.status_code == 200:
print('Password reset successfully:', response.json())
else:
print('Error resetting password:', response.text)
def reset_password_with_api_key(api_key, api_secret, current_password, new_password):
url = f"{baseUrl}/auth/account/reset-password"
headers = {
'Content-Type': 'application/json'
}
payload = {
"password": current_password,
"new_password": new_password,
"password_confirmation": new_password
}
response = requests.post(url,
auth=HTTPBasicAuth(api_key, api_secret),
headers=headers,
data=json.dumps(payload))
if response.status_code == 200:
print('Password reset successfully:', response.json())
else:
print('Error resetting password:', response.text)
# Usage
token = 'your_auth_token' # Replace with actual token
api_key = 'your_api_key' # Replace with actual API key
api_secret = 'your_api_secret' # Replace with actual API secret
reset_password_with_token(token, 'current_password', 'new_secure_password123')
reset_password_with_api_key(api_key, api_secret, 'current_password', 'new_secure_password123')
use reqwest::Client;
use serde::{Deserialize, Serialize};
use serde_json::Value;
#[derive(Serialize)]
struct PasswordResetRequest {
password: String,
new_password: String,
password_confirmation: String,
}
async fn reset_password_with_token(
client: &Client,
base_url: &str,
token: &str,
current_password: &str,
new_password: &str
) -> Result<Value, Box<dyn std::error::Error>> {
let password_reset_request = PasswordResetRequest {
password: current_password.to_string(),
new_password: new_password.to_string(),
password_confirmation: new_password.to_string(),
};
let response = client
.post(&format!("{}/auth/account/reset-password", base_url))
.header("Authorization", format!("Bearer {}", token))
.header("Content-Type", "application/json")
.json(&password_reset_request)
.send()
.await?;
let result = response.json::<Value>().await?;
println!("Password reset with token: {:?}", result);
Ok(result)
}
async fn reset_password_with_api_key(
client: &Client,
base_url: &str,
api_key: &str,
api_secret: &str,
current_password: &str,
new_password: &str
) -> Result<Value, Box<dyn std::error::Error>> {
let password_reset_request = PasswordResetRequest {
password: current_password.to_string(),
new_password: new_password.to_string(),
password_confirmation: new_password.to_string(),
};
let response = client
.post(&format!("{}/auth/account/reset-password", base_url))
.basic_auth(api_key, Some(api_secret))
.header("Content-Type", "application/json")
.json(&password_reset_request)
.send()
.await?;
let result = response.json::<Value>().await?;
println!("Password reset with API key: {:?}", result);
Ok(result)
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new();
let base_url = "your_base_url"; // Replace with actual base URL
let token = "your_auth_token"; // Replace with actual token
let api_key = "your_api_key"; // Replace with actual API key
let api_secret = "your_api_secret"; // Replace with actual API secret
// Reset password with token
reset_password_with_token(&client, base_url, token, "current_password", "new_secure_password123").await?;
// Reset password with API key
reset_password_with_api_key(&client, base_url, api_key, api_secret, "current_password", "new_secure_password123").await?;
Ok(())
}
Response
- Success
- Error
Http Code: 200
{
"message": "Password reset successfully"
}
Validation errors
Http Code: 400
{
"message": [
"password should not be empty",
"new_password must be longer than or equal to 8 characters",
"password_confirmation should not be empty"
],
"error": "Bad Request",
"statusCode": 400
}
Incorrect current password
Http Code: 400
{
"status": 400,
"error": "Current password is incorrect"
}
Password mismatch
Http Code: 400
{
"status": 400,
"error": "New password and confirmation do not match"
}
Unauthorized
Http Code: 401
{
"message": "Unauthorized",
"statusCode": 401
}
Forgot Password
Allows users to request a password reset by providing their email address. This endpoint generates a unique 8-character reset token and sends it via email. For security, it always returns success regardless of whether the email exists.
Request
| Property | Value |
|---|---|
| method | POST |
| url | $baseUrl/auth/account/forgot-password |
| Content-Type | application/json |
Body
| Property | Type | Required | Default | Description |
|---|---|---|---|---|
| string | Yes | - | Email address for password reset |
- cURL
- JavaScript
- Python
- Rust
curl -X POST "$baseUrl/auth/account/forgot-password" \
-H "Content-Type: application/json" \
-d '{
"email": "user@example.com"
}'
const requestPasswordReset = async (email) => {
try {
const response = await fetch(`${baseUrl}/auth/account/forgot-password`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
email: email,
}),
});
const data = await response.json();
console.log("Password reset requested:", data);
} catch (error) {
console.error("Error requesting password reset:", error);
}
};
// Usage
requestPasswordReset("user@example.com");
import requests
import json
def request_password_reset(email):
url = f"{baseUrl}/auth/account/forgot-password"
headers = {
'Content-Type': 'application/json'
}
payload = {
"email": email
}
response = requests.post(url, headers=headers, data=json.dumps(payload))
if response.status_code == 200:
print('Password reset requested:', response.json())
else:
print('Error requesting password reset:', response.text)
# Usage
request_password_reset('user@example.com')
use reqwest::Client;
use serde::{Deserialize, Serialize};
use serde_json::Value;
#[derive(Serialize)]
struct ForgotPasswordRequest {
email: String,
}
async fn request_password_reset(client: &Client, base_url: &str, email: &str)
-> Result<Value, Box<dyn std::error::Error>> {
let forgot_password_request = ForgotPasswordRequest {
email: email.to_string(),
};
let response = client
.post(&format!("{}/auth/account/forgot-password", base_url))
.header("Content-Type", "application/json")
.json(&forgot_password_request)
.send()
.await?;
let result = response.json::<Value>().await?;
println!("Password reset requested: {:?}", result);
Ok(result)
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new();
let base_url = "your_base_url"; // Replace with actual base URL
// Request password reset
request_password_reset(&client, base_url, "user@example.com").await?;
Ok(())
}
Response
- Success
- Error
Http Code: 200
{
"message": "If an account with this email exists, a password reset email has been sent"
}
Invalid email format
Http Code: 400
{
"message": [
"email must be an email",
"email should not be empty"
],
"error": "Bad Request",
"statusCode": 400
}
Create Password for Forgot Password
Allows users to set a new password using the token received via email from the forgot password flow. This endpoint validates the token and creates the new password.
Request
| Property | Value |
|---|---|
| method | POST |
| url | $baseUrl/auth/account/create-password-for-forgot-password |
| Content-Type | application/json |
Body
| Property | Type | Required | Default | Description |
|---|---|---|---|---|
| string | Yes | - | Email address associated with the reset token | |
| token | string | Yes | - | 8-character reset token from email |
| password | string | Yes | - | New password (minimum 8 characters) |
| password_confirmation | string | Yes | - | Confirmation of new password (must match) |
- cURL
- JavaScript
- Python
- Rust
curl -X POST "$baseUrl/auth/account/create-password-for-forgot-password" \
-H "Content-Type: application/json" \
-d '{
"email": "user@example.com",
"token": "12345678",
"password": "new_secure_password123",
"password_confirmation": "new_secure_password123"
}'
const createNewPassword = async (email, token, newPassword) => {
try {
const response = await fetch(`${baseUrl}/auth/account/create-password-for-forgot-password`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
email: email,
token: token,
password: newPassword,
password_confirmation: newPassword,
}),
});
const data = await response.json();
console.log("Password creation response:", data);
} catch (error) {
console.error("Error creating password:", error);
}
};
// Usage
createNewPassword("user@example.com", "12345678", "new_secure_password123");
import requests
import json
def create_new_password(email, token, new_password):
url = f"{baseUrl}/auth/account/create-password-for-forgot-password"
headers = {
'Content-Type': 'application/json'
}
payload = {
"email": email,
"token": token,
"password": new_password,
"password_confirmation": new_password
}
response = requests.post(url, headers=headers, data=json.dumps(payload))
if response.status_code == 200:
print('Password created successfully:', response.json())
else:
print('Error creating password:', response.text)
# Usage
create_new_password('user@example.com', '12345678', 'new_secure_password123')
use reqwest::Client;
use serde::{Deserialize, Serialize};
use serde_json::Value;
#[derive(Serialize)]
struct CreatePasswordRequest {
email: String,
token: String,
password: String,
password_confirmation: String,
}
async fn create_new_password(
client: &Client,
base_url: &str,
email: &str,
token: &str,
new_password: &str
) -> Result<Value, Box<dyn std::error::Error>> {
let create_password_request = CreatePasswordRequest {
email: email.to_string(),
token: token.to_string(),
password: new_password.to_string(),
password_confirmation: new_password.to_string(),
};
let response = client
.post(&format!("{}/auth/account/create-password-for-forgot-password", base_url))
.header("Content-Type", "application/json")
.json(&create_password_request)
.send()
.await?;
let result = response.json::<Value>().await?;
println!("Password created: {:?}", result);
Ok(result)
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new();
let base_url = "your_base_url"; // Replace with actual base URL
// Create new password
create_new_password(&client, base_url, "user@example.com", "12345678", "new_secure_password123").await?;
Ok(())
}
Response
- Success
- Error
Http Code: 200
{
"message": "Password created successfully"
}
Validation errors
Http Code: 400
{
"message": [
"email should not be empty",
"token should not be empty",
"password must be longer than or equal to 8 characters",
"password_confirmation should not be empty"
],
"error": "Bad Request",
"statusCode": 400
}
Invalid or expired token
Http Code: 400
{
"status": 400,
"error": "Invalid or expired reset token"
}
Password mismatch
Http Code: 400
{
"status": 400,
"error": "Password and confirmation do not match"
}
Email not found
Http Code: 400
{
"status": 400,
"error": "Email not found or token invalid"
}
Account me
To get the current authenticated account details, you need to send a GET request to our API. This endpoint returns information about the currently authenticated account.
Request
For this request, the request must be authorized using the Authorization header. The token is the data.token from the login response.
| Property | Value |
|---|---|
| method | GET |
| url | $baseUrl/auth/account/me |
| Content-Type | application/json |
Authorization
This request must have the authorization header. Refer to Authorization method guide for more details
- cURL
- JavaScript
- Python
- Rust
curl -X GET "$baseUrl/auth/account/me" \
-H "Content-Type: application/json"
const getAccountDetails = async () => {
try {
const response = await fetch(`${baseUrl}/auth/account/me`, {
method: "GET",
headers: {
"Content-Type": "application/json",
},
});
const data = await response.json();
console.log("Account details:", data);
} catch (error) {
console.error("Error fetching account details:", error);
}
};
// Usage
getAccountDetails();
import requests
def get_account_details():
url = f"{baseUrl}/auth/account/me"
headers = {
'Content-Type': 'application/json'
}
response = requests.get(url, headers=headers)
if response.status_code == 200:
print('Account details:', response.json())
else:
print('Error fetching account details:', response.text)
# Usage
get_account_details()
use reqwest::Client;
use serde_json::Value;
async fn get_account_details(client: &Client, base_url: &str) -> Result<Value, Box<dyn std::error::Error>> {
let url = format!("{}/auth/account/me", base_url);
let response = client
.get(&url)
.header("Content-Type", "application/json")
.send()
.await?;
if response.status().is_success() {
let data = response.json::<Value>().await?;
println!("Account details: {:?}", data);
Ok(data)
} else {
let error_text = response.text().await?;
println!("Error fetching account details: {}", error_text);
Err(Box::new(std::io::Error::new(std::io::ErrorKind::Other, error_text)))
}
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new();
let base_url = "your_base_url"; // Replace with actual base URL
// Get account details
get_account_details(&client, base_url).await?;
Ok(())
}
Response
- Success
- Error
Http Code: 200
{
"data": {
"id": 2,
"name": "First Account",
"email": "first@email.com",
"email_verified_at": null,
"api_key_generated_at": null,
"preferences": {
"allow_negative_balance": false
},
"created_at": "2025-05-08T15:21:41.017Z",
"updated_at": "2025-05-08T15:21:41.017Z"
},
"message": "authentication data"
}
Unauthorized
Http Code: 401
{
"message": "Unauthorized",
"statusCode": 401
}