Create Collection

🔒

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:

  1. Create a collection to group related products for better categorization.
  2. 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 NameTypeRequiredParameter LocationParameter ValueDescription
Access-TokenStringYesHeaderBx-_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-TypeStringYesHeaderapplication
/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 NameTypeMandatoryParameter LocationExample ValueDescription
errorStringNoResponse 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" }.
errorsArrayNoResponse Body{ "errors"["No Context"] }A list of errors that occurred during the request processing. Example: { "errors": [ "No Context" ] }.
Request-IdStringYesHeaderBx-_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

FieldTypeRequiredExampleDescription
titlestringYesSummer CollectionThe name of the collection.
handlestringNosummer-collectionA unique URL-friendly identifier for the collection.
descriptionstringNoA collection of summer products.The description of the collection.
imageobjectNoImage Object
image.srcstringNohttp://cdn.shoplazza.com/image.jpgThe source URL of the collection image.
image.widthint32No300The width of the collection image in pixels.
image.heightint32No300The height of the collection image in pixels.
image.altstringNoSummer Collection ImageAlt text for the collection image.
seo_titlestringNoSummer CollectionThe SEO title for the collection.
seo_descriptionstringNoExplore our summer collection.The SEO description for the collection.
seo_keywordsstringNosummer, collection, productsComma-separated keywords for SEO.
sort_orderstringNosales-descMerchandise 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_idsstringNo123e4567-e89b-12d3-a456-426614174000Comma-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

FieldTypeExampleDescription
idstringa60fe556-43ad-4e07-9125-507ac1bf71f7Unique identifier of the collection.
titlestringTest-CollectionName of the collection.
descriptionstringDescDescription of the collection.
handlestringtest-collectionURL-friendly handle for the collection.
smartbooleanfalseIndicates whether the collection is smart.
imageobjectImage ObjectObject containing details of the collection image.
image.srcstring//cdn.shoplazza.com/loading.pngSource URL of the collection image.
image.widthinteger100Width of the collection image in pixels.
image.heightinteger100Height of the collection image in pixels.
image.altstring""Alt text for the collection image.
image.pathstringloading.pngFile path of the collection image.
seo_titlestringseo_titleSEO title of the collection.
seo_descriptionstringDescSEO description of the collection.
seo_keywordsstringtestSEO keywords associated with the collection.
sort_orderstringtitle-ascMerchandise 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_atstring2024-04-16T10:31:12ZTimestamp when the collection was created.
updated_atstring2024-04-16T10:31:12ZTimestamp 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.

FieldTypeExampleDescription
errorsArray[ "Title is taken."]A list of errors encountered during the request processing.
FieldTypeExampleDescription
errorArray "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 CodeMessagePossible ReasonExample Response
400Bad RequestInvalid input format or request structure (e.g., missing required fields or incorrect data types).Bad Request
UnauthorizedThe request is missing valid authentication credentials or the credentials provided are invalid.Unauthorized
422Invalid or empty product_id, or product_id is not foundMissing required product_id, or incorrect UUID types.{ "errors": [ "productIds has an invalid UUID"]}
Title is takentitle is already existed{ "errors": ["Title is taken."] }
Unprocessable EntityMissing required field input, or invalid field input{ "errors": ["Title is required."] }
404Record Not FoundThe collection could not be created due to missing or invalid data, or the specified products do not exist.{ "errors": ["Record is required."] }
Language
Credentials
Header
URL
Click Try It! to start a request and see the response here!