SeloraXDEVELOPERS

Customers

Customers API

Manage customer data for the authenticated store. Customers are users who have placed orders or created accounts on the storefront.

List Customers

Retrieve a paginated list of customers with order summary data.

GET /api/apps/v1/customers

Authentication

Required. Must include valid app credentials.

Scope

read:customers

Query Parameters

ParameterTypeDefaultDescription
pageinteger1Page number
limitinteger50Items per page (max 250)
sortstringcreated_at:descSort results. Format: column:asc or column:desc. Allowed: created_at, updated_at, name
sincestring (ISO 8601)--Only return customers created on or after this date
searchstring--Search by name, email, or phone
include_guestsstringfalseSet to true to include guest checkout customers
total_orders_mininteger--Only return customers with at least this many orders
total_spent_mininteger--Only return customers who have spent at least this amount

Example Request

curl -X GET "https://api.selorax.io/api/apps/v1/customers?page=1&limit=50&sort=created_at:desc" \
  -H "Authorization: Bearer <token>"

Search for customers and filter by spend:

curl -X GET "https://api.selorax.io/api/apps/v1/customers?search=rahim&total_spent_min=5000" \
  -H "Authorization: Bearer <token>"

Or using client credentials:

curl -X GET "https://api.selorax.io/api/apps/v1/customers?since=2025-06-01T00:00:00Z&limit=50" \
  -H "X-Client-Id: sx_app_..." \
  -H "X-Client-Secret: sx_secret_..." \
  -H "X-Store-Id: 22"

Response

{
  "data": [
    {
      "user_id": 301,
      "store_id": 22,
      "name": "Rahim Ahmed",
      "email": "[email protected]",
      "phone": "01712345678",
      "address_json": {"address": "123 Main St", "city": "Dhaka"},
      "is_guest": 0,
      "created_at": "2025-01-20T06:30:00.000Z",
      "updated_at": "2025-06-15T10:30:00.000Z",
      "total_orders": 12,
      "total_spent": 18500
    },
    {
      "user_id": 289,
      "store_id": 22,
      "name": "Fatima Khatun",
      "email": null,
      "phone": "01898765432",
      "address_json": null,
      "is_guest": 0,
      "created_at": "2025-03-05T14:00:00.000Z",
      "updated_at": "2025-06-10T08:45:00.000Z",
      "total_orders": 3,
      "total_spent": 4200
    }
  ],
  "pagination": {
    "page": 1,
    "limit": 50,
    "total": 2
  },
  "status": 200
}

Response Fields

FieldTypeDescription
user_idintegerUnique customer identifier
store_idintegerStore the customer belongs to
namestringCustomer full name
emailstring or nullCustomer email address
phonestringCustomer phone number
address_jsonobject or nullCustomer's saved address
is_guestinteger (0 or 1)Whether the customer is a guest checkout user
total_ordersintegerTotal number of orders placed
total_spentintegerTotal amount spent across all orders
created_atstring (ISO 8601)When the customer account was created
updated_atstring (ISO 8601)When the customer record was last updated

Node.js Example

const response = await fetch(
  "https://api.selorax.io/api/apps/v1/customers?search=rahim&sort=name:asc",
  { headers: { Authorization: "Bearer sx_at_..." } }
);
const { data, pagination } = await response.json();
console.log(`Found ${pagination.total} customers`);

Python Example

import requests
 
response = requests.get(
    "https://api.selorax.io/api/apps/v1/customers",
    headers={"Authorization": "Bearer sx_at_..."},
    params={"total_orders_min": 5, "sort": "created_at:desc", "limit": 50},
)
data = response.json()
for customer in data["data"]:
    print(f"{customer['name']}: {customer['total_orders']} orders, ৳{customer['total_spent']}")

Get Customer

Retrieve a single customer by user ID, including order summary and verification status.

GET /api/apps/v1/customers/:user_id

Authentication

Required. Must include valid app credentials.

Scope

read:customers

Path Parameters

ParameterTypeDescription
user_idintegerThe customer's user ID

Example Request

curl -X GET "https://api.selorax.io/api/apps/v1/customers/301" \
  -H "Authorization: Bearer <token>"

Response

{
  "data": {
    "user_id": 301,
    "store_id": 22,
    "name": "Rahim Ahmed",
    "email": "[email protected]",
    "phone": "01712345678",
    "address_json": {"address": "123 Main St", "city": "Dhaka"},
    "is_guest": 0,
    "is_phone_verified": 1,
    "is_email_verified": 0,
    "created_at": "2025-01-20T06:30:00.000Z",
    "updated_at": "2025-06-15T10:30:00.000Z",
    "total_orders": 12,
    "total_spent": 18500
  },
  "status": 200
}

