SureCommerce REST API
Token-authenticated API for integrating SureCommerce with mobile apps, third-party services, and custom frontends.
Jump to section
🔸 Overview
Base URL
https://yourdomain.com/api/v1
Response Format
JSON (Content-Type: application/json)
All API responses follow a consistent envelope structure:
{
"success": true,
"data": { ... }, // resource data or array
"message": "...", // optional human-readable message
"meta": { ... } // pagination info (list endpoints only)
}
Pagination meta (list endpoints)
{
"meta": {
"current_page": 1,
"last_page": 5,
"per_page": 15,
"total": 73
}
}
🔒 Authentication
401 Unauthorized.Sending the token
Include the token in the Authorization header of every request:
GET /api/v1/products HTTP/1.1
Host: yourdomain.com
Authorization: Bearer YOUR_API_TOKEN
Accept: application/json
Example with cURL
curl -H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Accept: application/json" \
https://yourdomain.com/api/v1/products
Rate Limiting
Each API token has a configurable rate limit (requests per minute). When exceeded, the API returns 429 Too Many Requests. The limit can be adjusted per client in Admin → API Clients.
🔑 Token Management
API tokens are managed from the admin panel. Each token belongs to an API Client record that controls its name, status, and rate limit.
Creating a token
- Login to the Admin Panel at
/admin - Navigate to Admin → API Clients
- Click Add New and enter a name for the client (e.g., "Mobile App")
- Save. Then click Generate Token on the client detail page
- Copy the token immediately — it will not be shown again in full
Revoking a token
Go to Admin → API Clients → [client name] and click Revoke next to the token. The token becomes invalid immediately.
Updating rate limits
On the client detail page click Update Config to change the requests-per-minute limit for that client.
🛍 Products
/api/v1/products
List products
Returns a paginated list of active products.
Query parameters
| Parameter | Type | Description |
|---|---|---|
| search | string | Filter by product name (partial match) |
| category_id | integer | Filter by category ID |
| brand_id | integer | Filter by brand ID |
| sort | string | newest (default) | price_asc | price_desc |
| per_page | integer | Items per page (default: 15, max: 100) |
| page | integer | Page number (default: 1) |
Example response
{
"success": true,
"data": [
{
"id": 1,
"categoryId": 3,
"brandId": 2,
"defaultVariantId": 5,
"minPrice": 1990000,
"price": 2190000,
"priceVariant": 2190000,
"priceOriginal": 2490000,
"priceOld": 2490000,
"priceOldVariant": 2490000,
"hasFlashSale": false,
"sku": "SP001-RED-M",
"name": "Product Name",
"slug": "product-name",
"image": "https://yourdomain.com/uploads/products/image.jpg",
"slide": [],
"status": "published",
"createdAt": "2026-01-15T10:30:00.000000Z",
"updatedAt": "2026-06-01T08:00:00.000000Z",
"category": { "id": 3, "name": "Category Name", "slug": "category-name" },
"brand": { "id": 2, "name": "Brand Name", "slug": "brand-name" }
}
],
"meta": {
"current_page": 1,
"last_page": 5,
"per_page": 15,
"total": 73
}
}
/api/v1/products/{id}
Get product detail
Returns full product data including detail, accessories, technical specifications, and warranty info. Also includes variants and attributes.
Additional fields returned (vs list)
description— short descriptiondetail— full HTML descriptiontechnicalSpecifications— array of specification rowswarrantyDuration,warrantyDurationType,warrantyInforelatedProductIds— array of product IDsaccessoryIds— array of accessory product IDsattributes— product attributes arrayvariants— product variants array
Error response (404)
{ "success": false, "message": "Product not found." }
📁 Categories
/api/v1/categories
List categories
Returns paginated active categories. Supports per_page and page query parameters.
Response fields
id, name, slug, image, icon, description, parentId, order, status, productCount
/api/v1/categories/{id}
Get category detail
Returns a single category. Returns 404 if not found or inactive.
🏷 Brands
/api/v1/brands
List brands
Returns paginated active brands. Supports per_page and page query parameters.
Response fields: id, name, slug, logo, website, description, order, status
/api/v1/brands/{id}
Get brand detail
Returns a single brand. Returns 404 if not found or inactive.
📦 Orders
/api/v1/orders
List orders
Returns paginated orders. Supports per_page, page, and status filter.
Response fields
id, code, status, shippingFee, couponAmount, totalAmount, note, createdAt, customer (name, phone, email), payment (method, status)
/api/v1/orders/{id}
Get order detail
Returns full order detail including line items, shipping info, shipping history, and order history log.
Additional fields (vs list)
orderDetail— array of line items (product, variant, qty, price, flashSaleName)shipping— carrier, tracking code, shipping method, shipping historycustomer— full customer info including VAT detailsorderHistory— array of history events withtype,label,data,time
Example orderHistory entry
{
"id": 10,
"type": "delivering",
"label": "Delivering",
"data": null,
"adminUserId": 1,
"time": "2026-06-15T14:20:00.000000Z"
}
/api/v1/orders/{id}/status
Update order status
Transitions an order through its lifecycle. Only valid transitions are accepted — attempting an out-of-sequence change returns 422 with the list of allowed next statuses.
Status values
| Value | Constant | Meaning |
|---|---|---|
| 1 | STATUS_NEW | New — awaiting processing |
| 2 | STATUS_RECEIVED | Accepted / Processing |
| 21 | STATUS_DELIVERY | Out for delivery |
| 4 | STATUS_SUCCESS | Completed successfully |
| 3 | STATUS_CANCEL | Cancelled (stock restored) |
| 31 | STATUS_CANCEL_USER | Cancel requested by customer |
Allowed transitions
| Current status | Can transition to | Side effects |
|---|---|---|
| 1 — NEW | 2 — RECEIVED | History logged · Email sent to customer |
| 2 — RECEIVED | 21, 4, 3 | History logged · Email sent · Stock restored on CANCEL |
| 21 — DELIVERY | 4, 3 | History logged · Email sent · Stock restored on CANCEL |
| 31 — CANCEL_USER | 3, 2 | Stock restored on CANCEL · History logged |
| 4 — SUCCESS | — | Terminal state |
| 3 — CANCEL | — | Terminal state |
Request body (JSON)
| Field | Type | Description |
|---|---|---|
| status | integer (required) | Target status value (see table above) |
| reason | string (optional) | Cancellation reason — only used when transitioning to status 3 |
Example — accept order (NEW → RECEIVED)
PATCH /api/v1/orders/42/status
Authorization: Bearer {token}
Content-Type: application/json
{ "status": 2 }
Example — cancel order (RECEIVED → CANCEL)
PATCH /api/v1/orders/42/status
Authorization: Bearer {token}
Content-Type: application/json
{ "status": 3, "reason": "Customer requested cancellation" }
Success response 200
{
"success": true,
"message": "Order status updated.",
"data": { "id": 42, "code": "ORD-20260714", "status": 2, ... }
}
Invalid transition response 422
{
"success": false,
"message": "Status transition not allowed.",
"current": 1,
"allowed": [2]
}
🔒 Warranty
/api/v1/warranty/check
Check warranty status
Query parameters
| Parameter | Type | Description |
|---|---|---|
| code | string (required) | Serial / warranty code to check |
Possible responses
// Can be activated (200)
{
"success": true,
"data": {
"can_activate": true,
"serial": "SC20260001",
"product_name": "Product Name",
"sku": "SP001",
"warranty_period": "12 months"
}
}
// Already activated (422)
{
"success": false,
"message": "Warranty already activated.",
"data": {
"already_activated": true,
"activation_date": "15/01/2026",
"end_date": "15/01/2027"
}
}
// Counterfeit detected (422)
{
"success": false,
"is_counterfeit": true,
"risk_level": "high",
"message": "counterfeit_not_exist"
}
/api/v1/warranty/activate
Activate warranty
Request body (JSON)
| Field | Type | Required | Description |
|---|---|---|---|
| code | string | Yes | Serial / warranty code |
| name | string | Yes | Customer full name |
| phone | string | Yes | Customer phone number |
| string | No | Customer email — confirmation sent if provided | |
| address | string | No | Customer address |
Success response (200)
{
"success": true,
"message": "Warranty activated successfully.",
"data": {
"code": "SC20260001",
"activation_date": "13/07/2026",
"warranty_end": "13/07/2027"
}
}
An activation confirmation email is automatically queued if email was provided.
/api/v1/warranty/lookup
Lookup warranty by serial or phone
Searches for warranty info. Short numeric values (< 12 chars or starting with 0 / +) are treated as phone numbers and return all matching warranties. Longer strings are treated as serial numbers and return a single warranty.
Request body (JSON)
{ "serial": "0901234567" } // phone lookup
{ "serial": "SC20260001" } // serial lookup
Success response — serial lookup (200)
{
"success": true,
"data": {
"serial": "SC20260001",
"product_name": "Product Name",
"is_activated": true,
"activation_date": "13/07/2026 09:00",
"warranty_time": "12 months",
"expiration_date": "13/07/2027 09:00",
"days_remaining": 365,
"customer": {
"name": "Nguyen Van A",
"phone": "0901234567",
"email": "customer@example.com"
}
}
}
Success response — phone lookup (200)
{
"success": true,
"data": [
{
"serial": "SC20260001",
"product_name": "Product Name",
"is_activated": true,
"activation_date": "13/07/2026 09:00",
"warranty_time": "12 months",
"expiration_date": "13/07/2027 09:00",
"days_remaining": 365,
"customer": { "name": "Nguyen Van A", "phone": "0901234567", "email": null }
}
]
}
Not found (404)
{ "success": false, "message": "Not found." }
⚠️ Error Responses
| HTTP Code | Meaning | Common cause |
|---|---|---|
| 400 | Bad Request | Malformed JSON body |
| 401 | Unauthorized | Missing or invalid token |
| 404 | Not Found | Resource does not exist or is inactive |
| 422 | Unprocessable Entity | Validation failed or business rule violated |
| 429 | Too Many Requests | Rate limit exceeded for this token |
| 500 | Server Error | Unexpected server error (check Laravel logs) |
Validation error envelope (422)
{
"success": false,
"message": "The code field is required.",
"errors": {
"code": ["The code field is required."]
}
}
SureCommerce — REST API Reference
© 2026 DreamTeam. All rights reserved. | Install Guide | User Guide | FAQ