Developer Portal

KTOPUPSERVICE Reseller API

Secure reseller API for wallet balance checks, product catalog retrieval, asynchronous order creation, and order status queries. This portal documents the production reseller API contract, including request signing and idempotency requirements.

Overview

Resource-oriented endpoints, JSON responses, and standard HTTP status codes.

  • Check reseller wallet balances in USD.
  • Retrieve available products and purchasable SKUs.
  • Create orders asynchronously using an idempotency key.
  • Retrieve normalized order details by order ID.

Base URL

Use this production domain as the base URL for all reseller API v1 requests.

Production

https://ktopupservice.com

Sandbox / Staging

No public sandbox endpoint for reseller API v1.

Authentication

All reseller API requests must include API key authentication, a request timestamp, and an HMAC-SHA256 signature. Order creation requests additionally require an idempotency key to ensure safe retries.

When an IP whitelist is configured for your credential, requests must originate from one of its registered addresses. Credentials are managed by an administrator.

http
X-API-KEY: KTS_2d8c0f...
X-TIMESTAMP: 1760000000
X-SIGNATURE: 4ac3...
X-IDEMPOTENCY-KEY: ord_20260309_001  // POST /orders only

New API keys use the KTS_ prefix. Previously issued keys remain valid; send the complete key exactly as issued.

Auth Flow Order

  1. API key lookup
  2. Credential state check (enabled and not revoked)
  3. Timestamp validation
  4. IP allowlist check
  5. Signature verification
  6. Per-key rate limit check
  7. Replay protection for requests that make changes
  8. Business logic execution

Missing or invalid API keys fail fast before any credential-based rate-limit path.

Request Signing

Build the canonical string exactly as shown and sign it using HMAC-SHA256. Signature output must be lowercase hex.

text
METHOD
PATH
TIMESTAMP
BODY
  • Method must be uppercase.
  • Path excludes domain and query string.
  • Timestamp must be Unix seconds string (`^\\d10$`).
  • Body must match the raw JSON string sent over the wire.
  • GET requests use an empty body string.
bash
curl -X POST "{{BASE_URL}}/api/v1/reseller/orders" \
  -H "Content-Type: application/json" \
  -H "X-API-KEY: {{API_KEY}}" \
  -H "X-TIMESTAMP: {{UNIX_SECONDS}}" \
  -H "X-SIGNATURE: {{HMAC_SHA256_HEX}}" \
  -H "X-IDEMPOTENCY-KEY: {{UNIQUE_KEY}}" \
  -d '{"productId":"product_token","sku":"sku_token","userAccount":"98223878"}'

Idempotency

`X-IDEMPOTENCY-KEY` is required for `POST /api/v1/reseller/orders` to prevent duplicate order creation and duplicate wallet debit on retries.

  • Same key + same payload: safe retry, replay same logical result.
  • Same key + different payload: conflict (`409 IDEMPOTENCY_CONFLICT`).
  • Generate a fresh key for each new logical order attempt.
  • Never reuse a committed order key, even after 24 hours.
  • Retry an interrupted batch with its original key and exact payload; committed items are reused.

An order signature is bound to its first idempotency key. Changing the key while reusing that signature returns `409 REPLAY_DETECTED`. For a separate order with identical content, wait for a new Unix second and sign with the new timestamp. For a retry after timestamp expiry, sign again and keep the original key and body. A request still in progress may return 409; retry with backoff.

Reusing an idempotency key with changed parameters is treated as an integration error and is rejected.

Common Headers

HeaderRequiredDescription
Content-TypeJSON body requestsapplication/json
AcceptRecommendedapplication/json
X-API-KEYYesReseller API key (new keys use the KTS_ prefix)
X-TIMESTAMPYesUnix seconds string
X-SIGNATUREYesHMAC-SHA256 lowercase hex signature
X-IDEMPOTENCY-KEYPOST /ordersUnique key per logical order attempt

Quickstart

Create your first order in five calls.

