# DraftOrder - admin-graphql - OBJECT Version: 2024-04 ## Description An order that a merchant creates on behalf of a customer. Draft orders are useful for merchants that need to do the following tasks: - Create new orders for sales made by phone, in person, by chat, or elsewhere. When a merchant accepts payment for a draft order, an order is created. - Send invoices to customers to pay with a secure checkout link. - Use custom items to represent additional costs or products that aren't displayed in a shop's inventory. - Re-create orders manually from active sales channels. - Sell products at discount or wholesale rates. - Take pre-orders. - Save an order as a draft and resume working on it later. For draft orders in multiple currencies `presentment_money` is the source of truth for what a customer is going to be charged and `shop_money` is an estimate of what the merchant might receive in their shop currency. **Caution:** Only use this data if it's required for your app's functionality. Shopify will restrict [access to scopes](https://shopify.dev/api/usage/access-scopes) for apps that don't have a legitimate use for the associated data. ### Access Scopes `read_draft_orders` access scope. ## Fields * [appliedDiscount](/docs/api/admin-graphql/2024-04/objects/DraftOrderAppliedDiscount): DraftOrderAppliedDiscount - The custom order-level discount applied. * [billingAddress](/docs/api/admin-graphql/2024-04/objects/MailingAddress): MailingAddress - The billing address of the customer. * [billingAddressMatchesShippingAddress](/docs/api/admin-graphql/2024-04/scalars/Boolean): Boolean! - Whether the billing address matches the shipping address. * [completedAt](/docs/api/admin-graphql/2024-04/scalars/DateTime): DateTime - The date and time when the draft order was converted to a new order, and had it's status changed to **Completed**. * [createdAt](/docs/api/admin-graphql/2024-04/scalars/DateTime): DateTime! - The date and time when the draft order was created in Shopify. * [currencyCode](/docs/api/admin-graphql/2024-04/enums/CurrencyCode): CurrencyCode! - The shop currency used for calculation. * [customAttributes](/docs/api/admin-graphql/2024-04/objects/Attribute): Attribute! - The custom information added to the draft order on behalf of the customer. * [customer](/docs/api/admin-graphql/2024-04/objects/Customer): Customer - The customer who will be sent an invoice. * [defaultCursor](/docs/api/admin-graphql/2024-04/scalars/String): String! - A default [cursor](https://shopify.dev/api/usage/pagination-graphql) that returns the single next record, sorted ascending by ID. * [email](/docs/api/admin-graphql/2024-04/scalars/String): String - The email address of the customer, which is used to send notifications. * [hasTimelineComment](/docs/api/admin-graphql/2024-04/scalars/Boolean): Boolean! - Whether the merchant has added timeline comments to the draft order. * [id](/docs/api/admin-graphql/2024-04/scalars/ID): ID! - A globally-unique ID. * [invoiceEmailTemplateSubject](/docs/api/admin-graphql/2024-04/scalars/String): String! - The subject defined for the draft invoice email template. * [invoiceSentAt](/docs/api/admin-graphql/2024-04/scalars/DateTime): DateTime - The date and time when the invoice was last emailed to the customer. * [invoiceUrl](/docs/api/admin-graphql/2024-04/scalars/URL): URL - The link to the checkout, which is sent to the customer in the invoice email. * [legacyResourceId](/docs/api/admin-graphql/2024-04/scalars/UnsignedInt64): UnsignedInt64! - The ID of the corresponding resource in the REST Admin API. * [lineItemsSubtotalPrice](/docs/api/admin-graphql/2024-04/objects/MoneyBag): MoneyBag! - A subtotal of the line items and corresponding discounts, excluding include shipping charges, shipping discounts, taxes, or order discounts. * [marketName](/docs/api/admin-graphql/2024-04/scalars/String): String! - The name of the selected market. * [marketRegionCountryCode](/docs/api/admin-graphql/2024-04/enums/CountryCode): CountryCode! - The selected country code that determines the pricing. * [metafield](/docs/api/admin-graphql/2024-04/objects/Metafield): Metafield - A [custom field](https://shopify.dev/docs/apps/build/custom-data), including its `namespace` and `key`, that's associated with a Shopify resource for the purposes of adding and storing additional information. * [name](/docs/api/admin-graphql/2024-04/scalars/String): String! - The identifier for the draft order, which is unique within the store. For example, _#D1223_. * [note2](/docs/api/admin-graphql/2024-04/scalars/String): String - The text from an optional note attached to the draft order. * [order](/docs/api/admin-graphql/2024-04/objects/Order): Order - The order that was created from the draft order. * [paymentTerms](/docs/api/admin-graphql/2024-04/objects/PaymentTerms): PaymentTerms - The associated payment terms for this draft order. * [phone](/docs/api/admin-graphql/2024-04/scalars/String): String - The assigned phone number. * [poNumber](/docs/api/admin-graphql/2024-04/scalars/String): String - The purchase order number. * [presentmentCurrencyCode](/docs/api/admin-graphql/2024-04/enums/CurrencyCode): CurrencyCode! - The payment currency used for calculation. * [privateMetafield](/docs/api/admin-graphql/2024-04/objects/PrivateMetafield): PrivateMetafield - Returns a private metafield by namespace and key that belongs to the resource. * [purchasingEntity](/docs/api/admin-graphql/2024-04/unions/PurchasingEntity): PurchasingEntity - The purchasing entity. * [ready](/docs/api/admin-graphql/2024-04/scalars/Boolean): Boolean! - Whether the draft order is ready and can be completed. Draft orders might have asynchronous operations that can take time to finish. * [reserveInventoryUntil](/docs/api/admin-graphql/2024-04/scalars/DateTime): DateTime - The time after which inventory will automatically be restocked. * [shippingAddress](/docs/api/admin-graphql/2024-04/objects/MailingAddress): MailingAddress - The shipping address of the customer. * [shippingLine](/docs/api/admin-graphql/2024-04/objects/ShippingLine): ShippingLine - The line item containing the shipping information and costs. * [status](/docs/api/admin-graphql/2024-04/enums/DraftOrderStatus): DraftOrderStatus! - The status of the draft order. * [subtotalPrice](/docs/api/admin-graphql/2024-04/scalars/Money): Money! - The subtotal, in shop currency, of the line items and their discounts, excluding shipping charges, shipping discounts, and taxes. * [subtotalPriceSet](/docs/api/admin-graphql/2024-04/objects/MoneyBag): MoneyBag! - The subtotal, of the line items and their discounts, excluding shipping charges, shipping discounts, and taxes. * [tags](/docs/api/admin-graphql/2024-04/scalars/String): String! - The comma separated list of tags associated with the draft order. Updating `tags` overwrites any existing tags that were previously added to the draft order. To add new tags without overwriting existing tags, use the [tagsAdd](https://shopify.dev/api/admin-graphql/latest/mutations/tagsadd) mutation. * [taxExempt](/docs/api/admin-graphql/2024-04/scalars/Boolean): Boolean! - Whether the draft order is tax exempt. * [taxLines](/docs/api/admin-graphql/2024-04/objects/TaxLine): TaxLine! - The list of of taxes lines charged for each line item and shipping line. * [taxesIncluded](/docs/api/admin-graphql/2024-04/scalars/Boolean): Boolean! - Whether the line item prices include taxes. * [totalDiscountsSet](/docs/api/admin-graphql/2024-04/objects/MoneyBag): MoneyBag! - Total discounts. * [totalLineItemsPriceSet](/docs/api/admin-graphql/2024-04/objects/MoneyBag): MoneyBag! - Total price of line items. * [totalPrice](/docs/api/admin-graphql/2024-04/scalars/Money): Money! - The total price, in shop currency, includes taxes, shipping charges, and discounts. * [totalPriceSet](/docs/api/admin-graphql/2024-04/objects/MoneyBag): MoneyBag! - The total price, includes taxes, shipping charges, and discounts. * [totalShippingPrice](/docs/api/admin-graphql/2024-04/scalars/Money): Money! - The total shipping price in shop currency. * [totalShippingPriceSet](/docs/api/admin-graphql/2024-04/objects/MoneyBag): MoneyBag! - The total shipping price. * [totalTax](/docs/api/admin-graphql/2024-04/scalars/Money): Money! - The total tax in shop currency. * [totalTaxSet](/docs/api/admin-graphql/2024-04/objects/MoneyBag): MoneyBag! - The total tax. * [totalWeight](/docs/api/admin-graphql/2024-04/scalars/UnsignedInt64): UnsignedInt64! - The total weight in grams of the draft order. * [updatedAt](/docs/api/admin-graphql/2024-04/scalars/DateTime): DateTime! - The date and time when the draft order was last changed. The format is YYYY-MM-DD HH:mm:ss. For example, 2016-02-05 17:04:01. * [visibleToCustomer](/docs/api/admin-graphql/2024-04/scalars/Boolean): Boolean! - Whether the draft order will be visible to the customer on the self-serve portal. ## Connections * [events](/docs/api/admin-graphql/2024-04/connections/EventConnection): EventConnection! * [lineItems](/docs/api/admin-graphql/2024-04/connections/DraftOrderLineItemConnection): DraftOrderLineItemConnection! * [localizationExtensions](/docs/api/admin-graphql/2024-04/connections/LocalizationExtensionConnection): LocalizationExtensionConnection! * [metafields](/docs/api/admin-graphql/2024-04/connections/MetafieldConnection): MetafieldConnection! * [privateMetafields](/docs/api/admin-graphql/2024-04/connections/PrivateMetafieldConnection): PrivateMetafieldConnection! ## Related queries * [draftOrder](/docs/api/admin-graphql/2024-04/queries/draftOrder) Returns a DraftOrder resource by ID. * [draftOrders](/docs/api/admin-graphql/2024-04/queries/draftOrders) List of saved draft orders. ## Related mutations * [draftOrderComplete](/docs/api/admin-graphql/2024-04/mutations/draftOrderComplete) Completes a draft order and creates an order. * [draftOrderCreateFromOrder](/docs/api/admin-graphql/2024-04/mutations/draftOrderCreateFromOrder) Creates a draft order from order. * [draftOrderCreate](/docs/api/admin-graphql/2024-04/mutations/draftOrderCreate) Creates a draft order. * [draftOrderDuplicate](/docs/api/admin-graphql/2024-04/mutations/draftOrderDuplicate) Duplicates a draft order. * [draftOrderInvoiceSend](/docs/api/admin-graphql/2024-04/mutations/draftOrderInvoiceSend) Sends an email invoice for a draft order. * [draftOrderUpdate](/docs/api/admin-graphql/2024-04/mutations/draftOrderUpdate) Updates a draft order. If a checkout has been started for a draft order, any update to the draft will unlink the checkout. Checkouts are created but not immediately completed when opening the merchant credit card modal in the admin, and when a buyer opens the invoice URL. This is usually fine, but there is an edge case where a checkout is in progress and the draft is updated before the checkout completes. This will not interfere with the checkout and order creation, but if the link from draft to checkout is broken the draft will remain open even after the order is created. ## Related Unions * [CommentEventEmbed](/docs/api/admin-graphql/2024-04/unions/CommentEventEmbed) The main embed of a comment event. * [MetafieldReferencer](/docs/api/admin-graphql/2024-04/unions/MetafieldReferencer) Types of resources that may use metafields to reference other resources. ## Examples ### Get a draft order by ID Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-04/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query { draftOrder(id: \\\"gid://shopify/DraftOrder/276395349\\\") { name } }\"\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: `query {\n draftOrder(id: \"gid://shopify/DraftOrder/276395349\") {\n name\n }\n }`,\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n query {\n draftOrder(id: \"gid://shopify/DraftOrder/276395349\") {\n name\n }\n }\nQUERY\n\nresponse = client.query(query: query)\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n query {\n draftOrder(id: \"gid://shopify/DraftOrder/276395349\") {\n name\n }\n }`,\n);\n\nconst data = await response.json();\n" Graphql query: "query {\n draftOrder(id: \"gid://shopify/DraftOrder/276395349\") {\n name\n }\n}" #### Graphql Input null #### Graphql Response { "data": { "draftOrder": { "name": "#D1" } } } ### Get a list of draft orders by ID and GraphQL alias Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-04/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query { draftOrder1: draftOrder(id: \\\"gid://shopify/DraftOrder/276395349\\\") { name } draftOrder2: draftOrder(id: \\\"gid://shopify/DraftOrder/221448317\\\") { name } }\"\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: `query {\n draftOrder1: draftOrder(id: \"gid://shopify/DraftOrder/276395349\") {\n name\n }\n draftOrder2: draftOrder(id: \"gid://shopify/DraftOrder/221448317\") {\n name\n }\n }`,\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n query {\n draftOrder1: draftOrder(id: \"gid://shopify/DraftOrder/276395349\") {\n name\n }\n draftOrder2: draftOrder(id: \"gid://shopify/DraftOrder/221448317\") {\n name\n }\n }\nQUERY\n\nresponse = client.query(query: query)\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n query {\n draftOrder1: draftOrder(id: \"gid://shopify/DraftOrder/276395349\") {\n name\n }\n draftOrder2: draftOrder(id: \"gid://shopify/DraftOrder/221448317\") {\n name\n }\n }`,\n);\n\nconst data = await response.json();\n" Graphql query: "query {\n draftOrder1: draftOrder(id: \"gid://shopify/DraftOrder/276395349\") {\n name\n }\n draftOrder2: draftOrder(id: \"gid://shopify/DraftOrder/221448317\") {\n name\n }\n}" #### Graphql Input null #### Graphql Response { "data": { "draftOrder1": { "name": "#D1" }, "draftOrder2": { "name": "#D7" } } } ### Get a list of line item names for a draft order Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-04/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query { draftOrder(id: \\\"gid://shopify/DraftOrder/276395349\\\") { lineItems(first: 5) { edges { node { name } } } } }\"\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: `query {\n draftOrder(id: \"gid://shopify/DraftOrder/276395349\") {\n lineItems(first: 5) {\n edges {\n node {\n name\n }\n }\n }\n }\n }`,\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n query {\n draftOrder(id: \"gid://shopify/DraftOrder/276395349\") {\n lineItems(first: 5) {\n edges {\n node {\n name\n }\n }\n }\n }\n }\nQUERY\n\nresponse = client.query(query: query)\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n query {\n draftOrder(id: \"gid://shopify/DraftOrder/276395349\") {\n lineItems(first: 5) {\n edges {\n node {\n name\n }\n }\n }\n }\n }`,\n);\n\nconst data = await response.json();\n" Graphql query: "query {\n draftOrder(id: \"gid://shopify/DraftOrder/276395349\") {\n lineItems(first: 5) {\n edges {\n node {\n name\n }\n }\n }\n }\n}" #### Graphql Input null #### Graphql Response { "data": { "draftOrder": { "lineItems": { "edges": [ { "node": { "name": "Boots - Default" } } ] } } } } ### Get a metafield attached to a draft order Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-04/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query DraftOrderMetafield($namespace: String!, $key: String!, $ownerId: ID!) { draftOrder(id: $ownerId) { purchaseOrder: metafield(namespace: $namespace, key: $key) { value } } }\",\n \"variables\": {\n \"namespace\": \"my_fields\",\n \"key\": \"purchase_order\",\n \"ownerId\": \"gid://shopify/DraftOrder/276395349\"\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `query DraftOrderMetafield($namespace: String!, $key: String!, $ownerId: ID!) {\n draftOrder(id: $ownerId) {\n purchaseOrder: metafield(namespace: $namespace, key: $key) {\n value\n }\n }\n }`,\n \"variables\": {\n \"namespace\": \"my_fields\",\n \"key\": \"purchase_order\",\n \"ownerId\": \"gid://shopify/DraftOrder/276395349\"\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n query DraftOrderMetafield($namespace: String!, $key: String!, $ownerId: ID!) {\n draftOrder(id: $ownerId) {\n purchaseOrder: metafield(namespace: $namespace, key: $key) {\n value\n }\n }\n }\nQUERY\n\nvariables = {\n \"namespace\": \"my_fields\",\n \"key\": \"purchase_order\",\n \"ownerId\": \"gid://shopify/DraftOrder/276395349\"\n}\n\nresponse = client.query(query: query, variables: variables)\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n query DraftOrderMetafield($namespace: String!, $key: String!, $ownerId: ID!) {\n draftOrder(id: $ownerId) {\n purchaseOrder: metafield(namespace: $namespace, key: $key) {\n value\n }\n }\n }`,\n {\n variables: {\n \"namespace\": \"my_fields\",\n \"key\": \"purchase_order\",\n \"ownerId\": \"gid://shopify/DraftOrder/276395349\"\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "query DraftOrderMetafield($namespace: String!, $key: String!, $ownerId: ID!) {\n draftOrder(id: $ownerId) {\n purchaseOrder: metafield(namespace: $namespace, key: $key) {\n value\n }\n }\n}" #### Graphql Input { "namespace": "my_fields", "key": "purchase_order", "ownerId": "gid://shopify/DraftOrder/276395349" } #### Graphql Response { "data": { "draftOrder": { "purchaseOrder": { "value": "123" } } } } ### Get metafields attached to a draft order Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-04/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query DraftOrderMetafields($ownerId: ID!) { draftOrder(id: $ownerId) { metafields(first: 3) { edges { node { namespace key value } } } } }\",\n \"variables\": {\n \"ownerId\": \"gid://shopify/DraftOrder/276395349\"\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `query DraftOrderMetafields($ownerId: ID!) {\n draftOrder(id: $ownerId) {\n metafields(first: 3) {\n edges {\n node {\n namespace\n key\n value\n }\n }\n }\n }\n }`,\n \"variables\": {\n \"ownerId\": \"gid://shopify/DraftOrder/276395349\"\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n query DraftOrderMetafields($ownerId: ID!) {\n draftOrder(id: $ownerId) {\n metafields(first: 3) {\n edges {\n node {\n namespace\n key\n value\n }\n }\n }\n }\n }\nQUERY\n\nvariables = {\n \"ownerId\": \"gid://shopify/DraftOrder/276395349\"\n}\n\nresponse = client.query(query: query, variables: variables)\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n query DraftOrderMetafields($ownerId: ID!) {\n draftOrder(id: $ownerId) {\n metafields(first: 3) {\n edges {\n node {\n namespace\n key\n value\n }\n }\n }\n }\n }`,\n {\n variables: {\n \"ownerId\": \"gid://shopify/DraftOrder/276395349\"\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "query DraftOrderMetafields($ownerId: ID!) {\n draftOrder(id: $ownerId) {\n metafields(first: 3) {\n edges {\n node {\n namespace\n key\n value\n }\n }\n }\n }\n}" #### Graphql Input { "ownerId": "gid://shopify/DraftOrder/276395349" } #### Graphql Response { "data": { "draftOrder": { "metafields": { "edges": [ { "node": { "namespace": "my_fields", "key": "purchase_order", "value": "123" } } ] } } } }