B2B Ninja Docs

Interacting with Quotes

Interacting with Quotes

Create a quote

Let's build the Quote JSON object that will be used to create the quote.

{
"customer": {
"name": "John Doe",
"address": "1111 West Main St",
"address-2": "Apt 2",
"city": "New York",
"state": "NY",
"zipcode": "00010",
"country": "US"
},
"products": [
{
"id": 118,
"qty": 1
}
]
}

To create a quote of this type, you will need to run the following command in the terminal. Make sure to replace {{YOUR STORE_ID}} and {{YOUR AUTH TOKEN}} as described in the Getting Started

curl --location --request POST 'https://api.b2bninja.com/v3/bc/public/quotes' \
--header 'x-auth-client: {{YOUR STORE_ID}}' \
--header 'x-auth-token: {{YOUR AUTH TOKEN}}' \
--header 'Content-Type: application/json' \
--data-raw '{
"customer": {
"name": "John Doe",
"address": "1111 West Main St",
"address-2": "Apt 2",
"city": "New York",
"state": "NY",
"zipcode": "00010",
"country": "US"
},
"products": [
{
"id": 123,
"qty": 1
}
]
}'

The response given will be a JSON document similar to this:

{
"quote_id": "-MgLoujT1fqZrVpFb-6g",
"quote": {
"customer": {
"name": "John Doe",
"address": "1111 West Main St",
"address-2": "Apt 2",
"city": "New York",
"state": "New York",
"zipcode": "00010",
"country": "US"
},
"products": [
{
"id": 103,
"qty": 1,
"price": 200,
"price_total": 200,
"quote": "200.00",
"quote_total": "200.00",
"discount": 0,
"discount_total": 0,
"calculated_price": 200,
"key": null
}
],
"product_order": null,
"quote_total": "200.00",
"price_total": "200.00",
"shipping": {
"type": "no_additional",
"product": null
},
"created": 1628175576033,
"status": "new",
"tags": null,
"total": 0
},
"success": true
}

Note the top level quote_id field as that will be the id of the quote in the system and will be used for any follow up operations on this quote.

Update the quote

Let's add a tag to the quote so that the user knows this is an priority lead. If the store has a tag named priority and we set it on the quote, then it will show to the user in their quote list view, and on their quote edit view. If the store does not have a tag named priority enabled, you will need to go add one for this to display to the user. Updates done to the quote will be merged with the existing data on that quote automatically, so you only need to provide the JSON for the fields that need to be updated.

{
"tag_list": ["priority"]
}

Notice we are using the PUT request type and make sure to add the quote_id returned from the create request to update that specific quote.

curl --location --request PUT 'https://api.b2bninja.com/v3/bc/public/quotes/{{YOUR QUOTE_ID}}' \
--header 'x-auth-client: {{YOUR STORE_ID}}' \
--header 'x-auth-token: {{YOUR AUTH TOKEN}}' \
--header 'Content-Type: application/json' \
--data-raw '{
"tag_list": ["priority"]
}'

The response provided will be the entire quote including the updated field you just modified.

Coming Soon

This document will be updated with examples of how to Send a Quote, Delete a Quote, and Search for Quotes soon.

In the meantime, Use the reference section for Quote for the details on all the methods and parameters supported.