bash
curl -X GET "{{BASE_URL}}/api/v1/reseller/products" \
  -H "X-API-KEY: {{API_KEY}}" \
  -H "X-TIMESTAMP: {{UNIX_SECONDS}}" \
  -H "X-SIGNATURE: {{SIGNATURE}}"

Try API

Send signed requests directly from docs. Credentials stay in browser memory only.

Client-Side Only

Timestamp and signature are generated automatically.

Endpoint Reference

GET /api/v1/reseller/wallet/balance

Return current reseller wallet balance and currency.

Auth: X-API-KEY, X-TIMESTAMP, X-SIGNATURE

Request

No body parameters.

Response

json
{
  "balance": "120.500",
  "currency": "USD"
}

GET /api/v1/reseller/products

Return product catalog with required fields and purchasable SKUs.

Auth: X-API-KEY, X-TIMESTAMP, X-SIGNATURE

Request

No body parameters.

Response

json
{
  "products": [
    {
      "productId": "mobile-legends-brazil_qtupjesknc",
      "name": "Mobile Legends - Brazil",
      "status": "ACTIVE",
      "category": "GAMING",
      "fields": [
        {
          "key": "userAccount",
          "label": "User ID",
          "required": true
        },
        {
          "key": "server",
          "label": "Server",
          "required": true
        }
      ],
      "skus": [
        {
          "sku": "psk_wpzyko5vvCvYS2tp-A3CCdO2",
          "name": "78 Diamonds + 8 Bonus",
          "price": "1.150",
          "available": true
        },
        {
          "sku": "psk_wjM_c93kTOPG4oZUMaBGj_Lu",
          "name": "156 Diamonds + 16 Bonus",
          "price": "2.300",
          "available": true
        }
      ]
    },
    {
      "productId": "pubg-mobile-global_htizwdk6ug",
      "name": "PUBG Mobile (GLOBAL)",
      "status": "ACTIVE",
      "category": "GAMING",
      "fields": [
        {
          "key": "userAccount",
          "label": "User ID",
          "required": true
        }
      ],
      "skus": [
        {
          "sku": "psk_v_lvJK7fNSx4CEoQbj2hMUGx",
          "name": "57 + 3 Extra UC",
          "price": "0.905",
          "available": true
        },
        {
          "sku": "psk_K9DjZWGoMJzMi25nmxSS-FD2",
          "name": "300 + 25 Extra UC",
          "price": "4.679",
          "available": true
        }
      ]
    },
    {
      "productId": "genshin-impact-global_dfycqqr1te",
      "name": "Genshin impact - Global",
      "status": "ACTIVE",
      "category": "GAMING",
      "fields": [
        {
          "key": "userAccount",
          "label": "User ID",
          "required": true
        },
        {
          "key": "server",
          "label": "Server",
          "required": true
        }
      ],
      "skus": [
        {
          "sku": "psk_YZ4Maeq8Sft0fnjnnv3-Igk4",
          "name": "60 Genesis Crystals",
          "price": "0.990",
          "available": true
        },
        {
          "sku": "psk_1aUHkuKZXU7XM1RCR8jbW6wN",
          "name": "300 + 30 Genesis Crystal",
          "price": "4.990",
          "available": true
        }
      ]
    }
  ]
}

GET /api/v1/reseller/products/:productId

Return full detail for one active product by public productId.

Auth: X-API-KEY, X-TIMESTAMP, X-SIGNATURE

Request

bash
curl -X GET "{{BASE_URL}}/api/v1/reseller/products/mobile-legends-malaysia-id_pfbg3bb5qt" \
  -H "X-API-KEY: {{API_KEY}}" \
  -H "X-TIMESTAMP: {{UNIX_SECONDS}}" \
  -H "X-SIGNATURE: {{SIGNATURE}}"

Response

