Requires
write_collection
access scope. More access scope
The Create Collection API allows users to create a new collection in the store, including details like the title, description, associated products, SEO attributes, and merchandise sorting rules. This endpoint provides flexibility for managing collections and organizing products effectively.This API is especially useful for:
- Create a collection to group related products for better categorization.
- Apply specific sorting rules to arrange products in the collection.
Note: The operation is scoped to a specific shop, identified by its unique domain prefix (shopdomain), ensuring all updates are applied to the correct store.
Public Request Parameters
Parameter Name | Type | Required | Parameter Location | Parameter Value | Description |
---|---|---|---|---|---|
Access-Token | String | Yes | Header | Bx-_5aV eXNwl-4AB98s5xLV yg0fNzGf MuTpqtlBA | Used to authenticate API requests. Obtain an access token from the Access Token Guide. Pass it in the Authorization header for every request. |
Content-Type | String | Yes | Header | application /json | Indicates the media type of the request body. It tells the server how to parse the request and the client how to interpret the response. For more details, visit Content-Type. |
Public Response Parameters
Parameter Name | Type | Mandatory | Parameter Location | Example Value | Description |
---|---|---|---|---|---|
error | String | No | Response Body | { "error": "store is not active" } | Indicates an error encountered during the process. This field typically appears when the Access Token is missing or invalid. Example: { "error": "store is not active" } . |
errors | Array | No | Response Body | { "errors"["No Context"] } | A list of errors that occurred during the request processing. Example: { "errors": [ "No Context" ] } . |
Request-Id | String | Yes | Header | Bx-_5aV eXNwl-4AB98s5xLV yg0fNzGf MuTpqtlBA | A unique identifier for each request. It helps in identifying and debugging specific requests. |
Error and Errors Clarification:
Added explanation that the error and errors fields are currently dependent on the API implementation, with plans for future unification.
Request Parameters
Body Parameters
Field | Type | Required | Example | Description |
---|---|---|---|---|
title | string | Yes | Summer Collection | The name of the collection. |
handle | string | No | summer-collection | A unique URL-friendly identifier for the collection. |
description | string | No | A collection of summer products. | The description of the collection. |
image | object | No | Image Object | |
image.src | string | No | http://cdn.shoplazza.com/image.jpg | The source URL of the collection image. |
image.width | int32 | No | 300 | The width of the collection image in pixels. |
image.height | int32 | No | 300 | The height of the collection image in pixels. |
image.alt | string | No | Summer Collection Image | Alt text for the collection image. |
seo_title | string | No | Summer Collection | The SEO title for the collection. |
seo_description | string | No | Explore our summer collection. | The SEO description for the collection. |
seo_keywords | string | No | summer, collection, products | Comma-separated keywords for SEO. |
sort_order | string | No | sales-desc | Merchandise sorting rules. Options include: manual (default), sales-desc , price-asc , price-desc , views-desc , vendor-asc , vendor-desc , created-desc , and more. (see options below). |
product_ids | string | No | 123e4567-e89b-12d3-a456-426614174000 | Comma-separated list of product IDs to include in the collection. Must be valid UUIDs. |
Sort Order Options
manual
: Default manual sorting.sales-desc
: By total sales volume, high to low.published-desc
: By product published time, newest first.real-sales-desc
: By product real sales, more to less.inventory-quantity-asc
: By inventory quantity, less to more.inventory-quantity-desc
: By inventory quantity, more to less.views-desc
: By product page views, more to less.add-to-cart-count-desc
: By add-to-cart count, more to less.updated-desc
: By product update time, newest first.vendor-asc
: By supplier name A-Z.vendor-desc
: By supplier name Z-A.alpha-asc
: By product title A-Z.alpha-desc
: By product title Z-A.price-asc
: By price, low to high.price-desc
: By price, high to low.created-desc
: By creation time, newest first.
Response Explanation
Successful Response
Field | Type | Example | Description |
---|---|---|---|
id | string | a60fe556-43ad-4e07-9125-507ac1bf71f7 | Unique identifier of the collection. |
title | string | Test-Collection | Name of the collection. |
description | string | Desc | Description of the collection. |
handle | string | test-collection | URL-friendly handle for the collection. |
smart | boolean | false | Indicates whether the collection is smart. |
image | object | Image Object | Object containing details of the collection image. |
image.src | string | //cdn.shoplazza.com/loading.png | Source URL of the collection image. |
image.width | integer | 100 | Width of the collection image in pixels. |
image.height | integer | 100 | Height of the collection image in pixels. |
image.alt | string | "" | Alt text for the collection image. |
image.path | string | loading.png | File path of the collection image. |
seo_title | string | seo_title | SEO title of the collection. |
seo_description | string | Desc | SEO description of the collection. |
seo_keywords | string | test | SEO keywords associated with the collection. |
sort_order | string | title-asc | Merchandise sorting rules. Options include: manual (default), sales-desc , price-asc , price-desc , views-desc , vendor-asc , vendor-desc , created-desc , and more. (see Sort Order Options). |
created_at | string | 2024-04-16T10:31:12Z | Timestamp when the collection was created. |
updated_at | string | 2024-04-16T10:31:12Z | Timestamp when the collection was last updated. |
error Response
Error responses in the API can be represented using two different fields: errors
and error
. Both fields provide details about issues encountered during request processing. Below is an explanation of the fields with their respective examples and descriptions.
Field | Type | Example | Description |
---|---|---|---|
errors | Array | [ "Title is taken."] | A list of errors encountered during the request processing. |
Field | Type | Example | Description |
---|---|---|---|
error | Array | "store is not active" | Indicates an error encountered during the process. |
Request Examples
curl --request POST \
--url https://{shopdomain}.myshoplazza.com/openapi/2022-01/collections \
--header 'accept: application/json' \
--header 'access-token: {your-access-token}' \
--header 'content-type: application/json' \
--data '{
"collection": {
"title": "Summer Collection",
"handle": "summer-collection",
"description": "A collection of summer products.",
"image": {
"src": "http://cdn.shoplazza.com/image.jpg",
"width": 300,
"height": 300,
"alt": "Summer Collection Image"
},
"seo_title": "Summer Collection",
"seo_description": "Explore our summer collection.",
"seo_keywords": "summer, collection, products",
"sort_order": "sales-desc",
"product_ids": "123e4567-e89b-12d3-a456-426614174000,456e7890-e12b-34d5-c678-123456789abc"
}
}'
Success Response Example
{
"collection": {
"id": "a60fe556-43ad-4e07-9125-507ac1bf71f7",
"title": "Test-Collection",
"description": "Desc",
"handle": "test-collection",
"smart": false,
"image": {
"src": "//cdn.shoplazza.com/loading.png",
"width": 100,
"height": 100,
"alt": "",
"path": "loading.png"
},
"seo_title": "seo_title",
"seo_description": "Desc",
"seo_keywords": "test",
"sort_order": "title-asc",
"created_at": "2024-04-16T10:31:12Z",
"updated_at": "2024-04-16T10:31:12Z"
}
}
Error Response Example
{
"errors": [
"Title is taken."
]
}
{
"error": "store is not active"
}
Error Details
Status Code | Message | Possible Reason | Example Response |
---|---|---|---|
400 | Bad Request | Invalid input format or request structure (e.g., missing required fields or incorrect data types). | Bad Request |
Unauthorized | The request is missing valid authentication credentials or the credentials provided are invalid. | Unauthorized | |
422 | Invalid or empty product_id , or product_id is not found | Missing required product_id , or incorrect UUID types. | { "errors": [ "productIds has an invalid UUID"]} |
Title is taken | title is already existed | { "errors": ["Title is taken."] } | |
Unprocessable Entity | Missing required field input, or invalid field input | { "errors": ["Title is required."] } | |
404 | Record Not Found | The collection could not be created due to missing or invalid data, or the specified products do not exist. | { "errors": ["Record is required."] } |