Filter
What would you like to search for?
Backend API
Product attributes are additional characteristics of a product that can be used in different ways. Attributes can be made visible on your detail page with the visible flag or hidden from view. Visible attributes are typically used to display a list of specifications on a detail page. Hidden attributes are typically used as internal data points or to affect the behavior of products in your store theme.
Fields
Unique identifier for the attribute. Defaults to attribute name underscored.
A human-friendly name for the attribute.
Date and time the attribute was created.
Date and time the attribute was last updated.
Default value used when entering a value for the attribute.
Indicates if the category is available in the storefront category page filters.
Indicates if this attribute supports localized content.
When attribute type=image is indicated, the attribute contains multiple images.
Expandable list of products using the attribute.
Indicates the attribute requires a value when assigned to a product.
Indicates if this attribute is searchable on the backend.
Input type used when entering a value for the attribute.
List of values applicable to checkbox, radio, dropdown, and image attributes.
Indicates if this attribute is a variant.
Indicates the attribute is visible to customers.
Response
{
"id": "material",
"name": "Color",
"date_created": "2021-07-16T14:35:59.968Z",
"date_updated": "2021-07-16T14:35:59.968Z",
"default": null,
"required": false,
"type": "text",
"values": [
"Red",
"White",
"Blue",
"Green",
"Yellow",
"Black"
],
"visible": true
}
Create a new attribute.
Arguments
Unique identifier for the attribute. Defaults to attribute name underscored.
A human-friendly name for the attribute.
Indicates the attribute requires a value when assigned to a product.
Input type used when entering a value for the attribute.
List of values applicable to checkbox, radio, dropdown, and image attributes.
Indicates the attribute is visible to customers.
Default value used when entering a value for the attribute.
When attribute type=image is indicated, the attribute contains multiple images.
Expandable list of products using the attribute.
const swell = require('swell-node').init('store-id', 'secret-key');
await swell.post('/attributes', {
name: 'Material',
visible: true,
type: 'dropdown',
values: [
'Cotton',
'Polyester',
'Wool'
],
});
Response
{
"id": "material",
"name": "Material",
"date_created": "2019-04-01T00:00:00.000Z",
"required": false,
"visible": true,
"type": "dropdown",
"values": [
"Cotton",
"Polyester",
"Wool"
]
}
Retrieve an existing attribute using the ID, that was returned when created.
Arguments
The id of the attribute to retrieve.
Expanding link fields and child collections is performed using the expand argument.
- For example, expand=account would return a related customer account if one exists.
When the field represents a collection, you can specify the query limit,
- For example, expand=variants:10 would return up to 10 records of the variants collection.
See expanding for more details.
Return only the specified fields in the result.
- For example fields=name,slug would return only the fields name and slug in the response.
Supports nested object and array fields using dot-notation.
- For example, items.product_id. The category id is always returned.
Include one or more arbitrary queries in the response, possibly related to the main query.
See including for more details.
const swell = require('swell-node').init('store-id', 'secret-key');
await swell.get('/attributes/{id}', {
id: 'material',
});
Response
{
"id": "material",
"name": "Material",
"date_created": "2019-04-01T00:00:00.000Z",
"required": false,
"visible": true,
"type": "dropdown",
"values": [
"Cotton",
"Polyester",
"Wool"
]
Update an existing attribute using the ID, that was returned when created. Updating performs a merge operation. To explicitly override values such as arrays, use the $set operator.
Arguments
Unique identifier for the attribute. Defaults to attribute name underscored.
A human-friendly name for the attribute.
Set true to make the attribute require a value when added to a product.
Input type used when entering a value for the attribute.
List of values applicable to checkbox, radio, dropdown, and image attributes.
Indicates the attribute is visible to customers.
Default value used when entering a value for the attribute.
When attribute type=image is indicated, the attribute contains multiple images.
Expandable list of products using the attribute.
const swell = require('swell-node').init('store-id', 'secret-key');
await swell.put('/attributes/{id}', {
id: 'material',
required: true
});
Response
{
"id": "material",
"name": "Material",
"date_created": "2019-04-01T00:00:00.000Z",
"date_updated": "2019-04-01T00:00:00.000Z",
"required": true,
"visible": true,
"type": "dropdown",
"values": [
"Cotton",
"Polyester",
"Wool"
]
}
Return a list of product attributes.
Arguments
Expand link fields and child collections by using the expand argument.
- For example, expand=account would return a related customer account if one exists.
When the field represents a collection, you can specify the query limit.
- For example, expand=variants:10 would return up to 10 records of the variants collection.
See expanding for more details.
Returns only the specified fields in the result.
- For example fields=name,slug would return only the fields name and slug in the response.
Supports nested object and array fields using dot-notation.
- For example, items.product_id. The product id is always returned.
Include one or more arbitrary queries in the response which are potentially related to the main query.
See including for more details.
Limit the number of records returned, ranging between 1 and 1000. Defaults to 15.
The page number of results to return given the specified or default limit.
A text search is performed using the search argument. Searchable fields are defined by the model.
- For example, search=red would return records containing the word "red" anywhere in the defined text fields.
See searching for more details.
Expression to sort results by using a format similar to a SQL sort statement.
- For example, sort=name asc would return records sorted by name ascending.
See sorting for more details.
An object with criteria to filter the result.
- For example, active=true would return records containing a field active with the value true.
It's also possible to use query operators, for example, $eq, $ne, $gt, and more.
See querying for more details.
const swell = require('swell-node').init('store-id', 'secret-key');
await swell.get('/attributes', {
limit: 25,
page: 1
});
Response
{
"count": 51,
"results": [
{
"id": "material",
"name": "Color",
"date_created": "2021-07-16T14:35:59.968Z",
"date_updated": "2021-07-16T14:35:59.968Z",
"default": null,
"required": false,
"type": "text",
"values": [
"Red",
"White",
"Blue",
"Green",
"Yellow",
"Black"
],
"visible": true
},
{...},
{...}
],
"page": 1,
"pages": {
"1": {
"start": 1,
"end": 25
},
"2": {
"start": 26,
"end": 50
},
"2": {
"start": 51,
"end": 51
}
}
}
Delete an attribute.
Arguments
The id of the attribute to delete.
const swell = require('swell-node').init('store-id', 'secret-key');
await swell.delete('/attributes/{id}', {
id: 'material',
});
Response
{
"id": "material",
"name": "Material",
"date_created": "2019-04-01T00:00:00.000Z",
"date_updated": "2019-04-01T00:00:00.000Z",
"required": true,
"visible": true,
"type": "dropdown",
"values": [
"Cotton",
"Polyester",
"Wool"
]
}