Anchor to section titled 'undefined'

draftOrderDelete
mutation

Requires write_draft_orders access scope. Also: The user must have access to delete draft orders.

Deletes a draft order.


Specify the draft order to delete by its ID.


Was this section helpful?

The ID of the deleted draft order.

The list of errors that occurred from executing the mutation.


Was this section helpful?

Examples

Hide code
Copy
mutation draftOrderDelete($input: DraftOrderDeleteInput!) {
  draftOrderDelete(input: $input) {
    deletedId
  }
}
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 draftOrderDelete($input: DraftOrderDeleteInput!) { draftOrderDelete(input: $input) { deletedId } }",
 "variables": {
    "input": {
      "id": "gid://shopify/DraftOrder/276395349"
    }
  }
}'
const { admin } = await authenticate.admin(request);

const response = await admin.graphql(
  `#graphql
  mutation draftOrderDelete($input: DraftOrderDeleteInput!) {
    draftOrderDelete(input: $input) {
      deletedId
    }
  }`,
  {
    variables: {
      "input": {
        "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 draftOrderDelete($input: DraftOrderDeleteInput!) {
    draftOrderDelete(input: $input) {
      deletedId
    }
  }
QUERY

variables = {
  "input": {
    "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 draftOrderDelete($input: DraftOrderDeleteInput!) {
      draftOrderDelete(input: $input) {
        deletedId
      }
    }`,
    "variables": {
      "input": {
        "id": "gid://shopify/DraftOrder/276395349"
      }
    },
  },
});
use Shopify\Clients\Graphql;

$client = new Graphql("your-development-store.myshopify.com", $accessToken);
$query = <<<QUERY
  mutation draftOrderDelete($input: DraftOrderDeleteInput!) {
    draftOrderDelete(input: $input) {
      deletedId
    }
  }
QUERY;

$variables = [
  "input" => [
    "id" => "gid://shopify/DraftOrder/276395349",
  ],
];

$response = $client->query(["query" => $query, "variables" => $variables]);
Hide code
Input variables
Copy
{
  "input": {
    "id": "gid://shopify/DraftOrder/276395349"
  }
}
Hide code
Response
JSON
{
  "draftOrderDelete": {
    "deletedId": "gid://shopify/DraftOrder/276395349"
  }
}