# Collect
The Collect resource connects a product to a custom collection.
{{ '/api/reference/collect.png' | image }}Collects are meant for managing the relationship between products and custom collections. For every product in a custom collection there is a collect that tracks the ID of both the product and the custom collection. A product can be in more than one collection, and will have a collect connecting it to each collection. Unlike many Shopify resources, collects aren't apparent to store owners.
Collects are for placing products in custom collections only. Smart collections use rules to determine which products are their members. Creating a collect that links a product to a smart collection results in a 403 Forbidden error.
For more information on custom collections, see the CustomCollection resource.
## Resource Properties ### Collect * collection_id: The ID of the custom collection containing the product. * Type: x-string * Example: 841564295 * created_at: The date and time (ISO 8601 format) when the collect was created. * Type: x-string * Example: "2018-04-25T13:51:12-04:00" * id: A unique numeric identifier for the collect. * Type: x-string * Example: 841564295 * position: The position of this product in a manually sorted custom collection. The first position is 1. This value is applied only when the custom collection is sorted manually. * Type: x-string * Example: 2 * product_id: The unique numeric identifier for the product in the custom collection. * Type: x-string * Example: 632910392 * sort_value: This is the same value asposition
but padded with leading zeroes to make it alphanumeric-sortable. This value is applied only when the custom collection is sorted manually.
* Type: x-string
* Example: "0000000002"
* updated_at: The date and time (ISO 8601 format) when the collect was last updated.
* Type: x-string
* Example: "2018-04-25T13:51:12-04:00"
## Adds a product to a custom collection
Adds a product to a custom collection.
### Endpoint
/admin/api/#{api_version}/collects.json (POST)
### Parameters
* api_version (required):
### Responses
#### 201
Adds a product to a custom collection
Examples:
##### Create a new link between an existing product and an existing collection
Request:
```
POST /admin/api/unstable/collects.json
{"collect":{"product_id":921728736,"collection_id":841564295}}
```
Response:
```
HTTP/1.1 201 Created
{"collect":{"id":1071559574,"collection_id":841564295,"product_id":921728736,"created_at":"2025-01-02T11:20:42-05:00","updated_at":"2025-01-02T11:20:42-05:00","position":2,"sort_value":"0000000002"}}
```
#### 422
Adds a product to a custom collection
Examples:
##### Creating a collect without a product or collection ID fails and returns an error
Request:
```
POST /admin/api/unstable/collects.json
{"collect":{"body":"foobar"}}
```
Response:
```
HTTP/1.1 422 Unprocessable Entity
{"errors":{"product":["can't be blank"],"collection":["can't be blank"],"product_id":["must belong to John Smith Test Store"],"collection_id":["must belong to John Smith Test Store"]}}
```
## Retrieves a list of collects
Retrieves a list of collects. Note: This endpoint implements pagination by using links that are provided in the response header. To learn more, refer to Make paginated requests to the REST Admin API.
### Endpoint
/admin/api/#{api_version}/collects.json (GET)
### Parameters
* api_version (required):
* fields: Show only certain fields, specified by a comma-separated list of field names.
* limit: The maximum number of results to show.
* since_id: Restrict results to after the specified ID.
### Responses
#### 200
Retrieves a list of collects
Examples:
##### Retrieve all collects for the shop
Request:
```
GET /admin/api/2019-07/collects.json
```
Response:
```
HTTP/1.1 200 OK
{"collects":[{"id":358268117,"collection_id":482865238,"product_id":632910392,"created_at":null,"updated_at":null,"position":1,"sort_value":"0000000001"},{"id":455204334,"collection_id":841564295,"product_id":632910392,"created_at":null,"updated_at":null,"position":1,"sort_value":"0000000001"},{"id":773559378,"collection_id":395646240,"product_id":632910392,"created_at":null,"updated_at":null,"position":1,"sort_value":"0000000001"},{"id":800915878,"collection_id":482865238,"product_id":921728736,"created_at":null,"updated_at":null,"position":1,"sort_value":"0000000001"}]}
```
##### Retrieve only collects for a certain collection
Request:
```
GET /admin/api/2019-07/collects.json
```
Response:
```
HTTP/1.1 200 OK
{"collects":[{"id":455204334,"collection_id":841564295,"product_id":632910392,"created_at":null,"updated_at":null,"position":1,"sort_value":"0000000001"},{"id":1071559575,"collection_id":841564295,"product_id":921728736,"created_at":"2025-01-02T11:20:44-05:00","updated_at":"2025-01-02T11:20:44-05:00","position":2,"sort_value":"0000000002"}]}
```
##### Retrieve only collects for a certain product
Request:
```
GET /admin/api/2019-07/collects.json
```
Response:
```
HTTP/1.1 200 OK
{"collects":[{"id":358268117,"collection_id":482865238,"product_id":632910392,"created_at":null,"updated_at":null,"position":1,"sort_value":"0000000001"},{"id":455204334,"collection_id":841564295,"product_id":632910392,"created_at":null,"updated_at":null,"position":1,"sort_value":"0000000001"},{"id":773559378,"collection_id":395646240,"product_id":632910392,"created_at":null,"updated_at":null,"position":1,"sort_value":"0000000001"}]}
```
## Removes a product from a collection
Removes a product from a collection.
### Endpoint
/admin/api/#{api_version}/collects/{collect_id}.json (DELETE)
### Parameters
* api_version (required):
* collect_id (required):
### Responses
#### 200
Removes a product from a collection
Examples:
##### Delete the link between a product an a collection
Request:
```
DELETE /admin/api/unstable/collects/455204334.json
```
Response:
```
HTTP/1.1 200 OK
{}
```
## Retrieves a specific collect by its ID
Retrieves a specific collect by its ID.
### Endpoint
/admin/api/#{api_version}/collects/{collect_id}.json (GET)
### Parameters
* api_version (required):
* collect_id (required):
* fields: Show only certain fields, specified by a comma-separated list of field names.
### Responses
#### 200
Retrieves a specific collect by its ID
Examples:
##### Retrieve a collect with a certain ID
Request:
```
GET /admin/api/unstable/collects/455204334.json
```
Response:
```
HTTP/1.1 200 OK
{"collect":{"id":455204334,"collection_id":841564295,"product_id":632910392,"created_at":null,"updated_at":null,"position":1,"sort_value":"0000000001"}}
```
## Retrieves a count of collects
Retrieves a count of collects.
### Endpoint
/admin/api/#{api_version}/collects/count.json (GET)
### Parameters
* api_version (required):
### Responses
#### 200
Retrieves a count of collects
Examples:
##### Count all collects for the shop
Request:
```
GET /admin/api/2020-01/collects/count.json
```
Response:
```
HTTP/1.1 200 OK
{"count":2}
```
##### Count only collects for a certain collection
Request:
```
GET /admin/api/2020-01/collects/count.json
```
Response:
```
HTTP/1.1 200 OK
{"count":1}
```
##### Count only collects for a certain product
Request:
```
GET /admin/api/2020-01/collects/count.json
```
Response:
```
HTTP/1.1 200 OK
{"count":2}
```