API Documentation

Tích hợp hệ thống mua hàng tự động vào ứng dụng của bạn.

Tổng quan API

Tích hợp hệ thống mua hàng tự động vào ứng dụng của bạn. Hỗ trợ đầy đủ các tính năng: tạo đơn hàng, kiểm tra trạng thái, xem danh sách sản phẩm và nhiều hơn nữa.

Base URL
URL
https://api-shopkey.brotemplate.com
Content-Type
Header
application/json
API Key

Quản lý API Keys tại trang API Keys.

Response Envelope

All responses are wrapped in a standard envelope.

Response Envelope
FieldTypeDescription
success*booleanOperation result
dataobjectResponse payload (present on success)
errorobjectError details (present on failure)
└ message*stringHuman-readable error
└ code*stringMachine-readable error code
meta*objectResponse metadata
└ timestamp*stringISO 8601 timestamp
└ requestId*stringUnique request identifier
└ paginationobjectPagination info (present on list endpoints)

Xác thực API

Authenticate all API requests by including your API key in the x-api-key header. You can create and manage API keys from the API Keys page in your account.

Request Headers
FieldTypeDescription
x-api-key*stringAPI Key của bạn (40 ký tự, bắt đầu bằng sk_live_)
Content-Type*stringapplication/json (cho POST request)
Ví dụ Headers
HTTP Headers
x-api-key: sk_live_a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6
Content-Type: application/json
Giữ API Key an toàn. Không chia sẻ hoặc commit vào source code. Sử dụng biến môi trường để lưu trữ.

Tạo đơn hàng

POST

/v1/orders

Checkout cart with wallet balance

Creates one or more orders from the current cart and charges the wallet. Each line item references a product plan by its UUID.

Request Body (application/json)
FieldTypeDescription
items*array<object>Danh sách sản phẩm cần mua
└ planId*uuidID gói sản phẩm
└ quantitynumberSố lượng mua (mặc định: 1)
└ fieldsobjectDynamic checkout fields keyed by fieldKey (nếu gói yêu cầu)
└ stockIdsarray<uuid>Optional pre-selected stock IDs from preview
cURL
curl -X POST "https://api-shopkey.brotemplate.com/v1/orders" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"items":[{"planId":"123e4567-e89b-12d3-a456-426614174000","quantity":2}]}'
Response Fields
FieldTypeDescription
success*booleanOperation result
data*array<object>List of created orders
└ id*uuidOrder ID
└ planId*uuidPlan ID
└ quantity*numberQuantity purchased
└ status*stringOrder status (pending/completed)Enum: pending, processing, completed, cancelled, failed
└ unitPrice*stringPrice per unit
└ totalAmount*stringTotal charged amount
└ stocks*array<object>Delivered stock items
└ stockId*uuidStock ID
└ content*stringDelivered content (credential / key)
└ attachedContentstringDelivery note when completed
└ completedAtstringCompletion timestamp (ISO 8601)
meta*objectResponse metadata
└ timestamp*stringISO 8601 timestamp
└ requestId*stringUnique request identifier
Response Example
JSON
{
  "success": true,
  "data": [
    {
      "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "planId": "123e4567-e89b-12d3-a456-426614174000",
      "quantity": 2,
      "status": "completed",
      "unitPrice": "50000.0000",
      "totalAmount": "100000.0000",
      "stocks": [
        { "stockId": "s1", "content": "Account: [email protected] | Pass: abc123" },
        { "stockId": "s2", "content": "Account: [email protected] | Pass: xyz789" }
      ],
      "attachedContent": null,
      "completedAt": "2026-02-02T15:23:14.000Z"
    }
  ],
  "meta": {
    "timestamp": "2026-02-02T15:23:14.000Z",
    "requestId": "req-abc-123"
  }
}

Trạng thái đơn hàng

GET

/v1/orders/{id}

Get order detail

Returns the full detail of a single order, including delivered stock items.

Request Parameters
ParameterInTypeRequiredDescription
idPathuuidYesMã giao dịch (UUID của đơn hàng)
cURL
curl "https://api-shopkey.brotemplate.com/v1/orders/a1b2c3d4-e5f6-7890-abcd-ef1234567890" \
  -H "x-api-key: YOUR_API_KEY"
Response Fields
FieldTypeDescription
success*booleanOperation result
data*objectOrder detail
└ id*uuidOrder ID
└ productName*stringTên sản phẩm
└ planName*stringTên gói sản phẩm
└ quantity*numberSố lượng
└ status*stringTrạng thái đơn hàngEnum: pending, processing, completed, cancelled, failed
└ unitPrice*stringĐơn giá
└ totalAmount*stringTổng tiền
└ stocks*array<object>Nội dung giao hàng
└ stockId*uuidStock ID
└ content*stringNội dung (tài khoản | key)
└ attachedContentstringNội dung đính kèm khi hoàn thành
└ createdAt*stringThời gian tạo (ISO 8601)
└ completedAtstringThời gian hoàn thành (ISO 8601)
meta*objectResponse metadata
└ timestamp*stringThời gian response
└ requestId*stringRequest ID
Response Example
JSON
{
  "success": true,
  "data": {
    "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    "productName": "Key Adobe Creative Cloud All Apps",
    "planName": "Tài khoản 1 tháng",
    "quantity": 2,
    "status": "completed",
    "unitPrice": "375000.0000",
    "totalAmount": "750000.0000",
    "stocks": [
      { "stockId": "s1", "content": "[email protected] | pass123" },
      { "stockId": "s2", "content": "[email protected] | pass456" }
    ],
    "attachedContent": "Hướng dẫn kích hoạt: https://example.com/guide",
    "createdAt": "2026-02-02T15:23:14.000Z",
    "completedAt": "2026-02-02T15:23:14.000Z"
  },
  "meta": {
    "timestamp": "2026-02-02T15:23:14.000Z",
    "requestId": "req-abc-123"
  }
}

