Shopify API - How to create a draft order using postman

Shopify API – How to create a draft order using postman

In this article, we will talk about how to create a draft order using Postman in Shopify API.

The draft order is a draft version of an order that the owner can create when the customer wants to buy some products but they don’t pay yet. It is an order you create for your customer, instead of creating it by themselves. 

The draft order is converted to an order when the owner accepts payment for it. The draft order is created in these cases below. 

  • Accept payment for an order placed over the phone, in person, or in another way. On the Orders page, when you accept payment for your draft order, an order is created for it.
  • Send invoices to customers with a secure checkout link for them to pay.
  • To indicate additional expenses or products that aren’t displayed in your inventory, use custom items.
  • Orders can be manually re-created from any of your active sales channels.
  • Offer things at a discount or in bulk.
  • Pre-orders are accepted.
  • Save the orders as a draft so you can return them to them later. If you save your order as a draft, you can edit it later from your Shopify admin’s Drafts page.

Note: After you mark a draft order as paid, pending, or paid using a customer’s billing information, you can’t change it.

Now, let’s dive into the article to know how to create a draft order using Postman in Shopify API. 

With Shopify API, you can create a draft order with only a product variant ID, a discount, a discounted line item, percent discount on a line item. But in this article, Beehexa will show the way to create a draft order with only a product variant ID. 

Step 1: Generate API credentials from the Shopify admin

If this is the first time you make a call in the Postman, you must generate API credentials from the Shopify admin. Follow the process in How to build a custom app for Shopify in 2022? to know how to access Shopify API. 

  • After creating an app, you need to assign “Draft orders” scopes to the admin API scopes. 
  • Remember the Admin API access token and the API key to create a draft order in the Postman. 

After generating API credentials from Shopify admin. Let’s go to the draft order. In the Admin dashboard, choose orders, click draft orders. 

drafts

As you can see, there is no draft order created today.

Step 2: Create a draft order with only a product variant ID

Before creating a draft order, you need to determine the product variant ID that you want to create a draft order. 

Example: In this article, Beehexa will get a product variant ID from 2 product variants of the Beehexa T-Shirt 2021 New Version 01 product. 

  • In the admin dashboard, choose products.
  • Search Beehexa T-Shirt 2021 New Version 01 product.
  • Choose the yellow variant.
  • Finally, select the ID of the product variant in the URL.

In this case, product variant ID = 39593985409087

After that, we will create a draft order with only a product variant ID. 

  • Log in to your Postman and create a new workspace
  • Create a new POST with this URL:
https://{API_key}:{admin_API_access_token}@{shop}.myshopify.com/admin/api/{api-version}/{resource}.json
Code language: JavaScript (javascript)
  1. {API_key} – The API key that you generated.
  2. {admin_API_access_token} – The admin API access token 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 {draft_orders}:

https://ed86d512a2c95387ffa25f67074a222b:[email protected]/admin/api/2021-10/draft_orders.json
Code language: JavaScript (javascript)
  • Paste the URL above.
create a draft order

In the body section, click raw → Choose JSON, then enter the code

{ "draft_order": { "line_items": [{ "variant_id": 39593985409087, "quantity": 1 }] } }
Code language: JSON / JSON with Comments (json)
body

Then click Send

Response:

The API will return the data like this

{ "draft_order": { "id": 878336999487, "note": null, "email": null, "taxes_included": false, "currency": "AUD", "invoice_sent_at": null, "created_at": "2022-02-28T13:14:48+09:00", "updated_at": "2022-02-28T13:14:48+09:00", "tax_exempt": false, "completed_at": null, "name": "#D68", "status": "open", "line_items": [ { "id": 57264082845759, "variant_id": 39593985409087, "product_id": 4916307230783, "title": "Beehexa T-Shirt 2021 New Version 01", "variant_title": "Yellow", "sku": "", "vendor": "hexasync", "quantity": 1, "requires_shipping": true, "taxable": true, "gift_card": false, "fulfillment_service": "manual", "grams": 0, "tax_lines": [], "applied_discount": null, "name": "Beehexa T-Shirt 2021 New Version 01 - Yellow", "properties": [], "custom": false, "price": "1.00", "admin_graphql_api_id": "gid://shopify/DraftOrderLineItem/57264082845759" } ], "shipping_address": null, "billing_address": null, "invoice_url": "https://hexasync.myshopify.com/25322618943/invoices/41bbf11edd5d004800023891e48ae843", "applied_discount": null, "order_id": null, "shipping_line": null, "tax_lines": [], "tags": "", "note_attributes": [], "total_price": "1.00", "subtotal_price": "1.00", "total_tax": "0.00", "payment_terms": null, "admin_graphql_api_id": "gid://shopify/DraftOrder/878336999487", "customer": null } }
Code language: JSON / JSON with Comments (json)
response_draft order

Step 3: Verify the result

In the admin dashboard, go to the orders.

Click on draft orders

after creating a draft order

As you can see, the draft order has been created successfully. 

Above are all steps to create a draft order using Postman with Shopify API. If you have any questions, please leave a comment below or refer to our Shopify api documentation.

Shopify API – How to create a draft order using Postman

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

Hopefully, you can do it!

Shopify API - How to create a draft order using postman

Shopify API – How to create a draft order using postman

Join The Ride

Subscribe to our fortnightly newsletter with stories from our latest adventures and the best travel tips

Table of Contents