Dokumentasi Reseller API v1

Jual produk toko ini secara otomatis dari web / bot kamu. Harga reseller, saldo wallet, key dikirim langsung di respons.

Mulai

  1. Daftar sebagai reseller di /reseller, lalu isi saldo.
  2. Buka /reseller/api dan klik “Buat API key”. Key hanya tampil sekali.
  3. Kirim di setiap request: Authorization: Bearer rk_live_… (jangan lewat query string).

Base URL: https://domain-kamu.com/api/v1

Format respons

Sukses : { "data": ... }
Gagal  : { "error": { "code": "UNAUTHORIZED", "message": "…" } }

Uang = Rupiah bulat (integer), currency: "IDR". Batas 120 request/menit per key. SKU berbentuk <kode-produk>.<angka><d|h|m> (hari / jam / menit), ambil dari /products.

Endpoint

GET /me

Info akun reseller

{ "data": { "username": "budi", "role": "RESELLER", "currency": "IDR", "keyPrefix": "rk_live_ab12…f9e0", "rateLimitRpm": 120, "maxQuantity": 20 } }
GET /balance

Saldo wallet (data segar)

{ "data": { "balance": 150000, "currency": "IDR" } }
GET /products

Katalog flat per SKU, harga reseller

{ "data": { "currency": "IDR", "priceTier": "reseller", "items": [ { "apiCode": "produk-contoh.30d", "name": "Produk Contoh - 30 Hari", "product": "Produk Contoh", "productApiCode": "produk-contoh", "category": "android", "label": "30 Hari", "days": 30, "unit": "d", "price": 80000, "currency": "IDR", "stock": null, "inStock": true, "is_maintenance": false } ] } }
GET /stock?sku=produk-contoh.30d

Cek stok satu SKU

{ "data": { "apiCode": "produk-contoh.30d", "stock": null, "inStock": true, "is_maintenance": false } }
POST /orders

Buat order. Header Idempotency-Key wajib. Body: sku, quantity (1-20, default 1), target (opsional, maks 80)

{ "data": { "id": "…uuid", "code": "API-12345678-AB12CD", "status": "FULFILLED", "sku": "produk-contoh.30d", "quantity": 1, "price": 80000, "unitPrice": 80000, "currency": "IDR", "keys": ["KEY-XXXX"], "balance": 70000, "createdAt": "2026-11-21T10:00:00Z" } }
GET /orders?page=1&limit=20

Riwayat order API (limit 1-50). Key tidak ikut

{ "data": { "page": 1, "limit": 20, "total": 1, "hasMore": false, "items": [ { "id": "…", "code": "API-…", "status": "FULFILLED", "sku": "produk-contoh.30d", "quantity": 1, "price": 80000, "keysCount": 1, "createdAt": "…" } ] } }
GET /orders/:id

Detail order (id atau code) beserta keys

{ "data": { …seperti respons POST /orders } }

Status order: FULFILLED (semua key terkirim) atau PARTIAL (stok hanya cukup sebagian — hanya key yang terkirim yang ditagih, sisanya dikembalikan ke saldo).

Idempotency-Key

Buat satu key unik per order di sisi kamu (mis. ID order di sistemmu). Jika request terputus, kirim ulang dengan key yang sama: kamu mendapat order yang sama dan saldo tidak dipotong dua kali. Key sama dengan SKU berbeda ditolak 422. Hanya satu order per reseller diproses sekaligus; bila bentrok kamu menerima 409 PURCHASE_PENDING — tunggu sebentar lalu ulangi.

Kode error

KodeHTTPArti
UNAUTHORIZED401API key kosong, salah, atau sudah dicabut
FORBIDDEN403Akun bukan reseller aktif, atau API dimatikan admin
NOT_FOUND404Endpoint atau order tidak ditemukan
UNKNOWN_SKU404SKU tidak ada
IDEMPOTENCY_REQUIRED400Header Idempotency-Key kosong / lebih dari 100 karakter
DURATION_REQUIRED400SKU kosong atau formatnya salah
INVALID_QTY400quantity bukan bilangan bulat 1-20
PRODUCT_MAINTENANCE400Produk sedang maintenance
INSUFFICIENT_BALANCE402Saldo kurang (pesan memuat kebutuhan & saldo)
BUSY409 / 429Stok kosong/kurang (409) atau melewati 120 request/menit (429)
PURCHASE_PENDING409Masih ada order lain yang diproses untuk akunmu
IDEMPOTENCY_MISMATCH422Idempotency-Key yang sama dipakai untuk SKU berbeda
INTERNAL500Kesalahan server (coba ulang dengan Idempotency-Key yang sama)

Contoh curl

curl https://domain-kamu.com/api/v1/balance \
  -H "Authorization: Bearer rk_live_xxxxxxxx"

curl -X POST https://domain-kamu.com/api/v1/orders \
  -H "Authorization: Bearer rk_live_xxxxxxxx" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: order-0001" \
  -d '{"sku":"produk-contoh.30d","quantity":1}'

Contoh Node.js (v18+)

const BASE = 'https://domain-kamu.com/api/v1';
const KEY = process.env.RK_KEY; // rk_live_...

async function call(path, opts = {}) {
  const res = await fetch(BASE + path, {
    ...opts,
    headers: { Authorization: 'Bearer ' + KEY, 'Content-Type': 'application/json', ...(opts.headers || {}) },
  });
  const json = await res.json();
  if (!res.ok) throw Object.assign(new Error(json.error.message), { code: json.error.code, status: res.status });
  return json.data;
}

// Retry aman: Idempotency-Key SAMA = order yang sama, saldo tidak dipotong ulang
async function buy(sku, quantity, idem) {
  for (let i = 0; i < 4; i++) {
    try {
      return await call('/orders', { method: 'POST', headers: { 'Idempotency-Key': idem }, body: JSON.stringify({ sku, quantity }) });
    } catch (e) {
      if (![500, 429].includes(e.status) && e.code !== 'PURCHASE_PENDING') throw e;
      await new Promise((r) => setTimeout(r, 1500 * (i + 1)));
    }
  }
  throw new Error('Gagal setelah beberapa percobaan');
}

const order = await buy('produk-contoh.30d', 1, 'order-0001');
console.log(order.keys, order.balance);