json
{
  "product": {
    "productId": "genshin-impact-global_dfycqqr1te",
    "name": "Genshin impact - Global",
    "status": "ACTIVE",
    "category": "GAMING",
    "fields": [
      {
        "key": "userAccount",
        "label": "User ID",
        "required": true
      },
      {
        "key": "server",
        "label": "Server",
        "required": true,
        "serverList": [
          { "value": "America", "label": "America" },
          { "value": "Asia", "label": "Asia" },
          { "value": "Europe", "label": "Europe" },
          { "value": "TW_HK_MO", "label": "TW_HK_MO" }
        ]
      }
    ],
    "skus": [
      {
        "sku": "psk_YZ4Maeq8Sft0fnjnnv3-Igk4",
        "name": "60 Genesis Crystals",
        "price": "0.990",
        "available": true
      }
    ]
  }
}

POST /api/v1/reseller/orders

Create an order asynchronously. Accepted responses return PENDING state.

Auth: X-API-KEY, X-TIMESTAMP, X-SIGNATURE, X-IDEMPOTENCY-KEY

Request

json
{
  "productId": "mobile-legends-brazil_qtupjesknc",
  "sku": "psk_wpzyko5vvCvYS2tp-A3CCdO2",
  "userAccount": "98223878",
  "server": "2507",
  "role": null,
  "quantity": 1
}

Response

json
{
  "success": true,
  "order": {
    "id": "cmmb4u0d60006rmi9ykacbfri",
    "status": "PENDING",
    "amount": "1.150",
    "receiptNumber": null,
    "quantity": 1
  },
  "message": "Order submitted. Processing in background. Check Orders for updates."
}

GET /api/v1/reseller/orders/:orderId

Return strict public order detail for a reseller-owned order.

Auth: X-API-KEY, X-TIMESTAMP, X-SIGNATURE

Request

No body parameters.

Response

json
{
  "order": {
    "orderId": "cmmb4u0d60006rmi9ykacbfri",
    "receiptNumber": "KTS-20260303-0002",
    "status": "SUCCESS",
    "amount": "1.150",
    "product": {
      "productId": "mobile-legends-brazil_qtupjesknc",
      "name": "Mobile Legends - Brazil",
      "category": "GAMING",
      "productType": "TOPUP"
    },
    "userAccount": "98223878",
    "server": "2507",
    "role": null,
    "sku": "psk_wpzyko5vvCvYS2tp-A3CCdO2",
    "skuName": "78 Diamonds + 8 Bonus"
  }
}

Webhooks

Optional real-time order status updates with polling as fallback.

Webhooks notify your server when an order moves through `PENDING`, `PROCESSING`, `SUCCESS`, `FAILED`, or `REFUNDED`. Webhook delivery is optional but recommended for real-time integrations. Continue polling `GET /api/v1/reseller/orders/:orderId` as a fallback for missed, delayed, or failed webhook deliveries.

order.pendingorder.processingorder.successorder.failedorder.refunded

Example webhook flow

  1. Create an order and store the returned `order.id`.
  2. Configure a webhook endpoint.
  3. Wait for KTOPUPSERVICE to send an order event to your webhook URL.
  4. Verify `X-KTS-Signature`.
  5. Update the matching order in your own system.
  6. If no webhook is received, poll `GET /api/v1/reseller/orders/:orderId` as fallback.

Webhooks are a notification system. The order lookup endpoint is still the source of truth for the current order state.

Management endpoints

  • GET /api/v1/reseller/webhooks/endpoints
  • POST /api/v1/reseller/webhooks/endpoints
  • PATCH /api/v1/reseller/webhooks/endpoints/:id
  • DELETE /api/v1/reseller/webhooks/endpoints/:id
  • GET /api/v1/reseller/webhooks/logs
  • POST /api/v1/reseller/webhooks/test

Webhook endpoint requirements

  • Return a `2xx` response within 10 seconds.
  • Use HTTPS in production.
  • Use the standard HTTPS port (443) and publicly routable IP addresses.
  • Do not redirect requests.
  • Do not perform long blocking work before responding.
  • Verify `X-KTS-Signature` before trusting the payload.
  • Store processed event IDs to prevent duplicate processing.

POST /api/v1/reseller/webhooks/endpoints

Create a webhook endpoint. The full secret is returned only once.

Auth: X-API-KEY, X-TIMESTAMP, X-SIGNATURE

Request

