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

namestringrequired

Human-friendly name of the product.

optionsarray of objectrequired

Specify the denominations available on the product.

typestringrequired

Set to giftcard to indicate the product is a gift card.

POST/products
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

namestringrequired

Human-friendly name of the product.

optionsarray of objectrequired

Specify the denominations available on the product.

typestringrequired

Set to giftcard to indicate the product is a gift card.

deliveryenum

For gift cards fulfilled digitally, set delivery=shipment.

POST/products
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"
}