Backend API
Gift card products are products with type=giftcard. When preparing to sell gift cards in a store, consider whether there is a need to fulfill physical cards or have a gift card code automatically generated and email to the customer.
When selling physical gift cards, an admin would generate gift card codes from the Swell dashboard and export the codes for printing. In this case, the gift card product would have delivery=shipment instead of delivery=giftcard.
Create a gift card product that will be fulfilled automatically by email.
Arguments
name
stringrequiredHuman-friendly name of the product.
options
array of objectrequiredSpecify the denominations available on the product.
.name
stringrequiredName of the denominated value.
.values
array of objectrequiredList of possible values for this option.
.name
stringrequiredHuman-friendly name of the option value.
.price
currencyrequiredValue fulfilled as a gift card when the option is selected.
.variant
booleanrequiredMust be true for gift card options.
type
stringrequiredSet to giftcard to indicate the product is a gift card.
delivery
enumFor gift cards fulfilled digitally, set delivery=giftcard.
Possible enum values:
active
booleanSet true to make the product visible to customers in a storefront, otherwise it will be hidden.
attributes
objectAn object containing custom attribute key/value pairs. See attributes for more details.
category_id
objectIdPrimary category, commonly used as a navigation anchor.
description
stringA long-form description of the product. Can have HTML or other markup languages.
images
array of objectList of images depicting the bundle.
.caption
stringA brief description of the image, intended for display as a caption or alt text.
.file
objectAn object representing the image's source file.
file.data
filedataSet or overwrite file data. Use the following format when writing a file from binary data (for example an image): data[$binary]=<base64 encoded binary daya>.
file.filename
stringOptional file name.
meta_description
stringPage description used for search engine optimization purposes.
meta_keywords
stringPage keywords used for search engine optimization purposes.
meta_title
stringPage title used to override product name in storefronts.
slug
stringLowercase, 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.
tags
stringList of arbitrary tags typically used as metadata to improve search results or associate custom behavior with a product.
const swell = require('swell-node').init('store-id', 'secret-key');
await swell.post('/products', {
name: 'Gift Card',
type: 'giftcard',
options: [
{
name: 'Value',
variant: true,
values: [
{
name: '$25',
price: 25,
},
{
name: '$50',
price: 50,
},
{
name: '$100',
price: 100,
},
],
},
],
});
Response
{
"id": "5cad15bc9b14d1990724663a",
"delivery": "giftcard"
"name": "Gift Card",
"options": [
{
"id": "5ca24ab32599d4179c24a624",
"name": "Value",
"variant": true,
"values": [
{
"id": "5ca24ad59c077817e5fe2ba3",
"name": "$25",
"price": 25
},
{
"id": "5ca24ad59c077817e5fe2ba4",
"name": "$50",
"price": 50
},
{
"id": "5ca24ad59c077817e5fe2ba5",
"name": "$100",
"price": 100
}
]
}
],
"slug": "gift-card",
"type": "giftcard"
}
Create a gift card product that will be fulfilled by shipping a physical card.
Arguments
name
stringrequiredHuman-friendly name of the product.
options
array of objectrequiredSpecify the denominations available on the product.
.name
stringrequiredName of the denominated value.
.values
array of objectrequiredList of possible values for this option.
.name
stringrequiredHuman-friendly name of the option value.
.price
currencyrequiredValue fulfilled as a gift card when the option is selected.
.variant
booleanrequiredMust be true for gift card options.
type
stringrequiredSet to giftcard to indicate the product is a gift card.
delivery
enumFor gift cards fulfilled digitally, set delivery=shipment.
Possible enum values:
active
booleanSet true to make the product visible to customers in a storefront, otherwise it will be hidden.
attributes
objectAn object containing custom attribute key/value pairs. See attributes for more details.
category_id
objectIdPrimary category, commonly used as a navigation anchor.
description
stringA long-form description of the product. Can have HTML or other markup languages.
images
array of objectList of images depicting the bundle.
.caption
stringA brief description of the image, intended for display as a caption or alt text.
.file
objectAn object representing the image's source file.
file.data
filedataSet or overwrite file data. Use the following format when writing a file from binary data (for example an image): data[$binary]=<base64 encoded binary daya>.
file.filename
stringOptional file name.
meta_description
stringPage description used for search engine optimization purposes.
meta_keywords
stringPage keywords used for search engine optimization purposes.
meta_title
stringPage title used to override product name in storefronts.
slug
stringLowercase, 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.
tags
stringList of arbitrary tags typically used as metadata to improve search results or associate custom behavior with a product.
const swell = require('swell-node').init('store-id', 'secret-key');
await swell.post('/products', {
name: 'Gift Card',
type: 'giftcard',
delivery: 'shipment',
options: [
{
name: 'Value',
variant: true,
values: [
{
name: '$25',
price: 25,
},
{
name: '$50',
price: 50,
},
{
name: '$100',
price: 100,
},
],
},
],
});
Response
{
"id": "5cad15bc9b14d1990724663a",
"delivery": "shipment"
"name": "Gift Card",
"options": [
{
"id": "5ca24ab32599d4179c24a624",
"name": "Value",
"variant": true,
"values": [
{
"id": "5ca24ad59c077817e5fe2ba3",
"name": "$25",
"price": 25
},
{
"id": "5ca24ad59c077817e5fe2ba4",
"name": "$50",
"price": 50
},
{
"id": "5ca24ad59c077817e5fe2ba5",
"name": "$100",
"price": 100
}
]
}
],
"slug": "gift-card",
"type": "giftcard"
}