Backend API

Gift card debits keep a record of transactions for which a gift card is used for payment in order to ensure that a gift card balance is updated with each use. These debit collections are stored on the gift card entry and associated each transaction to the parent gift card and payment entries.

Fields

idobjectIdauto

Unique identifier for the gift card debit.

parent_idobjectIdrequired

The id of the parent gift card.

parentGift Card

Link to the parent gift card.

date_createddateauto

Date the debit is created.

date_updateddateauto

Date the debit was last updated.

amountcurrencyrequired

Amount of the debit transaction.

payment_idobjectId

The id of the related payment.

paymentPayment

Link to the associated payment.

refund_idobjectId

The id for the associated refund, if applicable.

refundRefund

Link to the associated refund, if applicable.

currencystring

Three-letter ISO currency code in uppercase. Defaults to your store's base currency.

The gift card debit model
{
  "parent_id": "5fd21b2b53c2be21778d1f7e",
  "payment_id": "5fd21b5353c2be21778d3293",
  "amount": 35,
  "currency": "USD",
  "date_created": "2020-12-10T12:57:55.651Z",
  "id": "5fd21b5353c2be21778d337d"
}

Create a new gift card debit.

Arguments

idobjectId

The ID of the gift card debit.

amountcurrencyrequired

Initial gift card debit value. Minimum of 0.01.

parent_idobjectIdrequired

ID of the parent gift card.

currencystring

Three-letter ISO currency code in uppercase. Defaults to the store's base currency.

date_createddate

Date and time the gift card debit was created.

date_updateddate

Date and time the gift card debit was last updated.

parentGift Card
paymentPayment

Expandable link to the payment.

payment_idobjectId
refundRefund
refund_idobjectId

Unique identifier for the refund.

POST/giftcards:debits
const swell = require('swell-node').init('store-id', 'secret-key');

await swell.post('/giftcards:debits', {
	parent_id: 5fd21b2b53c2be21778d1f7e,
  amount: 10.99,
	currency: 'USD'
});
The gift card debit model
{
  "parent_id": "5fd21b2b53c2be21778d1f7e",
  "payment_id": "5fd21b5353c2be21778d3293",
  "amount": 35,
  "currency": "USD",
  "date_created": "2020-12-10T12:57:55.651Z",
  "id": "5fd21b5353c2be21778d337d"
}

Retrieve an existing gift card debit using the ID that was returned when created.

Arguments

idobjectIdrequired

ID of the gift card debit to be retrieved.

GET/giftcards:debits/:id
const swell = require('swell-node').init('store-id', 'secret-key');

await swell.get('/giftcards:debits/{id}', {
});

Update an existing gift card debit using the ID that was returned when created.

Arguments

idobjectIdrequired

Unique identifier for the gift card debit.

currencystring
amountcurrency
PUT/giftcards:debits/:id
const swell = require('swell-node').init('store-id', 'secret-key');

await swell.put('/giftcards:debits/{id}', {
  currency = 'JPY'
});
The gift card debit model
{
  "parent_id": "5fd21b2b53c2be21778d1f7e",
  "payment_id": "5fd21b5353c2be21778d3293",
  "amount": 35,
  "currency": "USD",
  "date_created": "2020-12-10T12:57:55.651Z",
  "id": "5fd21b5353c2be21778d337d"
}

Return a list of gift card debits.

Arguments

expandstring

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.

fieldsstring

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.
includeobject

Include one or more arbitrary queries in the response which are potentially related to the main query.

See including for more details.

limitint

Limit the number of records returned, ranging between 1 and 1000. Defaults to 15.

pageint

The page number of results to return given the specified or default limit.

searchstring

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.

sortstring

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.

whereobject

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.

GET/giftcards:debits
const swell = require('swell-node').init('store-id', 'secret-key');

await swell.get('/giftcards:debits', {
});
The gift card debit model
{
  "parent_id": "5fd21b2b53c2be21778d1f7e",
  "payment_id": "5fd21b5353c2be21778d3293",
  "amount": 35,
  "currency": "USD",
  "date_created": "2020-12-10T12:57:55.651Z",
  "id": "5fd21b5353c2be21778d337d"
}

Delete a gift card debit permanently.

Arguments

idobjectIdrequired

The ID of the gift card debit to delete.

DELETE/giftcards:debits/:id
const swell = require('swell-node').init('store-id', 'secret-key');

await swell.delete('/giftcards:debits/{id}', {
});