# collectionCreate - admin-graphql - MUTATION Version: 2025-01 ## Description Creates a collection. ### Access Scopes `write_products` access scope. Also: The app must have access to the input fields used to create the collection. Further, the store must not be on the Starter or Retail plans and user must have a permission to create collection. ## Arguments * [input](/docs/api/admin-graphql/2025-01/input-objects/CollectionInput): CollectionInput! - The properties to use when creating the collection. ## Returns * [collection](/docs/api/admin-graphql/2025-01/objects/Collection): Collection The collection that has been created. * [userErrors](/docs/api/admin-graphql/2025-01/objects/UserError): UserError! The list of errors that occurred from executing the mutation. ## Examples ### Create a new metafield on a new collection Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation createCollectionMetafields($input: CollectionInput!) { collectionCreate(input: $input) { collection { id metafields(first: 3) { edges { node { id namespace key value } } } } userErrors { message field } } }\",\n \"variables\": {\n \"input\": {\n \"metafields\": [\n {\n \"namespace\": \"my_field\",\n \"key\": \"subtitle\",\n \"type\": \"single_line_text_field\",\n \"value\": \"Bold Colors\"\n }\n ],\n \"title\": \"Spring Styles\"\n }\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation createCollectionMetafields($input: CollectionInput!) {\n collectionCreate(input: $input) {\n collection {\n id\n metafields(first: 3) {\n edges {\n node {\n id\n namespace\n key\n value\n }\n }\n }\n }\n userErrors {\n message\n field\n }\n }\n }`,\n \"variables\": {\n \"input\": {\n \"metafields\": [\n {\n \"namespace\": \"my_field\",\n \"key\": \"subtitle\",\n \"type\": \"single_line_text_field\",\n \"value\": \"Bold Colors\"\n }\n ],\n \"title\": \"Spring Styles\"\n }\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n mutation createCollectionMetafields($input: CollectionInput!) {\n collectionCreate(input: $input) {\n collection {\n id\n metafields(first: 3) {\n edges {\n node {\n id\n namespace\n key\n value\n }\n }\n }\n }\n userErrors {\n message\n field\n }\n }\n }\nQUERY\n\nvariables = {\n \"input\": {\n \"metafields\": [{\"namespace\"=>\"my_field\", \"key\"=>\"subtitle\", \"type\"=>\"single_line_text_field\", \"value\"=>\"Bold Colors\"}],\n \"title\": \"Spring Styles\"\n }\n}\n\nresponse = client.query(query: query, variables: variables)\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation createCollectionMetafields($input: CollectionInput!) {\n collectionCreate(input: $input) {\n collection {\n id\n metafields(first: 3) {\n edges {\n node {\n id\n namespace\n key\n value\n }\n }\n }\n }\n userErrors {\n message\n field\n }\n }\n }`,\n {\n variables: {\n \"input\": {\n \"metafields\": [\n {\n \"namespace\": \"my_field\",\n \"key\": \"subtitle\",\n \"type\": \"single_line_text_field\",\n \"value\": \"Bold Colors\"\n }\n ],\n \"title\": \"Spring Styles\"\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation createCollectionMetafields($input: CollectionInput!) {\n collectionCreate(input: $input) {\n collection {\n id\n metafields(first: 3) {\n edges {\n node {\n id\n namespace\n key\n value\n }\n }\n }\n }\n userErrors {\n message\n field\n }\n }\n}" #### Graphql Input { "input": { "metafields": [ { "namespace": "my_field", "key": "subtitle", "type": "single_line_text_field", "value": "Bold Colors" } ], "title": "Spring Styles" } } #### Graphql Response { "data": { "collectionCreate": { "collection": { "id": "gid://shopify/Collection/1063001313", "metafields": { "edges": [ { "node": { "id": "gid://shopify/Metafield/1069228937", "namespace": "my_field", "key": "subtitle", "value": "Bold Colors" } } ] } }, "userErrors": [] } } } ### Create a smart collection with metafield definition conditions Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation CollectionCreate($input: CollectionInput!) { collectionCreate(input: $input) { userErrors { field message } collection { id title descriptionHtml handle sortOrder ruleSet { appliedDisjunctively rules { column relation condition conditionObject { ... on CollectionRuleMetafieldCondition { metafieldDefinition { id name type { name } ownerType } } } } } } } }\",\n \"variables\": {\n \"input\": {\n \"title\": \"Our entire leather collection\",\n \"descriptionHtml\": \"Check out our leather products.\",\n \"ruleSet\": {\n \"appliedDisjunctively\": false,\n \"rules\": [\n {\n \"column\": \"PRODUCT_METAFIELD_DEFINITION\",\n \"relation\": \"EQUALS\",\n \"condition\": \"leather\",\n \"conditionObjectId\": \"gid://shopify/MetafieldDefinition/1071456109\"\n },\n {\n \"column\": \"VARIANT_METAFIELD_DEFINITION\",\n \"relation\": \"EQUALS\",\n \"condition\": \"true\",\n \"conditionObjectId\": \"gid://shopify/MetafieldDefinition/1071456110\"\n }\n ]\n }\n }\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation CollectionCreate($input: CollectionInput!) {\n collectionCreate(input: $input) {\n userErrors {\n field\n message\n }\n collection {\n id\n title\n descriptionHtml\n handle\n sortOrder\n ruleSet {\n appliedDisjunctively\n rules {\n column\n relation\n condition\n conditionObject {\n ... on CollectionRuleMetafieldCondition {\n metafieldDefinition {\n id\n name\n type {\n name\n }\n ownerType\n }\n }\n }\n }\n }\n }\n }\n }`,\n \"variables\": {\n \"input\": {\n \"title\": \"Our entire leather collection\",\n \"descriptionHtml\": \"Check out our leather products.\",\n \"ruleSet\": {\n \"appliedDisjunctively\": false,\n \"rules\": [\n {\n \"column\": \"PRODUCT_METAFIELD_DEFINITION\",\n \"relation\": \"EQUALS\",\n \"condition\": \"leather\",\n \"conditionObjectId\": \"gid://shopify/MetafieldDefinition/1071456109\"\n },\n {\n \"column\": \"VARIANT_METAFIELD_DEFINITION\",\n \"relation\": \"EQUALS\",\n \"condition\": \"true\",\n \"conditionObjectId\": \"gid://shopify/MetafieldDefinition/1071456110\"\n }\n ]\n }\n }\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n mutation CollectionCreate($input: CollectionInput!) {\n collectionCreate(input: $input) {\n userErrors {\n field\n message\n }\n collection {\n id\n title\n descriptionHtml\n handle\n sortOrder\n ruleSet {\n appliedDisjunctively\n rules {\n column\n relation\n condition\n conditionObject {\n ... on CollectionRuleMetafieldCondition {\n metafieldDefinition {\n id\n name\n type {\n name\n }\n ownerType\n }\n }\n }\n }\n }\n }\n }\n }\nQUERY\n\nvariables = {\n \"input\": {\n \"title\": \"Our entire leather collection\",\n \"descriptionHtml\": \"Check out our leather products.\",\n \"ruleSet\": {\n \"appliedDisjunctively\": false,\n \"rules\": [{\"column\"=>\"PRODUCT_METAFIELD_DEFINITION\", \"relation\"=>\"EQUALS\", \"condition\"=>\"leather\", \"conditionObjectId\"=>\"gid://shopify/MetafieldDefinition/1071456109\"}, {\"column\"=>\"VARIANT_METAFIELD_DEFINITION\", \"relation\"=>\"EQUALS\", \"condition\"=>\"true\", \"conditionObjectId\"=>\"gid://shopify/MetafieldDefinition/1071456110\"}]\n }\n }\n}\n\nresponse = client.query(query: query, variables: variables)\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation CollectionCreate($input: CollectionInput!) {\n collectionCreate(input: $input) {\n userErrors {\n field\n message\n }\n collection {\n id\n title\n descriptionHtml\n handle\n sortOrder\n ruleSet {\n appliedDisjunctively\n rules {\n column\n relation\n condition\n conditionObject {\n ... on CollectionRuleMetafieldCondition {\n metafieldDefinition {\n id\n name\n type {\n name\n }\n ownerType\n }\n }\n }\n }\n }\n }\n }\n }`,\n {\n variables: {\n \"input\": {\n \"title\": \"Our entire leather collection\",\n \"descriptionHtml\": \"Check out our leather products.\",\n \"ruleSet\": {\n \"appliedDisjunctively\": false,\n \"rules\": [\n {\n \"column\": \"PRODUCT_METAFIELD_DEFINITION\",\n \"relation\": \"EQUALS\",\n \"condition\": \"leather\",\n \"conditionObjectId\": \"gid://shopify/MetafieldDefinition/1071456109\"\n },\n {\n \"column\": \"VARIANT_METAFIELD_DEFINITION\",\n \"relation\": \"EQUALS\",\n \"condition\": \"true\",\n \"conditionObjectId\": \"gid://shopify/MetafieldDefinition/1071456110\"\n }\n ]\n }\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation CollectionCreate($input: CollectionInput!) {\n collectionCreate(input: $input) {\n userErrors {\n field\n message\n }\n collection {\n id\n title\n descriptionHtml\n handle\n sortOrder\n ruleSet {\n appliedDisjunctively\n rules {\n column\n relation\n condition\n conditionObject {\n ... on CollectionRuleMetafieldCondition {\n metafieldDefinition {\n id\n name\n type {\n name\n }\n ownerType\n }\n }\n }\n }\n }\n }\n }\n}" #### Graphql Input { "input": { "title": "Our entire leather collection", "descriptionHtml": "Check out our leather products.", "ruleSet": { "appliedDisjunctively": false, "rules": [ { "column": "PRODUCT_METAFIELD_DEFINITION", "relation": "EQUALS", "condition": "leather", "conditionObjectId": "gid://shopify/MetafieldDefinition/1071456109" }, { "column": "VARIANT_METAFIELD_DEFINITION", "relation": "EQUALS", "condition": "true", "conditionObjectId": "gid://shopify/MetafieldDefinition/1071456110" } ] } } } #### Graphql Response { "data": { "collectionCreate": { "userErrors": [], "collection": { "id": "gid://shopify/Collection/1063001314", "title": "Our entire leather collection", "descriptionHtml": "Check out our leather products.", "handle": "our-entire-leather-collection", "sortOrder": "BEST_SELLING", "ruleSet": { "appliedDisjunctively": false, "rules": [ { "column": "PRODUCT_METAFIELD_DEFINITION", "relation": "EQUALS", "condition": "leather", "conditionObject": { "metafieldDefinition": { "id": "gid://shopify/MetafieldDefinition/1071456109", "name": "Material", "type": { "name": "single_line_text_field" }, "ownerType": "PRODUCT" } } }, { "column": "VARIANT_METAFIELD_DEFINITION", "relation": "EQUALS", "condition": "true", "conditionObject": { "metafieldDefinition": { "id": "gid://shopify/MetafieldDefinition/1071456110", "name": "Imported", "type": { "name": "boolean" }, "ownerType": "PRODUCTVARIANT" } } } ] } } } } } ### Creates a custom collection Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation CollectionCreate($input: CollectionInput!) { collectionCreate(input: $input) { collection { id title descriptionHtml updatedAt handle image { id height width url } products(first: 10) { nodes { id featuredImage { id height width url } } } } userErrors { field message } } }\",\n \"variables\": {\n \"input\": {\n \"title\": \"New Custom Collection\",\n \"descriptionHtml\": \"This is a custom collection.\",\n \"handle\": \"custom-collection\",\n \"products\": [\n \"gid://shopify/Product/20995642\"\n ]\n }\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation CollectionCreate($input: CollectionInput!) {\n collectionCreate(input: $input) {\n collection {\n id\n title\n descriptionHtml\n updatedAt\n handle\n image {\n id\n height\n width\n url\n }\n products(first: 10) {\n nodes {\n id\n featuredImage {\n id\n height\n width\n url\n }\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n }`,\n \"variables\": {\n \"input\": {\n \"title\": \"New Custom Collection\",\n \"descriptionHtml\": \"This is a custom collection.\",\n \"handle\": \"custom-collection\",\n \"products\": [\n \"gid://shopify/Product/20995642\"\n ]\n }\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n mutation CollectionCreate($input: CollectionInput!) {\n collectionCreate(input: $input) {\n collection {\n id\n title\n descriptionHtml\n updatedAt\n handle\n image {\n id\n height\n width\n url\n }\n products(first: 10) {\n nodes {\n id\n featuredImage {\n id\n height\n width\n url\n }\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n }\nQUERY\n\nvariables = {\n \"input\": {\n \"title\": \"New Custom Collection\",\n \"descriptionHtml\": \"This is a custom collection.\",\n \"handle\": \"custom-collection\",\n \"products\": [\"gid://shopify/Product/20995642\"]\n }\n}\n\nresponse = client.query(query: query, variables: variables)\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation CollectionCreate($input: CollectionInput!) {\n collectionCreate(input: $input) {\n collection {\n id\n title\n descriptionHtml\n updatedAt\n handle\n image {\n id\n height\n width\n url\n }\n products(first: 10) {\n nodes {\n id\n featuredImage {\n id\n height\n width\n url\n }\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n }`,\n {\n variables: {\n \"input\": {\n \"title\": \"New Custom Collection\",\n \"descriptionHtml\": \"This is a custom collection.\",\n \"handle\": \"custom-collection\",\n \"products\": [\n \"gid://shopify/Product/20995642\"\n ]\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation CollectionCreate($input: CollectionInput!) {\n collectionCreate(input: $input) {\n collection {\n id\n title\n descriptionHtml\n updatedAt\n handle\n image {\n id\n height\n width\n url\n }\n products(first: 10) {\n nodes {\n id\n featuredImage {\n id\n height\n width\n url\n }\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n}" #### Graphql Input { "input": { "title": "New Custom Collection", "descriptionHtml": "This is a custom collection.", "handle": "custom-collection", "products": [ "gid://shopify/Product/20995642" ] } } #### Graphql Response { "data": { "collectionCreate": { "collection": { "id": "gid://shopify/Collection/1063001311", "title": "New Custom Collection", "descriptionHtml": "This is a custom collection.", "updatedAt": "2024-11-12T16:11:29Z", "handle": "custom-collection", "image": null, "products": { "nodes": [ { "id": "gid://shopify/Product/20995642", "featuredImage": { "id": "gid://shopify/ProductImage/916933471", "height": 400, "width": 85, "url": "https://cdn.shopify.com/s/files/1/2637/1970/products/element58.jpg?v=1731426897" } } ] } }, "userErrors": [] } } } ### Creates a smart collection Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation CollectionCreate($input: CollectionInput!) { collectionCreate(input: $input) { userErrors { field message } collection { id title descriptionHtml handle sortOrder ruleSet { appliedDisjunctively rules { column relation condition } } } } }\",\n \"variables\": {\n \"input\": {\n \"title\": \"Our entire shoe collection\",\n \"descriptionHtml\": \"View <b>every</b> shoe available in our store.\",\n \"ruleSet\": {\n \"appliedDisjunctively\": false,\n \"rules\": {\n \"column\": \"TITLE\",\n \"relation\": \"CONTAINS\",\n \"condition\": \"shoe\"\n }\n }\n }\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation CollectionCreate($input: CollectionInput!) {\n collectionCreate(input: $input) {\n userErrors {\n field\n message\n }\n collection {\n id\n title\n descriptionHtml\n handle\n sortOrder\n ruleSet {\n appliedDisjunctively\n rules {\n column\n relation\n condition\n }\n }\n }\n }\n }`,\n \"variables\": {\n \"input\": {\n \"title\": \"Our entire shoe collection\",\n \"descriptionHtml\": \"View <b>every</b> shoe available in our store.\",\n \"ruleSet\": {\n \"appliedDisjunctively\": false,\n \"rules\": {\n \"column\": \"TITLE\",\n \"relation\": \"CONTAINS\",\n \"condition\": \"shoe\"\n }\n }\n }\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n mutation CollectionCreate($input: CollectionInput!) {\n collectionCreate(input: $input) {\n userErrors {\n field\n message\n }\n collection {\n id\n title\n descriptionHtml\n handle\n sortOrder\n ruleSet {\n appliedDisjunctively\n rules {\n column\n relation\n condition\n }\n }\n }\n }\n }\nQUERY\n\nvariables = {\n \"input\": {\n \"title\": \"Our entire shoe collection\",\n \"descriptionHtml\": \"View <b>every</b> shoe available in our store.\",\n \"ruleSet\": {\n \"appliedDisjunctively\": false,\n \"rules\": {\n \"column\": \"TITLE\",\n \"relation\": \"CONTAINS\",\n \"condition\": \"shoe\"\n }\n }\n }\n}\n\nresponse = client.query(query: query, variables: variables)\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation CollectionCreate($input: CollectionInput!) {\n collectionCreate(input: $input) {\n userErrors {\n field\n message\n }\n collection {\n id\n title\n descriptionHtml\n handle\n sortOrder\n ruleSet {\n appliedDisjunctively\n rules {\n column\n relation\n condition\n }\n }\n }\n }\n }`,\n {\n variables: {\n \"input\": {\n \"title\": \"Our entire shoe collection\",\n \"descriptionHtml\": \"View <b>every</b> shoe available in our store.\",\n \"ruleSet\": {\n \"appliedDisjunctively\": false,\n \"rules\": {\n \"column\": \"TITLE\",\n \"relation\": \"CONTAINS\",\n \"condition\": \"shoe\"\n }\n }\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation CollectionCreate($input: CollectionInput!) {\n collectionCreate(input: $input) {\n userErrors {\n field\n message\n }\n collection {\n id\n title\n descriptionHtml\n handle\n sortOrder\n ruleSet {\n appliedDisjunctively\n rules {\n column\n relation\n condition\n }\n }\n }\n }\n}" #### Graphql Input { "input": { "title": "Our entire shoe collection", "descriptionHtml": "View <b>every</b> shoe available in our store.", "ruleSet": { "appliedDisjunctively": false, "rules": { "column": "TITLE", "relation": "CONTAINS", "condition": "shoe" } } } } #### Graphql Response { "data": { "collectionCreate": { "userErrors": [], "collection": { "id": "gid://shopify/Collection/1063001312", "title": "Our entire shoe collection", "descriptionHtml": "View <b>every</b> shoe available in our store.", "handle": "our-entire-shoe-collection", "sortOrder": "BEST_SELLING", "ruleSet": { "appliedDisjunctively": false, "rules": [ { "column": "TITLE", "relation": "CONTAINS", "condition": "shoe" } ] } } } } }