Shopify API - Create An Order

Shopify API – Create An Order Using Postman

In this article, Beehexa will show you how to create an order with tax lines split across taxable line items. It means your created order will specify the price of items and total tax with each different rate to which these products are subject. You can follow step by step this process to create an order with tax lines split across taxable line items using Postman in Shopify.

Step 1: Generate API credentials from the Shopify admin

Generate API credentials from the Shopify admin
  • Click Create a new private app
  • In the App details section, enter a name for your app, and an emergency developer email
  • In the Admin API section, select the areas of your store that you want the app to access
Generate API credentials from the Shopify admin
  • Click Save

The Admin API section displays the app’s API key and password when you save the app’s details. 

Step 2: Create An Order With Tax Lines Split Across Taxable Line Items

  • Log in to your Postman and create a new workspace
  • Create a new POST with this URL:
https://{username}:{password}@{shop}.myshopify.com/admin/api/{api-version}/{resource}.json
Code language: JavaScript (javascript)
  1. {username} – The API key that you generated.
  2. {password} – The API password that you generated.
  3. {shop} – The name of your development store.
  4. {api-version} – The supported API version that you want to use.
  5. {resource} – A resource endpoint from the REST Admin API.

Or you can copy this example in the Shopify Admin, remember change {resource} to {orders}:

Example URL
https://33a72f01e02987636e1c1a9a4e95c840:[email protected]/admin/api/2021-10/orders.json
Code language: JavaScript (javascript)
  • Paste the URL above.
post

In the body section, enter this code:

{ "order": { "line_items": [{ "title": "Red Leather Coat", "price": 129.99, "grams": "1700", "quantity": 1 }, { "title": "Blue Suede Shoes", "price": 85.95, "grams": "750", "quantity": 1, "taxable": false }, { "title": "Raspberry Beret", "price": 19.99, "grams": "320", "quantity": 2 }], "tax_lines": [{ "price": 10.2, "rate": 0.06, "title": "State tax" }, { "price": 4.25, "rate": 0.025, "title": "County tax" }], "total_tax": 14.45 } }
Code language: JSON / JSON with Comments (json)

This code determines what products that you want to order including titles, prices, weight, and quantity. The tax line is taxed to which these products are subject. 

Then click Send

Response:

The API will return the data like this

