Skip to main content

Import B2B orders

Plus

Only stores on the Shopify Plus plan can use apps with B2B features.

Note

This tutorial describes how to import historical order data. To create and collect payment for B2B orders, refer to the Manage draft orders tutorial instead.

A business-to-business (B2B) merchant might run certain B2B operations outside of Shopify, but want to import their non-Shopify B2B orders into Shopify. This can help the B2B merchant to move their B2B business to Shopify without losing historical order data, and enable buyers to review their full order history within their customer account pages on a Shopify storefront.

In this tutorial, you'll learn how to import orders with the REST Admin API and associate them with B2B company locations and company contacts.



  • A B2B merchant must import or create all relevant companies, company locations, company contacts, and products in Shopify before they can import B2B orders. If these resources aren't created in Shopify before the order import, then an error is returned.

The B2B order import feature uses the REST Admin API's POST orders endpoint to enable B2B merchants to import B2B orders into Shopify.

When you include both company.location_id and customer.id in the request, a B2B order is created and associated with the company location.

Caution

The customer must have a role assignment to the specified company location. If the customer doesn't have a role assignment to that location, then an error is returned.

The line_item.price isn't a required parameter for importing B2B orders. When a merchant doesn't add prices to their line items, the API populates the line_item.price automatically based on the variant price.

Because this can result in inaccurate order data, you should implement validation logic within the app to ensure that merchants input accurate price data when importing B2B orders.

When an order is successfully created in a B2B context, the API response includes the following company details:

"company": {
"id": 123,
"location_id": 12345
}

The following request creates a B2B order for a company:

Import B2B orders

Endpoint

POST https://{shop}.myshopify.com/admin/api/{api_version}/orders.json

Request

{
"order": {
"line_items": [
{
"variant_id": 123,
"quantity": 1,
"price": 10.20
}
],
"customer": {
"id": 12345
},
"company": {
"location_id": 123456789
}
}
}

JSON response

{
"order": {
"id": 987,
"admin_graphql_api_id": "gid://shopify/Order/987",
"app_id": 111,
"browser_ip": null,
"buyer_accepts_marketing": true,
"cancel_reason": null,
"cancelled_at": null,
"cart_token": null,
"checkout_id": null,
"checkout_token": null,
"client_details": null,
"closed_at": null,
"company": {
"id": 222,
"location_id": 123456789
},
"confirmed": true,
"contact_email": "bo.wang@example.com",
"created_at": "2023-01-05T15:00:00-05:00",
"currency": "USD",
"current_subtotal_price": "10.20",
"current_subtotal_price_set": {
"shop_money": {
"amount": "10.20",
"currency_code": "USD"
},
"presentment_money": {
"amount": "10.20",
"currency_code": "USD"
}
},
"current_total_discounts": "0.00",
"current_total_discounts_set": {
"shop_money": {

Was this page helpful?