---
title: "collectionAddProducts"
description: "Add a batch of products to the collection."
doc_type: graphql
doc_category: adminGraphQL
doc_version: v20270301
source_url:
  html: 'https://developer.shopline.com/docs/admin-graph-ql-api/products-and-collections/mutations/collection-add-products'
  md: 'https://developer.shopline.com/docs/admin-graph-ql-api/products-and-collections/mutations/collection-add-products.md'
---
# collectionAddProducts

Add a batch of products to the collection.

- **API Version:** v20270301
- **API Type:** Admin
- **API Protocol:** GraphQL
- **Operation Type:** Mutation

## Type Signature

`CollectionAddProductsPayload`

## Arguments

* `id`

  [ID!](https://developer.shopline.com/docs/admin-graph-ql-api/common/scalars/id.md)

  Specify the ID for the collection that needs updating. Note: Smart collections are not permitted.

* `productIds`

  [[ID!]](https://developer.shopline.com/docs/admin-graph-ql-api/common/scalars/id.md)

  The ID of the product scheduled for addition to the collection. If the product already exists in the collection, an error will be triggered, and no products will be added.

## Returns

* `collection`

  [Collection](https://developer.shopline.com/docs/admin-graph-ql-api/products-and-collections/objects/collection.md)

  Updated collection. If an error occurs, returns null.

* `userErrors`

  [[UserError]!](https://developer.shopline.com/docs/admin-graph-ql-api/common-objects/objects/user-error.md)

  A list of the errors encountered during the mutation. 

## Code Example

```graphql
mutation collectionAddProducts($id: ID! $productIds: [ID!] ) {
	collectionAddProducts(id: $id, productIds: $productIds ) 
		 {
			# CollectionAddProductsPayload fields
		}
		
	}

```

## Variables

```json
{
  "id": {},
  "productIds": {}
}
```

## Error Handling

For detailed information about common codes, see [Status and error codes](https://developer.shopline.com/docs/apps/api-instructions-for-use/graph-ql-admin-api/overview.md#status-and-error-codes).

