{
  "info": {
    "name": "Trakor API — Acme Fabrics Walkthrough",
    "_postman_id": "d3b4a8f0-1111-4a2b-9a11-acmefabrics0001",
    "description": "End-to-end Postman collection that mirrors the Trakor API Walkthrough in /docs, using sample data for Acme Fabrics Pvt Ltd. Set the `host` and `apiKey` collection variables before running. Each request maps to a step in the docs; steps that run inside the app (QR generation, challans, invoices, payments, ledgers) are documented in the folder descriptions.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "variable": [
    { "key": "host", "value": "https://your-app-domain.lovable.app", "type": "string" },
    { "key": "apiKey", "value": "sk_live_replace_me", "type": "string" },
    { "key": "vendorName", "value": "Bharat Yarns LLP", "type": "string" },
    { "key": "vendorGSTIN", "value": "27ABCDE1234F1Z5", "type": "string" },
    { "key": "vendorState", "value": "Maharashtra", "type": "string" },
    { "key": "partyName", "value": "Rangoli Retail", "type": "string" },
    { "key": "partyGSTIN", "value": "29AAACR1234B1Z9", "type": "string" },
    { "key": "partyState", "value": "Karnataka", "type": "string" },
    { "key": "partyPhone", "value": "+91 98450 12345", "type": "string" },
    { "key": "productName", "value": "Cotton Shirt — Blue L", "type": "string" },
    { "key": "productPrice", "value": "899", "type": "string" }
  ],
  "auth": {
    "type": "apikey",
    "apikey": [
      { "key": "key", "value": "X-API-KEY", "type": "string" },
      { "key": "value", "value": "{{apiKey}}", "type": "string" },
      { "key": "in", "value": "header", "type": "string" }
    ]
  },
  "item": [
    {
      "name": "Step 1 — Wallet health check",
      "request": {
        "method": "GET",
        "header": [],
        "url": {
          "raw": "{{host}}/api/public/v1/wallet",
          "host": ["{{host}}"],
          "path": ["api", "public", "v1", "wallet"]
        },
        "description": "Poll wallet before large batches. Returns { wallet_balance, is_frozen, low_balance }. Low-balance threshold is 50 credits."
      }
    },
    {
      "name": "Step 2 — Upsert vendor (Acme's supplier)",
      "request": {
        "method": "POST",
        "header": [{ "key": "Content-Type", "value": "application/json" }],
        "url": {
          "raw": "{{host}}/api/public/v1/vendors",
          "host": ["{{host}}"],
          "path": ["api", "public", "v1", "vendors"]
        },
        "body": {
          "mode": "raw",
          "raw": "{\n  \"name\": \"{{vendorName}}\",\n  \"gstin\": \"{{vendorGSTIN}}\",\n  \"state\": \"{{vendorState}}\",\n  \"phone\": \"+91 98200 11111\",\n  \"email\": \"accounts@bharatyarns.example\",\n  \"contact_info\": \"Suresh Patil — Purchase\"\n}"
        },
        "description": "Idempotent by name — repeat calls return the existing vendor with `created: false`."
      }
    },
    {
      "name": "Step 3 — List vendors (search)",
      "request": {
        "method": "GET",
        "header": [],
        "url": {
          "raw": "{{host}}/api/public/v1/vendors?q=Bharat&limit=20",
          "host": ["{{host}}"],
          "path": ["api", "public", "v1", "vendors"],
          "query": [
            { "key": "q", "value": "Bharat" },
            { "key": "limit", "value": "20" }
          ]
        }
      }
    },
    {
      "name": "Step 4 — Upsert party (Acme's customer)",
      "request": {
        "method": "POST",
        "header": [{ "key": "Content-Type", "value": "application/json" }],
        "url": {
          "raw": "{{host}}/api/public/v1/parties",
          "host": ["{{host}}"],
          "path": ["api", "public", "v1", "parties"]
        },
        "body": {
          "mode": "raw",
          "raw": "{\n  \"name\": \"{{partyName}}\",\n  \"contact_info\": \"Meera Rao | {{partyPhone}} | GSTIN {{partyGSTIN}} | State {{partyState}}\"\n}"
        }
      }
    },
    {
      "name": "Step 5 — List parties (search)",
      "request": {
        "method": "GET",
        "header": [],
        "url": {
          "raw": "{{host}}/api/public/v1/parties?q=Rangoli&limit=20",
          "host": ["{{host}}"],
          "path": ["api", "public", "v1", "parties"],
          "query": [
            { "key": "q", "value": "Rangoli" },
            { "key": "limit", "value": "20" }
          ]
        }
      }
    },
    {
      "name": "Step 6 — Upsert product",
      "request": {
        "method": "POST",
        "header": [{ "key": "Content-Type", "value": "application/json" }],
        "url": {
          "raw": "{{host}}/api/public/v1/products",
          "host": ["{{host}}"],
          "path": ["api", "public", "v1", "products"]
        },
        "body": {
          "mode": "raw",
          "raw": "{\n  \"name\": \"{{productName}}\",\n  \"description\": \"Combed cotton, size L, colour Blue\",\n  \"price\": {{productPrice}}\n}"
        },
        "description": "Idempotent by name. Returns the auto-generated SKU. GST %, HSN, UoM, and custom fields are configured inside the app."
      }
    },
    {
      "name": "Step 7 — List products (search)",
      "request": {
        "method": "GET",
        "header": [],
        "url": {
          "raw": "{{host}}/api/public/v1/products?q=Cotton&limit=20",
          "host": ["{{host}}"],
          "path": ["api", "public", "v1", "products"],
          "query": [
            { "key": "q", "value": "Cotton" },
            { "key": "limit", "value": "20" }
          ]
        }
      }
    },
    {
      "name": "Step 8 — Re-check wallet after a batch",
      "request": {
        "method": "GET",
        "header": [],
        "url": {
          "raw": "{{host}}/api/public/v1/wallet",
          "host": ["{{host}}"],
          "path": ["api", "public", "v1", "wallet"]
        },
        "description": "Call again after in-app QR generation / challan / invoice actions to confirm credit deductions:\n\n- QR generation: 1 credit per code\n- QR template creation: 10,000 credits\n- Delivery Challan: 1 credit\n- Sales / Purchase / Proforma invoice: 1 credit each\n\nSteps that run in-app (not via REST yet):\n1. QR — Generate → deducts N credits\n2. Challans → New → scan / add products\n3. Convert Challan → Invoice (CGST+SGST intra-state, IGST inter-state)\n4. Invoice → Record payment\n5. Parties → Ledger → PDF/XLS for date range"
      }
    },
    {
      "name": "Auth failure check (no API key)",
      "request": {
        "method": "GET",
        "header": [],
        "auth": { "type": "noauth" },
        "url": {
          "raw": "{{host}}/api/public/v1/wallet",
          "host": ["{{host}}"],
          "path": ["api", "public", "v1", "wallet"]
        },
        "description": "Expected: 401 Missing X-API-KEY header. Useful sanity check when wiring up your ERP."
      }
    }
  ]
}
