{
  "info": {
    "_postman_id": "a7b8c9d0-1234-4567-89ab-cdef01234567",
    "name": "licensepanel.org Reseller API v1",
    "description": "Complete Postman collection for the licensepanel.org Wholesale License & GetCID Reseller API v1.\n\nIncludes automatic HMAC-SHA256 request signing via the collection-level Pre-request Script.\n\nSet `api_key` (`rk_test_...` for Sandbox or `rk_live_...` for Production) and `api_secret` (`rks_...`) in Collection Variables.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "variable": [
    { "key": "base_url", "value": "https://licensepanel.org", "type": "string" },
    { "key": "api_key", "value": "rk_test_replace_with_your_key", "type": "string" },
    { "key": "api_secret", "value": "rks_test_replace_with_your_secret", "type": "string" },
    { "key": "product_id", "value": "1", "type": "string" },
    { "key": "order_id", "value": "1", "type": "string" },
    { "key": "client_reference_id", "value": "order-ref-001", "type": "string" },
    { "key": "iid", "value": "123456712345671234567123456712345671234567123456712345671234567", "type": "string" }
  ],
  "event": [
    {
      "listen": "prerequest",
      "script": {
        "type": "text/javascript",
        "exec": [
          "const apiKey = pm.collectionVariables.get('api_key') || '';",
          "const apiSecret = pm.collectionVariables.get('api_secret') || '';",
          "const timestamp = Math.floor(Date.now() / 1000).toString();",
          "const rawBody = (pm.request.body && pm.request.body.mode === 'raw' && pm.request.body.raw) ? pm.request.body.raw : '';",
          "const payload = timestamp + '.' + rawBody;",
          "const signature = CryptoJS.HmacSHA256(payload, apiSecret).toString(CryptoJS.enc.Hex);",
          "",
          "pm.request.headers.upsert({ key: 'Accept', value: 'application/json' });",
          "pm.request.headers.upsert({ key: 'X-RK-Api-Key', value: apiKey });",
          "pm.request.headers.upsert({ key: 'X-RK-Timestamp', value: timestamp });",
          "pm.request.headers.upsert({ key: 'X-RK-Signature', value: signature });"
        ]
      }
    }
  ],
  "item": [
    {
      "name": "Account & Wallet",
      "description": "Retrieve authenticated reseller profile, tier, discount, wallet balance, CID points, and wallet transactions.",
      "item": [
        {
          "name": "Get Account Profile",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/api/v1/account",
              "host": ["{{base_url}}"],
              "path": ["api", "v1", "account"]
            },
            "description": "Returns customer_id, email, tier, currency, wallet_balance, and cid_points."
          },
          "response": [
            {
              "name": "200 OK",
              "status": "OK",
              "code": 200,
              "_postman_previewlanguage": "json",
              "body": "{\n  \"success\": true,\n  \"mode\": \"test\",\n  \"account\": {\n    \"customer_id\": 12,\n    \"email\": \"reseller@example.com\",\n    \"tier\": \"gold\",\n    \"currency\": \"USD\",\n    \"wallet_balance\": 250.00,\n    \"cid_points\": 15\n  }\n}"
            }
          ]
        },
        {
          "name": "List Wallet Transactions",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/api/v1/account/transactions?per_page=20&page=1",
              "host": ["{{base_url}}"],
              "path": ["api", "v1", "account", "transactions"],
              "query": [
                { "key": "per_page", "value": "20" },
                { "key": "page", "value": "1" }
              ]
            },
            "description": "Paginated wallet transaction history (credits, order debits, refunds, deposits)."
          },
          "response": []
        }
      ]
    },
    {
      "name": "Products & Tier Pricing",
      "description": "Browse active products with your reseller tier discount already applied.",
      "item": [
        {
          "name": "List Active Products",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/api/v1/products?q=Windows",
              "host": ["{{base_url}}"],
              "path": ["api", "v1", "products"],
              "query": [
                { "key": "q", "value": "Windows", "description": "Optional search filter by product name or SKU" }
              ]
            },
            "description": "Returns all active products with wholesale prices calculated for the authenticated reseller's tier."
          },
          "response": []
        },
        {
          "name": "Get Product Details",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/api/v1/products/{{product_id}}",
              "host": ["{{base_url}}"],
              "path": ["api", "v1", "products", "{{product_id}}"]
            },
            "description": "Returns full details, stock status, and tier-adjusted price for a single product."
          },
          "response": []
        }
      ]
    },
    {
      "name": "Orders & Fulfillment",
      "description": "Place idempotent license key orders, inspect order status/keys, and replay order webhooks.",
      "item": [
        {
          "name": "Create Order (Idempotent)",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Content-Type", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"product_id\": 1,\n  \"quantity\": 1,\n  \"extended_warranty\": false,\n  \"instant_only\": true,\n  \"client_reference_id\": \"{{client_reference_id}}\",\n  \"webhook_url\": \"https://your-store.example.com/webhooks/licensepanel\"\n}"
            },
            "url": {
              "raw": "{{base_url}}/api/v1/orders",
              "host": ["{{base_url}}"],
              "path": ["api", "v1", "orders"]
            },
            "description": "Places a license order. Using the same `client_reference_id` in the same mode is idempotent and returns the existing order without double-charging. In `test` mode, you can optionally pass `\"simulate_status\": \"complete\" | \"processing\" | \"canceled\" | \"refunded\"`."
          },
          "response": []
        },
        {
          "name": "List Orders",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/api/v1/orders?per_page=20&page=1",
              "host": ["{{base_url}}"],
              "path": ["api", "v1", "orders"],
              "query": [
                { "key": "per_page", "value": "20" },
                { "key": "page", "value": "1" }
              ]
            },
            "description": "Lists paginated orders for the authenticated reseller in the current API key mode (test/live)."
          },
          "response": []
        },
        {
          "name": "Lookup Order by client_reference_id",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/api/v1/orders?client_reference_id={{client_reference_id}}",
              "host": ["{{base_url}}"],
              "path": ["api", "v1", "orders"],
              "query": [
                { "key": "client_reference_id", "value": "{{client_reference_id}}" }
              ]
            },
            "description": "Retrieves an order using your idempotency key `client_reference_id`."
          },
          "response": []
        },
        {
          "name": "Get Order Details & Keys",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/api/v1/orders/{{order_id}}",
              "host": ["{{base_url}}"],
              "path": ["api", "v1", "orders", "{{order_id}}"]
            },
            "description": "Returns full order payload including allocated license keys."
          },
          "response": []
        },
        {
          "name": "Replay Order Webhook",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Content-Type", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{}"
            },
            "url": {
              "raw": "{{base_url}}/api/v1/orders/{{order_id}}/replay-webhook",
              "host": ["{{base_url}}"],
              "path": ["api", "v1", "orders", "{{order_id}}", "replay-webhook"]
            },
            "description": "Re-dispatches the webhook delivery for an order that has a configured `webhook_url`."
          },
          "response": []
        }
      ]
    },
    {
      "name": "GetCID Activation",
      "description": "Generate Microsoft Confirmation ID (CID) from a 54 or 63-digit Installation ID (IID).",
      "item": [
        {
          "name": "Generate Confirmation ID (CID)",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Content-Type", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"iid\": \"{{iid}}\"\n}"
            },
            "url": {
              "raw": "{{base_url}}/api/v1/cid/generate",
              "host": ["{{base_url}}"],
              "path": ["api", "v1", "cid", "generate"]
            },
            "description": "Generates a Microsoft Confirmation ID (CID) from a 54-digit or 63-digit Installation ID (spaces/dashes are stripped automatically). Consumes 1 CID point in live mode."
          },
          "response": []
        },
        {
          "name": "Get CID History",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/api/v1/cid/history?per_page=20&page=1",
              "host": ["{{base_url}}"],
              "path": ["api", "v1", "cid", "history"],
              "query": [
                { "key": "per_page", "value": "20" },
                { "key": "page", "value": "1" }
              ]
            },
            "description": "Paginated history of CID generation requests in the current mode."
          },
          "response": []
        }
      ]
    }
  ]
}
