Anchor to draftOrderDeletedraft
draftOrderDelete
mutation
Requires access scope. Also: The user must have access to delete draft orders.
Deletes a draft order.
Anchor to Arguments
Arguments
- Anchor to inputinput•Draft
Order requiredDelete Input! Specify the draft order to delete by its ID.
Was this section helpful?
Anchor to DraftOrderDeletePayload returnsDraftOrderDeletePayload returns
- Anchor to deletedIddeleted•
Id The ID of the deleted draft order.
- Anchor to userErrorsuser•
Errors [UserError!]! non-null The list of errors that occurred from executing the mutation.
Was this section helpful?
- Delete a draft order by ID and return the deleted ID
- Deleting a draft order that doesn't exist returns an error
- Remove an existing DraftOrder
- draftOrderDelete reference
Examples
1const { admin } = await authenticate.admin(request);23const response = await admin.graphql(4 `#graphql5 mutation draftOrderDelete($input: DraftOrderDeleteInput!) {6 draftOrderDelete(input: $input) {7 deletedId8 }9 }`,10 {11 variables: {12 "input": {13 "id": "gid://shopify/DraftOrder/276395349"14 }15 },16 },17);1819const data = await response.json();20
mutation draftOrderDelete($input: DraftOrderDeleteInput!) {
draftOrderDelete(input: $input) {
deletedId
}
}
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 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();
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"
}
},
},
});
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)
Input variables
JSON1{2 "input": {3 "id": "gid://shopify/DraftOrder/276395349"4 }5}
Response
JSON1{2 "draftOrderDelete": {3 "deletedId": "gid://shopify/DraftOrder/276395349"4 }5}