--- title: draftOrderComplete - GraphQL Admin description: >- Completes a [draft order](https://shopify.dev/docs/api/admin-graphql/latest/objects/DraftOrder) and converts it into a [regular order](https://shopify.dev/docs/api/admin-graphql/latest/objects/Order). The order appears in the merchant's orders list, and the customer can be notified about their order. Use the `draftOrderComplete` mutation when a merchant is ready to finalize a draft order and create a real order in their store. The `draftOrderComplete` mutation also supports sales channel attribution for tracking order sources using the [`sourceName`](https://shopify.dev/docs/api/admin-graphql/latest/mutations/draftOrderComplete#arguments-sourceName) argument, [cart validation](https://shopify.dev/docs/apps/build/checkout/cart-checkout-validation) controls for app integrations, and detailed error reporting for failed completions. You can complete a draft order with different [payment scenarios](https://help.shopify.com/manual/fulfillment/managing-orders/payments): - Mark the order as paid immediately. - Set the order as payment pending using [payment terms](https://shopify.dev/docs/api/admin-graphql/latest/objects/PaymentTerms). - Specify a custom payment amount. - Select a specific payment gateway. > Note: > When completing a draft order, inventory is [reserved](https://shopify.dev/docs/apps/build/orders-fulfillment/inventory-management-apps#inventory-states) for the items in the order. This means the items will no longer be available for other customers to purchase. Make sure to verify inventory availability before completing the draft order. api_version: 2024-10 api_name: admin type: mutation api_type: graphql source_url: html: >- https://shopify.dev/docs/api/admin-graphql/2024-10/mutations/draftOrderComplete md: >- https://shopify.dev/docs/api/admin-graphql/2024-10/mutations/draftOrderComplete.txt --- # draft​Order​Complete mutation Requires `write_draft_orders` access scope. Also: The user must have access to mark as paid, or set payment terms. Completes a [draft order](https://shopify.dev/docs/api/admin-graphql/latest/objects/DraftOrder) and converts it into a [regular order](https://shopify.dev/docs/api/admin-graphql/latest/objects/Order). The order appears in the merchant's orders list, and the customer can be notified about their order. Use the `draftOrderComplete` mutation when a merchant is ready to finalize a draft order and create a real order in their store. The `draftOrderComplete` mutation also supports sales channel attribution for tracking order sources using the [`sourceName`](https://shopify.dev/docs/api/admin-graphql/latest/mutations/draftOrderComplete#arguments-sourceName) argument, [cart validation](https://shopify.dev/docs/apps/build/checkout/cart-checkout-validation) controls for app integrations, and detailed error reporting for failed completions. You can complete a draft order with different [payment scenarios](https://help.shopify.com/manual/fulfillment/managing-orders/payments): * Mark the order as paid immediately. * Set the order as payment pending using [payment terms](https://shopify.dev/docs/api/admin-graphql/latest/objects/PaymentTerms). * Specify a custom payment amount. * Select a specific payment gateway. *** Note When completing a draft order, inventory is [reserved](https://shopify.dev/docs/apps/build/orders-fulfillment/inventory-management-apps#inventory-states) for the items in the order. This means the items will no longer be available for other customers to purchase. Make sure to verify inventory availability before completing the draft order. *** ## Arguments * id [ID!](https://shopify.dev/docs/api/admin-graphql/2024-10/scalars/ID) required The draft order to complete. * payment​Gateway​Id [ID](https://shopify.dev/docs/api/admin-graphql/2024-10/scalars/ID) The gateway for the completed draft order. * source​Name [String](https://shopify.dev/docs/api/admin-graphql/2024-10/scalars/String) A channel definition handle used for sales channel attribution. * payment​Pending [Boolean](https://shopify.dev/docs/api/admin-graphql/2024-10/scalars/Boolean) DeprecatedDefault:false *** ## Draft​Order​Complete​Payload returns * draft​Order [Draft​Order](https://shopify.dev/docs/api/admin-graphql/2024-10/objects/DraftOrder) The completed draft order. * user​Errors [\[User​Error!\]!](https://shopify.dev/docs/api/admin-graphql/2024-10/objects/UserError) non-null The list of errors that occurred from executing the mutation. *** ## Examples * ### Complete a draft order #### Description Convert a finalized draft order into a completed \[order]\(https\://shopify.dev/docs/api/admin-graphql/latest/objects/Order) that's ready for fulfillment and payment processing. This example shows the process for completing an order. When an order is marked as paid, you receive a new order ID to track and fulfill the order. Use this example when a customer has confirmed their purchase and payment is received. #### Query ```graphql mutation draftOrderComplete($id: ID!) { draftOrderComplete(id: $id) { draftOrder { id order { id } } } } ``` #### Variables ```json { "id": "gid://shopify/DraftOrder/276395349" } ``` #### cURL ```bash curl -X POST \ https://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "mutation draftOrderComplete($id: ID!) { draftOrderComplete(id: $id) { draftOrder { id order { id } } } }", "variables": { "id": "gid://shopify/DraftOrder/276395349" } }' ``` #### Remix ```javascript const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql mutation draftOrderComplete($id: ID!) { draftOrderComplete(id: $id) { draftOrder { id order { id } } } }`, { variables: { "id": "gid://shopify/DraftOrder/276395349" }, }, ); const data = await response.json(); ``` #### Ruby ```ruby session = ShopifyAPI::Auth::Session.new( shop: "your-development-store.myshopify.com", access_token: access_token ) client = ShopifyAPI::Clients::Graphql::Admin.new( session: session ) query = <<~QUERY mutation draftOrderComplete($id: ID!) { draftOrderComplete(id: $id) { draftOrder { id order { id } } } } QUERY variables = { "id": "gid://shopify/DraftOrder/276395349" } response = client.query(query: query, variables: variables) ``` #### Node.js ```javascript const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: { "query": `mutation draftOrderComplete($id: ID!) { draftOrderComplete(id: $id) { draftOrder { id order { id } } } }`, "variables": { "id": "gid://shopify/DraftOrder/276395349" }, }, }); ``` #### Response ```json { "draftOrderComplete": { "draftOrder": { "id": "gid://shopify/DraftOrder/276395349", "order": { "id": "gid://shopify/Order/1073459969" } } } } ``` * ### Complete a draft order using a payment gateway #### Description Create a draft order using the \[\`paymentGatewayId\`]\(https\://shopify.dev/docs/api/admin-graphql/latest/mutations/draftOrderComplete#arguments-paymentGatewayId) argument for specialized payment processing. This example demonstrates completing orders through specific payment providers, such as custom payment gateways or alternative payment methods. Learn more about \[third-party payment providers]\(https\://help.shopify.com/manual/payments/third-party-providers). #### Query ```graphql mutation draftOrderComplete($id: ID!, $paymentGatewayId: ID) { draftOrderComplete(id: $id, paymentGatewayId: $paymentGatewayId) { draftOrder { id order { id paymentGatewayNames } } } } ``` #### Variables ```json { "id": "gid://shopify/DraftOrder/276395349", "paymentGatewayId": "gid://shopify/PaymentGateway/371889432" } ``` #### cURL ```bash curl -X POST \ https://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "mutation draftOrderComplete($id: ID!, $paymentGatewayId: ID) { draftOrderComplete(id: $id, paymentGatewayId: $paymentGatewayId) { draftOrder { id order { id paymentGatewayNames } } } }", "variables": { "id": "gid://shopify/DraftOrder/276395349", "paymentGatewayId": "gid://shopify/PaymentGateway/371889432" } }' ``` #### Remix ```javascript const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql mutation draftOrderComplete($id: ID!, $paymentGatewayId: ID) { draftOrderComplete(id: $id, paymentGatewayId: $paymentGatewayId) { draftOrder { id order { id paymentGatewayNames } } } }`, { variables: { "id": "gid://shopify/DraftOrder/276395349", "paymentGatewayId": "gid://shopify/PaymentGateway/371889432" }, }, ); const data = await response.json(); ``` #### Ruby ```ruby session = ShopifyAPI::Auth::Session.new( shop: "your-development-store.myshopify.com", access_token: access_token ) client = ShopifyAPI::Clients::Graphql::Admin.new( session: session ) query = <<~QUERY mutation draftOrderComplete($id: ID!, $paymentGatewayId: ID) { draftOrderComplete(id: $id, paymentGatewayId: $paymentGatewayId) { draftOrder { id order { id paymentGatewayNames } } } } QUERY variables = { "id": "gid://shopify/DraftOrder/276395349", "paymentGatewayId": "gid://shopify/PaymentGateway/371889432" } response = client.query(query: query, variables: variables) ``` #### Node.js ```javascript const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: { "query": `mutation draftOrderComplete($id: ID!, $paymentGatewayId: ID) { draftOrderComplete(id: $id, paymentGatewayId: $paymentGatewayId) { draftOrder { id order { id paymentGatewayNames } } } }`, "variables": { "id": "gid://shopify/DraftOrder/276395349", "paymentGatewayId": "gid://shopify/PaymentGateway/371889432" }, }, }); ``` #### Response ```json { "draftOrderComplete": { "draftOrder": { "id": "gid://shopify/DraftOrder/276395349", "order": { "id": "gid://shopify/Order/1073459968", "paymentGatewayNames": [ "Cash on Delivery (COD)" ] } } } } ``` * ### draftOrderComplete reference [Open in GraphiQL](http://localhost:3457/graphiql?query=mutation%20draftOrderComplete\(%24id%3A%20ID!\)%20%7B%0A%20%20draftOrderComplete\(id%3A%20%24id\)%20%7B%0A%20%20%20%20draftOrder%20%7B%0A%20%20%20%20%20%20id%0A%20%20%20%20%20%20order%20%7B%0A%20%20%20%20%20%20%20%20id%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%20%7D%0A%7D\&variables=%7B%0A%20%20%22id%22%3A%20%22gid%3A%2F%2Fshopify%2FDraftOrder%2F276395349%22%0A%7D) ```javascript const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql mutation draftOrderComplete($id: ID!) { draftOrderComplete(id: $id) { draftOrder { id order { id } } } }`, { variables: { "id": "gid://shopify/DraftOrder/276395349" }, }, ); const data = await response.json(); ``` ## Input variables JSON ```json { "id": "gid://shopify/DraftOrder/276395349" } ``` ## Response JSON ```json { "draftOrderComplete": { "draftOrder": { "id": "gid://shopify/DraftOrder/276395349", "order": { "id": "gid://shopify/Order/1073459969" } } } } ```