{ "order": { "id": 4244165656639, "admin_graphql_api_id": "gid://shopify/Order/4244165656639", "app_id": 4491355, "browser_ip": null, "buyer_accepts_marketing": false, "cancel_reason": null, "cancelled_at": null, "cart_token": null, "checkout_id": null, "checkout_token": null, "closed_at": null, "confirmed": true, "contact_email": null, "created_at": "2022-01-05T10:52:40+09:00", "currency": "AUD", "current_subtotal_price": "255.92", "current_subtotal_price_set": { "shop_money": { "amount": "255.92", "currency_code": "AUD" }, "presentment_money": { "amount": "255.92", "currency_code": "AUD" } }, "current_total_discounts": "0.00", "current_total_discounts_set": { "shop_money": { "amount": "0.00", "currency_code": "AUD" }, "presentment_money": { "amount": "0.00", "currency_code": "AUD" } }, "current_total_duties_set": null, "current_total_price": "270.37", "current_total_price_set": { "shop_money": { "amount": "270.37", "currency_code": "AUD" }, "presentment_money": { "amount": "270.37", "currency_code": "AUD" } }, "current_total_tax": "14.45", "current_total_tax_set": { "shop_money": { "amount": "14.45", "currency_code": "AUD" }, "presentment_money": { "amount": "14.45", "currency_code": "AUD" } }, "customer_locale": null, "device_id": null, "discount_codes": [], "email": "", "estimated_taxes": false, "financial_status": "paid", "fulfillment_status": null, "gateway": "", "landing_site": null, "landing_site_ref": null, "location_id": null, "name": "#1157", "note": null, "note_attributes": [], "number": 157, "order_number": 1157, "order_status_url": "https://hexasync.myshopify.com/25322618943/orders/9594c8db621a0765e1c6d536470f6eaa/authenticate?key=0a1ba38ac97fd0f04c16275cdc46326c", "original_total_duties_set": null, "payment_gateway_names": [], "phone": null, "presentment_currency": "AUD", "processed_at": "2022-01-05T10:52:40+09:00", "processing_method": "", "reference": null, "referring_site": null, "source_identifier": null, "source_name": "4491355", "source_url": null, "subtotal_price": "255.92", "subtotal_price_set": { "shop_money": { "amount": "255.92", "currency_code": "AUD" }, "presentment_money": { "amount": "255.92", "currency_code": "AUD" } }, "tags": "", "tax_lines": [ { "price": "10.20", "rate": 0.06, "title": "State tax", "price_set": { "shop_money": { "amount": "10.20", "currency_code": "AUD" }, "presentment_money": { "amount": "10.20", "currency_code": "AUD" } }, "channel_liable": null }, { "price": "4.25", "rate": 0.025, "title": "County tax", "price_set": { "shop_money": { "amount": "4.25", "currency_code": "AUD" }, "presentment_money": { "amount": "4.25", "currency_code": "AUD" } }, "channel_liable": null } ], "taxes_included": false, "test": false, "token": "9594c8db621a0765e1c6d536470f6eaa", "total_discounts": "0.00", "total_discounts_set": { "shop_money": { "amount": "0.00", "currency_code": "AUD" }, "presentment_money": { "amount": "0.00", "currency_code": "AUD" } }, "total_line_items_price": "255.92", "total_line_items_price_set": { "shop_money": { "amount": "255.92", "currency_code": "AUD" }, "presentment_money": { "amount": "255.92", "currency_code": "AUD" } }, "total_outstanding": "270.37", "total_price": "270.37", "total_price_set": { "shop_money": { "amount": "270.37", "currency_code": "AUD" }, "presentment_money": { "amount": "270.37", "currency_code": "AUD" } }, "total_price_usd": "194.57", "total_shipping_price_set": { "shop_money": { "amount": "0.00", "currency_code": "AUD" }, "presentment_money": { "amount": "0.00", "currency_code": "AUD" } }, "total_tax": "14.45", "total_tax_set": { "shop_money": { "amount": "14.45", "currency_code": "AUD" }, "presentment_money": { "amount": "14.45", "currency_code": "AUD" } }, "total_tip_received": "0.00", "total_weight": 0, "updated_at": "2022-01-05T10:52:40+09:00", "user_id": null, "discount_applications": [], "fulfillments": [], "line_items": [ { "id": 10850713174079, "admin_graphql_api_id": "gid://shopify/LineItem/10850713174079", "fulfillable_quantity": 1, "fulfillment_service": "manual", "fulfillment_status": null, "gift_card": false, "grams": 1700, "name": "Red Leather Coat", "price": "129.99", "price_set": { "shop_money": { "amount": "129.99", "currency_code": "AUD" }, "presentment_money": { "amount": "129.99", "currency_code": "AUD" } }, "product_exists": false, "product_id": null, "properties": [], "quantity": 1, "requires_shipping": true, "sku": null, "taxable": true, "title": "Red Leather Coat", "total_discount": "0.00", "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "AUD" }, "presentment_money": { "amount": "0.00", "currency_code": "AUD" } }, "variant_id": null, "variant_inventory_management": null, "variant_title": null, "vendor": null, "tax_lines": [ { "channel_liable": null, "price": "7.81", "price_set": { "shop_money": { "amount": "7.81", "currency_code": "AUD" }, "presentment_money": { "amount": "7.81", "currency_code": "AUD" } }, "rate": 0.06, "title": "State tax" }, { "channel_liable": null, "price": "3.26", "price_set": { "shop_money": { "amount": "3.26", "currency_code": "AUD" }, "presentment_money": { "amount": "3.26", "currency_code": "AUD" } }, "rate": 0.025, "title": "County tax" } ], "duties": [], "discount_allocations": [] }, { "id": 10850713206847, "admin_graphql_api_id": "gid://shopify/LineItem/10850713206847", "fulfillable_quantity": 1, "fulfillment_service": "manual", "fulfillment_status": null, "gift_card": false, "grams": 750, "name": "Blue Suede Shoes", "price": "85.95", "price_set": { "shop_money": { "amount": "85.95", "currency_code": "AUD" }, "presentment_money": { "amount": "85.95", "currency_code": "AUD" } }, "product_exists": false, "product_id": null, "properties": [], "quantity": 1, "requires_shipping": true, "sku": null, "taxable": false, "title": "Blue Suede Shoes", "total_discount": "0.00", "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "AUD" }, "presentment_money": { "amount": "0.00", "currency_code": "AUD" } }, "variant_id": null, "variant_inventory_management": null, "variant_title": null, "vendor": null, "tax_lines": [], "duties": [], "discount_allocations": [] }, { "id": 10850713239615, "admin_graphql_api_id": "gid://shopify/LineItem/10850713239615", "fulfillable_quantity": 2, "fulfillment_service": "manual", "fulfillment_status": null, "gift_card": false, "grams": 320, "name": "Raspberry Beret", "price": "19.99", "price_set": { "shop_money": { "amount": "19.99", "currency_code": "AUD" }, "presentment_money": { "amount": "19.99", "currency_code": "AUD" } }, "product_exists": false, "product_id": null, "properties": [], "quantity": 2, "requires_shipping": true, "sku": null, "taxable": true, "title": "Raspberry Beret", "total_discount": "0.00", "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "AUD" }, "presentment_money": { "amount": "0.00", "currency_code": "AUD" } }, "variant_id": null, "variant_inventory_management": null, "variant_title": null, "vendor": null, "tax_lines": [ { "channel_liable": null, "price": "2.39", "price_set": { "shop_money": { "amount": "2.39", "currency_code": "AUD" }, "presentment_money": { "amount": "2.39", "currency_code": "AUD" } }, "rate": 0.06, "title": "State tax" }, { "channel_liable": null, "price": "0.99", "price_set": { "shop_money": { "amount": "0.99", "currency_code": "AUD" }, "presentment_money": { "amount": "0.99", "currency_code": "AUD" } }, "rate": 0.025, "title": "County tax" } ], "duties": [], "discount_allocations": [] } ], "payment_terms": null, "refunds": [], "shipping_lines": [] } }
Code language: JSON / JSON with Comments (json)
response

Step 3: Verify The Result

In the Admin, choose orders, then click all orders.

the order

As you can see the order has been created successfully.

I have shown you all steps to create an order with tax lines split across taxable line items with Shopify API using Postman. If you have any questions please leave a comment below or refer to our Devdocs

If you still do not understand the tutorial’s content, you can watch the video below for a more overview.

Shopify API – How to create an order

Hopefully, you can do it!

Related Articles

Share on facebook
Share on twitter
Share on linkedin
Share on pinterest
Share on print
Share on email