Backend API
The pages model contains data relating to content pages within your storefront and the content within them.
We recommend not making changes via the API for the pages model when possible and suggest using the dashboard model editor instead. If you do wish to make changes via the API, see our data model customization guide.
Fields
id
objectIdUnique identifier for the page.
name
stringrequiredHuman-friendly name of the page.
slug
stringrequiredLowercase, hyphenated identifier typically used in URLs. When creating a product, a slug will be generated automatically from the name. Maximum length of 1,000 characters.
content
stringHTML formatted page content.
date_created
dateDate and time the page was created.
date_published
dateDate and time the page was published.
date_updated
dateDate and time the page was updated.
meta_description
stringPage description used for search engine optimization purposes.
published
booleanIndicates whether the page is published. Defaults to false.
redirect
stringURL to specify a page redirect.
Create a new content page. If you wish to generate your own unique ID for the record, it must use BSON ObjectID format for compatibility.
Arguments
id
objectIdrequiredUnique identifier for the page.
slug
stringautoSlug identifier of the page. Defaults to a slug-formatted version of the title.
title
stringrequiredTitle of the page.
content
stringHTML or text content of the page.
published
booleanIndicates whether the page is published and should be displayed in the storefront.
date_published
dateDate the page was published. May be used to indicate the publish date in the storefront, or to delay publishing until a future date.
meta_title
stringTitle used for SEO purposes, if different than the page title.
meta_description
stringDescription used for SEO purposes. Typically the storefront will use a number of characters from the page's content if this is not defined.
meta_keywords
stringKeywords used for SEO purposes.
theme_template
stringTemplate used to render this page in a storefront theme, if applicable.
const swell = require('swell-node').init('store-id', 'secret-key');
await swell.post('/content/pages', {
title: 'Example page'
});
Response
{
"id": "60f199509111e70000000022",
"amount": 100,
"amount_spent": 25,
"balance": 75,
"code": "C9X9L7D9Q3MAXC3P",
"code_formatted": "C9X9 L7D9 Q3MA XC3P",
"code_pattern": "{XXXX} {XXXX} {XXXX} {XXXX}",
"currency": "USD",
"date_created": "2021-07-16T14:36:00.142Z",
"date_updated": "2021-07-16T14:36:00.142Z",
"last4": "XC3P",
"redeemed": false,
"send_email": "friend@example.com",
"send_note": null
}Retrieve an existing content page using the ID that was returned when created.
Arguments
id
objectIdrequiredID of the gift card to retrieve.
expand
stringExpanding 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.
fields
stringReturn 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 gift card id is always returned.
include
stringInclude 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('/content/pages/{id}', {
id: '60f199509111e70000000022',
});
Response
{
"id": "60f199509111e70000000028",
"amount": 100,
"amount_spent": 25,
"balance": 75,
"code": "C9X9L7D9Q3MAXC3P",
"code_formatted": "C9X9 L7D9 Q3MA XC3P",
"code_pattern": "{XXXX} {XXXX} {XXXX} {XXXX}",
"currency": "USD",
"date_created": "2021-07-16T14:36:00.142Z",
"date_updated": "2021-07-16T14:36:00.142Z",
"last4": "XC3P",
"redeemed": false,
"send_email": "friend@example.com",
"send_note": null
}Update an existing page using the ID that was returned when created.
Arguments
id
objectIdrequiredUnique identifier for the page.
slug
stringautoSlug identifier of the page. Defaults to a slug-formatted version of the title.
title
stringrequiredTitle of the page.
content
stringHTML or text content of the page.
published
booleanIndicates whether the page is published and should be displayed in the storefront.
date_published
dateDate the page was published. May be used to indicate the publish date in the storefront, or to delay publishing until a future date.
meta_title
stringTitle used for SEO purposes, if different than the page title.
meta_description
stringDescription used for SEO purposes. Typically the storefront will use a number of characters from the page's content if this is not defined.
meta_keywords
stringKeywords used for SEO purposes.
theme_template
stringTemplate used to render this page in a storefront theme, if applicable.
const swell = require('swell-node').init('store-id', 'secret-key');
await swell.put('/content/pages/{id}', {
id: '60f199509111e70000000022'
});
Response
{
"id": "60f199509111e70000000022",
"amount": 100,
"amount_spent": 25,
"balance": 75,
"code": "C9X9L7D9Q3MAXC3P",
"code_formatted": "C9X9 L7D9 Q3MA XC3P",
"code_pattern": "{XXXX} {XXXX} {XXXX} {XXXX}",
"currency": "USD",
"date_created": "2021-07-16T14:36:00.142Z",
"date_updated": "2021-07-16T14:36:00.142Z",
"last4": "XC3P",
"redeemed": false,
"send_email": "friend@example.com",
"send_note": null
}Return a list of content pages.
Arguments
expand
stringExpand 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.
fields
stringReturns 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
objectInclude one or more arbitrary queries in the response which are potentially related to the main query.
See including for more details.
limit
intLimit the number of records returned, ranging between 1 and 1000. Defaults to 15.
page
intThe page number of results to return given the specified or default limit.
search
stringA 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.
sort
stringExpression 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.
where
objectAn 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.put('/content/pages', {
...
});
Response
{
"count": 51,
"results": [
{
"id": "60f199509111e70000000022",
"amount": 100,
"amount_spent": 25,
"balance": 75,
"code": "C9X9L7D9Q3MAXC3P",
"code_formatted": "C9X9 L7D9 Q3MA XC3P",
"code_pattern": "{XXXX} {XXXX} {XXXX} {XXXX}",
"currency": "USD",
"date_created": "2021-07-16T14:36:00.142Z",
"date_updated": "2021-07-16T14:36:00.142Z",
"last4": "XC3P",
"redeemed": false,
"send_email": "friend@example.com",
"send_note": null
},
{...},
{...}
],
"page": 1,
"pages": {
"1": {
"start": 1,
"end": 25
},
"2": {
"start": 26,
"end": 50
},
"2": {
"start": 51,
"end": 51
}
}
}Delete a content page permanently.
Arguments
id
objectIdrequiredThe ID of the page to delete.
const swell = require('swell-node').init('store-id', 'secret-key');
await swell.delete('/content/pages/{id}', {
id: '60f199509111e7000000002b'
});
Response
{
"id": "60f199509111e7000000002e",
"amount": 100,
"amount_spent": 25,
"balance": 75,
"code": "C9X9L7D9Q3MAXC3P",
"code_formatted": "C9X9 L7D9 Q3MA XC3P",
"code_pattern": "{XXXX} {XXXX} {XXXX} {XXXX}",
"currency": "USD",
"date_created": "2021-07-16T14:36:00.142Z",
"date_updated": "2021-07-16T14:36:00.142Z",
"last4": "XC3P",
"redeemed": false,
"send_email": "friend@example.com",
"send_note": null
}