Danh sách đơn hàng

GET

/v1/orders

List my product orders

Returns a paginated list of orders belonging to the authenticated user.

Request Parameters
ParameterInTypeRequiredDescription
statusQuerystringNoLọc theo trạng thái: pending, processing, completed, cancelled
searchQuerystringNoTìm kiếm theo tên sản phẩm hoặc mã đơn
pageQueryintegerNoSố trang (mặc định: 1)
limitQueryintegerNoSố lượng/trang (mặc định: 20, tối đa: 100)
cURL
curl "https://api-shopkey.brotemplate.com/v1/orders?status=completed&page=1&limit=20" \
  -H "x-api-key: YOUR_API_KEY"
Response Fields
FieldTypeDescription
success*booleanOperation result
data*array<object>Danh sách đơn hàng
└ id*uuidOrder ID
└ productName*stringTên sản phẩm
└ planName*stringTên gói
└ quantity*numberSố lượng
└ status*stringTrạng tháiEnum: pending, processing, completed, cancelled, failed
└ totalAmount*stringTổng tiền
└ createdAt*stringNgày tạo (ISO 8601)
└ completedAtstringNgày hoàn thành (ISO 8601)
meta*objectResponse metadata
└ timestamp*stringThời gian response
└ requestId*stringRequest ID
└ paginationobjectThông tin phân trang
└ page*integerTrang hiện tại
└ limit*integerSố lượng/trang
└ total*integerTổng số đơn
└ totalPages*integerTổng số trang
└ hasNext*booleanCòn trang tiếp theo?
└ hasPrev*booleanCó trang trước?
Response Example
JSON
{
  "success": true,
  "data": [
    {
      "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "productName": "Key Adobe Creative Cloud All Apps",
      "planName": "Tài khoản 1 tháng",
      "quantity": 1,
      "status": "completed",
      "totalAmount": "375000.0000",
      "createdAt": "2026-02-02T15:23:14.000Z",
      "completedAt": "2026-02-02T15:23:14.000Z"
    }
  ],
  "meta": {
    "timestamp": "2026-02-02T15:23:14.000Z",
    "requestId": "req-abc-123",
    "pagination": {
      "page": 1,
      "limit": 20,
      "total": 45,
      "totalPages": 3,
      "hasNext": true,
      "hasPrev": false
    }
  }
}

Danh sách sản phẩm

GET

/v1/products

List active products

Returns a paginated list of active products with their plans and pricing.

Request Parameters
ParameterInTypeRequiredDescription
categoryIdQueryuuidNoLọc theo danh mục
searchQuerystringNoTìm kiếm theo tên sản phẩm
sortQuerystringNoSắp xếp: newest, oldest, price_asc, price_desc, bestseller
pageQueryintegerNoSố trang (mặc định: 1)
limitQueryintegerNoSố lượng/trang (mặc định: 10, tối đa: 100)
cURL
curl "https://api-shopkey.brotemplate.com/v1/products?page=1&limit=10" \
  -H "x-api-key: YOUR_API_KEY"
Response Fields
FieldTypeDescription
success*booleanOperation result
data*array<object>Danh sách sản phẩm
└ id*uuidID sản phẩm
└ name*stringTên sản phẩm
└ slug*stringSlug
└ descriptionstringMô tả sản phẩm
└ isFeatured*booleanSản phẩm nổi bật?
└ isBestseller*booleanSản phẩm bán chạy?
└ salesCount*numberSố lượng đã bán
└ pricestringGiá gốc
└ salePricestringGiá khuyến mãi
└ rating*stringĐánh giá trung bình
└ createdAt*stringNgày tạo (ISO 8601)
meta*objectResponse metadata
└ timestamp*stringThời gian response
└ requestId*stringRequest ID
└ paginationobjectThông tin phân trang
└ page*integerTrang hiện tại
└ limit*integerSố lượng/trang
└ total*integerTổng số sản phẩm
└ totalPages*integerTổng số trang
└ hasNext*booleanCòn trang tiếp theo?
└ hasPrev*booleanCó trang trước?
Response Example
JSON
{
  "success": true,
  "data": [
    {
      "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "name": "Key Adobe Creative Cloud All Apps",
      "slug": "key-adobe-creative-cloud-all-apps",
      "description": "Mô tả sản phẩm...",
      "isFeatured": false,
      "isBestseller": true,
      "salesCount": 24,
      "price": "500000.0000",
      "salePrice": "375000.0000",
      "rating": "4.5",
      "createdAt": "2026-01-01T00:00:00.000Z"
    }
  ],
  "meta": {
    "timestamp": "2026-02-02T15:23:14.000Z",
    "requestId": "req-abc-123",
    "pagination": {
      "page": 1,
      "limit": 10,
      "total": 21,
      "totalPages": 3,
      "hasNext": true,
      "hasPrev": false
    }
  }
}