json
{
  "url": "https://example.com/webhooks/ktopupservice",
  "subscribedEvents": ["order.processing", "order.success", "order.failed", "order.refunded"]
}

Response

json
{
  "endpoint": {
    "id": "cmwebhook123",
    "url": "https://example.com/webhooks/ktopupservice",
    "isActive": true,
    "subscribedEvents": ["order.processing", "order.success", "order.failed", "order.refunded"],
    "secretPreview": "whsec_****abcd",
    "createdAt": "2026-04-27T00:00:00.000Z",
    "updatedAt": "2026-04-27T00:00:00.000Z"
  },
  "secret": "whsec_full_secret_returned_once"
}

order.success payload

json
{
  "id": "evt_abc123",
  "type": "order.success",
  "createdAt": "2026-04-27T00:00:00.000Z",
  "data": {
    "orderId": "cmmb4u0d60006rmi9ykacbfri",
    "receiptNumber": "KTS-20260303-0002",
    "status": "SUCCESS",
    "amount": "1.150",
    "currency": "USD",
    "product": {
      "productId": "mobile-legends-brazil_qtupjesknc",
      "name": "Mobile Legends - Brazil",
      "category": "GAMING",
      "productType": "TOPUP"
    },
    "userAccount": "98223878",
    "server": "2507",
    "role": null,
    "sku": "psk_wpzyko5vvCvYS2tp-A3CCdO2",
    "skuName": "78 Diamonds + 8 Bonus",
    "voucher": null,
    "createdAt": "2026-04-27T00:00:00.000Z",
    "updatedAt": "2026-04-27T00:01:00.000Z"
  }
}

Outgoing headers

http
Content-Type: application/json
X-KTS-Event: order.success
X-KTS-Timestamp: 1760000000
X-KTS-Signature: <hex hmac sha256>
X-KTS-Webhook-ID: evt_xxx

Signature input is timestamp + "." + rawJsonBody; verify the exact raw JSON body you receive.

Node.js signature verification

javascript
const crypto = require("crypto");

function verifyKtopupserviceWebhook({ rawBody, signature, timestamp, secret }) {
  const now = Math.floor(Date.now() / 1000);
  if (Math.abs(now - Number(timestamp)) > 300) {
    return false;
  }

  const expected = crypto
    .createHmac("sha256", secret)
    .update(`${timestamp}.${rawBody}`)
    .digest("hex");

  return crypto.timingSafeEqual(
    Buffer.from(expected),
    Buffer.from(signature)
  );
}

Idempotency on your side

Webhook events may be delivered more than once because of retries, network failures, or delayed responses.

  • Store the webhook event `id` or `X-KTS-Webhook-ID`.
  • Ignore duplicate event IDs.
  • Never credit or deliver twice for the same event.
  • Optionally re-fetch `GET /api/v1/reseller/orders/:orderId` before final fulfillment.

Retry behavior

  • 2xx responses are marked delivered.
  • Timeout is 10 seconds.
  • Max attempts is 6: immediate, 1m, 5m, 15m, 1h, 6h.
  • Redirects are not followed.

A webhook event marked `FAILED` means KTOPUPSERVICE could not deliver the webhook after all retry attempts. It does not mean the order itself failed. Confirm the order state with `GET /api/v1/reseller/orders/:orderId`.

Recommended webhook handling pattern

  1. Receive webhook.
  2. Verify timestamp and signature.
  3. Check if event ID was already processed.
  4. Save the event or enqueue internal processing.
  5. Return `200 OK` quickly.
  6. Process heavy work asynchronously.

Avoid

  • External API calls before returning response.
  • Long database transactions before returning response.
  • Treating webhook delivery failure as order failure.
  • Trusting payloads without signature verification.

Common webhook issues

  • Invalid signature: use the exact raw request body, not parsed JSON.
  • Timeout: respond within 10 seconds.
  • Duplicate deliveries: implement event ID deduplication.
  • No webhook received: check endpoint is active, subscribed events, HTTPS URL, and webhook logs; then poll order detail as fallback.
  • Redirect response: redirects are not followed, so use the final destination URL directly.

