---
title: Use draft orders
description: >-
  Learn how to use draft orders in apps that support Shopify merchants selling
  B2B.
source_url:
  html: 'https://shopify.dev/docs/apps/build/b2b/draft-orders'
  md: 'https://shopify.dev/docs/apps/build/b2b/draft-orders.md'
---

# Use draft orders

Merchants often need to create draft orders for company approval when selling business-to-business (B2B). After [creating a company](https://shopify.dev/docs/apps/build/b2b/start-building), you can use the GraphQL Admin API to [create draft orders](https://shopify.dev/docs/api/admin-graphql/latest/mutations/draftOrderCreate) for a purchasing entity. A purchasing entity is a combination of the company, company contact, and company location.

***

## What you'll learn

In this tutorial, you'll learn how to do the following tasks:

* [Calculate a draft order for a purchasing entity](#step-1-calculate-a-draft-order-for-a-purchasing-entity)
* [Create a draft order for a purchasing entity](#step-2-create-a-draft-order-for-a-purchasing-entity)
* [Send an invoice for a draft order](#step-3-send-an-invoice-for-a-draft-order)
* [Mark a draft order as complete](#step-4-mark-a-draft-order-as-complete)

***

## Requirements

* Your app has the `write_products` [access scope](https://shopify.dev/docs/api/usage/access-scopes). Learn how to [configure your access scopes using Shopify CLI](https://shopify.dev/docs/apps/build/cli-for-apps/app-configuration).
* You've added [products](https://shopify.dev/docs/api/admin-graphql/latest/objects/product) to your dev store.
* You've [created a company](https://shopify.dev/docs/apps/build/b2b/start-building).

***

## Step 1: Calculate a draft order for a purchasing entity

Before creating a draft order for a purchasing entity, you can preview information such as total taxes and prices using the [`draftOrderCalculate`](https://shopify.dev/docs/api/admin-graphql/latest/mutations/draftOrderCalculate) mutation:

## POST https://{shop}.myshopify.com/api/{api\_version}/graphql.json

## GraphQL mutation

```graphql
mutation{
  draftOrderCalculate(
    input: {
      purchasingEntity: {
         purchasingCompany: {
           companyId: "gid://shopify/Company/1"
           companyLocationId: "gid://shopify/CompanyLocation/1"
           companyContactId: "gid://shopify/CompanyContact/1"
         }
      }
      billingAddress: {
        address1: "273 Lenore Stravenue",
        address2: "Suite 573",
        city: "Laketown",
        company: "Alfredo Group",
        firstName: "Avery",
        lastName: "Brown",
        phone: "(800) 555 0100",
        provinceCode: "TN",
        zip: "38103"
      },
      customAttributes: null,
      lineItems: [
        {
          appliedDiscount: null,
          originalUnitPrice: "132.99",
          quantity: 1,
          sku: "",
          title: "Aerodynamic Bronze Car",
          variantId: "gid://shopify/ProductVariant/349",
          taxable: true,
          requiresShipping: true,
          customAttributes: [],
        }
      ],
      note: null,
      shippingAddress: {
        address1: "273 Lenore Stravenue",
        address2: "Suite 573",
        city: "Laketown",
        company: "Alfredo Group",
        firstName: "Avery",
        lastName: "Brown",
        phone: "(800) 555 0100",
        provinceCode: "TN",
        zip: "38103"
      },
      tags: [],
      email: "averybrown@example.com",
      phone: null,
      taxExempt: false,
      reserveInventoryUntil: null,
      appliedDiscount: null,
      shippingLine: null,
      localizationExtensions: []
    }
  ) {
    calculatedDraftOrder{
      totalPrice
    }
  }
}
```

## JSON response

```json
{
  "data": {
    "calculatedDraftOrder": {
      "totalPrice": 132.99
    }
  }
}
```

***

## Step 2: Create a draft order for a purchasing entity

When you're satisfied with the calculated draft order, you can create the draft order by passing the same input from your [calculated draft order](#step-1-calculate-a-draft-order-for-a-purchasing-entity) to the [`draftOrderCreate`](https://shopify.dev/docs/api/admin-graphql/latest/mutations/draftordercreate) mutation:

## POST https://{shop}.myshopify.com/api/{api\_version}/graphql.json

## GraphQL mutation

```graphql
mutation{
  draftOrderCreate(
    input: {
      purchasingEntity: {
         purchasingCompany: {
           companyId: "gid://shopify/Company/1"
           companyLocationId: "gid://shopify/CompanyLocation/1"
           companyContactId: "gid://shopify/CompanyContact/1"
         }
      }
      billingAddress: {
        address1: "273 Lenore Stravenue",
        address2: "Suite 573",
        city: "Laketown",
        company: "Alfredo Group",
        firstName: "Avery",
        lastName: "Brown",
        phone: "(800) 555 0100",
        provinceCode: "TN",
        zip: "38103"
      },
      customAttributes: null,
      lineItems: [
        {
          appliedDiscount: null,
          originalUnitPrice: "132.99",
          quantity: 1,
          sku: "",
          title: "Aerodynamic Bronze Car",
          variantId: "gid://shopify/ProductVariant/349",
          taxable: true,
          requiresShipping: true,
          customAttributes: [],
        }
      ],
      note: null,
      shippingAddress: {
        address1: "273 Lenore Stravenue",
        address2: "Suite 573",
        city: "Laketown",
        company: "Alfredo Group",
        firstName: "Avery",
        lastName: "Brown",
        phone: "(800) 555 0100",
        provinceCode: "TN",
        zip: "38103"
      },
      tags: [],
      email: "averybrown@example.com",
      phone: null,
      taxExempt: false,
      reserveInventoryUntil: null,
      appliedDiscount: null,
      shippingLine: null,
      localizationExtensions: []
    }
  ) {
    draftOrder{
      id
      totalPrice
    }
  }
}
```

## JSON response

```json
{
  "data": {
    "draftOrder": {
      "id": "gid://shopify/DraftOrder/10"
      "totalPrice": 132.99
    }
  }
}
```

***

## Step 3: Send an invoice for a draft order

Sending an invoice for a B2B draft order is identical to sending an invoice for a consumer draft order. After creating a draft order, you can pass the draft order ID to the [`draftOrderInvoiceSend`](https://shopify.dev/docs/api/admin-graphql/latest/mutations/draftOrderInvoiceSend) mutation to send the invoice to the company contact:

## POST https://{shop}.myshopify.com/api/{api\_version}/graphql.json

## GraphQL mutation

```graphql
mutation{
  draftOrderInvoiceSend(
    id: "gid://shopify/DraftOrder/10"
  ) {
    draftOrder{
      id
    }
  }
}
```

## JSON response

```json
{
  "data": {
    "draftOrder": {
      "id": "gid://shopify/DraftOrder/10"
    }
  }
}
```

***

## Step 4: Mark a draft order as complete

Marking a B2B draft order as complete is identical to marking a consumer draft order as complete. After creating a draft order, you can pass the draft order ID to the [`draftOrderComplete`](https://shopify.dev/docs/api/admin-graphql/latest/mutations/draftOrderComplete) mutation to mark the draft order as complete and create a corresponding order:

## POST https://{shop}.myshopify.com/api/{api\_version}/graphql.json

## GraphQL mutation

```graphql
mutation{
  draftOrderComplete(
    id: "gid://shopify/DraftOrder/10"
  ) {
    draftOrder{
      id
      order {
        id
      }
    }
  }
}
```

## JSON response

```json
{
  "data": {
    "draftOrder": {
      "id": "gid://shopify/DraftOrder/10",
      "order": {
        "id": "gid://shopify/Order/1"
      }
    }
  }
}
```

***

## Next steps

* Learn how to [create a B2B checkout UI](https://shopify.dev/docs/apps/build/b2b/create-checkout-ui) with the GraphQL Admin API.

***
