{
  "info": {
    "name": "Algan B2B API",
    "description": "Official Postman Collection for the Algan B2B API. Includes automated HMAC-SHA256 signature generation via pre-request scripts. Set your `API_KEY` and `API_SECRET` in the collection variables or your active environment.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "variable": [
    {
      "key": "baseUrl",
      "value": "https://algan.id/api/v1",
      "type": "string"
    },
    {
      "key": "API_KEY",
      "value": "YOUR_API_KEY",
      "type": "string"
    },
    {
      "key": "API_SECRET",
      "value": "YOUR_API_SECRET",
      "type": "string"
    }
  ],
  "event": [
    {
      "listen": "prerequest",
      "script": {
        "type": "text/javascript",
        "exec": [
          "const apiKey = pm.environment.get('API_KEY') || pm.variables.get('API_KEY');",
          "const apiSecret = pm.environment.get('API_SECRET') || pm.variables.get('API_SECRET');",
          "",
          "if (!apiKey || !apiSecret) {",
          "    console.warn('API_KEY or API_SECRET not set in environment/collection variables.');",
          "}",
          "",
          "const timestamp = Date.now().toString();",
          "pm.request.headers.add({key: 'X-Timestamp', value: timestamp});",
          "pm.request.headers.add({key: 'X-Api-Key', value: apiKey});",
          "",
          "let bodyStr = '';",
          "if (pm.request.body && pm.request.body.mode === 'raw' && pm.request.body.raw) {",
          "    try {",
          "        bodyStr = JSON.stringify(JSON.parse(pm.request.body.raw));",
          "        pm.request.body.raw = bodyStr;",
          "    } catch(e) {",
          "        bodyStr = pm.request.body.raw;",
          "    }",
          "}",
          "",
          "const message = bodyStr + timestamp;",
          "const signature = CryptoJS.HmacSHA256(message, apiSecret).toString(CryptoJS.enc.Hex);",
          "",
          "pm.request.headers.add({key: 'X-Signature', value: signature});"
        ]
      }
    }
  ],
  "item": [
    {
      "name": "GET /balance",
      "request": {
        "method": "GET",
        "header": [],
        "url": {
          "raw": "{{baseUrl}}/balance",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "balance"
          ]
        },
        "description": "Fetch current account balance."
      },
      "response": [
        {
          "name": "Success",
          "originalRequest": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{baseUrl}}/balance",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "balance"
              ]
            }
          },
          "status": "OK",
          "code": 200,
          "body": "{\n    \"success\": true,\n    \"data\": {\n        \"balance\": 500000,\n        \"currency\": \"IDR\"\n    }\n}"
        }
      ]
    },
    {
      "name": "GET /categories",
      "request": {
        "method": "GET",
        "header": [],
        "url": {
          "raw": "{{baseUrl}}/categories",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "categories"
          ]
        },
        "description": "Fetch all available game/product categories and required form fields."
      },
      "response": [
        {
          "name": "Success",
          "originalRequest": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{baseUrl}}/categories",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "categories"
              ]
            }
          },
          "status": "OK",
          "code": 200,
          "body": "{\n    \"success\": true,\n    \"data\": {\n        \"categories\": [\n            {\n                \"name\": \"Mobile Legends: Bang Bang ID\",\n                \"slug\": \"MLBBID\",\n                \"forms\": [\n                    { \"name\": \"userId\", \"type\": \"text\", \"label\": \"User ID\", \"required\": true },\n                    { \"name\": \"zoneId\", \"type\": \"text\", \"label\": \"Zone ID\", \"required\": true }\n                ]\n            }\n        ]\n    }\n}"
        }
      ]
    },
    {
      "name": "GET /products",
      "request": {
        "method": "GET",
        "header": [],
        "url": {
          "raw": "{{baseUrl}}/products?category_slug=MLBBID",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "products"
          ],
          "query": [
            {
              "key": "category_slug",
              "value": "MLBBID",
              "description": "Optional category slug to filter products"
            }
          ]
        },
        "description": "Fetch available products, optionally filtered by category."
      },
      "response": [
        {
          "name": "Success",
          "originalRequest": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{baseUrl}}/products?category_slug=MLBBID",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "products"
              ],
              "query": [
                {
                  "key": "category_slug",
                  "value": "MLBBID"
                }
              ]
            }
          },
          "status": "OK",
          "code": 200,
          "body": "{\n    \"success\": true,\n    \"data\": {\n        \"products\": [\n            {\n                \"code\": \"MLBBID-11\",\n                \"name\": \"11 Diamonds (10 + 1 Bonus)\",\n                \"category\": \"Mobile Legends: Bang Bang ID\",\n                \"price\": 3341,\n                \"status\": \"active\"\n            }\n        ]\n    },\n    \"meta\": {\n        \"total\": 1,\n        \"page\": 1,\n        \"limit\": 50,\n        \"total_pages\": 1,\n        \"has_more\": false\n    }\n}"
        }
      ]
    },
    {
      "name": "POST /order",
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"ref_id\": \"ORDER-{{$timestamp}}\",\n  \"product_code\": \"MLBBID-11\",\n  \"target\": \"2081190166\",\n  \"zone\": \"19751\",\n  \"price\": 3341\n}"
        },
        "url": {
          "raw": "{{baseUrl}}/order",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "order"
          ]
        },
        "description": "Place a new order."
      },
      "response": [
        {
          "name": "Success",
          "originalRequest": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\"ref_id\":\"ORDER-12345\",\"product_code\":\"MLBBID-11\",\"target\":\"2081190166\",\"zone\":\"19751\",\"price\":3341}"
            },
            "url": {
              "raw": "{{baseUrl}}/order",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "order"
              ]
            }
          },
          "status": "OK",
          "code": 200,
          "body": "{\n    \"success\": true,\n    \"data\": {\n        \"order_id\": \"41a113d3-374c-4de8-91ae-8bd53cf703ab\",\n        \"ref_id\": \"ORDER-12345\",\n        \"product_name\": \"11 Diamonds (10 + 1 Bonus)\",\n        \"price\": 3341,\n        \"status\": \"processing\",\n        \"message\": \"Order diterima dan sedang diproses\"\n    }\n}"
        }
      ]
    },
    {
      "name": "GET /order-status",
      "request": {
        "method": "GET",
        "header": [],
        "url": {
          "raw": "{{baseUrl}}/order-status?ref_id=ORDER-12345",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "order-status"
          ],
          "query": [
            {
              "key": "ref_id",
              "value": "ORDER-12345"
            }
          ]
        },
        "description": "Check the status of an existing order by its ref_id."
      },
      "response": [
        {
          "name": "Success",
          "originalRequest": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{baseUrl}}/order-status?ref_id=ORDER-12345",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "order-status"
              ],
              "query": [
                {
                  "key": "ref_id",
                  "value": "ORDER-12345"
                }
              ]
            }
          },
          "status": "OK",
          "code": 200,
          "body": "{\n    \"success\": true,\n    \"data\": {\n        \"order_id\": \"41a113d3-374c-4de8-91ae-8bd53cf703ab\",\n        \"ref_id\": \"ORDER-12345\",\n        \"product_code\": \"MLBBID-11\",\n        \"target\": \"2081190166\",\n        \"zone\": \"19751\",\n        \"status\": \"success\",\n        \"sn\": \"1234567890\",\n        \"price\": 3341,\n        \"created_at\": \"2026-05-18T12:00:00.000Z\"\n    }\n}"
        }
      ]
    },
    {
      "name": "GET /orders",
      "request": {
        "method": "GET",
        "header": [],
        "url": {
          "raw": "{{baseUrl}}/orders?page=1&limit=10",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "orders"
          ],
          "query": [
            {
              "key": "page",
              "value": "1"
            },
            {
              "key": "limit",
              "value": "10"
            }
          ]
        },
        "description": "Fetch a paginated list of your recent orders."
      },
      "response": [
        {
          "name": "Success",
          "originalRequest": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{baseUrl}}/orders?page=1&limit=10",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "orders"
              ],
              "query": [
                {
                  "key": "page",
                  "value": "1"
                },
                {
                  "key": "limit",
                  "value": "10"
                }
              ]
            }
          },
          "status": "OK",
          "code": 200,
          "body": "{\n    \"success\": true,\n    \"data\": {\n        \"orders\": [\n            {\n                \"order_id\": \"41a113d3-374c-4de8-91ae-8bd53cf703ab\",\n                \"ref_id\": \"ORDER-12345\",\n                \"product_code\": \"ALGAN-B2B-MLBBID-11\",\n                \"target\": \"2081190166\",\n                \"zone\": \"19751\",\n                \"status\": \"success\",\n                \"price\": 3341,\n                \"created_at\": \"2026-05-18T12:00:00.000Z\"\n            }\n        ]\n    },\n    \"meta\": {\n        \"total\": 1,\n        \"page\": 1,\n        \"limit\": 10,\n        \"total_pages\": 1,\n        \"has_more\": false\n    }\n}"
        }
      ]
    },
    {
      "name": "GET /wallet-history",
      "request": {
        "method": "GET",
        "header": [],
        "url": {
          "raw": "{{baseUrl}}/wallet-history?page=1&limit=10",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "wallet-history"
          ],
          "query": [
            {
              "key": "page",
              "value": "1"
            },
            {
              "key": "limit",
              "value": "10"
            }
          ]
        },
        "description": "Fetch a paginated list of your wallet transaction history."
      },
      "response": [
        {
          "name": "Success",
          "originalRequest": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{baseUrl}}/wallet-history?page=1&limit=10",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "wallet-history"
              ],
              "query": [
                {
                  "key": "page",
                  "value": "1"
                },
                {
                  "key": "limit",
                  "value": "10"
                }
              ]
            }
          },
          "status": "OK",
          "code": 200,
          "body": "{\n    \"success\": true,\n    \"data\": {\n        \"history\": [\n            {\n                \"id\": \"tx_123\",\n                \"amount\": -3341,\n                \"type\": \"debit\",\n                \"description\": \"Order ORDER-12345\",\n                \"balance_after\": 496659,\n                \"created_at\": \"2026-05-18T12:00:00.000Z\"\n            }\n        ]\n    },\n    \"meta\": {\n        \"total\": 1,\n        \"page\": 1,\n        \"limit\": 10,\n        \"total_pages\": 1,\n        \"has_more\": false\n    }\n}"
        }
      ]
    }
  ]
}