Security

  • Production webhook URLs must use https.
  • Localhost and private/internal IP ranges are blocked.
  • Store webhook secrets securely and never expose them client-side.
  • Deduplicate by `X-KTS-Webhook-ID` or payload `id`.

Local test note

Do not create fake KTOPUPSERVICE signatures for local testing. Use `POST /api/v1/reseller/webhooks/test` to send a signed `webhook.test` event from KTOPUPSERVICE to your configured endpoint.

json
{
  "endpointId": "cmwebhook123"
}

Order lifecycle

Orders are processed asynchronously. After create order returns, clients should poll order detail until reaching a terminal status.

Rendering lifecycle diagram...

`POST /api/v1/reseller/orders` returns `202` while processing begins. Use `GET /api/v1/reseller/orders/:orderId` to poll for `PENDING`, `SUCCESS`, or `FAILED`.

Error Handling

API errors use a stable JSON shape with machine-readable code and human-readable message.

json
{
  "error": "Invalid signature",
  "code": "INVALID_SIGNATURE"
}
StatusMeaning
200Successful read operation
202Order accepted for async processing
400Invalid request payload or parameters
401Missing/invalid authentication header
403Rejected after auth checks
404Resource not found
409Idempotency conflict or in-progress collision
429Rate limit exceeded (Retry-After provided)
500Internal server error
INVALID_API_KEYMISSING_API_KEYINVALID_SIGNATUREMISSING_SIGNATUREINVALID_TIMESTAMP_FORMATTIMESTAMP_OUT_OF_WINDOWMISSING_TIMESTAMPIP_NOT_ALLOWEDRESELLER_NOT_APPROVEDCREDENTIAL_DISABLEDCREDENTIAL_REVOKEDMISSING_IDEMPOTENCY_KEYIDEMPOTENCY_CONFLICTIDEMPOTENCY_IN_PROGRESSPRODUCT_NOT_FOUNDORDER_NOT_FOUNDRATE_LIMITEDINTERNAL_ERROR

Order Lifecycle and Statuses

  • PENDING: accepted and still processing.
  • PROCESSING: provider or staff processing is in progress.
  • SUCCESS: fulfilled successfully.
  • FAILED: terminal failure.
  • REFUNDED: refunded after failure, cancellation, or admin action.

Additional terminal statuses may appear from lifecycle mapping (for example REFUNDED or TIMEOUT). Treat non-success terminal states as non-fulfillment outcomes.

Webhooks are recommended for real-time updates. Polling remains supported and should be used as a fallback if webhook delivery fails.

Rate Limits

Default policy is 120 requests / 60 seconds / API key.

  • Exceeded requests return HTTP 429.
  • `Retry-After` header indicates wait time in seconds.
  • Apply jittered backoff on client retries.

Best Practices

  • Use unique idempotency keys for every new logical order.
  • Keep server clock synchronized (NTP) to avoid timestamp rejection.
  • Retry only when safe, and reuse the same payload for replay retries.
  • Cache product catalog carefully, but re-check availability before ordering.
  • Do not hardcode product availability assumptions.
  • Log order IDs and idempotency keys in your integration layer.
  • Protect API key/secret and rotate secrets regularly.

Sample Integration Flow

  1. Authenticate every request with API key, timestamp, and signature.
  2. Fetch products and select product ID + SKU.
  3. Validate required fields from product `fields[]`.
  4. Create order with idempotency key.
  5. Use webhooks for real-time updates and poll order detail as a fallback until terminal status.

Support and Troubleshooting

Invalid signature

  • Verify canonical line order and exact path.
  • Sign the exact raw body bytes sent.
  • Ensure lowercase hex HMAC output.

Timestamp rejected

  • Send Unix seconds (10-digit string), not milliseconds.
  • Check host clock drift and timezone handling.

Idempotency conflict

  • Same key used with a different payload.
  • Generate a fresh key for a new order attempt.

Order remains pending

  • Continue polling `GET /orders/:orderId`; webhooks are not a replacement for fallback polling.
  • Escalate with orderId and UTC timestamps.