Backend API
Create a new category.
Arguments
A human-friendly name for the category.
Set true to make the category visible to customers in a storefront, otherwise it will be hidden from view.
A long-form description of the category, often containing HTML or other markup languages.
Unique identifier typically used in URLs. Defaults to name converted to lowercase and hyphenated. If the category has a parent, the default slug will be prefixed with the parent slug. Maximum length of 1,000 characters.
List of images depicting the category.
Unique identifier for the object.
A brief description of the image.
An object representing the image file.
Unique identifier for the file.
MIME content type of the file.
A reference to the raw file data.
Date the file was uploaded.
Optional file name.
Image height in pixels, if applicable.
Size of the file in bytes.
An MD5 hash of the file contents. This can be used to uniquely identify the file for caching purposes.
A public URL to reference the file. Updated automatically if file content changes.
Image width in pixels, if applicable.
Page description used for search engine optimization purposes.
Page keywords used for search engine optimization purposes.
Page title used to override product name in storefronts.
The id of the parent category, if applicable.
Position of the category in a list.
Default product sorting is applied when retrieving products using the category or categories filter. This can be one of the following: popularity, price_asc, price_desc, date_asc. date_desc. If not specified, products are sorted by their manually defined sort value.
ID of the top level category in the hierarchy.
Expandable link to the top level category.
Expandable link to the parent category, if applicable.
Expandable list of child categories.
Expandable list of category products.
Expandable list of products as indexed and sorted by their respective position.
const { swell } = require('swell-node');
swell.init('store-id', 'secret-key');
await swell.post('/categories', {
name: 'Widgets',
active: true,
});
Response
{
"id": "5ca9871f9b14d199072432a1",
"active": false,
"name": "Widgets",
"slug": "widgets",
"date_created": "2019-04-01T00:00:00.000Z"
}