Shopify API 2024 – How to create a draft order using postman

Table of Contents

This article will discuss 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 by themselves. 

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

     

      • Accept payment for an order placed over the phone, in person, or 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.

      • Use custom items to indicate additional expenses or products not displayed in your inventory.

      • 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 learn 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 how 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 of How to build a custom app for Shopify in 2022? To know how to access Shopify API. 

       

        • After creating an app, you must 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 the Shopify admin. Let’s go to the draft order. In the Admin dashboard, choose orders, and click draft orders. 

      drafts

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

      Step 2: Create a draft order using Postman 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

             

              1. {API_key} – The API key that you generated.

              1. {admin_API_access_token} – The admin API access token that you generated.

              1. {shop} – The name of your development store.

              1. {api-version} – The supported API version that you want to use.

              1. {resource} – A resource endpoint from the REST Admin API.

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

            https://ed86d512a2c95387ffa25f67074a222b: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@hexasync.myshopify.com/admin/api/2021-10/draft_orders.json

               

                • 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
                      }]
                  }
              }
              

              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
                  }
              }

              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 comment below or refer to our blog: What is an API?. Besides, you can see more Shopify API documentation in the developer docs.

              https://youtu.be/NcFPnWBRPD8
              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!