Anchor to collectionRemoveProductscollection
collection Remove Products
mutation
Requires access scope. Also: The user must have a permission to remove products from a collection.
Removes a set of products from a given collection. The mutation can take a long time to run. Instead of returning an updated collection the mutation returns a job, which should be polled. For use with manual collections only.
Anchor to Arguments
Arguments
- •ID!required
The ID of the collection to remove products from. The ID must reference an existing manual collection.
- Anchor to productIdsproduct•
Ids [ID!]!required The IDs of products to remove from the collection. The mutation doesn't validate that the products belong to the collection or whether the products exist.
Was this section helpful?
- •
The asynchronous job removing the products.
- Anchor to userErrorsuser•
Errors [UserError!]!non-null The list of errors that occurred from executing the mutation.
Was this section helpful?
- Remove a product from a manual collection
- Remove a product from a non-existent collection
- Remove a product from a smart collection
- Removes a product from a collection
- collectionRemoveProducts reference
Examples
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation collectionRemoveProducts($id: ID!, $productIds: [ID!]!) {
collectionRemoveProducts(id: $id, productIds: $productIds) {
job {
done
id
}
userErrors {
field
message
}
}
}`,
{
variables: {
"id": "gid://shopify/Collection/1007901140",
"productIds": [
"gid://shopify/Product/20995642"
]
},
},
);
const data = await response.json();
mutation collectionRemoveProducts($id: ID!, $productIds: [ID!]!) {
collectionRemoveProducts(id: $id, productIds: $productIds) {
job {
done
id
}
userErrors {
field
message
}
}
}
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2025-04/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "mutation collectionRemoveProducts($id: ID!, $productIds: [ID!]!) { collectionRemoveProducts(id: $id, productIds: $productIds) { job { done id } userErrors { field message } } }",
"variables": {
"id": "gid://shopify/Collection/1007901140",
"productIds": [
"gid://shopify/Product/20995642"
]
}
}'
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation collectionRemoveProducts($id: ID!, $productIds: [ID!]!) {
collectionRemoveProducts(id: $id, productIds: $productIds) {
job {
done
id
}
userErrors {
field
message
}
}
}`,
{
variables: {
"id": "gid://shopify/Collection/1007901140",
"productIds": [
"gid://shopify/Product/20995642"
]
},
},
);
const data = await response.json();
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `mutation collectionRemoveProducts($id: ID!, $productIds: [ID!]!) {
collectionRemoveProducts(id: $id, productIds: $productIds) {
job {
done
id
}
userErrors {
field
message
}
}
}`,
"variables": {
"id": "gid://shopify/Collection/1007901140",
"productIds": [
"gid://shopify/Product/20995642"
]
},
},
});
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 collectionRemoveProducts($id: ID!, $productIds: [ID!]!) {
collectionRemoveProducts(id: $id, productIds: $productIds) {
job {
done
id
}
userErrors {
field
message
}
}
}
QUERY
variables = {
"id": "gid://shopify/Collection/1007901140",
"productIds": ["gid://shopify/Product/20995642"]
}
response = client.query(query: query, variables: variables)
Input variables
JSON{
"id": "gid://shopify/Collection/1007901140",
"productIds": [
"gid://shopify/Product/20995642"
]
}
Response
JSON{
"collectionRemoveProducts": {
"job": {
"done": false,
"id": "gid://shopify/Job/0d9c63ab-d903-4f1e-b9b1-6ddf55948dfb"
},
"userErrors": []
}
}