Global API
Code Examples
Create an Invoice with a Bundle Item
1min
the following is an example of creating an invoice with a bundle item note you can only create one record at a time request // create a map to store all the data of an invoice list\<object> invoicelist = new list\<object>(); map\<string, object> invoicemap = new map\<string, object>(); invoicemap put('txndate', '2025/05/08'); invoicemap put('docnumber', 'i001'); invoicemap put('exchangerate', 1 0); // contact and customer info invoicemap put('salestermref', new map\<string, object>{'value' => '4'}); invoicemap put('customerref', new map\<string, object>{'value' => '74'}); // line items list\<object> lineitemlist = new list\<object>(); // grouplinedetail item map\<string, object> grouplineitem = new map\<string, object>(); grouplineitem put('amount', 100 0); grouplineitem put('detailtype', 'grouplinedetail'); map\<string, object> grouplinedetail = new map\<string, object>(); grouplinedetail put('groupitemref', new map\<string, object>{'value' => '26'}); grouplinedetail put('quantity', 1); // sub line items inside group list\<object> groupsublines = new list\<object>(); map\<string, object> subitem1 = new map\<string, object>(); subitem1 put('amount', 50 0); subitem1 put('detailtype', 'salesitemlinedetail'); subitem1 put('salesitemlinedetail', new map\<string, object>{ 'itemref' => new map\<string, object>{'value' => '23'}, 'qty' => 2, 'unitprice' => 25 }); groupsublines add(subitem1); map\<string, object> subitem2 = new map\<string, object>(); subitem2 put('amount', 50 0); subitem2 put('detailtype', 'salesitemlinedetail'); subitem2 put('salesitemlinedetail', new map\<string, object>{ 'itemref' => new map\<string, object>{'value' => '24'}, 'qty' => 1, 'unitprice' => 50 }); groupsublines add(subitem2); // add sub lines to grouplinedetail grouplinedetail put('line', groupsublines); grouplineitem put('grouplinedetail', grouplinedetail); lineitemlist add(grouplineitem); // add line items to invoice invoicemap put('line', lineitemlist); invoicelist add(invoicemap); // final request map map\<string, object> reqjsonmap = new map\<string, object>(); reqjsonmap put('invoices', invoicelist); string reqjson = json serialize(reqjsonmap); map\<string, object> finalreqmap = new map\<string, object>(); finalreqmap put('options', new map\<string, object>()); finalreqmap put('version', '1 0'); finalreqmap put('action', 'createinvoice'); finalreqmap put('requestjson', reqjson); finalreqmap put('skipdml', false); finalreqmap put('qborgid', '9341454612812784'); system debug('request ' + finalreqmap); // api call map\<string, object> respmap = breadwinner qbo breadwinnerqbapi call(finalreqmap); system debug('response ' + respmap); response { action=createinvoice, responsejson={ "statuscode" 200, "invoices" \[ { "txntaxdetail" { "totaltax" 0 }, "txndate" "2025 05 08", "totalamt" 100 00, "synctoken" "0", "sparse"\ false, "sfrecordid" "a0aj2000006g0ubmay", "salestermref" { "value" "4", "name" "net 60" }, "salesforcerecordid" "a0aj2000006g0ubmay", "metadata" { "lastupdatedtime" "2025 05 19t06 09 43 07 00", "createtime" "2025 05 19t06 09 43 07 00" }, "line" \[ { "linenum" 1, "id" "1", "grouplinedetail" { "quantity" 1, "line" \[ { "salesitemlinedetail" { "unitprice" 25, "taxcoderef" { "value" "non" }, "qty" 2, "itemref" { "value" "23", "name" "inv1" } }, "linenum" 2, "id" "2", "detailtype" "salesitemlinedetail", "amount" 50 00 }, { "salesitemlinedetail" { "unitprice" 50, "taxcoderef" { "value" "non" }, "qty" 1, "itemref" { "value" "24", "name" "inv2" } }, "linenum" 3, "id" "3", "detailtype" "salesitemlinedetail", "amount" 50 00 } ], "groupitemref" { "value" "26", "name" "inv" } }, "detailtype" "grouplinedetail", "amount" 100 00 }, { "detailtype" "subtotallinedetail", "amount" 100 00 } ], "id" "181", "homebalance" 100 00, "exchangerate" 1, "emailstatus" "notset", "duedate" "2025 07 07", "docnumber" "i001", "customfield" \[], "customerref" { "value" "74", "name" "bundle cust" }, "currencyref" { "value" "usd", "name" "united states dollar" }, "balance" 100 00, "allowonlinecreditcardpayment"\ false, "allowonlineachpayment"\ false } ] }, timestamp=1747660186183, validrequest=true, version=1 0 } do you want to know the list of supported parameters for create and send invoice? see invoice docid\ gee1fj42amxfapeumyyqi