Guides and Examples
...
Quotes
Preview vs Commit
16 min
preview vs commit the nue cpq quote api offers two modes for creating quotes preview (dry run) and commit (persist) both modes execute the full pricing engine product resolution, bundle expansion, discount propagation, and price tag evaluation but differ in whether the result is saved to the database this guide explains when to use each mode, shows how the request and response differ, and demonstrates the common preview then commit pattern overview comparison aspect preview commit endpoint post /cpq/quotes\ preview post /cpq/quotes pricing calculation full pricing engine full pricing engine database writes none quote + line items persisted response quote id null real uuid request body identical identical use case validation, what if, ui previews creating finalized quotes authentication all examples below use the following headers const myheaders = new headers(); myheaders append("nue api key", "your api key here"); myheaders append("content type", "application/json"); use case 1 preview mode pricing preview preview a quote to see calculated pricing without creating any database records this is ideal for pricing previews in a ui, what if analysis, ai driven validation, and integration testing request body { "opportunityid" "006xx000001abc123", "name" "q1 2026 enterprise license", "subscriptionstartdate" "2026 01 01", "subscriptionenddate" "2027 01 01", "subscriptiontermdimension" "month", "subscriptionterm" 12, "products" \[ { "productsku" "nue on salesforce", "uom" "user/month", "quantity" 10 } ] } curl curl x post 'https //api nue io/cpq/quotes\ preview' \\ h 'nue api key your api key here' \\ h 'content type application/json' \\ d '{ "opportunityid" "006xx000001abc123", "name" "q1 2026 enterprise license", "subscriptionstartdate" "2026 01 01", "subscriptionenddate" "2027 01 01", "subscriptiontermdimension" "month", "subscriptionterm" 12, "products" \[ { "productsku" "nue on salesforce", "uom" "user/month", "quantity" 10 } ] }' javascript fetch const myheaders = new headers(); myheaders append("nue api key", "your api key here"); myheaders append("content type", "application/json"); const quotedata = { opportunityid "006xx000001abc123", name "q1 2026 enterprise license", subscriptionstartdate "2026 01 01", subscriptionenddate "2027 01 01", subscriptiontermdimension "month", subscriptionterm 12, products \[ { productsku "nue on salesforce", uom "user/month", quantity 10 } ] }; fetch('https //api nue io/cpq/quotes\ preview', { method 'post', headers myheaders, body json stringify(quotedata) }) then(response => response json()) then(result => { console log('preview result '); console log(` quote id ${result data quote id}`); // null not persisted console log(` total amount $${result data quote totalamount}`); console log(` line items ${result data quotelineitems length}`); }) catch(error => console log('error ', error)); expected response { "status" "succeed", "data" { "quote" { "id" null, "name" "q1 2026 enterprise license", "totalamount" 3588 00, "subscriptionstartdate" "2026 01 01", "subscriptionenddate" "2027 01 01", "subscriptionterm" 12, "subscriptiontermdimension" "month" }, "quotelineitems" \[ { "product" { "sku" "nue on salesforce", "name" "nue on salesforce" }, "quantity" 10, "listprice" 29 90, "listtotalprice" 3588 00, "totalprice" 3588 00, "childrenlineitems" \[] } ] }, "warnings" \[] } the quote id is null because nothing was written to the database use case 2 commit mode create a real quote commit the quote to persist it to the database the request body is identical to preview; only the endpoint changes request body { "opportunityid" "006xx000001abc123", "name" "q1 2026 enterprise license", "subscriptionstartdate" "2026 01 01", "subscriptionenddate" "2027 01 01", "subscriptiontermdimension" "month", "subscriptionterm" 12, "products" \[ { "productsku" "nue on salesforce", "uom" "user/month", "quantity" 10 } ] } curl curl x post 'https //api nue io/cpq/quotes' \\ h 'nue api key your api key here' \\ h 'content type application/json' \\ d '{ "opportunityid" "006xx000001abc123", "name" "q1 2026 enterprise license", "subscriptionstartdate" "2026 01 01", "subscriptionenddate" "2027 01 01", "subscriptiontermdimension" "month", "subscriptionterm" 12, "products" \[ { "productsku" "nue on salesforce", "uom" "user/month", "quantity" 10 } ] }' javascript fetch const myheaders = new headers(); myheaders append("nue api key", "your api key here"); myheaders append("content type", "application/json"); const quotedata = { opportunityid "006xx000001abc123", name "q1 2026 enterprise license", subscriptionstartdate "2026 01 01", subscriptionenddate "2027 01 01", subscriptiontermdimension "month", subscriptionterm 12, products \[ { productsku "nue on salesforce", uom "user/month", quantity 10 } ] }; fetch('https //api nue io/cpq/quotes', { method 'post', headers myheaders, body json stringify(quotedata) }) then(response => response json()) then(result => { console log('commit result '); console log(` quote id ${result data quote id}`); // uuid persisted console log(` total amount $${result data quote totalamount}`); console log(` line items ${result data quotelineitems length}`); }) catch(error => console log('error ', error)); expected response { "status" "succeed", "data" { "quote" { "id" "a1b2c3d4 e5f6 7890 abcd ef1234567890", "name" "q1 2026 enterprise license", "totalamount" 3588 00, "subscriptionstartdate" "2026 01 01", "subscriptionenddate" "2027 01 01", "subscriptionterm" 12, "subscriptiontermdimension" "month" }, "quotelineitems" \[ { "product" { "sku" "nue on salesforce", "name" "nue on salesforce" }, "quantity" 10, "listprice" 29 90, "listtotalprice" 3588 00, "totalprice" 3588 00, "childrenlineitems" \[] } ] }, "warnings" \[] } the quote id now contains a uuid the quote, line items, and all pricing data are persisted use case 3 preview then commit pattern a common integration pattern is to preview a quote first, present the pricing to a user or validation system, and then commit only after approval because the request body is the same for both endpoints, you can reuse the exact same payload request body (used for both calls) { "opportunityid" "006xx000001abc123", "name" "q1 2026 enterprise license", "subscriptionstartdate" "2026 01 01", "subscriptionenddate" "2027 01 01", "subscriptiontermdimension" "month", "subscriptionterm" 12, "discount" 10, "products" \[ { "productsku" "nue on salesforce", "uom" "user/month", "quantity" 10 }, { "productsku" "nue platform", "uom" "user/year", "quantity" 5 } ] } curl \# step 1 preview curl x post 'https //api nue io/cpq/quotes\ preview' \\ h 'nue api key your api key here' \\ h 'content type application/json' \\ d '{ "opportunityid" "006xx000001abc123", "name" "q1 2026 enterprise license", "subscriptionstartdate" "2026 01 01", "subscriptionenddate" "2027 01 01", "subscriptiontermdimension" "month", "subscriptionterm" 12, "discount" 10, "products" \[ { "productsku" "nue on salesforce", "uom" "user/month", "quantity" 10 }, { "productsku" "nue platform", "uom" "user/year", "quantity" 5 } ] }' \# step 2 if approved, commit with the same body curl x post 'https //api nue io/cpq/quotes' \\ h 'nue api key your api key here' \\ h 'content type application/json' \\ d '{ "opportunityid" "006xx000001abc123", "name" "q1 2026 enterprise license", "subscriptionstartdate" "2026 01 01", "subscriptionenddate" "2027 01 01", "subscriptiontermdimension" "month", "subscriptionterm" 12, "discount" 10, "products" \[ { "productsku" "nue on salesforce", "uom" "user/month", "quantity" 10 }, { "productsku" "nue platform", "uom" "user/year", "quantity" 5 } ] }' javascript fetch const myheaders = new headers(); myheaders append("nue api key", "your api key here"); myheaders append("content type", "application/json"); const quotedata = { opportunityid "006xx000001abc123", name "q1 2026 enterprise license", subscriptionstartdate "2026 01 01", subscriptionenddate "2027 01 01", subscriptiontermdimension "month", subscriptionterm 12, discount 10, products \[ { productsku "nue on salesforce", uom "user/month", quantity 10 }, { productsku "nue platform", uom "user/year", quantity 5 } ] }; async function previewthencommit(quotepayload) { // step 1 preview the quote const previewresponse = await fetch('https //api nue io/cpq/quotes\ preview', { method 'post', headers myheaders, body json stringify(quotepayload) }); const preview = await previewresponse json(); console log(' preview '); console log(` quote id ${preview\ data quote id}`); // null console log(` total amount $${preview\ data quote totalamount}`); console log(` line items ${preview\ data quotelineitems length}`); // step 2 validate or present to user const totalamount = preview\ data quote totalamount; if (totalamount > 50000) { console log('quote exceeds $50,000 requires manager approval '); return preview; } // step 3 commit the same payload const commitresponse = await fetch('https //api nue io/cpq/quotes', { method 'post', headers myheaders, body json stringify(quotepayload) }); const committed = await commitresponse json(); console log(' committed '); console log(` quote id ${committed data quote id}`); // uuid console log(` total amount $${committed data quote totalamount}`); return committed; } previewthencommit(quotedata) then(result => console log('done ')) catch(error => console log('error ', error)); expected preview response { "status" "succeed", "data" { "quote" { "id" null, "name" "q1 2026 enterprise license", "totalamount" 3674 70, "discount" 10 }, "quotelineitems" \[ { "product" { "sku" "nue on salesforce", "name" "nue on salesforce" }, "quantity" 10, "listtotalprice" 3588 00, "discount" 10, "totalprice" 3229 20 }, { "product" { "sku" "nue platform", "name" "nue platform" }, "quantity" 5, "listtotalprice" 495 00, "discount" 10, "totalprice" 445 50 } ] }, "warnings" \[] } expected commit response { "status" "succeed", "data" { "quote" { "id" "f7e8d9c0 b1a2 3456 cdef 789012345678", "name" "q1 2026 enterprise license", "totalamount" 3674 70, "discount" 10 }, "quotelineitems" \[ { "product" { "sku" "nue on salesforce", "name" "nue on salesforce" }, "quantity" 10, "listtotalprice" 3588 00, "discount" 10, "totalprice" 3229 20 }, { "product" { "sku" "nue platform", "name" "nue platform" }, "quantity" 5, "listtotalprice" 495 00, "discount" 10, "totalprice" 445 50 } ] }, "warnings" \[] } the only difference between the two responses is the quote id field behavior comparison behavior preview commit product resolution full full bundle expansion full full pricing engine full calculation full calculation discount propagation full full price tag evaluation full full database writes none quote + all line items persisted quote id in response null uuid idempotency fully idempotent (no side effects) creates a new quote each call downstream triggers none may trigger workflows, notifications when to use each mode scenario mode why price calculator ui preview no database clutter from exploratory pricing ai agent building a quote preview first, then commit validate pricing before persisting batch quote generation commit directly persist finalized quotes what if comparisons preview run multiple scenarios without side effects integration testing preview validate api integration without creating records final quote creation commit persist the approved quote for downstream processing key takeaways the request body is identical for both endpoints only the url differs preview runs the full pricing engine but does not persist anything commit runs the same pricing engine and saves the result to the database use the preview then commit pattern to validate before persisting in preview mode, quote id is always null in commit mode, it is a uuid