Response Fields

Includes all list fields plus:

FieldTypeDescription
is_phone_verifiedinteger (0 or 1)Whether the customer's phone is verified
is_email_verifiedinteger (0 or 1)Whether the customer's email is verified

Error Responses

CodeStatusMeaning
invalid_token401Token is expired or invalid
insufficient_scope403App does not have read:customers scope

If the user_id does not exist or does not belong to the authenticated store:

{
  "message": "Customer not found.",
  "status": 404
}

Update Customer

Update a customer's information. Only provided fields are updated.

PUT /api/apps/v1/customers/:user_id

Authentication

Required. Must include valid app credentials.

Scope

write:customers

Path Parameters

ParameterTypeDescription
user_idintegerThe customer's user ID

Request Body

FieldTypeRequiredDescription
namestringNoCustomer full name (max 255 characters)
emailstringNoValid email address
phonestringNoPhone number (max 20 characters)
address_jsonobjectNoCustomer address as a JSON object

At least one field must be provided.

Example Request

curl -X PUT "https://api.selorax.io/api/apps/v1/customers/301" \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Rahim Ahmed Khan",
    "address_json": {
      "address": "456 New Street",
      "city": "Dhaka",
      "area": "Gulshan"
    }
  }'

Response

{
  "data": {
    "user_id": 301,
    "store_id": 22,
    "name": "Rahim Ahmed Khan",
    "email": "[email protected]",
    "phone": "01712345678",
    "address_json": {"address": "456 New Street", "city": "Dhaka", "area": "Gulshan"},
    "is_guest": 0,
    "is_phone_verified": 1,
    "is_email_verified": 0,
    "created_at": "2025-01-20T06:30:00.000Z",
    "updated_at": "2025-06-20T12:00:00.000Z"
  },
  "message": "Customer updated.",
  "status": 200
}

Error Responses

CodeStatusMeaning
invalid_token401Token is expired or invalid
insufficient_scope403App does not have write:customers scope
--400Validation error (invalid email, missing fields, etc.)
--404Customer not found

Customer Order History

Retrieve a paginated list of orders for a specific customer. This is a sub-resource to keep sensitive order data separate from the customer profile.

GET /api/apps/v1/customers/:user_id/orders

Authentication

Required. Must include valid app credentials.

Scope

read:customers

Path Parameters

ParameterTypeDescription
user_idintegerThe customer's user ID

Query Parameters

ParameterTypeDefaultDescription
pageinteger1Page number
limitinteger50Items per page (max 250)
statusstring--Filter by order status (e.g. pending, confirmed, delivered)

Example Request

curl -X GET "https://api.selorax.io/api/apps/v1/customers/301/orders?status=delivered&limit=10" \
  -H "Authorization: Bearer <token>"

Response

{
  "data": [
    {
      "order_id": 1045,
      "store_id": 22,
      "user_id": 301,
      "order_status": "delivered",
      "financial_status": "paid",
      "fulfillment_status": "fulfilled",
      "sub_total": 1500,
      "tax": 0,
      "shipping": 60,
      "discount": 100,
      "grand_total": 1460,
      "payment_method": "cod",
      "note": null,
      "created_at": "2025-06-15T10:30:00.000Z",
      "updated_at": "2025-06-18T14:00:00.000Z"
    }
  ],
  "pagination": {
    "page": 1,
    "limit": 10,
    "total": 1
  },
  "status": 200
}

Response Fields

Same fields as the Orders API list response.

Error Responses

Returns 404 if the customer does not exist or does not belong to the authenticated store.


Create Customer

Create a new customer. Phone number must be unique per store.

POST /api/apps/v1/customers

Scope

write:customers

Request Body

FieldTypeRequiredDescription
namestringYesCustomer name
phonestringYesPhone number (min 10 characters, unique per store)
emailstringNoEmail address
addressobjectNoAddress object (stored as JSON)

Example Request

curl -X POST "https://api.selorax.io/api/apps/v1/customers" \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Karim Hossain",
    "phone": "01812345678",
    "email": "[email protected]",
    "address": {
      "address": "789 Park Avenue",
      "city": "Chittagong"
    }
  }'

Response (201)

{
  "data": {
    "user_id": 350,
    "name": "Karim Hossain",
    "phone": "01812345678",
    "email": "[email protected]",
    "store_id": 22
  },
  "status": 201
}

Error Responses

StatusMeaning
400Missing name or phone
409Phone number already exists for this store

Delete Customer

Delete a customer. Customers with existing orders cannot be deleted.

DELETE /api/apps/v1/customers/:user_id

Scope

write:customers

Error Responses

StatusMeaning
400Customer has orders (cannot delete)
404Customer not found