Anchor to section titled 'undefined'

draftOrderComplete
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 and creates an order.


Anchor to id
id
required

The draft order to complete.

The gateway for the completed draft order.

A channel definition handle used for sales channel attribution.


Was this section helpful?

The completed draft order.

The list of errors that occurred from executing the mutation.


Was this section helpful?

Examples

Hide code
DescriptionCopy
mutation draftOrderComplete($id: ID!) {
  draftOrderComplete(id: $id) {
    draftOrder {
      id
      order {
        id
      }
    }
  }
}
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2024-01/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"
  }
}'
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();
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)
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"
    },
  },
});
use Shopify\Clients\Graphql;

$client = new Graphql("your-development-store.myshopify.com", $accessToken);
$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]);
Hide code
Input variables
Copy
{
  "id": "gid://shopify/DraftOrder/276395349"
}
Hide code
Response
JSON
{
  "draftOrderComplete": {
    "draftOrder": {
      "id": "gid://shopify/DraftOrder/276395349",
      "order": {
        "id": "gid://shopify/Order/1073459966"
      }
    }
  }
}