collectionAddProducts mutation

Adds products to a collection.

Required access

write_products access scope.

On this page

Interactive example

This is an example mutation query. Use the embedded interactive tool below to edit the query.

Hint: use Ctrl + Space for autocompleting fields.

mutation collectionAddProducts($id: ID!, $productIds: [ID!]!) { collectionAddProducts(id: $id, productIds: $productIds) {
  1. <font style="color:#1F61A0;">collection</font> <font style="color:#555555;">{</font>
  2. <font style="color:#1F61A0;">id</font>
  3. <font style="color:#555555;">}</font>
  4. <font style="color:#1F61A0;">userErrors</font> <font style="color:#555555;">{</font>
  5. <font style="color:#1F61A0;">field</font>
  6. <font style="color:#1F61A0;">message</font>
  7. <font style="color:#555555;">}</font>
} } { “id”: “Z2lkOi8vU2hvcGlmeS9FeGFtcGxlLzE=”, “productIds”: [
  1. <font style="color:#D64292;">"Z2lkOi8vU2hvcGlmeS9FeGFtcGxlLzE="</font>
] }

Arguments

Argument Description
id
(
[ID!](https://shopify.dev/docs/admin-api/graphql/reference/scalar#id-2021-01)

) REQUIRED
The ID of the collection that’s being updated.
productIds
(
[[ID!]!](https://shopify.dev/docs/admin-api/graphql/reference/scalar#id-2021-01)

) REQUIRED
The IDs of the products that are being added to the collection.

Return fields

  • collection ([Collection](https://shopify.dev/docs/admin-api/graphql/reference/products-and-collections/collection))
    The updated collection.
  • userErrors ([[UserError!]!](https://shopify.dev/docs/admin-api/graphql/reference/usererror))
    List of errors that occurred executing the mutation.