Danh sách danh mục

GET

/v1/categories

List active categories as a tree

Returns the full category tree with nested sub-categories.

cURL
curl "https://api-shopkey.brotemplate.com/v1/categories" \
  -H "x-api-key: YOUR_API_KEY"
Response Fields
FieldTypeDescription
success*booleanOperation result
data*objectCategory tree
└ tree*array<object>Cây danh mục
└ id*uuidID danh mục
└ parentIduuidID danh mục cha (null nếu là root)
└ name*stringTên danh mục
└ slug*stringSlug
└ iconUrlstringURL icon
└ sortOrder*numberThứ tự sắp xếp
└ status*stringTrạng tháiEnum: active, inactive
└ childrenarray<object>Danh mục con (đệ quy)
meta*objectResponse metadata
└ timestamp*stringThời gian response
└ requestId*stringRequest ID
Response Example
JSON
{
  "success": true,
  "data": {
    "tree": [
      {
        "id": "cat-001",
        "parentId": null,
        "name": "Tiện Ích",
        "slug": "tien-ich",
        "iconUrl": "https://example.com/icon.png",
        "sortOrder": 0,
        "status": "active",
        "children": [
          {
            "id": "cat-002",
            "parentId": "cat-001",
            "name": "Giải Trí",
            "slug": "giai-tri",
            "sortOrder": 1,
            "status": "active",
            "children": []
          }
        ]
      }
    ]
  },
  "meta": {
    "timestamp": "2026-02-02T15:23:14.000Z",
    "requestId": "req-abc-123"
  }
}

Kiểm tra số dư

GET

/v1/wallet/summary

Get current user wallet summary

Returns the current wallet balance, lifetime deposit, and total spent.

cURL
curl "https://api-shopkey.brotemplate.com/v1/wallet/summary" \
  -H "x-api-key: YOUR_API_KEY"
Response Fields
FieldTypeDescription
success*booleanOperation result
data*objectWallet information
└ currency*stringLoại tiền tệ (VND)
└ balance*stringSố dư khả dụng hiện tại
└ totalDeposited*stringTổng nạp tích lũy
└ totalSpent*stringTổng chi tiêu xấp xỉ
meta*objectResponse metadata
└ timestamp*stringThời gian response
└ requestId*stringRequest ID
Response Example
JSON
{
  "success": true,
  "data": {
    "currency": "VND",
    "balance": "93537500.0000",
    "totalDeposited": "100000000.0000",
    "totalSpent": "6462500.0000"
  },
  "meta": {
    "timestamp": "2026-02-02T15:23:14.000Z",
    "requestId": "req-abc-123"
  }
}

Thông tin tài khoản

GET

/v1/auth/me

Current user profile

Returns the authenticated user&apos;s profile information and account settings.

cURL
curl "https://api-shopkey.brotemplate.com/v1/auth/me" \
  -H "x-api-key: YOUR_API_KEY"
Response Fields
FieldTypeDescription
success*booleanOperation result
data*objectUser profile
└ id*uuidUser ID
└ email*stringEmail
└ username*stringTên đăng nhập
└ fullnamestringHọ tên đầy đủ
└ phonestringSố điện thoại
└ avatarUrlstringURL ảnh đại diện
└ role*stringVai tròEnum: admin, user
└ active*booleanTài khoản đang hoạt động?
meta*objectResponse metadata
└ timestamp*stringThời gian response
└ requestId*stringRequest ID
Response Example
JSON
{
  "success": true,
  "data": {
    "id": "user-001",
    "email": "[email protected]",
    "username": "admin",
    "fullname": "Admin User",
    "phone": "0987654321",
    "avatarUrl": "/uploads/avatars/avatar.jpg",
    "role": "user",
    "active": true
  },
  "meta": {
    "timestamp": "2026-02-02T15:23:14.000Z",
    "requestId": "req-abc-123"
  }
}

Error Codes

All API endpoints return errors in a consistent envelope. Every non-2xx response contains an error object with the following structure.

Error CodeHTTP StatusDescription
UNAUTHORIZED401Missing or invalid x-api-key header
FORBIDDEN403Insufficient permissions for this resource
NOT_FOUND404Requested resource does not exist
VALIDATION_ERROR422Request body or parameters failed validation
RATE_LIMIT_EXCEEDED429Too many requests — rate limit applied
INTERNAL_ERROR500Unexpected server error
INSUFFICIENT_BALANCE400Wallet balance too low for this operation
OUT_OF_STOCK400Requested item is currently out of stock