{
    "info": {
        "name": "QBO Connect — Instance API v1",
        "description": "Instance API as called by the Odoo module (docs/api/API_CONTRACTS.md).\n\n1. Set base_url (QBO Connect) and odoo_base_url (the registered Odoo origin: http://127.0.0.1:8069 for mock Odoo, or e.g. http://192.168.x.x:8029 for an Odoo on the LAN) and odoo_callback_path (/qbo_connect/webhook for mock Odoo, /quickbook_online_connector/webhook for the Odoo module). Production accepts only https on a public host. Plain http works only in local development (APP_ENV=local, sandbox keys) for localhost and for private IPs listed in QBO_DEV_ALLOWED_PRIVATE_IPS in the QBO Connect .env (ADR-026, docs/local-dev/LOCAL_DEV.md). The mock license driver accepts only WK-… keys.\n2. Run **Register instance**: it stores instance_id and instance_secret in collection variables.\n3. Every other request (except the unsigned **Recover instance**) is signed by the collection pre-request script (X-QBO-Instance, X-QBO-Timestamp, X-QBO-Nonce, X-QBO-Signature).\n\nLost secret: Webkul support issues a one-time recovery code; put it in recovery_code and run **Recover instance**. A connected module uses **Rotate secret** instead (re-registering the same URL returns 409 and never resets the secret).\n\nNever commit or share this collection with instance_secret or recovery_code filled in.",
        "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
    },
    "item": [
        {
            "name": "Instance API",
            "description": "Register / rotate / recover the instance secret, start the Intuit connection, list connections, confirm a resync and disconnect.\nHealth, Register instance and Recover instance are unsigned; everything else is HMAC-signed.",
            "item": [
                {
                    "name": "Health",
                    "request": {
                        "method": "GET",
                        "header": [
                            {
                                "key": "Accept",
                                "value": "application/json"
                            }
                        ],
                        "url": {
                            "raw": "{{base_url}}/api/v1/health",
                            "host": [
                                "{{base_url}}"
                            ],
                            "path": [
                                "api",
                                "v1",
                                "health"
                            ]
                        },
                        "description": "Public reachability + version check. Unsigned."
                    },
                    "event": [
                        {
                            "listen": "test",
                            "script": {
                                "type": "text/javascript",
                                "exec": [
                                    "pm.test('HTTP 200', function () {",
                                    "    pm.expect(pm.response.code).to.be.oneOf([200]);",
                                    "});"
                                ]
                            }
                        }
                    ]
                },
                {
                    "name": "Register instance",
                    "request": {
                        "method": "POST",
                        "header": [
                            {
                                "key": "Accept",
                                "value": "application/json"
                            },
                            {
                                "key": "Content-Type",
                                "value": "application/json"
                            }
                        ],
                        "url": {
                            "raw": "{{base_url}}/api/v1/instances/register",
                            "host": [
                                "{{base_url}}"
                            ],
                            "path": [
                                "api",
                                "v1",
                                "instances",
                                "register"
                            ]
                        },
                        "description": "Unsigned (10/min/IP). 201 new instance. 422 validation_failed (error.details.fields.base_url / callback_url) when a URL breaks the rules (ADR-026): https on a public host, or in local development plain http for localhost and allowlisted LAN IPs; callback_url on the same scheme, host and port as base_url. 409 instance_already_registered (error.details.instance_id) when this license + base URL is already registered: the secret is NOT rotated (ADR-008); use Rotate secret or Recover instance. The test script stores instance_id and instance_secret in collection variables; the secret is shown once.",
                        "body": {
                            "mode": "raw",
                            "raw": "{\n    \"license_key\": \"{{license_key}}\",\n    \"base_url\": \"{{odoo_base_url}}\",\n    \"callback_url\": \"{{odoo_base_url}}{{odoo_callback_path}}\",\n    \"odoo_version\": \"18.0\",\n    \"module_version\": \"0.1.0-mock\"\n}",
                            "options": {
                                "raw": {
                                    "language": "json"
                                }
                            }
                        }
                    },
                    "event": [
                        {
                            "listen": "test",
                            "script": {
                                "type": "text/javascript",
                                "exec": [
                                    "pm.test('HTTP 201', function () {",
                                    "    pm.expect(pm.response.code).to.be.oneOf([201]);",
                                    "});",
                                    "const json = pm.response.json();",
                                    "if (json.instance_id && json.instance_secret) {",
                                    "    pm.collectionVariables.set('instance_id', json.instance_id);",
                                    "    pm.collectionVariables.set('instance_secret', json.instance_secret);",
                                    "    console.log('Stored ' + json.instance_id + ' (secret fingerprint ' + json.secret_fingerprint + '). Clear instance_secret before exporting this collection.');",
                                    "}"
                                ]
                            }
                        }
                    ]
                },
                {
                    "name": "Rotate secret",
                    "request": {
                        "method": "POST",
                        "header": [
                            {
                                "key": "Accept",
                                "value": "application/json"
                            },
                            {
                                "key": "Content-Type",
                                "value": "application/json"
                            }
                        ],
                        "url": {
                            "raw": "{{base_url}}/api/v1/instances/rotate-secret",
                            "host": [
                                "{{base_url}}"
                            ],
                            "path": [
                                "api",
                                "v1",
                                "instances",
                                "rotate-secret"
                            ]
                        },
                        "description": "Signed with the current secret (ADR-008). Returns 200 {instance_id, instance_secret, secret_fingerprint, rotated_at} with Cache-Control: no-store. The old secret stops working immediately and any pending recovery code is cancelled. The test script stores the new instance_secret."
                    },
                    "event": [
                        {
                            "listen": "test",
                            "script": {
                                "type": "text/javascript",
                                "exec": [
                                    "pm.test('HTTP 200', function () {",
                                    "    pm.expect(pm.response.code).to.be.oneOf([200]);",
                                    "});",
                                    "const json = pm.response.json();",
                                    "if (json.instance_id && json.instance_secret) {",
                                    "    pm.collectionVariables.set('instance_id', json.instance_id);",
                                    "    pm.collectionVariables.set('instance_secret', json.instance_secret);",
                                    "    console.log('Stored the new secret for ' + json.instance_id + ' (fingerprint ' + json.secret_fingerprint + '). The previous secret no longer works.');",
                                    "}"
                                ]
                            }
                        }
                    ]
                },
                {
                    "name": "Recover instance",
                    "request": {
                        "method": "POST",
                        "header": [
                            {
                                "key": "Accept",
                                "value": "application/json"
                            },
                            {
                                "key": "Content-Type",
                                "value": "application/json"
                            }
                        ],
                        "url": {
                            "raw": "{{base_url}}/api/v1/instances/recover",
                            "host": [
                                "{{base_url}}"
                            ],
                            "path": [
                                "api",
                                "v1",
                                "instances",
                                "recover"
                            ]
                        },
                        "description": "Unsigned, rate limited per IP (5/min). For a lost secret: set recovery_code to the one-time code issued by Webkul support on the admin instance page. Returns the same 200 shape as Rotate secret. Every failure (unknown instance, wrong license key, wrong/expired/used code) returns 403 recovery_failed; the code is cancelled after 5 wrong attempts. The test script stores the new instance_secret and clears recovery_code.",
                        "body": {
                            "mode": "raw",
                            "raw": "{\n    \"instance_id\": \"{{instance_id}}\",\n    \"license_key\": \"{{license_key}}\",\n    \"recovery_code\": \"{{recovery_code}}\"\n}",
                            "options": {
                                "raw": {
                                    "language": "json"
                                }
                            }
                        }
                    },
                    "event": [
                        {
                            "listen": "test",
                            "script": {
                                "type": "text/javascript",
                                "exec": [
                                    "pm.test('HTTP 200', function () {",
                                    "    pm.expect(pm.response.code).to.be.oneOf([200]);",
                                    "});",
                                    "const json = pm.response.json();",
                                    "if (json.instance_id && json.instance_secret) {",
                                    "    pm.collectionVariables.set('instance_id', json.instance_id);",
                                    "    pm.collectionVariables.set('instance_secret', json.instance_secret);",
                                    "    pm.collectionVariables.set('recovery_code', '');",
                                    "    console.log('Stored the new secret for ' + json.instance_id + ' (fingerprint ' + json.secret_fingerprint + '). The previous secret no longer works.');",
                                    "}"
                                ]
                            }
                        }
                    ]
                },
                {
                    "name": "Start connect",
                    "request": {
                        "method": "POST",
                        "header": [
                            {
                                "key": "Accept",
                                "value": "application/json"
                            },
                            {
                                "key": "Content-Type",
                                "value": "application/json"
                            }
                        ],
                        "url": {
                            "raw": "{{base_url}}/api/v1/connect/start",
                            "host": [
                                "{{base_url}}"
                            ],
                            "path": [
                                "api",
                                "v1",
                                "connect",
                                "start"
                            ]
                        },
                        "description": "Signed. Returns a single-use connect_url (10 min) to open in a browser. return_url must be on the registered base URL.",
                        "body": {
                            "mode": "raw",
                            "raw": "{\n    \"return_url\": \"{{odoo_base_url}}/qbo/return\"\n}",
                            "options": {
                                "raw": {
                                    "language": "json"
                                }
                            }
                        }
                    },
                    "event": [
                        {
                            "listen": "test",
                            "script": {
                                "type": "text/javascript",
                                "exec": [
                                    "pm.test('HTTP 201', function () {",
                                    "    pm.expect(pm.response.code).to.be.oneOf([201]);",
                                    "});",
                                    "console.log('Open in a browser: ' + pm.response.json().connect_url);"
                                ]
                            }
                        }
                    ]
                },
                {
                    "name": "Start reconnect",
                    "request": {
                        "method": "POST",
                        "header": [
                            {
                                "key": "Accept",
                                "value": "application/json"
                            },
                            {
                                "key": "Content-Type",
                                "value": "application/json"
                            }
                        ],
                        "url": {
                            "raw": "{{base_url}}/api/v1/connect/start",
                            "host": [
                                "{{base_url}}"
                            ],
                            "path": [
                                "api",
                                "v1",
                                "connect",
                                "start"
                            ]
                        },
                        "description": "Signed. Reconnect an existing connection (same QuickBooks company).",
                        "body": {
                            "mode": "raw",
                            "raw": "{\n    \"return_url\": \"{{odoo_base_url}}/qbo/return\",\n    \"connection_id\": \"{{connection_id}}\"\n}",
                            "options": {
                                "raw": {
                                    "language": "json"
                                }
                            }
                        }
                    },
                    "event": [
                        {
                            "listen": "test",
                            "script": {
                                "type": "text/javascript",
                                "exec": [
                                    "pm.test('HTTP 201', function () {",
                                    "    pm.expect(pm.response.code).to.be.oneOf([201]);",
                                    "});"
                                ]
                            }
                        }
                    ]
                },
                {
                    "name": "List connections",
                    "request": {
                        "method": "GET",
                        "header": [
                            {
                                "key": "Accept",
                                "value": "application/json"
                            }
                        ],
                        "url": {
                            "raw": "{{base_url}}/api/v1/connections",
                            "host": [
                                "{{base_url}}"
                            ],
                            "path": [
                                "api",
                                "v1",
                                "connections"
                            ]
                        },
                        "description": "Signed. Stores the first connection id in connection_id and its realm_id in realm_id when they are empty."
                    },
                    "event": [
                        {
                            "listen": "test",
                            "script": {
                                "type": "text/javascript",
                                "exec": [
                                    "pm.test('HTTP 200', function () {",
                                    "    pm.expect(pm.response.code).to.be.oneOf([200]);",
                                    "});",
                                    "const rows = pm.response.json().data || [];",
                                    "const active = rows.find(function (r) { return r.status === 'active'; }) || rows[0];",
                                    "if (active && !pm.collectionVariables.get('connection_id')) {",
                                    "    pm.collectionVariables.set('connection_id', active.id);",
                                    "}",
                                    "if (active && !pm.collectionVariables.get('realm_id')) {",
                                    "    pm.collectionVariables.set('realm_id', active.realm_id);",
                                    "}"
                                ]
                            }
                        }
                    ]
                },
                {
                    "name": "Show connection",
                    "request": {
                        "method": "GET",
                        "header": [
                            {
                                "key": "Accept",
                                "value": "application/json"
                            }
                        ],
                        "url": {
                            "raw": "{{base_url}}/api/v1/connections/{{connection_id}}",
                            "host": [
                                "{{base_url}}"
                            ],
                            "path": [
                                "api",
                                "v1",
                                "connections",
                                "{{connection_id}}"
                            ]
                        },
                        "description": "Signed."
                    },
                    "event": [
                        {
                            "listen": "test",
                            "script": {
                                "type": "text/javascript",
                                "exec": [
                                    "pm.test('HTTP 200', function () {",
                                    "    pm.expect(pm.response.code).to.be.oneOf([200]);",
                                    "});",
                                    "// ADR-033: entity changes this connection missed; Confirm resync sends the count back after the resync.",
                                    "const sync = (pm.response.json().data || {}).sync_required;",
                                    "pm.collectionVariables.set('sync_missed_events', sync ? String(sync.missed_events) : '');"
                                ]
                            }
                        }
                    ]
                },
                {
                    "name": "Show connection with result code",
                    "request": {
                        "method": "GET",
                        "header": [
                            {
                                "key": "Accept",
                                "value": "application/json"
                            }
                        ],
                        "url": {
                            "raw": "{{base_url}}/api/v1/connections/{{connection_id}}?result_code={{result_code}}",
                            "host": [
                                "{{base_url}}"
                            ],
                            "path": [
                                "api",
                                "v1",
                                "connections",
                                "{{connection_id}}"
                            ],
                            "query": [
                                {
                                    "key": "result_code",
                                    "value": "{{result_code}}"
                                }
                            ]
                        },
                        "description": "Signed. Confirms the browser return: meta.result_code_valid is true once, within 10 minutes."
                    },
                    "event": [
                        {
                            "listen": "test",
                            "script": {
                                "type": "text/javascript",
                                "exec": [
                                    "pm.test('HTTP 200', function () {",
                                    "    pm.expect(pm.response.code).to.be.oneOf([200]);",
                                    "});"
                                ]
                            }
                        }
                    ]
                },
                {
                    "name": "Confirm resync",
                    "request": {
                        "method": "POST",
                        "header": [
                            {
                                "key": "Accept",
                                "value": "application/json"
                            },
                            {
                                "key": "Content-Type",
                                "value": "application/json"
                            }
                        ],
                        "url": {
                            "raw": "{{base_url}}/api/v1/connections/{{connection_id}}/sync-complete",
                            "host": [
                                "{{base_url}}"
                            ],
                            "path": [
                                "api",
                                "v1",
                                "connections",
                                "{{connection_id}}",
                                "sync-complete"
                            ]
                        },
                        "description": "Signed. Odoo sends this after it has resynchronised the connection (CDC or a full reconciliation) because of a qbo.sync_required webhook. missed_events is the count from that webhook, or sync_required.missed_events from Show connection. The marker is cleared only if no further entity change was missed in the meantime: when the response still has sync_required, resync again and confirm the new count. Skipped while sync_missed_events is empty (Show connection fills it).",
                        "body": {
                            "mode": "raw",
                            "raw": "{\n    \"missed_events\": {{sync_missed_events}}\n}",
                            "options": {
                                "raw": {
                                    "language": "json"
                                }
                            }
                        }
                    },
                    "event": [
                        {
                            "listen": "prerequest",
                            "script": {
                                "type": "text/javascript",
                                "exec": [
                                    "// Only when Show connection reported missed entity changes (sync_required.missed_events).",
                                    "if (!pm.collectionVariables.get('sync_missed_events') && pm.execution && pm.execution.skipRequest) {",
                                    "    console.log('Skipped: nothing to resync. Show connection fills sync_missed_events from sync_required.');",
                                    "    pm.execution.skipRequest();",
                                    "}"
                                ]
                            }
                        },
                        {
                            "listen": "test",
                            "script": {
                                "type": "text/javascript",
                                "exec": [
                                    "pm.test('HTTP 200', function () {",
                                    "    pm.expect(pm.response.code).to.be.oneOf([200]);",
                                    "});",
                                    "// Still set: more entity changes were missed after the count was read. Resync again and confirm the new count.",
                                    "const sync = (pm.response.json().data || {}).sync_required;",
                                    "pm.collectionVariables.set('sync_missed_events', sync ? String(sync.missed_events) : '');"
                                ]
                            }
                        }
                    ]
                },
                {
                    "name": "Get access token",
                    "request": {
                        "method": "POST",
                        "header": [
                            {
                                "key": "Accept",
                                "value": "application/json"
                            },
                            {
                                "key": "Content-Type",
                                "value": "application/json"
                            }
                        ],
                        "url": {
                            "raw": "{{base_url}}/api/v1/token",
                            "host": [
                                "{{base_url}}"
                            ],
                            "path": [
                                "api",
                                "v1",
                                "token"
                            ]
                        },
                        "description": "Signed. Access-token handoff — DISABLED by default (ADR-019): returns 403 token_handoff_disabled (handoff is off on this service). Use the Proxy requests instead. Never returns the refresh token.",
                        "body": {
                            "mode": "raw",
                            "raw": "{\n    \"connection_id\": \"{{connection_id}}\"\n}",
                            "options": {
                                "raw": {
                                    "language": "json"
                                }
                            }
                        }
                    },
                    "event": [
                        {
                            "listen": "test",
                            "script": {
                                "type": "text/javascript",
                                "exec": [
                                    "pm.test('HTTP 200 (handoff enabled) or 403 token_handoff_disabled (default)', function () {",
                                    "    pm.expect(pm.response.code).to.be.oneOf([200, 403]);",
                                    "});"
                                ]
                            }
                        }
                    ]
                },
                {
                    "name": "Disconnect",
                    "request": {
                        "method": "POST",
                        "header": [
                            {
                                "key": "Accept",
                                "value": "application/json"
                            },
                            {
                                "key": "Content-Type",
                                "value": "application/json"
                            }
                        ],
                        "url": {
                            "raw": "{{base_url}}/api/v1/connections/{{connection_id}}/disconnect",
                            "host": [
                                "{{base_url}}"
                            ],
                            "path": [
                                "api",
                                "v1",
                                "connections",
                                "{{connection_id}}",
                                "disconnect"
                            ]
                        },
                        "description": "Signed. Revokes at Intuit (best effort) and deletes tokens. Idempotent."
                    },
                    "event": [
                        {
                            "listen": "test",
                            "script": {
                                "type": "text/javascript",
                                "exec": [
                                    "pm.test('HTTP 200', function () {",
                                    "    pm.expect(pm.response.code).to.be.oneOf([200]);",
                                    "});"
                                ]
                            }
                        }
                    ]
                }
            ]
        },
        {
            "name": "QuickBooks API (proxy)",
            "description": "Every request goes to `{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/...` and is HMAC-signed by the collection\npre-request script, exactly like the Odoo module. QBO Connect forwards it to the QuickBooks Online Accounting API of the\nconnection's environment with the stored bearer token (ADR-019) and relays Intuit's status and body, plus `intuit_tid`\nand `X-QBO-Upstream-Status`. **SANDBOX ONLY**: the requests create, change, void and delete test data named\n`QBOC-TEST <run_id> ...`.\n\nFirst run: set `realm_id` (Instance API → List connections stores it), then run folders 1 → 12 in order; later\nfolders use ids stored by earlier ones (accounts, tax codes, customer, vendor, item). Writes carry\n`requestid={{request_id}}` (a fresh idempotency key generated before signing).\nContract: docs/api/API_CONTRACTS.md · operation matrix: docs/research/intuit-accounting-entities.md.",
            "item": [
                {
                    "name": "1. Company & setup",
                    "description": "Start here. **CompanyInfo** also starts a new test-data run (`run_id`), so names like `QBOC-TEST <run_id> Customer` stay\nunique. Preferences shows the tax set-up (`TaxPrefs`) and features (e.g. inventory tracking).\nDocs: https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/companyinfo · https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/preferences",
                    "item": [
                        {
                            "name": "CompanyInfo (starts a new test run)",
                            "request": {
                                "method": "GET",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/companyinfo/{{realm_id}}",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "companyinfo",
                                        "{{realm_id}}"
                                    ]
                                },
                                "description": "Read the connected company. Country decides tax rules (non-US companies need a TaxCodeRef on transaction lines)."
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "pm.test('CompanyInfo returned', function () { pm.expect(json.CompanyInfo && json.CompanyInfo.Id).to.be.a('string'); });",
                                            "pm.collectionVariables.set('run_id', Date.now().toString(36));",
                                            "pm.collectionVariables.set('changed_since', new Date(Date.now() - 6 * 3600 * 1000).toISOString().slice(0, 19) + '-00:00');",
                                            "console.log('Company: ' + json.CompanyInfo.CompanyName + ' (' + json.CompanyInfo.Country + '), run_id ' + pm.collectionVariables.get('run_id'));"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Preferences",
                            "request": {
                                "method": "GET",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/preferences",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "preferences"
                                    ]
                                },
                                "description": ""
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "pm.test('Preferences returned', function () { pm.expect(json.Preferences && json.Preferences.Id).to.be.a('string'); });"
                                        ]
                                    }
                                }
                            ]
                        }
                    ]
                },
                {
                    "name": "2. Accounts (chart of accounts)",
                    "description": "Name-list entity: create, read, query, update, **deactivate** (`Active: false`); no delete. The first three requests\npick the income / expense / bank accounts that the item, bill and bill-payment requests use.\nDocs: https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/account",
                    "item": [
                        {
                            "name": "Query income accounts",
                            "request": {
                                "method": "GET",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/query?query=select * from Account where AccountType = 'Income' and Active = true MAXRESULTS 5",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "query"
                                    ],
                                    "query": [
                                        {
                                            "key": "query",
                                            "value": "select * from Account where AccountType = 'Income' and Active = true MAXRESULTS 5"
                                        }
                                    ]
                                },
                                "description": ""
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "const rows = (json.QueryResponse && json.QueryResponse.Account) || [];",
                                            "pm.test('at least 1 Account row(s)', function () { pm.expect(rows.length).to.be.at.least(1); });",
                                            "if (rows.length) { pm.collectionVariables.set('income_account_id', String(rows[0].Id)); }"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Query expense accounts",
                            "request": {
                                "method": "GET",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/query?query=select * from Account where AccountType = 'Expense' and Active = true MAXRESULTS 5",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "query"
                                    ],
                                    "query": [
                                        {
                                            "key": "query",
                                            "value": "select * from Account where AccountType = 'Expense' and Active = true MAXRESULTS 5"
                                        }
                                    ]
                                },
                                "description": ""
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "const rows = (json.QueryResponse && json.QueryResponse.Account) || [];",
                                            "pm.test('at least 1 Account row(s)', function () { pm.expect(rows.length).to.be.at.least(1); });",
                                            "if (rows.length) { pm.collectionVariables.set('expense_account_id', String(rows[0].Id)); }"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Query bank accounts",
                            "request": {
                                "method": "GET",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/query?query=select * from Account where AccountType = 'Bank' and Active = true MAXRESULTS 5",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "query"
                                    ],
                                    "query": [
                                        {
                                            "key": "query",
                                            "value": "select * from Account where AccountType = 'Bank' and Active = true MAXRESULTS 5"
                                        }
                                    ]
                                },
                                "description": ""
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "const rows = (json.QueryResponse && json.QueryResponse.Account) || [];",
                                            "pm.test('at least 1 Account row(s)', function () { pm.expect(rows.length).to.be.at.least(1); });",
                                            "if (rows.length) { pm.collectionVariables.set('bank_account_id', String(rows[0].Id)); }"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Count accounts",
                            "request": {
                                "method": "GET",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/query?query=select count(*) from Account",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "query"
                                    ],
                                    "query": [
                                        {
                                            "key": "query",
                                            "value": "select count(*) from Account"
                                        }
                                    ]
                                },
                                "description": ""
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('totalCount', function () { pm.expect(json.QueryResponse.totalCount).to.be.a('number'); });"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Create account",
                            "request": {
                                "method": "POST",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    },
                                    {
                                        "key": "Content-Type",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/account?requestid={{request_id}}",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "account"
                                    ],
                                    "query": [
                                        {
                                            "key": "requestid",
                                            "value": "{{request_id}}"
                                        }
                                    ]
                                },
                                "description": "Name must be unique and must not contain double quotes or a colon. AccountType (and optionally AccountSubType) decides where it appears.",
                                "body": {
                                    "mode": "raw",
                                    "raw": "{\n    \"Name\": \"QBOC-TEST {{run_id}} Expense\",\n    \"AccountType\": \"Expense\",\n    \"Description\": \"QBO Connect Postman test\"\n}",
                                    "options": {
                                        "raw": {
                                            "language": "json"
                                        }
                                    }
                                }
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "pm.test('Account returned', function () { pm.expect(json.Account && json.Account.Id).to.be.a('string'); });",
                                            "if (json.Account) { pm.collectionVariables.set('account_id', String(json.Account.Id)); }",
                                            "if (json.Account) { pm.collectionVariables.set('account_sync_token', String(json.Account.SyncToken)); }"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Read account",
                            "request": {
                                "method": "GET",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/account/{{account_id}}",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "account",
                                        "{{account_id}}"
                                    ]
                                },
                                "description": ""
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "pm.test('Account returned', function () { pm.expect(json.Account && json.Account.Id).to.be.a('string'); });",
                                            "if (json.Account) { pm.collectionVariables.set('account_sync_token', String(json.Account.SyncToken)); }"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Update account (sparse)",
                            "request": {
                                "method": "POST",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    },
                                    {
                                        "key": "Content-Type",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/account?requestid={{request_id}}",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "account"
                                    ],
                                    "query": [
                                        {
                                            "key": "requestid",
                                            "value": "{{request_id}}"
                                        }
                                    ]
                                },
                                "description": "Every update needs the current Id and SyncToken (optimistic locking).",
                                "body": {
                                    "mode": "raw",
                                    "raw": "{\n    \"Id\": \"{{account_id}}\",\n    \"SyncToken\": \"{{account_sync_token}}\",\n    \"sparse\": true,\n    \"Description\": \"Updated by QBO Connect Postman test\"\n}",
                                    "options": {
                                        "raw": {
                                            "language": "json"
                                        }
                                    }
                                }
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "pm.test('Account returned', function () { pm.expect(json.Account && json.Account.Id).to.be.a('string'); });",
                                            "if (json.Account) { pm.collectionVariables.set('account_sync_token', String(json.Account.SyncToken)); }"
                                        ]
                                    }
                                }
                            ]
                        }
                    ]
                },
                {
                    "name": "3. Tax (TaxCode, TaxRate, TaxAgency)",
                    "description": "TaxCode and TaxRate are read/query only. **Query tax codes** stores the first active code with sales rates\n(`sales_tax_code_id`) and with purchase rates (`purchase_tax_code_id`); the invoice, credit-memo and bill requests put\nthem on each line, which non-US (e.g. Canadian) companies require.\nDocs: https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/taxcode · https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/taxrate · https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/taxagency · https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/taxservice",
                    "item": [
                        {
                            "name": "Query tax codes",
                            "request": {
                                "method": "GET",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/query?query=select * from TaxCode MAXRESULTS 100",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "query"
                                    ],
                                    "query": [
                                        {
                                            "key": "query",
                                            "value": "select * from TaxCode MAXRESULTS 100"
                                        }
                                    ]
                                },
                                "description": ""
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "const rows = (json.QueryResponse && json.QueryResponse.TaxCode) || [];",
                                            "pm.test('at least 1 TaxCode row(s)', function () { pm.expect(rows.length).to.be.at.least(1); });",
                                            "if (rows.length) { pm.collectionVariables.set('tax_code_id', String(rows[0].Id)); }",
                                            "const active = rows.filter(function (r) { return r.Active; });",
                                            "const sales = active.find(function (r) { return r.SalesTaxRateList && (r.SalesTaxRateList.TaxRateDetail || []).length; });",
                                            "const purchase = active.find(function (r) { return r.PurchaseTaxRateList && (r.PurchaseTaxRateList.TaxRateDetail || []).length; });",
                                            "if (sales) { pm.collectionVariables.set('sales_tax_code_id', sales.Id); }",
                                            "if (purchase) { pm.collectionVariables.set('purchase_tax_code_id', purchase.Id); }"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Read tax code",
                            "request": {
                                "method": "GET",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/taxcode/{{tax_code_id}}",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "taxcode",
                                        "{{tax_code_id}}"
                                    ]
                                },
                                "description": ""
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "pm.test('TaxCode returned', function () { pm.expect(json.TaxCode && json.TaxCode.Id).to.be.a('string'); });"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Query tax rates",
                            "request": {
                                "method": "GET",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/query?query=select * from TaxRate MAXRESULTS 20",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "query"
                                    ],
                                    "query": [
                                        {
                                            "key": "query",
                                            "value": "select * from TaxRate MAXRESULTS 20"
                                        }
                                    ]
                                },
                                "description": ""
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "const rows = (json.QueryResponse && json.QueryResponse.TaxRate) || [];",
                                            "pm.test('at least 1 TaxRate row(s)', function () { pm.expect(rows.length).to.be.at.least(1); });",
                                            "if (rows.length) { pm.collectionVariables.set('tax_rate_id', String(rows[0].Id)); }"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Read tax rate",
                            "request": {
                                "method": "GET",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/taxrate/{{tax_rate_id}}",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "taxrate",
                                        "{{tax_rate_id}}"
                                    ]
                                },
                                "description": ""
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "pm.test('TaxRate returned', function () { pm.expect(json.TaxRate && json.TaxRate.Id).to.be.a('string'); });"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Query tax agencies",
                            "request": {
                                "method": "GET",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/query?query=select * from TaxAgency",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "query"
                                    ],
                                    "query": [
                                        {
                                            "key": "query",
                                            "value": "select * from TaxAgency"
                                        }
                                    ]
                                },
                                "description": ""
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "const rows = (json.QueryResponse && json.QueryResponse.TaxAgency) || [];"
                                        ]
                                    }
                                }
                            ]
                        }
                    ]
                },
                {
                    "name": "3b. Tax set-up writes (permanent, opt-in)",
                    "description": "Creates a tax agency and, through TaxService, a tax code with a new rate. **Permanent**: the API has no delete or\ndeactivate for TaxAgency, TaxCode or TaxRate. Skipped unless the collection variable `allow_permanent_tax_writes` is\n`true` (needs Postman with `pm.execution.skipRequest`). TaxService answers without an entity envelope:\n`{\"TaxCode\":..,\"TaxCodeId\":..,\"TaxRateDetails\":[{\"TaxRateId\":..,\"RateValue\":\"5%\"}]}`. `TaxRateName` max 10 characters.\nDocs: https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/taxagency · https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/taxservice",
                    "item": [
                        {
                            "name": "Create tax agency",
                            "request": {
                                "method": "POST",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    },
                                    {
                                        "key": "Content-Type",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/taxagency?requestid={{request_id}}",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "taxagency"
                                    ],
                                    "query": [
                                        {
                                            "key": "requestid",
                                            "value": "{{request_id}}"
                                        }
                                    ]
                                },
                                "description": "",
                                "body": {
                                    "mode": "raw",
                                    "raw": "{\n    \"DisplayName\": \"QBOC-TEST {{run_id}} Agency\"\n}",
                                    "options": {
                                        "raw": {
                                            "language": "json"
                                        }
                                    }
                                }
                            },
                            "event": [
                                {
                                    "listen": "prerequest",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "// Permanent data: tax agencies, codes and rates cannot be deleted or deactivated through the API.",
                                            "if (pm.collectionVariables.get('allow_permanent_tax_writes') !== 'true' && pm.execution && pm.execution.skipRequest) {",
                                            "    console.log('Skipped: set allow_permanent_tax_writes = true to create tax agencies / tax codes.');",
                                            "    pm.execution.skipRequest();",
                                            "}"
                                        ]
                                    }
                                },
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "pm.test('TaxAgency returned', function () { pm.expect(json.TaxAgency && json.TaxAgency.Id).to.be.a('string'); });",
                                            "if (json.TaxAgency) { pm.collectionVariables.set('tax_agency_id', String(json.TaxAgency.Id)); }"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Create tax code with a new rate (TaxService)",
                            "request": {
                                "method": "POST",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    },
                                    {
                                        "key": "Content-Type",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/taxservice/taxcode?requestid={{request_id}}",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "taxservice",
                                        "taxcode"
                                    ],
                                    "query": [
                                        {
                                            "key": "requestid",
                                            "value": "{{request_id}}"
                                        }
                                    ]
                                },
                                "description": "",
                                "body": {
                                    "mode": "raw",
                                    "raw": "{\n    \"TaxCode\": \"QBOC-TEST {{run_id}}\",\n    \"TaxRateDetails\": [\n        {\n            \"TaxRateName\": \"QT{{run_id}}\",\n            \"RateValue\": \"5\",\n            \"TaxAgencyId\": \"{{tax_agency_id}}\",\n            \"TaxApplicableOn\": \"Sales\"\n        }\n    ]\n}",
                                    "options": {
                                        "raw": {
                                            "language": "json"
                                        }
                                    }
                                }
                            },
                            "event": [
                                {
                                    "listen": "prerequest",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "// Permanent data: tax agencies, codes and rates cannot be deleted or deactivated through the API.",
                                            "if (pm.collectionVariables.get('allow_permanent_tax_writes') !== 'true' && pm.execution && pm.execution.skipRequest) {",
                                            "    console.log('Skipped: set allow_permanent_tax_writes = true to create tax agencies / tax codes.');",
                                            "    pm.execution.skipRequest();",
                                            "}"
                                        ]
                                    }
                                },
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "pm.test('TaxCodeId returned', function () { pm.expect(json.TaxCodeId).to.be.a('string'); });",
                                            "if (json.TaxCodeId) { pm.collectionVariables.set('new_tax_code_id', json.TaxCodeId); }"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Read new tax code",
                            "request": {
                                "method": "GET",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/taxcode/{{new_tax_code_id}}",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "taxcode",
                                        "{{new_tax_code_id}}"
                                    ]
                                },
                                "description": ""
                            },
                            "event": [
                                {
                                    "listen": "prerequest",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "// Permanent data: tax agencies, codes and rates cannot be deleted or deactivated through the API.",
                                            "if (pm.collectionVariables.get('allow_permanent_tax_writes') !== 'true' && pm.execution && pm.execution.skipRequest) {",
                                            "    console.log('Skipped: set allow_permanent_tax_writes = true to create tax agencies / tax codes.');",
                                            "    pm.execution.skipRequest();",
                                            "}"
                                        ]
                                    }
                                },
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "pm.test('TaxCode returned', function () { pm.expect(json.TaxCode && json.TaxCode.Id).to.be.a('string'); });"
                                        ]
                                    }
                                }
                            ]
                        }
                    ]
                },
                {
                    "name": "4. Customers",
                    "description": "Name-list entity: create, read, query, sparse update, deactivate (in **12. Cleanup**); no delete.\n`DisplayName` must be unique across customers, vendors and employees.\nDocs: https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/customer",
                    "item": [
                        {
                            "name": "Create customer",
                            "request": {
                                "method": "POST",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    },
                                    {
                                        "key": "Content-Type",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/customer?requestid={{request_id}}",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "customer"
                                    ],
                                    "query": [
                                        {
                                            "key": "requestid",
                                            "value": "{{request_id}}"
                                        }
                                    ]
                                },
                                "description": "Always send requestid on writes: the proxy only resubmits a POST after a 5xx/network error when requestid makes it idempotent.",
                                "body": {
                                    "mode": "raw",
                                    "raw": "{\n    \"DisplayName\": \"QBOC-TEST {{run_id}} Customer\",\n    \"CompanyName\": \"QBO Connect Test Co\",\n    \"PrimaryEmailAddr\": {\n        \"Address\": \"{{test_email}}\"\n    },\n    \"BillAddr\": {\n        \"Line1\": \"100 Test Street\",\n        \"City\": \"Toronto\",\n        \"CountrySubDivisionCode\": \"ON\",\n        \"PostalCode\": \"M5V 2T6\",\n        \"Country\": \"CA\"\n    }\n}",
                                    "options": {
                                        "raw": {
                                            "language": "json"
                                        }
                                    }
                                }
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "pm.test('Customer returned', function () { pm.expect(json.Customer && json.Customer.Id).to.be.a('string'); });",
                                            "if (json.Customer) { pm.collectionVariables.set('customer_id', String(json.Customer.Id)); }",
                                            "if (json.Customer) { pm.collectionVariables.set('customer_sync_token', String(json.Customer.SyncToken)); }"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Read customer",
                            "request": {
                                "method": "GET",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/customer/{{customer_id}}",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "customer",
                                        "{{customer_id}}"
                                    ]
                                },
                                "description": ""
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "pm.test('Customer returned', function () { pm.expect(json.Customer && json.Customer.Id).to.be.a('string'); });",
                                            "if (json.Customer) { pm.collectionVariables.set('customer_sync_token', String(json.Customer.SyncToken)); }"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Query customer by DisplayName",
                            "request": {
                                "method": "GET",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/query?query=select * from Customer where DisplayName = 'QBOC-TEST {{run_id}} Customer'",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "query"
                                    ],
                                    "query": [
                                        {
                                            "key": "query",
                                            "value": "select * from Customer where DisplayName = 'QBOC-TEST {{run_id}} Customer'"
                                        }
                                    ]
                                },
                                "description": ""
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "const rows = (json.QueryResponse && json.QueryResponse.Customer) || [];",
                                            "pm.test('at least 1 Customer row(s)', function () { pm.expect(rows.length).to.be.at.least(1); });"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Query customers changed since",
                            "request": {
                                "method": "GET",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/query?query=select * from Customer where MetaData.LastUpdatedTime > '{{changed_since}}' ORDERBY MetaData.LastUpdatedTime MAXRESULTS 50",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "query"
                                    ],
                                    "query": [
                                        {
                                            "key": "query",
                                            "value": "select * from Customer where MetaData.LastUpdatedTime > '{{changed_since}}' ORDERBY MetaData.LastUpdatedTime MAXRESULTS 50"
                                        }
                                    ]
                                },
                                "description": ""
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "const rows = (json.QueryResponse && json.QueryResponse.Customer) || [];"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Update customer (sparse)",
                            "request": {
                                "method": "POST",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    },
                                    {
                                        "key": "Content-Type",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/customer?requestid={{request_id}}",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "customer"
                                    ],
                                    "query": [
                                        {
                                            "key": "requestid",
                                            "value": "{{request_id}}"
                                        }
                                    ]
                                },
                                "description": "Sparse update: only the fields sent change. Needs the current SyncToken (Read customer refreshes it).",
                                "body": {
                                    "mode": "raw",
                                    "raw": "{\n    \"Id\": \"{{customer_id}}\",\n    \"SyncToken\": \"{{customer_sync_token}}\",\n    \"sparse\": true,\n    \"Notes\": \"Updated by QBO Connect Postman test\",\n    \"PrimaryPhone\": {\n        \"FreeFormNumber\": \"(416) 555-0100\"\n    }\n}",
                                    "options": {
                                        "raw": {
                                            "language": "json"
                                        }
                                    }
                                }
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "pm.test('Customer returned', function () { pm.expect(json.Customer && json.Customer.Id).to.be.a('string'); });",
                                            "if (json.Customer) { pm.collectionVariables.set('customer_sync_token', String(json.Customer.SyncToken)); }"
                                        ]
                                    }
                                }
                            ]
                        }
                    ]
                },
                {
                    "name": "5. Vendors",
                    "description": "Name-list entity: create, read, query, sparse update, deactivate (in **12. Cleanup**); no delete.\nDocs: https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/vendor",
                    "item": [
                        {
                            "name": "Create vendor",
                            "request": {
                                "method": "POST",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    },
                                    {
                                        "key": "Content-Type",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/vendor?requestid={{request_id}}",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "vendor"
                                    ],
                                    "query": [
                                        {
                                            "key": "requestid",
                                            "value": "{{request_id}}"
                                        }
                                    ]
                                },
                                "description": "",
                                "body": {
                                    "mode": "raw",
                                    "raw": "{\n    \"DisplayName\": \"QBOC-TEST {{run_id}} Vendor\",\n    \"CompanyName\": \"QBO Connect Test Supplier\",\n    \"PrimaryEmailAddr\": {\n        \"Address\": \"{{test_email}}\"\n    }\n}",
                                    "options": {
                                        "raw": {
                                            "language": "json"
                                        }
                                    }
                                }
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "pm.test('Vendor returned', function () { pm.expect(json.Vendor && json.Vendor.Id).to.be.a('string'); });",
                                            "if (json.Vendor) { pm.collectionVariables.set('vendor_id', String(json.Vendor.Id)); }",
                                            "if (json.Vendor) { pm.collectionVariables.set('vendor_sync_token', String(json.Vendor.SyncToken)); }"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Read vendor",
                            "request": {
                                "method": "GET",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/vendor/{{vendor_id}}",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "vendor",
                                        "{{vendor_id}}"
                                    ]
                                },
                                "description": ""
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "pm.test('Vendor returned', function () { pm.expect(json.Vendor && json.Vendor.Id).to.be.a('string'); });",
                                            "if (json.Vendor) { pm.collectionVariables.set('vendor_sync_token', String(json.Vendor.SyncToken)); }"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Query vendors (LIKE)",
                            "request": {
                                "method": "GET",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/query?query=select * from Vendor where DisplayName LIKE 'QBOC-TEST {{run_id}}%25'",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "query"
                                    ],
                                    "query": [
                                        {
                                            "key": "query",
                                            "value": "select * from Vendor where DisplayName LIKE 'QBOC-TEST {{run_id}}%25'"
                                        }
                                    ]
                                },
                                "description": "`%25` is the URL-encoded `%` wildcard."
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "const rows = (json.QueryResponse && json.QueryResponse.Vendor) || [];",
                                            "pm.test('at least 1 Vendor row(s)', function () { pm.expect(rows.length).to.be.at.least(1); });"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Update vendor (sparse)",
                            "request": {
                                "method": "POST",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    },
                                    {
                                        "key": "Content-Type",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/vendor?requestid={{request_id}}",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "vendor"
                                    ],
                                    "query": [
                                        {
                                            "key": "requestid",
                                            "value": "{{request_id}}"
                                        }
                                    ]
                                },
                                "description": "",
                                "body": {
                                    "mode": "raw",
                                    "raw": "{\n    \"Id\": \"{{vendor_id}}\",\n    \"SyncToken\": \"{{vendor_sync_token}}\",\n    \"sparse\": true,\n    \"AcctNum\": \"QBOC-{{run_id}}\"\n}",
                                    "options": {
                                        "raw": {
                                            "language": "json"
                                        }
                                    }
                                }
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "pm.test('Vendor returned', function () { pm.expect(json.Vendor && json.Vendor.Id).to.be.a('string'); });",
                                            "if (json.Vendor) { pm.collectionVariables.set('vendor_sync_token', String(json.Vendor.SyncToken)); }"
                                        ]
                                    }
                                }
                            ]
                        }
                    ]
                },
                {
                    "name": "6. Products & services (Item)",
                    "description": "Name-list entity: create, read, query, sparse update, **deactivate** (`Active: false`); no delete. `Name` must be unique.\nService items need an income account; NonInventory items here also get an expense account. Inventory items need\n`TrackQtyOnHand`, `QtyOnHand`, `InvStartDate`, an income account of detail type *Sales of Product Income*, an\ninventory asset account and a cost-of-goods-sold account (the company must track inventory). Sparse update works.\nDocs: https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/item",
                    "item": [
                        {
                            "name": "Create service item",
                            "request": {
                                "method": "POST",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    },
                                    {
                                        "key": "Content-Type",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/item?requestid={{request_id}}",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "item"
                                    ],
                                    "query": [
                                        {
                                            "key": "requestid",
                                            "value": "{{request_id}}"
                                        }
                                    ]
                                },
                                "description": "",
                                "body": {
                                    "mode": "raw",
                                    "raw": "{\n    \"Name\": \"QBOC-TEST {{run_id}} Service\",\n    \"Type\": \"Service\",\n    \"IncomeAccountRef\": {\n        \"value\": \"{{income_account_id}}\"\n    },\n    \"UnitPrice\": 100,\n    \"Description\": \"QBO Connect Postman test\"\n}",
                                    "options": {
                                        "raw": {
                                            "language": "json"
                                        }
                                    }
                                }
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "pm.test('Item returned', function () { pm.expect(json.Item && json.Item.Id).to.be.a('string'); });",
                                            "if (json.Item) { pm.collectionVariables.set('item_id', String(json.Item.Id)); }",
                                            "if (json.Item) { pm.collectionVariables.set('item_sync_token', String(json.Item.SyncToken)); }"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Create non-inventory item",
                            "request": {
                                "method": "POST",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    },
                                    {
                                        "key": "Content-Type",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/item?requestid={{request_id}}",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "item"
                                    ],
                                    "query": [
                                        {
                                            "key": "requestid",
                                            "value": "{{request_id}}"
                                        }
                                    ]
                                },
                                "description": "",
                                "body": {
                                    "mode": "raw",
                                    "raw": "{\n    \"Name\": \"QBOC-TEST {{run_id}} NonInventory\",\n    \"Type\": \"NonInventory\",\n    \"IncomeAccountRef\": {\n        \"value\": \"{{income_account_id}}\"\n    },\n    \"ExpenseAccountRef\": {\n        \"value\": \"{{expense_account_id}}\"\n    },\n    \"UnitPrice\": 25\n}",
                                    "options": {
                                        "raw": {
                                            "language": "json"
                                        }
                                    }
                                }
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "pm.test('Item returned', function () { pm.expect(json.Item && json.Item.Id).to.be.a('string'); });",
                                            "if (json.Item) { pm.collectionVariables.set('noninventory_item_id', String(json.Item.Id)); }"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Query product-sales income accounts",
                            "request": {
                                "method": "GET",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/query?query=select * from Account where AccountSubType = 'SalesOfProductIncome' and Active = true MAXRESULTS 1",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "query"
                                    ],
                                    "query": [
                                        {
                                            "key": "query",
                                            "value": "select * from Account where AccountSubType = 'SalesOfProductIncome' and Active = true MAXRESULTS 1"
                                        }
                                    ]
                                },
                                "description": "Inventory items need an income account of detail type Sales of Product Income (otherwise fault 6430)."
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "const rows = (json.QueryResponse && json.QueryResponse.Account) || [];",
                                            "pm.test('at least 1 Account row(s)', function () { pm.expect(rows.length).to.be.at.least(1); });",
                                            "if (rows.length) { pm.collectionVariables.set('product_income_account_id', String(rows[0].Id)); }"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Query inventory accounts",
                            "request": {
                                "method": "GET",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/query?query=select * from Account where AccountSubType = 'Inventory' and Active = true MAXRESULTS 1",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "query"
                                    ],
                                    "query": [
                                        {
                                            "key": "query",
                                            "value": "select * from Account where AccountSubType = 'Inventory' and Active = true MAXRESULTS 1"
                                        }
                                    ]
                                },
                                "description": ""
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "const rows = (json.QueryResponse && json.QueryResponse.Account) || [];",
                                            "pm.test('at least 1 Account row(s)', function () { pm.expect(rows.length).to.be.at.least(1); });",
                                            "if (rows.length) { pm.collectionVariables.set('asset_account_id', String(rows[0].Id)); }"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Query cost-of-goods-sold accounts",
                            "request": {
                                "method": "GET",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/query?query=select * from Account where AccountType = 'Cost of Goods Sold' and Active = true MAXRESULTS 1",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "query"
                                    ],
                                    "query": [
                                        {
                                            "key": "query",
                                            "value": "select * from Account where AccountType = 'Cost of Goods Sold' and Active = true MAXRESULTS 1"
                                        }
                                    ]
                                },
                                "description": ""
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "const rows = (json.QueryResponse && json.QueryResponse.Account) || [];",
                                            "pm.test('at least 1 Account row(s)', function () { pm.expect(rows.length).to.be.at.least(1); });",
                                            "if (rows.length) { pm.collectionVariables.set('cogs_account_id', String(rows[0].Id)); }"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Create inventory item",
                            "request": {
                                "method": "POST",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    },
                                    {
                                        "key": "Content-Type",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/item?requestid={{request_id}}",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "item"
                                    ],
                                    "query": [
                                        {
                                            "key": "requestid",
                                            "value": "{{request_id}}"
                                        }
                                    ]
                                },
                                "description": "",
                                "body": {
                                    "mode": "raw",
                                    "raw": "{\n    \"Name\": \"QBOC-TEST {{run_id}} Inventory\",\n    \"Type\": \"Inventory\",\n    \"TrackQtyOnHand\": true,\n    \"QtyOnHand\": 10,\n    \"InvStartDate\": \"2026-12-01\",\n    \"IncomeAccountRef\": {\n        \"value\": \"{{product_income_account_id}}\"\n    },\n    \"ExpenseAccountRef\": {\n        \"value\": \"{{cogs_account_id}}\"\n    },\n    \"AssetAccountRef\": {\n        \"value\": \"{{asset_account_id}}\"\n    },\n    \"UnitPrice\": 40,\n    \"PurchaseCost\": 15\n}",
                                    "options": {
                                        "raw": {
                                            "language": "json"
                                        }
                                    }
                                }
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "pm.test('Item returned', function () { pm.expect(json.Item && json.Item.Id).to.be.a('string'); });",
                                            "if (json.Item) { pm.collectionVariables.set('inventory_item_id', String(json.Item.Id)); }"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Read item",
                            "request": {
                                "method": "GET",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/item/{{item_id}}",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "item",
                                        "{{item_id}}"
                                    ]
                                },
                                "description": ""
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "pm.test('Item returned', function () { pm.expect(json.Item && json.Item.Id).to.be.a('string'); });",
                                            "if (json.Item) { pm.collectionVariables.set('item_sync_token', String(json.Item.SyncToken)); }"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Query items (Name LIKE, Type)",
                            "request": {
                                "method": "GET",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/query?query=select * from Item where Name LIKE 'QBOC-TEST {{run_id}}%25' and Type = 'Service'",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "query"
                                    ],
                                    "query": [
                                        {
                                            "key": "query",
                                            "value": "select * from Item where Name LIKE 'QBOC-TEST {{run_id}}%25' and Type = 'Service'"
                                        }
                                    ]
                                },
                                "description": ""
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "const rows = (json.QueryResponse && json.QueryResponse.Item) || [];",
                                            "pm.test('at least 1 Item row(s)', function () { pm.expect(rows.length).to.be.at.least(1); });"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Update item price (sparse)",
                            "request": {
                                "method": "POST",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    },
                                    {
                                        "key": "Content-Type",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/item?requestid={{request_id}}",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "item"
                                    ],
                                    "query": [
                                        {
                                            "key": "requestid",
                                            "value": "{{request_id}}"
                                        }
                                    ]
                                },
                                "description": "",
                                "body": {
                                    "mode": "raw",
                                    "raw": "{\n    \"Id\": \"{{item_id}}\",\n    \"SyncToken\": \"{{item_sync_token}}\",\n    \"sparse\": true,\n    \"UnitPrice\": 120,\n    \"Description\": \"Updated by QBO Connect Postman test\"\n}",
                                    "options": {
                                        "raw": {
                                            "language": "json"
                                        }
                                    }
                                }
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "pm.test('Item returned', function () { pm.expect(json.Item && json.Item.Id).to.be.a('string'); });",
                                            "if (json.Item) { pm.collectionVariables.set('item_sync_token', String(json.Item.SyncToken)); }"
                                        ]
                                    }
                                }
                            ]
                        }
                    ]
                },
                {
                    "name": "7. Invoices",
                    "description": "Transaction: create, read, query, sparse update, **PDF**, **send**, **void** (`?operation=void`), **delete**\n(`?operation=delete`). Lines need an `ItemRef`; non-US companies also need a `TaxCodeRef` per line.\nRun order matters: void and delete act on the invoice created here.\nDocs: https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/invoice",
                    "item": [
                        {
                            "name": "Create invoice",
                            "request": {
                                "method": "POST",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    },
                                    {
                                        "key": "Content-Type",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/invoice?requestid={{request_id}}",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "invoice"
                                    ],
                                    "query": [
                                        {
                                            "key": "requestid",
                                            "value": "{{request_id}}"
                                        }
                                    ]
                                },
                                "description": "Re-sending the same requestid returns the original invoice instead of creating a second one.",
                                "body": {
                                    "mode": "raw",
                                    "raw": "{\n    \"CustomerRef\": {\n        \"value\": \"{{customer_id}}\"\n    },\n    \"Line\": [\n        {\n            \"DetailType\": \"SalesItemLineDetail\",\n            \"Amount\": 240,\n            \"Description\": \"QBO Connect Postman test\",\n            \"SalesItemLineDetail\": {\n                \"ItemRef\": {\n                    \"value\": \"{{item_id}}\"\n                },\n                \"Qty\": 2,\n                \"UnitPrice\": 120,\n                \"TaxCodeRef\": {\n                    \"value\": \"{{sales_tax_code_id}}\"\n                }\n            }\n        }\n    ],\n    \"PrivateNote\": \"QBO Connect Postman test\"\n}",
                                    "options": {
                                        "raw": {
                                            "language": "json"
                                        }
                                    }
                                }
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "pm.test('Invoice returned', function () { pm.expect(json.Invoice && json.Invoice.Id).to.be.a('string'); });",
                                            "if (json.Invoice) { pm.collectionVariables.set('invoice_id', String(json.Invoice.Id)); }",
                                            "if (json.Invoice) { pm.collectionVariables.set('invoice_sync_token', String(json.Invoice.SyncToken)); }",
                                            "if (json.Invoice) { pm.collectionVariables.set('invoice_total', String(json.Invoice.TotalAmt)); }"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Read invoice",
                            "request": {
                                "method": "GET",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/invoice/{{invoice_id}}",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "invoice",
                                        "{{invoice_id}}"
                                    ]
                                },
                                "description": ""
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "pm.test('Invoice returned', function () { pm.expect(json.Invoice && json.Invoice.Id).to.be.a('string'); });",
                                            "if (json.Invoice) { pm.collectionVariables.set('invoice_sync_token', String(json.Invoice.SyncToken)); }"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Query invoices by customer",
                            "request": {
                                "method": "GET",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/query?query=select * from Invoice where CustomerRef = '{{customer_id}}' ORDERBY TxnDate DESC MAXRESULTS 10",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "query"
                                    ],
                                    "query": [
                                        {
                                            "key": "query",
                                            "value": "select * from Invoice where CustomerRef = '{{customer_id}}' ORDERBY TxnDate DESC MAXRESULTS 10"
                                        }
                                    ]
                                },
                                "description": ""
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "const rows = (json.QueryResponse && json.QueryResponse.Invoice) || [];",
                                            "pm.test('at least 1 Invoice row(s)', function () { pm.expect(rows.length).to.be.at.least(1); });"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Query open invoices (Balance > 0)",
                            "request": {
                                "method": "GET",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/query?query=select * from Invoice where Balance > '0' ORDERBY DueDate STARTPOSITION 1 MAXRESULTS 20",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "query"
                                    ],
                                    "query": [
                                        {
                                            "key": "query",
                                            "value": "select * from Invoice where Balance > '0' ORDERBY DueDate STARTPOSITION 1 MAXRESULTS 20"
                                        }
                                    ]
                                },
                                "description": ""
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "const rows = (json.QueryResponse && json.QueryResponse.Invoice) || [];"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Update invoice (sparse)",
                            "request": {
                                "method": "POST",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    },
                                    {
                                        "key": "Content-Type",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/invoice?requestid={{request_id}}",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "invoice"
                                    ],
                                    "query": [
                                        {
                                            "key": "requestid",
                                            "value": "{{request_id}}"
                                        }
                                    ]
                                },
                                "description": "",
                                "body": {
                                    "mode": "raw",
                                    "raw": "{\n    \"Id\": \"{{invoice_id}}\",\n    \"SyncToken\": \"{{invoice_sync_token}}\",\n    \"sparse\": true,\n    \"PrivateNote\": \"Updated by QBO Connect Postman test\",\n    \"DueDate\": \"2026-12-31\"\n}",
                                    "options": {
                                        "raw": {
                                            "language": "json"
                                        }
                                    }
                                }
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "pm.test('Invoice returned', function () { pm.expect(json.Invoice && json.Invoice.Id).to.be.a('string'); });",
                                            "if (json.Invoice) { pm.collectionVariables.set('invoice_sync_token', String(json.Invoice.SyncToken)); }"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Download invoice PDF",
                            "request": {
                                "method": "GET",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/pdf"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/invoice/{{invoice_id}}/pdf",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "invoice",
                                        "{{invoice_id}}",
                                        "pdf"
                                    ]
                                },
                                "description": "`Accept: application/pdf`; the proxy relays the PDF bytes and Content-Type."
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "pm.test('PDF returned', function () { pm.expect(pm.response.headers.get('Content-Type')).to.include('application/pdf'); });"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Send invoice by e-mail",
                            "request": {
                                "method": "POST",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    },
                                    {
                                        "key": "Content-Type",
                                        "value": "application/octet-stream"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/invoice/{{invoice_id}}/send?sendTo={{test_email}}&requestid={{request_id}}",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "invoice",
                                        "{{invoice_id}}",
                                        "send"
                                    ],
                                    "query": [
                                        {
                                            "key": "sendTo",
                                            "value": "{{test_email}}"
                                        },
                                        {
                                            "key": "requestid",
                                            "value": "{{request_id}}"
                                        }
                                    ]
                                },
                                "description": "Empty body, `Content-Type: application/octet-stream`. Sandbox limit: 40 e-mails per day per company. Uses a reserved example.com address.",
                                "body": {
                                    "mode": "raw",
                                    "raw": "",
                                    "options": {
                                        "raw": {
                                            "language": "text"
                                        }
                                    }
                                }
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "pm.test('Invoice returned', function () { pm.expect(json.Invoice && json.Invoice.Id).to.be.a('string'); });",
                                            "if (json.Invoice) { pm.collectionVariables.set('invoice_sync_token', String(json.Invoice.SyncToken)); }",
                                            "pm.test('EmailStatus set', function () { pm.expect(json.Invoice.EmailStatus).to.be.a('string'); });"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Void invoice",
                            "request": {
                                "method": "POST",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    },
                                    {
                                        "key": "Content-Type",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/invoice?operation=void&requestid={{request_id}}",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "invoice"
                                    ],
                                    "query": [
                                        {
                                            "key": "operation",
                                            "value": "void"
                                        },
                                        {
                                            "key": "requestid",
                                            "value": "{{request_id}}"
                                        }
                                    ]
                                },
                                "description": "Keeps the invoice with zero amounts (audit trail); linked payments become unapplied.",
                                "body": {
                                    "mode": "raw",
                                    "raw": "{\n    \"Id\": \"{{invoice_id}}\",\n    \"SyncToken\": \"{{invoice_sync_token}}\"\n}",
                                    "options": {
                                        "raw": {
                                            "language": "json"
                                        }
                                    }
                                }
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "pm.test('Invoice returned', function () { pm.expect(json.Invoice && json.Invoice.Id).to.be.a('string'); });",
                                            "if (json.Invoice) { pm.collectionVariables.set('invoice_sync_token', String(json.Invoice.SyncToken)); }"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Delete invoice",
                            "request": {
                                "method": "POST",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    },
                                    {
                                        "key": "Content-Type",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/invoice?operation=delete&requestid={{request_id}}",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "invoice"
                                    ],
                                    "query": [
                                        {
                                            "key": "operation",
                                            "value": "delete"
                                        },
                                        {
                                            "key": "requestid",
                                            "value": "{{request_id}}"
                                        }
                                    ]
                                },
                                "description": "",
                                "body": {
                                    "mode": "raw",
                                    "raw": "{\n    \"Id\": \"{{invoice_id}}\",\n    \"SyncToken\": \"{{invoice_sync_token}}\"\n}",
                                    "options": {
                                        "raw": {
                                            "language": "json"
                                        }
                                    }
                                }
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "pm.test('Invoice Deleted', function () { pm.expect(json.Invoice && json.Invoice.status).to.eql('Deleted'); });"
                                        ]
                                    }
                                }
                            ]
                        }
                    ]
                },
                {
                    "name": "8. Customer payments (Payment)",
                    "description": "Self-contained: creates its own invoice, pays it in full, voids and deletes the payment, then deletes the invoice.\nVoid is `?operation=update&include=void` with a sparse body.\nDocs: https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/payment",
                    "item": [
                        {
                            "name": "Create invoice to pay",
                            "request": {
                                "method": "POST",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    },
                                    {
                                        "key": "Content-Type",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/invoice?requestid={{request_id}}",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "invoice"
                                    ],
                                    "query": [
                                        {
                                            "key": "requestid",
                                            "value": "{{request_id}}"
                                        }
                                    ]
                                },
                                "description": "",
                                "body": {
                                    "mode": "raw",
                                    "raw": "{\n    \"CustomerRef\": {\n        \"value\": \"{{customer_id}}\"\n    },\n    \"Line\": [\n        {\n            \"DetailType\": \"SalesItemLineDetail\",\n            \"Amount\": 100,\n            \"Description\": \"QBO Connect Postman test\",\n            \"SalesItemLineDetail\": {\n                \"ItemRef\": {\n                    \"value\": \"{{item_id}}\"\n                },\n                \"Qty\": 1,\n                \"UnitPrice\": 100,\n                \"TaxCodeRef\": {\n                    \"value\": \"{{sales_tax_code_id}}\"\n                }\n            }\n        }\n    ],\n    \"PrivateNote\": \"QBO Connect Postman test (payment)\"\n}",
                                    "options": {
                                        "raw": {
                                            "language": "json"
                                        }
                                    }
                                }
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "pm.test('Invoice returned', function () { pm.expect(json.Invoice && json.Invoice.Id).to.be.a('string'); });",
                                            "if (json.Invoice) { pm.collectionVariables.set('pay_invoice_id', String(json.Invoice.Id)); }",
                                            "if (json.Invoice) { pm.collectionVariables.set('pay_invoice_total', String(json.Invoice.TotalAmt)); }"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Create payment",
                            "request": {
                                "method": "POST",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    },
                                    {
                                        "key": "Content-Type",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/payment?requestid={{request_id}}",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "payment"
                                    ],
                                    "query": [
                                        {
                                            "key": "requestid",
                                            "value": "{{request_id}}"
                                        }
                                    ]
                                },
                                "description": "`TotalAmt` and the line `Amount` are the invoice total; `LinkedTxn` applies the payment to the invoice.",
                                "body": {
                                    "mode": "raw",
                                    "raw": "{\n    \"CustomerRef\": {\n        \"value\": \"{{customer_id}}\"\n    },\n    \"TotalAmt\": {{pay_invoice_total}},\n    \"Line\": [\n        {\n            \"Amount\": {{pay_invoice_total}},\n            \"LinkedTxn\": [\n                {\n                    \"TxnId\": \"{{pay_invoice_id}}\",\n                    \"TxnType\": \"Invoice\"\n                }\n            ]\n        }\n    ]\n}",
                                    "options": {
                                        "raw": {
                                            "language": "json"
                                        }
                                    }
                                }
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "pm.test('Payment returned', function () { pm.expect(json.Payment && json.Payment.Id).to.be.a('string'); });",
                                            "if (json.Payment) { pm.collectionVariables.set('payment_id', String(json.Payment.Id)); }",
                                            "if (json.Payment) { pm.collectionVariables.set('payment_sync_token', String(json.Payment.SyncToken)); }"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Read payment",
                            "request": {
                                "method": "GET",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/payment/{{payment_id}}",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "payment",
                                        "{{payment_id}}"
                                    ]
                                },
                                "description": ""
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "pm.test('Payment returned', function () { pm.expect(json.Payment && json.Payment.Id).to.be.a('string'); });",
                                            "if (json.Payment) { pm.collectionVariables.set('payment_sync_token', String(json.Payment.SyncToken)); }"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Query payments by customer",
                            "request": {
                                "method": "GET",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/query?query=select * from Payment where CustomerRef = '{{customer_id}}'",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "query"
                                    ],
                                    "query": [
                                        {
                                            "key": "query",
                                            "value": "select * from Payment where CustomerRef = '{{customer_id}}'"
                                        }
                                    ]
                                },
                                "description": ""
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "const rows = (json.QueryResponse && json.QueryResponse.Payment) || [];",
                                            "pm.test('at least 1 Payment row(s)', function () { pm.expect(rows.length).to.be.at.least(1); });"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Void payment",
                            "request": {
                                "method": "POST",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    },
                                    {
                                        "key": "Content-Type",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/payment?operation=update&include=void&requestid={{request_id}}",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "payment"
                                    ],
                                    "query": [
                                        {
                                            "key": "operation",
                                            "value": "update"
                                        },
                                        {
                                            "key": "include",
                                            "value": "void"
                                        },
                                        {
                                            "key": "requestid",
                                            "value": "{{request_id}}"
                                        }
                                    ]
                                },
                                "description": "",
                                "body": {
                                    "mode": "raw",
                                    "raw": "{\n    \"Id\": \"{{payment_id}}\",\n    \"SyncToken\": \"{{payment_sync_token}}\",\n    \"sparse\": true\n}",
                                    "options": {
                                        "raw": {
                                            "language": "json"
                                        }
                                    }
                                }
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "pm.test('Payment returned', function () { pm.expect(json.Payment && json.Payment.Id).to.be.a('string'); });",
                                            "if (json.Payment) { pm.collectionVariables.set('payment_sync_token', String(json.Payment.SyncToken)); }"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Delete payment",
                            "request": {
                                "method": "POST",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    },
                                    {
                                        "key": "Content-Type",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/payment?operation=delete&requestid={{request_id}}",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "payment"
                                    ],
                                    "query": [
                                        {
                                            "key": "operation",
                                            "value": "delete"
                                        },
                                        {
                                            "key": "requestid",
                                            "value": "{{request_id}}"
                                        }
                                    ]
                                },
                                "description": "",
                                "body": {
                                    "mode": "raw",
                                    "raw": "{\n    \"Id\": \"{{payment_id}}\",\n    \"SyncToken\": \"{{payment_sync_token}}\"\n}",
                                    "options": {
                                        "raw": {
                                            "language": "json"
                                        }
                                    }
                                }
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "pm.test('Payment Deleted', function () { pm.expect(json.Payment && json.Payment.status).to.eql('Deleted'); });"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Read invoice to pay (refresh SyncToken)",
                            "request": {
                                "method": "GET",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/invoice/{{pay_invoice_id}}",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "invoice",
                                        "{{pay_invoice_id}}"
                                    ]
                                },
                                "description": ""
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "pm.test('Invoice returned', function () { pm.expect(json.Invoice && json.Invoice.Id).to.be.a('string'); });",
                                            "if (json.Invoice) { pm.collectionVariables.set('pay_invoice_sync_token', String(json.Invoice.SyncToken)); }"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Delete invoice to pay",
                            "request": {
                                "method": "POST",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    },
                                    {
                                        "key": "Content-Type",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/invoice?operation=delete&requestid={{request_id}}",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "invoice"
                                    ],
                                    "query": [
                                        {
                                            "key": "operation",
                                            "value": "delete"
                                        },
                                        {
                                            "key": "requestid",
                                            "value": "{{request_id}}"
                                        }
                                    ]
                                },
                                "description": "Leaves the test customer without an open balance, so 12. Cleanup can deactivate it.",
                                "body": {
                                    "mode": "raw",
                                    "raw": "{\n    \"Id\": \"{{pay_invoice_id}}\",\n    \"SyncToken\": \"{{pay_invoice_sync_token}}\"\n}",
                                    "options": {
                                        "raw": {
                                            "language": "json"
                                        }
                                    }
                                }
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "pm.test('Invoice Deleted', function () { pm.expect(json.Invoice && json.Invoice.status).to.eql('Deleted'); });"
                                        ]
                                    }
                                }
                            ]
                        }
                    ]
                },
                {
                    "name": "9. Credit memos",
                    "description": "Transaction: create, read, query, sparse update, delete.\nDocs: https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/creditmemo",
                    "item": [
                        {
                            "name": "Create credit memo",
                            "request": {
                                "method": "POST",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    },
                                    {
                                        "key": "Content-Type",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/creditmemo?requestid={{request_id}}",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "creditmemo"
                                    ],
                                    "query": [
                                        {
                                            "key": "requestid",
                                            "value": "{{request_id}}"
                                        }
                                    ]
                                },
                                "description": "",
                                "body": {
                                    "mode": "raw",
                                    "raw": "{\n    \"CustomerRef\": {\n        \"value\": \"{{customer_id}}\"\n    },\n    \"Line\": [\n        {\n            \"DetailType\": \"SalesItemLineDetail\",\n            \"Amount\": 30,\n            \"Description\": \"QBO Connect Postman test\",\n            \"SalesItemLineDetail\": {\n                \"ItemRef\": {\n                    \"value\": \"{{item_id}}\"\n                },\n                \"Qty\": 1,\n                \"UnitPrice\": 30,\n                \"TaxCodeRef\": {\n                    \"value\": \"{{sales_tax_code_id}}\"\n                }\n            }\n        }\n    ],\n    \"PrivateNote\": \"QBO Connect Postman test\"\n}",
                                    "options": {
                                        "raw": {
                                            "language": "json"
                                        }
                                    }
                                }
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "pm.test('CreditMemo returned', function () { pm.expect(json.CreditMemo && json.CreditMemo.Id).to.be.a('string'); });",
                                            "if (json.CreditMemo) { pm.collectionVariables.set('creditmemo_id', String(json.CreditMemo.Id)); }",
                                            "if (json.CreditMemo) { pm.collectionVariables.set('creditmemo_sync_token', String(json.CreditMemo.SyncToken)); }"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Read credit memo",
                            "request": {
                                "method": "GET",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/creditmemo/{{creditmemo_id}}",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "creditmemo",
                                        "{{creditmemo_id}}"
                                    ]
                                },
                                "description": ""
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "pm.test('CreditMemo returned', function () { pm.expect(json.CreditMemo && json.CreditMemo.Id).to.be.a('string'); });",
                                            "if (json.CreditMemo) { pm.collectionVariables.set('creditmemo_sync_token', String(json.CreditMemo.SyncToken)); }"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Query credit memos by customer",
                            "request": {
                                "method": "GET",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/query?query=select * from CreditMemo where CustomerRef = '{{customer_id}}'",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "query"
                                    ],
                                    "query": [
                                        {
                                            "key": "query",
                                            "value": "select * from CreditMemo where CustomerRef = '{{customer_id}}'"
                                        }
                                    ]
                                },
                                "description": ""
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "const rows = (json.QueryResponse && json.QueryResponse.CreditMemo) || [];",
                                            "pm.test('at least 1 CreditMemo row(s)', function () { pm.expect(rows.length).to.be.at.least(1); });"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Update credit memo (sparse)",
                            "request": {
                                "method": "POST",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    },
                                    {
                                        "key": "Content-Type",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/creditmemo?requestid={{request_id}}",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "creditmemo"
                                    ],
                                    "query": [
                                        {
                                            "key": "requestid",
                                            "value": "{{request_id}}"
                                        }
                                    ]
                                },
                                "description": "",
                                "body": {
                                    "mode": "raw",
                                    "raw": "{\n    \"Id\": \"{{creditmemo_id}}\",\n    \"SyncToken\": \"{{creditmemo_sync_token}}\",\n    \"sparse\": true,\n    \"PrivateNote\": \"Updated by QBO Connect Postman test\"\n}",
                                    "options": {
                                        "raw": {
                                            "language": "json"
                                        }
                                    }
                                }
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "pm.test('CreditMemo returned', function () { pm.expect(json.CreditMemo && json.CreditMemo.Id).to.be.a('string'); });",
                                            "if (json.CreditMemo) { pm.collectionVariables.set('creditmemo_sync_token', String(json.CreditMemo.SyncToken)); }"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Delete credit memo",
                            "request": {
                                "method": "POST",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    },
                                    {
                                        "key": "Content-Type",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/creditmemo?operation=delete&requestid={{request_id}}",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "creditmemo"
                                    ],
                                    "query": [
                                        {
                                            "key": "operation",
                                            "value": "delete"
                                        },
                                        {
                                            "key": "requestid",
                                            "value": "{{request_id}}"
                                        }
                                    ]
                                },
                                "description": "",
                                "body": {
                                    "mode": "raw",
                                    "raw": "{\n    \"Id\": \"{{creditmemo_id}}\",\n    \"SyncToken\": \"{{creditmemo_sync_token}}\"\n}",
                                    "options": {
                                        "raw": {
                                            "language": "json"
                                        }
                                    }
                                }
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "pm.test('CreditMemo Deleted', function () { pm.expect(json.CreditMemo && json.CreditMemo.status).to.eql('Deleted'); });"
                                        ]
                                    }
                                }
                            ]
                        }
                    ]
                },
                {
                    "name": "10. Bills & bill payments",
                    "description": "Bill: create, read, query, **full** update (sparse is rejected), delete. BillPayment (pay a bill by cheque/bank or credit card): create,\nread, query, void (`?operation=update&include=void`), delete. Delete the bill payment before the bill.\nDocs: https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/bill · https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/billpayment",
                    "item": [
                        {
                            "name": "Create bill",
                            "request": {
                                "method": "POST",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    },
                                    {
                                        "key": "Content-Type",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/bill?requestid={{request_id}}",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "bill"
                                    ],
                                    "query": [
                                        {
                                            "key": "requestid",
                                            "value": "{{request_id}}"
                                        }
                                    ]
                                },
                                "description": "Expense lines use AccountBasedExpenseLineDetail (an expense account); item lines use ItemBasedExpenseLineDetail.",
                                "body": {
                                    "mode": "raw",
                                    "raw": "{\n    \"VendorRef\": {\n        \"value\": \"{{vendor_id}}\"\n    },\n    \"Line\": [\n        {\n            \"DetailType\": \"AccountBasedExpenseLineDetail\",\n            \"Amount\": 80,\n            \"Description\": \"QBO Connect Postman test\",\n            \"AccountBasedExpenseLineDetail\": {\n                \"AccountRef\": {\n                    \"value\": \"{{expense_account_id}}\"\n                },\n                \"TaxCodeRef\": {\n                    \"value\": \"{{purchase_tax_code_id}}\"\n                }\n            }\n        }\n    ],\n    \"PrivateNote\": \"QBO Connect Postman test\"\n}",
                                    "options": {
                                        "raw": {
                                            "language": "json"
                                        }
                                    }
                                }
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "pm.test('Bill returned', function () { pm.expect(json.Bill && json.Bill.Id).to.be.a('string'); });",
                                            "if (json.Bill) { pm.collectionVariables.set('bill_id', String(json.Bill.Id)); }",
                                            "if (json.Bill) { pm.collectionVariables.set('bill_sync_token', String(json.Bill.SyncToken)); }",
                                            "if (json.Bill) { pm.collectionVariables.set('bill_total', String(json.Bill.TotalAmt)); }"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Read bill",
                            "request": {
                                "method": "GET",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/bill/{{bill_id}}",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "bill",
                                        "{{bill_id}}"
                                    ]
                                },
                                "description": ""
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "pm.test('Bill returned', function () { pm.expect(json.Bill && json.Bill.Id).to.be.a('string'); });",
                                            "if (json.Bill) { pm.collectionVariables.set('bill_sync_token', String(json.Bill.SyncToken)); }"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Query bills by vendor",
                            "request": {
                                "method": "GET",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/query?query=select * from Bill where VendorRef = '{{vendor_id}}'",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "query"
                                    ],
                                    "query": [
                                        {
                                            "key": "query",
                                            "value": "select * from Bill where VendorRef = '{{vendor_id}}'"
                                        }
                                    ]
                                },
                                "description": ""
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "const rows = (json.QueryResponse && json.QueryResponse.Bill) || [];",
                                            "pm.test('at least 1 Bill row(s)', function () { pm.expect(rows.length).to.be.at.least(1); });"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Update bill (full)",
                            "request": {
                                "method": "POST",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    },
                                    {
                                        "key": "Content-Type",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/bill?requestid={{request_id}}",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "bill"
                                    ],
                                    "query": [
                                        {
                                            "key": "requestid",
                                            "value": "{{request_id}}"
                                        }
                                    ]
                                },
                                "description": "Bills need a FULL update: a sparse update is rejected with fault 2020 \"Required parameter VendorRef is missing\" (verified on the sandbox). Send every field you want to keep; omitted writable fields are cleared.",
                                "body": {
                                    "mode": "raw",
                                    "raw": "{\n    \"Id\": \"{{bill_id}}\",\n    \"SyncToken\": \"{{bill_sync_token}}\",\n    \"sparse\": false,\n    \"VendorRef\": {\n        \"value\": \"{{vendor_id}}\"\n    },\n    \"Line\": [\n        {\n            \"DetailType\": \"AccountBasedExpenseLineDetail\",\n            \"Amount\": 80,\n            \"Description\": \"QBO Connect Postman test\",\n            \"AccountBasedExpenseLineDetail\": {\n                \"AccountRef\": {\n                    \"value\": \"{{expense_account_id}}\"\n                },\n                \"TaxCodeRef\": {\n                    \"value\": \"{{purchase_tax_code_id}}\"\n                }\n            }\n        }\n    ],\n    \"PrivateNote\": \"Updated by QBO Connect Postman test\",\n    \"DueDate\": \"2026-12-31\"\n}",
                                    "options": {
                                        "raw": {
                                            "language": "json"
                                        }
                                    }
                                }
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "pm.test('Bill returned', function () { pm.expect(json.Bill && json.Bill.Id).to.be.a('string'); });",
                                            "if (json.Bill) { pm.collectionVariables.set('bill_sync_token', String(json.Bill.SyncToken)); }"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Create bill payment (cheque)",
                            "request": {
                                "method": "POST",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    },
                                    {
                                        "key": "Content-Type",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/billpayment?requestid={{request_id}}",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "billpayment"
                                    ],
                                    "query": [
                                        {
                                            "key": "requestid",
                                            "value": "{{request_id}}"
                                        }
                                    ]
                                },
                                "description": "PayType Check needs CheckPayment.BankAccountRef; PayType CreditCard needs CreditCardPayment.CCAccountRef.",
                                "body": {
                                    "mode": "raw",
                                    "raw": "{\n    \"VendorRef\": {\n        \"value\": \"{{vendor_id}}\"\n    },\n    \"PayType\": \"Check\",\n    \"CheckPayment\": {\n        \"BankAccountRef\": {\n            \"value\": \"{{bank_account_id}}\"\n        }\n    },\n    \"TotalAmt\": {{bill_total}},\n    \"Line\": [\n        {\n            \"Amount\": {{bill_total}},\n            \"LinkedTxn\": [\n                {\n                    \"TxnId\": \"{{bill_id}}\",\n                    \"TxnType\": \"Bill\"\n                }\n            ]\n        }\n    ]\n}",
                                    "options": {
                                        "raw": {
                                            "language": "json"
                                        }
                                    }
                                }
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "pm.test('BillPayment returned', function () { pm.expect(json.BillPayment && json.BillPayment.Id).to.be.a('string'); });",
                                            "if (json.BillPayment) { pm.collectionVariables.set('billpayment_id', String(json.BillPayment.Id)); }",
                                            "if (json.BillPayment) { pm.collectionVariables.set('billpayment_sync_token', String(json.BillPayment.SyncToken)); }"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Read bill payment",
                            "request": {
                                "method": "GET",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/billpayment/{{billpayment_id}}",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "billpayment",
                                        "{{billpayment_id}}"
                                    ]
                                },
                                "description": ""
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "pm.test('BillPayment returned', function () { pm.expect(json.BillPayment && json.BillPayment.Id).to.be.a('string'); });",
                                            "if (json.BillPayment) { pm.collectionVariables.set('billpayment_sync_token', String(json.BillPayment.SyncToken)); }"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Query bill payments by vendor",
                            "request": {
                                "method": "GET",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/query?query=select * from BillPayment where VendorRef = '{{vendor_id}}'",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "query"
                                    ],
                                    "query": [
                                        {
                                            "key": "query",
                                            "value": "select * from BillPayment where VendorRef = '{{vendor_id}}'"
                                        }
                                    ]
                                },
                                "description": ""
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "const rows = (json.QueryResponse && json.QueryResponse.BillPayment) || [];",
                                            "pm.test('at least 1 BillPayment row(s)', function () { pm.expect(rows.length).to.be.at.least(1); });"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Void bill payment",
                            "request": {
                                "method": "POST",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    },
                                    {
                                        "key": "Content-Type",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/billpayment?operation=update&include=void&requestid={{request_id}}",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "billpayment"
                                    ],
                                    "query": [
                                        {
                                            "key": "operation",
                                            "value": "update"
                                        },
                                        {
                                            "key": "include",
                                            "value": "void"
                                        },
                                        {
                                            "key": "requestid",
                                            "value": "{{request_id}}"
                                        }
                                    ]
                                },
                                "description": "",
                                "body": {
                                    "mode": "raw",
                                    "raw": "{\n    \"Id\": \"{{billpayment_id}}\",\n    \"SyncToken\": \"{{billpayment_sync_token}}\",\n    \"sparse\": true\n}",
                                    "options": {
                                        "raw": {
                                            "language": "json"
                                        }
                                    }
                                }
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "pm.test('BillPayment returned', function () { pm.expect(json.BillPayment && json.BillPayment.Id).to.be.a('string'); });",
                                            "if (json.BillPayment) { pm.collectionVariables.set('billpayment_sync_token', String(json.BillPayment.SyncToken)); }"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Delete bill payment",
                            "request": {
                                "method": "POST",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    },
                                    {
                                        "key": "Content-Type",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/billpayment?operation=delete&requestid={{request_id}}",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "billpayment"
                                    ],
                                    "query": [
                                        {
                                            "key": "operation",
                                            "value": "delete"
                                        },
                                        {
                                            "key": "requestid",
                                            "value": "{{request_id}}"
                                        }
                                    ]
                                },
                                "description": "",
                                "body": {
                                    "mode": "raw",
                                    "raw": "{\n    \"Id\": \"{{billpayment_id}}\",\n    \"SyncToken\": \"{{billpayment_sync_token}}\"\n}",
                                    "options": {
                                        "raw": {
                                            "language": "json"
                                        }
                                    }
                                }
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "pm.test('BillPayment Deleted', function () { pm.expect(json.BillPayment && json.BillPayment.status).to.eql('Deleted'); });"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Read bill (refresh SyncToken)",
                            "request": {
                                "method": "GET",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/bill/{{bill_id}}",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "bill",
                                        "{{bill_id}}"
                                    ]
                                },
                                "description": ""
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "pm.test('Bill returned', function () { pm.expect(json.Bill && json.Bill.Id).to.be.a('string'); });",
                                            "if (json.Bill) { pm.collectionVariables.set('bill_sync_token', String(json.Bill.SyncToken)); }"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Delete bill",
                            "request": {
                                "method": "POST",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    },
                                    {
                                        "key": "Content-Type",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/bill?operation=delete&requestid={{request_id}}",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "bill"
                                    ],
                                    "query": [
                                        {
                                            "key": "operation",
                                            "value": "delete"
                                        },
                                        {
                                            "key": "requestid",
                                            "value": "{{request_id}}"
                                        }
                                    ]
                                },
                                "description": "",
                                "body": {
                                    "mode": "raw",
                                    "raw": "{\n    \"Id\": \"{{bill_id}}\",\n    \"SyncToken\": \"{{bill_sync_token}}\"\n}",
                                    "options": {
                                        "raw": {
                                            "language": "json"
                                        }
                                    }
                                }
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "pm.test('Bill Deleted', function () { pm.expect(json.Bill && json.Bill.status).to.eql('Deleted'); });"
                                        ]
                                    }
                                }
                            ]
                        }
                    ]
                },
                {
                    "name": "11. Pagination, filtering, CDC & batch",
                    "description": "Query language: `select * | count(*) from Entity [where ...] [orderby ...] [startposition n] [maxresults n]`\n(STARTPOSITION is 1-based; MAXRESULTS max 1000). Batch: up to 30 items per request, 40 batch requests per minute per\ncompany (the proxy enforces 40/min); each item succeeds or fails on its own (`BatchItemResponse[].Fault`).\nDocs: https://developer.intuit.com/app/developer/qbo/docs/learn/explore-the-quickbooks-online-api/data-queries ·\nhttps://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/batch · https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/changedatacapture",
                    "item": [
                        {
                            "name": "Count customers",
                            "request": {
                                "method": "GET",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/query?query=select count(*) from Customer",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "query"
                                    ],
                                    "query": [
                                        {
                                            "key": "query",
                                            "value": "select count(*) from Customer"
                                        }
                                    ]
                                },
                                "description": ""
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('totalCount', function () { pm.expect(json.QueryResponse.totalCount).to.be.a('number'); });"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Page through customers",
                            "request": {
                                "method": "GET",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/query?query=select * from Customer ORDERBY Id STARTPOSITION {{start_position}} MAXRESULTS {{max_results}}",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "query"
                                    ],
                                    "query": [
                                        {
                                            "key": "query",
                                            "value": "select * from Customer ORDERBY Id STARTPOSITION {{start_position}} MAXRESULTS {{max_results}}"
                                        }
                                    ]
                                },
                                "description": "Set start_position / max_results; the test moves start_position to the next page (resets to 1 after the last page)."
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "const rows = (json.QueryResponse && json.QueryResponse.Customer) || [];",
                                            "const size = Number(pm.collectionVariables.get('max_results'));",
                                            "pm.collectionVariables.set('start_position', String(rows.length < size ? 1 : Number(pm.collectionVariables.get('start_position')) + size));"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Filter: include inactive items (Active IN)",
                            "request": {
                                "method": "GET",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/query?query=select * from Item where Active IN (true, false) and Name LIKE 'QBOC-TEST%25' MAXRESULTS 50",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "query"
                                    ],
                                    "query": [
                                        {
                                            "key": "query",
                                            "value": "select * from Item where Active IN (true, false) and Name LIKE 'QBOC-TEST%25' MAXRESULTS 50"
                                        }
                                    ]
                                },
                                "description": ""
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "const rows = (json.QueryResponse && json.QueryResponse.Item) || [];"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Query (POST, application/text)",
                            "request": {
                                "method": "POST",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    },
                                    {
                                        "key": "Content-Type",
                                        "value": "application/text"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/query?requestid={{request_id}}",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "query"
                                    ],
                                    "query": [
                                        {
                                            "key": "requestid",
                                            "value": "{{request_id}}"
                                        }
                                    ]
                                },
                                "description": "Long or complex statements can be sent in the body instead of the URL.",
                                "body": {
                                    "mode": "raw",
                                    "raw": "select * from Vendor MAXRESULTS 3",
                                    "options": {
                                        "raw": {
                                            "language": "text"
                                        }
                                    }
                                }
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "const rows = (json.QueryResponse && json.QueryResponse.Vendor) || [];"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Change data capture (CDC)",
                            "request": {
                                "method": "GET",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/cdc?entities=Customer,Vendor,Item,Invoice,Bill,Payment&changedSince={{changed_since}}",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "cdc"
                                    ],
                                    "query": [
                                        {
                                            "key": "entities",
                                            "value": "Customer,Vendor,Item,Invoice,Bill,Payment"
                                        },
                                        {
                                            "key": "changedSince",
                                            "value": "{{changed_since}}"
                                        }
                                    ]
                                },
                                "description": "Changes (incl. deletes) since a time up to 30 days ago; at most 1000 objects per response."
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('CDCResponse', function () { pm.expect(json.CDCResponse).to.be.an('array'); });"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Batch 1: create invoice + credit memo + query + failing item",
                            "request": {
                                "method": "POST",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    },
                                    {
                                        "key": "Content-Type",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/batch?requestid={{request_id}}",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "batch"
                                    ],
                                    "query": [
                                        {
                                            "key": "requestid",
                                            "value": "{{request_id}}"
                                        }
                                    ]
                                },
                                "description": "Intuit: use batch for transactions, not for list entities (customers, vendors, items), and items in one batch must not depend on each other. \"bad\" references ids that do not exist, to show a per-item Fault while the other items succeed.",
                                "body": {
                                    "mode": "raw",
                                    "raw": "{\n    \"BatchItemRequest\": [\n        {\n            \"bId\": \"inv\",\n            \"operation\": \"create\",\n            \"Invoice\": {\n                \"CustomerRef\": {\n                    \"value\": \"{{customer_id}}\"\n                },\n                \"Line\": [\n                    {\n                        \"DetailType\": \"SalesItemLineDetail\",\n                        \"Amount\": 10,\n                        \"Description\": \"QBO Connect Postman test\",\n                        \"SalesItemLineDetail\": {\n                            \"ItemRef\": {\n                                \"value\": \"{{item_id}}\"\n                            },\n                            \"Qty\": 1,\n                            \"UnitPrice\": 10,\n                            \"TaxCodeRef\": {\n                                \"value\": \"{{sales_tax_code_id}}\"\n                            }\n                        }\n                    }\n                ],\n                \"PrivateNote\": \"QBO Connect Postman batch\"\n            }\n        },\n        {\n            \"bId\": \"cm\",\n            \"operation\": \"create\",\n            \"CreditMemo\": {\n                \"CustomerRef\": {\n                    \"value\": \"{{customer_id}}\"\n                },\n                \"Line\": [\n                    {\n                        \"DetailType\": \"SalesItemLineDetail\",\n                        \"Amount\": 5,\n                        \"Description\": \"QBO Connect Postman test\",\n                        \"SalesItemLineDetail\": {\n                            \"ItemRef\": {\n                                \"value\": \"{{item_id}}\"\n                            },\n                            \"Qty\": 1,\n                            \"UnitPrice\": 5,\n                            \"TaxCodeRef\": {\n                                \"value\": \"{{sales_tax_code_id}}\"\n                            }\n                        }\n                    }\n                ],\n                \"PrivateNote\": \"QBO Connect Postman batch\"\n            }\n        },\n        {\n            \"bId\": \"q\",\n            \"Query\": \"select * from Invoice where CustomerRef = '{{customer_id}}' MAXRESULTS 5\"\n        },\n        {\n            \"bId\": \"bad\",\n            \"operation\": \"create\",\n            \"Invoice\": {\n                \"CustomerRef\": {\n                    \"value\": \"999999999\"\n                },\n                \"Line\": [\n                    {\n                        \"DetailType\": \"SalesItemLineDetail\",\n                        \"Amount\": 1,\n                        \"SalesItemLineDetail\": {\n                            \"ItemRef\": {\n                                \"value\": \"999999999\"\n                            }\n                        }\n                    }\n                ]\n            }\n        }\n    ]\n}",
                                    "options": {
                                        "raw": {
                                            "language": "json"
                                        }
                                    }
                                }
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "const byId = {}; (json.BatchItemResponse || []).forEach(function (r) { byId[r.bId] = r; });",
                                            "pm.test('one response per item', function () { pm.expect(Object.keys(byId).length).to.eql(4); });",
                                            "pm.test('inv created an invoice', function () { pm.expect(byId.inv && byId.inv.Invoice && byId.inv.Invoice.Id).to.be.a('string'); });",
                                            "pm.test('cm created a credit memo', function () { pm.expect(byId.cm && byId.cm.CreditMemo && byId.cm.CreditMemo.Id).to.be.a('string'); });",
                                            "pm.test('q returned a QueryResponse', function () { pm.expect(byId.q && byId.q.QueryResponse).to.be.an('object'); });",
                                            "pm.test('bad failed on its own', function () { pm.expect(byId.bad && byId.bad.Fault).to.be.an('object'); });",
                                            "if (byId.inv && byId.inv.Invoice) { pm.collectionVariables.set('batch_invoice_id', byId.inv.Invoice.Id); pm.collectionVariables.set('batch_invoice_sync_token', byId.inv.Invoice.SyncToken); }",
                                            "if (byId.cm && byId.cm.CreditMemo) { pm.collectionVariables.set('batch_creditmemo_id', byId.cm.CreditMemo.Id); pm.collectionVariables.set('batch_creditmemo_sync_token', byId.cm.CreditMemo.SyncToken); }"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Batch 2: sparse update + delete",
                            "request": {
                                "method": "POST",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    },
                                    {
                                        "key": "Content-Type",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/batch?requestid={{request_id}}",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "batch"
                                    ],
                                    "query": [
                                        {
                                            "key": "requestid",
                                            "value": "{{request_id}}"
                                        }
                                    ]
                                },
                                "description": "",
                                "body": {
                                    "mode": "raw",
                                    "raw": "{\n    \"BatchItemRequest\": [\n        {\n            \"bId\": \"upd\",\n            \"operation\": \"update\",\n            \"Invoice\": {\n                \"Id\": \"{{batch_invoice_id}}\",\n                \"SyncToken\": \"{{batch_invoice_sync_token}}\",\n                \"sparse\": true,\n                \"PrivateNote\": \"Batch update by QBO Connect Postman test\"\n            }\n        },\n        {\n            \"bId\": \"del\",\n            \"operation\": \"delete\",\n            \"CreditMemo\": {\n                \"Id\": \"{{batch_creditmemo_id}}\",\n                \"SyncToken\": \"{{batch_creditmemo_sync_token}}\"\n            }\n        }\n    ]\n}",
                                    "options": {
                                        "raw": {
                                            "language": "json"
                                        }
                                    }
                                }
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "const byId = {}; (json.BatchItemResponse || []).forEach(function (r) { byId[r.bId] = r; });",
                                            "pm.test('upd updated the invoice', function () { pm.expect(byId.upd && byId.upd.Invoice && byId.upd.Invoice.Id).to.be.a('string'); });",
                                            "pm.test('del deleted the credit memo', function () { pm.expect(byId.del && byId.del.CreditMemo && byId.del.CreditMemo.status).to.eql('Deleted'); });",
                                            "if (byId.upd && byId.upd.Invoice) { pm.collectionVariables.set('batch_invoice_sync_token', byId.upd.Invoice.SyncToken); }"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Delete batch invoice",
                            "request": {
                                "method": "POST",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    },
                                    {
                                        "key": "Content-Type",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/invoice?operation=delete&requestid={{request_id}}",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "invoice"
                                    ],
                                    "query": [
                                        {
                                            "key": "operation",
                                            "value": "delete"
                                        },
                                        {
                                            "key": "requestid",
                                            "value": "{{request_id}}"
                                        }
                                    ]
                                },
                                "description": "",
                                "body": {
                                    "mode": "raw",
                                    "raw": "{\n    \"Id\": \"{{batch_invoice_id}}\",\n    \"SyncToken\": \"{{batch_invoice_sync_token}}\"\n}",
                                    "options": {
                                        "raw": {
                                            "language": "json"
                                        }
                                    }
                                }
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "pm.test('Invoice Deleted', function () { pm.expect(json.Invoice && json.Invoice.status).to.eql('Deleted'); });"
                                        ]
                                    }
                                }
                            ]
                        }
                    ]
                },
                {
                    "name": "12. Cleanup (deactivate test data)",
                    "description": "Name-list entities cannot be deleted in QuickBooks; deactivating (`Active: false`) is the supported way to retire\nthem (and is how Odoo \"archives\" a product, customer or vendor). Inactive records are found with\n`where Active = false` or `Active IN (true, false)`. A customer with an open balance cannot be deactivated\n(fault 6220 \"Delete List Has Balance Error\"): void or delete its open invoices first.",
                    "item": [
                        {
                            "name": "Read service item",
                            "request": {
                                "method": "GET",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/item/{{item_id}}",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "item",
                                        "{{item_id}}"
                                    ]
                                },
                                "description": ""
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "pm.test('Item returned', function () { pm.expect(json.Item && json.Item.Id).to.be.a('string'); });",
                                            "if (json.Item) { pm.collectionVariables.set('cleanup_sync_token', String(json.Item.SyncToken)); }"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Deactivate service item",
                            "request": {
                                "method": "POST",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    },
                                    {
                                        "key": "Content-Type",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/item?requestid={{request_id}}",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "item"
                                    ],
                                    "query": [
                                        {
                                            "key": "requestid",
                                            "value": "{{request_id}}"
                                        }
                                    ]
                                },
                                "description": "",
                                "body": {
                                    "mode": "raw",
                                    "raw": "{\n    \"Id\": \"{{item_id}}\",\n    \"SyncToken\": \"{{cleanup_sync_token}}\",\n    \"sparse\": true,\n    \"Active\": false\n}",
                                    "options": {
                                        "raw": {
                                            "language": "json"
                                        }
                                    }
                                }
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "pm.test('Item returned', function () { pm.expect(json.Item && json.Item.Id).to.be.a('string'); });",
                                            "pm.test('inactive', function () { pm.expect(json.Item.Active).to.eql(false); });"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Read non-inventory item",
                            "request": {
                                "method": "GET",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/item/{{noninventory_item_id}}",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "item",
                                        "{{noninventory_item_id}}"
                                    ]
                                },
                                "description": ""
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "pm.test('Item returned', function () { pm.expect(json.Item && json.Item.Id).to.be.a('string'); });",
                                            "if (json.Item) { pm.collectionVariables.set('cleanup_sync_token', String(json.Item.SyncToken)); }"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Deactivate non-inventory item",
                            "request": {
                                "method": "POST",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    },
                                    {
                                        "key": "Content-Type",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/item?requestid={{request_id}}",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "item"
                                    ],
                                    "query": [
                                        {
                                            "key": "requestid",
                                            "value": "{{request_id}}"
                                        }
                                    ]
                                },
                                "description": "",
                                "body": {
                                    "mode": "raw",
                                    "raw": "{\n    \"Id\": \"{{noninventory_item_id}}\",\n    \"SyncToken\": \"{{cleanup_sync_token}}\",\n    \"sparse\": true,\n    \"Active\": false\n}",
                                    "options": {
                                        "raw": {
                                            "language": "json"
                                        }
                                    }
                                }
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "pm.test('Item returned', function () { pm.expect(json.Item && json.Item.Id).to.be.a('string'); });",
                                            "pm.test('inactive', function () { pm.expect(json.Item.Active).to.eql(false); });"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Read inventory item",
                            "request": {
                                "method": "GET",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/item/{{inventory_item_id}}",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "item",
                                        "{{inventory_item_id}}"
                                    ]
                                },
                                "description": ""
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "pm.test('Item returned', function () { pm.expect(json.Item && json.Item.Id).to.be.a('string'); });",
                                            "if (json.Item) { pm.collectionVariables.set('cleanup_sync_token', String(json.Item.SyncToken)); }"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Deactivate inventory item",
                            "request": {
                                "method": "POST",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    },
                                    {
                                        "key": "Content-Type",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/item?requestid={{request_id}}",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "item"
                                    ],
                                    "query": [
                                        {
                                            "key": "requestid",
                                            "value": "{{request_id}}"
                                        }
                                    ]
                                },
                                "description": "",
                                "body": {
                                    "mode": "raw",
                                    "raw": "{\n    \"Id\": \"{{inventory_item_id}}\",\n    \"SyncToken\": \"{{cleanup_sync_token}}\",\n    \"sparse\": true,\n    \"Active\": false\n}",
                                    "options": {
                                        "raw": {
                                            "language": "json"
                                        }
                                    }
                                }
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "pm.test('Item returned', function () { pm.expect(json.Item && json.Item.Id).to.be.a('string'); });",
                                            "pm.test('inactive', function () { pm.expect(json.Item.Active).to.eql(false); });"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Read customer",
                            "request": {
                                "method": "GET",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/customer/{{customer_id}}",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "customer",
                                        "{{customer_id}}"
                                    ]
                                },
                                "description": ""
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "pm.test('Customer returned', function () { pm.expect(json.Customer && json.Customer.Id).to.be.a('string'); });",
                                            "if (json.Customer) { pm.collectionVariables.set('cleanup_sync_token', String(json.Customer.SyncToken)); }"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Deactivate customer",
                            "request": {
                                "method": "POST",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    },
                                    {
                                        "key": "Content-Type",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/customer?requestid={{request_id}}",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "customer"
                                    ],
                                    "query": [
                                        {
                                            "key": "requestid",
                                            "value": "{{request_id}}"
                                        }
                                    ]
                                },
                                "description": "",
                                "body": {
                                    "mode": "raw",
                                    "raw": "{\n    \"Id\": \"{{customer_id}}\",\n    \"SyncToken\": \"{{cleanup_sync_token}}\",\n    \"sparse\": true,\n    \"Active\": false\n}",
                                    "options": {
                                        "raw": {
                                            "language": "json"
                                        }
                                    }
                                }
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "pm.test('Customer returned', function () { pm.expect(json.Customer && json.Customer.Id).to.be.a('string'); });",
                                            "pm.test('inactive', function () { pm.expect(json.Customer.Active).to.eql(false); });"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Read vendor",
                            "request": {
                                "method": "GET",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/vendor/{{vendor_id}}",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "vendor",
                                        "{{vendor_id}}"
                                    ]
                                },
                                "description": ""
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "pm.test('Vendor returned', function () { pm.expect(json.Vendor && json.Vendor.Id).to.be.a('string'); });",
                                            "if (json.Vendor) { pm.collectionVariables.set('cleanup_sync_token', String(json.Vendor.SyncToken)); }"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Deactivate vendor",
                            "request": {
                                "method": "POST",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    },
                                    {
                                        "key": "Content-Type",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/vendor?requestid={{request_id}}",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "vendor"
                                    ],
                                    "query": [
                                        {
                                            "key": "requestid",
                                            "value": "{{request_id}}"
                                        }
                                    ]
                                },
                                "description": "",
                                "body": {
                                    "mode": "raw",
                                    "raw": "{\n    \"Id\": \"{{vendor_id}}\",\n    \"SyncToken\": \"{{cleanup_sync_token}}\",\n    \"sparse\": true,\n    \"Active\": false\n}",
                                    "options": {
                                        "raw": {
                                            "language": "json"
                                        }
                                    }
                                }
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "pm.test('Vendor returned', function () { pm.expect(json.Vendor && json.Vendor.Id).to.be.a('string'); });",
                                            "pm.test('inactive', function () { pm.expect(json.Vendor.Active).to.eql(false); });"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Read test account",
                            "request": {
                                "method": "GET",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/account/{{account_id}}",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "account",
                                        "{{account_id}}"
                                    ]
                                },
                                "description": ""
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "pm.test('Account returned', function () { pm.expect(json.Account && json.Account.Id).to.be.a('string'); });",
                                            "if (json.Account) { pm.collectionVariables.set('cleanup_sync_token', String(json.Account.SyncToken)); }"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Deactivate test account",
                            "request": {
                                "method": "POST",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    },
                                    {
                                        "key": "Content-Type",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/account?requestid={{request_id}}",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "account"
                                    ],
                                    "query": [
                                        {
                                            "key": "requestid",
                                            "value": "{{request_id}}"
                                        }
                                    ]
                                },
                                "description": "",
                                "body": {
                                    "mode": "raw",
                                    "raw": "{\n    \"Id\": \"{{account_id}}\",\n    \"SyncToken\": \"{{cleanup_sync_token}}\",\n    \"sparse\": true,\n    \"Active\": false\n}",
                                    "options": {
                                        "raw": {
                                            "language": "json"
                                        }
                                    }
                                }
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "pm.test('Account returned', function () { pm.expect(json.Account && json.Account.Id).to.be.a('string'); });",
                                            "pm.test('inactive', function () { pm.expect(json.Account.Active).to.eql(false); });"
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "name": "Query inactive test items",
                            "request": {
                                "method": "GET",
                                "header": [
                                    {
                                        "key": "Accept",
                                        "value": "application/json"
                                    }
                                ],
                                "url": {
                                    "raw": "{{base_url}}/api/v1/qbo/v3/company/{{realm_id}}/query?query=select * from Item where Active = false and Name LIKE 'QBOC-TEST {{run_id}}%25'",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "api",
                                        "v1",
                                        "qbo",
                                        "v3",
                                        "company",
                                        "{{realm_id}}",
                                        "query"
                                    ],
                                    "query": [
                                        {
                                            "key": "query",
                                            "value": "select * from Item where Active = false and Name LIKE 'QBOC-TEST {{run_id}}%25'"
                                        }
                                    ]
                                },
                                "description": ""
                            },
                            "event": [
                                {
                                    "listen": "test",
                                    "script": {
                                        "type": "text/javascript",
                                        "exec": [
                                            "const json = pm.response.json();",
                                            "pm.test('HTTP 200', function () { pm.expect(pm.response.code).to.eql(200); });",
                                            "const rows = (json.QueryResponse && json.QueryResponse.Item) || [];"
                                        ]
                                    }
                                }
                            ]
                        }
                    ]
                }
            ],
            "event": [
                {
                    "listen": "test",
                    "script": {
                        "type": "text/javascript",
                        "exec": [
                            "// Common checks for every proxied QuickBooks call (runs after each request in this folder).",
                            "pm.test('relayed from QuickBooks (X-QBO-Upstream-Status)', function () {",
                            "    pm.expect(pm.response.headers.has('X-QBO-Upstream-Status'), 'QBO Connect error: ' + pm.response.text().slice(0, 300)).to.be.true;",
                            "});",
                            "pm.test('intuit_tid present (quote it to Intuit support)', function () {",
                            "    pm.expect(pm.response.headers.get('intuit_tid')).to.be.a('string');",
                            "});",
                            "if ((pm.response.headers.get('Content-Type') || '').indexOf('json') !== -1) {",
                            "    const body = pm.response.json();",
                            "    pm.test('no QuickBooks Fault', function () {",
                            "        pm.expect(body.Fault, JSON.stringify(body.Fault)).to.be.undefined;",
                            "    });",
                            "}"
                        ]
                    }
                }
            ]
        }
    ],
    "event": [
        {
            "listen": "prerequest",
            "script": {
                "type": "text/javascript",
                "exec": [
                    "// QBO Connect request signing — docs/api/API_CONTRACTS.md \"Request signing\".",
                    "// Runs before every request in this collection; health, instances/register and instances/recover are unsigned.",
                    "(function () {",
                    "    // Values that must be identical in the signed and in the sent request are generated here, before signing:",
                    "    // a fresh Intuit idempotency key (requestid, max 36 chars for batch) for every request.",
                    "    pm.variables.set('request_id', 'pm-' + pm.variables.replaceIn('{{$guid}}').replace(/-/g, '').slice(0, 30));",
                    "    if (!pm.collectionVariables.get('run_id')) {",
                    "        pm.collectionVariables.set('run_id', Date.now().toString(36));",
                    "    }",
                    "",
                    "    const CryptoJS = require('crypto-js');",
                    "    const originPattern = /^[a-z][a-z0-9+.-]*:\\/\\/[^\\/?#]*/i;",
                    "",
                    "    const resolvedUrl = pm.variables.replaceIn(pm.request.url.toString()).split('#')[0];",
                    "    const queryStart = resolvedUrl.indexOf('?');",
                    "    const rawQuery = queryStart === -1 ? '' : resolvedUrl.slice(queryStart + 1);",
                    "    const fullPath = (queryStart === -1 ? resolvedUrl : resolvedUrl.slice(0, queryStart)).replace(originPattern, '');",
                    "    const basePath = pm.variables.replaceIn('{{base_url}}').replace(originPattern, '').replace(/\\/+$/, '');",
                    "",
                    "    // Sign the path the app sees (without any base_url sub-directory and without a trailing slash).",
                    "    let path = basePath !== '' && fullPath.indexOf(basePath + '/') === 0 ? fullPath.slice(basePath.length) : fullPath;",
                    "    path = '/' + path.replace(/^\\/+/, '').replace(/\\/+$/, '');",
                    "",
                    "    if (/^\\/api\\/v1\\/(health|instances\\/(register|recover))$/.test(path)) {",
                    "        return;",
                    "    }",
                    "",
                    "    const instanceId = pm.variables.get('instance_id');",
                    "    const secret = pm.variables.get('instance_secret');",
                    "",
                    "    if (!instanceId || !secret) {",
                    "        throw new Error('instance_id / instance_secret are empty: run \"Register instance\" first.');",
                    "    }",
                    "",
                    "    // RFC 3986 encoding, as PHP rawurlencode() / Python quote(safe=\"\").",
                    "    const rfc3986 = function (value) {",
                    "        return encodeURIComponent(value).replace(/[!'()*]/g, function (c) {",
                    "            return '%' + c.charCodeAt(0).toString(16).toUpperCase();",
                    "        });",
                    "    };",
                    "    const decode = function (value) {",
                    "        try {",
                    "            return decodeURIComponent(value.replace(/\\+/g, ' '));",
                    "        } catch (e) {",
                    "            return value;",
                    "        }",
                    "    };",
                    "",
                    "    // Parse the query as the server will (last duplicate wins), then sort keys and re-encode.",
                    "    const params = {};",
                    "    rawQuery.split('&').filter(function (pair) { return pair !== ''; }).forEach(function (pair) {",
                    "        const eq = pair.indexOf('=');",
                    "        params[decode(eq === -1 ? pair : pair.slice(0, eq))] = decode(eq === -1 ? '' : pair.slice(eq + 1));",
                    "    });",
                    "    const canonicalQuery = Object.keys(params).sort().map(function (key) {",
                    "        return rfc3986(key) + '=' + rfc3986(params[key]);",
                    "    }).join('&');",
                    "",
                    "    const body = pm.request.body && pm.request.body.mode === 'raw' && !pm.request.body.disabled",
                    "        ? pm.variables.replaceIn(pm.request.body.raw || '')",
                    "        : '';",
                    "    const timestamp = Math.floor(Date.now() / 1000).toString();",
                    "    const nonce = pm.variables.replaceIn('{{$guid}}').replace(/-/g, '');",
                    "",
                    "    const canonical = [",
                    "        'QBO1-HMAC-SHA256',",
                    "        pm.request.method.toUpperCase(),",
                    "        path,",
                    "        canonicalQuery,",
                    "        timestamp,",
                    "        nonce,",
                    "        CryptoJS.SHA256(body).toString(CryptoJS.enc.Hex)",
                    "    ].join('\\n');",
                    "    const signature = 'v1=' + CryptoJS.HmacSHA256(canonical, secret).toString(CryptoJS.enc.Hex);",
                    "",
                    "    pm.request.headers.upsert({ key: 'X-QBO-Instance', value: instanceId });",
                    "    pm.request.headers.upsert({ key: 'X-QBO-Timestamp', value: timestamp });",
                    "    pm.request.headers.upsert({ key: 'X-QBO-Nonce', value: nonce });",
                    "    pm.request.headers.upsert({ key: 'X-QBO-Signature', value: signature });",
                    "})();"
                ]
            }
        }
    ],
    "variable": [
        {
            "key": "base_url",
            "value": "http://localhost:8000",
            "type": "string"
        },
        {
            "key": "odoo_base_url",
            "value": "http://127.0.0.1:8069",
            "type": "string",
            "description": "Odoo origin registered as base_url. LAN Odoo over http (local dev only): e.g. http://192.168.x.x:8029 with QBO_DEV_ALLOWED_PRIVATE_IPS=192.168.x.x in the QBO Connect .env."
        },
        {
            "key": "odoo_callback_path",
            "value": "/qbo_connect/webhook",
            "type": "string",
            "description": "Webhook path on the Odoo origin: /qbo_connect/webhook (mock Odoo) or /quickbook_online_connector/webhook (Odoo module)."
        },
        {
            "key": "license_key",
            "value": "",
            "type": "string"
        },
        {
            "key": "instance_id",
            "value": "",
            "type": "string"
        },
        {
            "key": "instance_secret",
            "value": "",
            "type": "string"
        },
        {
            "key": "connection_id",
            "value": "",
            "type": "string"
        },
        {
            "key": "result_code",
            "value": "",
            "type": "string"
        },
        {
            "key": "recovery_code",
            "value": "",
            "type": "string"
        },
        {
            "key": "realm_id",
            "value": "",
            "description": "QuickBooks company id (realm_id from List connections)"
        },
        {
            "key": "sync_missed_events",
            "value": "",
            "type": "string",
            "description": "sync_required.missed_events from Show connection; Confirm resync sends it back. Empty: nothing to resync."
        },
        {
            "key": "run_id",
            "value": "",
            "type": "string",
            "description": "Test-data run id; CompanyInfo starts a new one."
        },
        {
            "key": "allow_permanent_tax_writes",
            "value": "false",
            "type": "string",
            "description": "true enables folder 3b (creates a tax agency and tax code that cannot be deleted)."
        },
        {
            "key": "test_email",
            "value": "qboc-test@example.com",
            "type": "string",
            "description": "Reserved example.com address used for test customers, vendors and invoice e-mails."
        },
        {
            "key": "changed_since",
            "value": "",
            "type": "string",
            "description": "ISO 8601 time for CDC / LastUpdatedTime filters; CompanyInfo sets it to 6 hours ago."
        },
        {
            "key": "start_position",
            "value": "1",
            "type": "string",
            "description": "Query paging: 1-based STARTPOSITION."
        },
        {
            "key": "max_results",
            "value": "2",
            "type": "string",
            "description": "Query paging: MAXRESULTS (max 1000)."
        },
        {
            "key": "income_account_id",
            "value": "",
            "type": "string"
        },
        {
            "key": "expense_account_id",
            "value": "",
            "type": "string"
        },
        {
            "key": "bank_account_id",
            "value": "",
            "type": "string"
        },
        {
            "key": "asset_account_id",
            "value": "",
            "type": "string"
        },
        {
            "key": "cogs_account_id",
            "value": "",
            "type": "string"
        },
        {
            "key": "account_id",
            "value": "",
            "type": "string"
        },
        {
            "key": "account_sync_token",
            "value": "",
            "type": "string"
        },
        {
            "key": "tax_code_id",
            "value": "",
            "type": "string"
        },
        {
            "key": "sales_tax_code_id",
            "value": "",
            "type": "string"
        },
        {
            "key": "purchase_tax_code_id",
            "value": "",
            "type": "string"
        },
        {
            "key": "tax_rate_id",
            "value": "",
            "type": "string"
        },
        {
            "key": "tax_agency_id",
            "value": "",
            "type": "string"
        },
        {
            "key": "new_tax_code_id",
            "value": "",
            "type": "string"
        },
        {
            "key": "product_income_account_id",
            "value": "",
            "type": "string"
        },
        {
            "key": "customer_id",
            "value": "",
            "type": "string"
        },
        {
            "key": "customer_sync_token",
            "value": "",
            "type": "string"
        },
        {
            "key": "batch_invoice_id",
            "value": "",
            "type": "string"
        },
        {
            "key": "batch_invoice_sync_token",
            "value": "",
            "type": "string"
        },
        {
            "key": "batch_creditmemo_id",
            "value": "",
            "type": "string"
        },
        {
            "key": "batch_creditmemo_sync_token",
            "value": "",
            "type": "string"
        },
        {
            "key": "vendor_id",
            "value": "",
            "type": "string"
        },
        {
            "key": "vendor_sync_token",
            "value": "",
            "type": "string"
        },
        {
            "key": "item_id",
            "value": "",
            "type": "string"
        },
        {
            "key": "item_sync_token",
            "value": "",
            "type": "string"
        },
        {
            "key": "noninventory_item_id",
            "value": "",
            "type": "string"
        },
        {
            "key": "inventory_item_id",
            "value": "",
            "type": "string"
        },
        {
            "key": "invoice_id",
            "value": "",
            "type": "string"
        },
        {
            "key": "invoice_sync_token",
            "value": "",
            "type": "string"
        },
        {
            "key": "invoice_total",
            "value": "",
            "type": "string"
        },
        {
            "key": "pay_invoice_id",
            "value": "",
            "type": "string"
        },
        {
            "key": "pay_invoice_total",
            "value": "",
            "type": "string"
        },
        {
            "key": "payment_id",
            "value": "",
            "type": "string"
        },
        {
            "key": "payment_sync_token",
            "value": "",
            "type": "string"
        },
        {
            "key": "creditmemo_id",
            "value": "",
            "type": "string"
        },
        {
            "key": "creditmemo_sync_token",
            "value": "",
            "type": "string"
        },
        {
            "key": "bill_id",
            "value": "",
            "type": "string"
        },
        {
            "key": "bill_sync_token",
            "value": "",
            "type": "string"
        },
        {
            "key": "bill_total",
            "value": "",
            "type": "string"
        },
        {
            "key": "billpayment_id",
            "value": "",
            "type": "string"
        },
        {
            "key": "billpayment_sync_token",
            "value": "",
            "type": "string"
        },
        {
            "key": "cleanup_sync_token",
            "value": "",
            "type": "string"
        },
        {
            "key": "pay_invoice_sync_token",
            "value": "",
            "type": "string"
        }
    ]
}
