Storefront Customer Accounts
Bazaara customer accounts are isolated per store. A user registered on Store A cannot log in or access Store B unless they sign up there too.
1. Customer Sign Up
Register a new customer account for a specific storefront.
- Method:
POST - Route:
/api/v1/stores/:storeId/auth/signup
curl -X POST https://api.bazaara.store/api/v1/stores/YOUR_STORE_ID/auth/signup \
-H "Content-Type: application/json" \
-d '{
"name": "Jane Doe",
"email": "jane.doe@example.com",
"password": "securepassword123"
}'
interface SignupResponse {
success: boolean;
accessToken: string;
refreshToken: string;
user: { id: string; name: string; email: string };
}
async function signUpCustomer(storeId: string): Promise<SignupResponse> {
const response = await fetch(`https://api.bazaara.store/api/v1/stores/${storeId}/auth/signup`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
name: "Jane Doe",
email: "jane.doe@example.com",
password: "securepassword123"
})
});
return response.json();
}
import requests
def sign_up(store_id):
url = f"https://api.bazaara.store/api/v1/stores/{store_id}/auth/signup"
payload = {
"name": "Jane Doe",
"email": "jane.doe@example.com",
"password": "securepassword123"
}
response = requests.post(url, json=payload)
return response.json()
use serde::{Deserialize, Serialize};
#[derive(Serialize)]
struct SignupPayload {
name: String,
email: String,
password: String,
}
async fn sign_up(store_id: &str) -> Result<serde_json::Value, reqwest::Error> {
let client = reqwest::Client::new();
let payload = SignupPayload {
name: "Jane Doe".to_string(),
email: "jane.doe@example.com".to_string(),
password: "securepassword123".to_string(),
};
let res = client.post(&format!("https://api.bazaara.store/api/v1/stores/{}/auth/signup", store_id))
.json(&payload)
.send()
.await?
.json::<serde_json::Value>()
.await?;
Ok(res)
}
2. Customer Login
Authenticate customer and get JWT Bearer Access Token.
- Method:
POST - Route:
/api/v1/stores/:storeId/auth/login
curl -X POST https://api.bazaara.store/api/v1/stores/YOUR_STORE_ID/auth/login \
-H "Content-Type: application/json" \
-d '{
"email": "jane.doe@example.com",
"password": "securepassword123"
}'
async function loginCustomer(storeId: string) {
const response = await fetch(`https://api.bazaara.store/api/v1/stores/${storeId}/auth/login`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
email: "jane.doe@example.com",
password: "securepassword123"
})
});
return response.json();
}
import requests
def login(store_id):
url = f"https://api.bazaara.store/api/v1/stores/{store_id}/auth/login"
payload = {
"email": "jane.doe@example.com",
"password": "securepassword123"
}
response = requests.post(url, json=payload)
return response.json()
async fn login(store_id: &str) -> Result<serde_json::Value, reqwest::Error> {
let client = reqwest::Client::new();
let params = [("email", "jane.doe@example.com"), ("password", "securepassword123")];
let res = client.post(&format!("https://api.bazaara.store/api/v1/stores/{}/auth/login", store_id))
.json(¶ms)
.send()
.await?
.json::<serde_json::Value>()
.await?;
Ok(res)
}
3. Forgot Password Flow
Request a password reset token for the customer account on this storefront.
- Method:
POST - Route:
/api/v1/stores/:storeId/auth/forgot-password
curl -X POST https://api.bazaara.store/api/v1/stores/YOUR_STORE_ID/auth/forgot-password \
-H "Content-Type: application/json" \
-d '{ "email": "jane.doe@example.com" }'
async function forgotPassword(storeId: string) {
const response = await fetch(`https://api.bazaara.store/api/v1/stores/${storeId}/auth/forgot-password`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ email: "jane.doe@example.com" })
});
return response.json(); // Contains the resetToken for sandbox testing
}
import requests
def forgot_password(store_id):
url = f"https://api.bazaara.store/api/v1/stores/{store_id}/auth/forgot-password"
response = requests.post(url, json={"email": "jane.doe@example.com"})
return response.json()
async fn forgot_password(store_id: &str) -> Result<serde_json::Value, reqwest::Error> {
let client = reqwest::Client::new();
let res = client.post(&format!("https://api.bazaara.store/api/v1/stores/{}/auth/forgot-password", store_id))
.json(&serde_json::json!({ "email": "jane.doe@example.com" }))
.send()
.await?
.json::<serde_json::Value>()
.await?;
Ok(res)
}
4. Reset Password Flow
Submit the reset token along with the new password to save new credentials.
- Method:
POST - Route:
/api/v1/stores/:storeId/auth/reset-password
curl -X POST https://api.bazaara.store/api/v1/stores/YOUR_STORE_ID/auth/reset-password \
-H "Content-Type: application/json" \
-d '{
"token": "RESET_TOKEN_HERE",
"newPassword": "myNewSecurePassword123!"
}'
async function resetPassword(storeId: string, token: string) {
const response = await fetch(`https://api.bazaara.store/api/v1/stores/${storeId}/auth/reset-password`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
token,
newPassword: "myNewSecurePassword123!"
})
});
return response.json();
}
import requests
def reset_password(store_id, token):
url = f"https://api.bazaara.store/api/v1/stores/{store_id}/auth/reset-password"
payload = {
"token": token,
"newPassword": "myNewSecurePassword123!"
}
response = requests.post(url, json=payload)
return response.json()
async fn reset_password(store_id: &str, token: &str) -> Result<serde_json::Value, reqwest::Error> {
let client = reqwest::Client::new();
let res = client.post(&format!("https://api.bazaara.store/api/v1/stores/{}/auth/reset-password", store_id))
.json(&serde_json::json!({
"token": token,
"newPassword": "myNewSecurePassword123!"
}))
.send()
.await?
.json::<serde_json::Value>()
.await?;
Ok(res)
}