swellAPI.getCustomerDetails()

This method returns an object containing all the program details about the logged-in customer. You can use this to create custom interfaces that display items like their current point balance, referral link, and earning/redemption history.

$(document).on("swell:setup", function(){
    var customerDetails = swellAPI.getCustomerDetails();

    $("#custom-point-balance-ui").html(customerDetails.pointsBalance);
    $("#custom-referral-link-ui").html(customerDetails.referralLink);

    customerDetails.actionHistoryItems.forEach(function(item) {
      $("#custom-history-container").append(
        "<li>" +
          item.date   + " -- " +
          item.action + " -- " +
          item.points +
        "</li>");
    });
  })
vipTier:
description: "Earn VIP status after spending $200 in a calendar year"
id: 113
name: "VIP"
pointsMultiplier: "1.4"
vipTierSubscriptionDate: "2019-06-16T11:03:03.000Z"
vipTierExpirationDate: "2020-06-16T11:03:03.000Z"

Details Object

AttributeTypeDescription
created_atdatetimeThe timestamp this customer entered our database
actionHistoryItemsarrayThe customer’s earning and redemption history
emailstringThe customer’s email address
pointRedemptionsarrayAn array containing the customer’s point redemption history
pointsBalanceintThe customer’s current point balance
pointsEarnedintThe total number of points ever earned for this customer
purchasesarrayAn array containing the customer’s purchase history
referralCodestringThe customer’s referral code (eg. abcd123)
referralLinkstringThe customer’s unique referral link
referralDiscountCodestringThe customer’s unique referral discount code
referralDiscountCodeIdintAn internal id for this customer’s referral discount code
referralDiscountCodeOrdersintThe number of orders made with this customer’s referral discount code
referralsarrayAn array containing the customer’s referral history
vipTierobjAn object with details about the customer’s current tier level
vipTierStatsobjAn object with details about the customer’s current progress toward vip tiers
payoutEmailstringThe customer’s paypal email used for receiving cash payouts
totalEarnedstringTotal amount earned as part of the affiliate program
payoutPercentagestringThe customer’s payout percentage for the affiliate program
isAffiliateboolFlag for whether or not this customer is an affiliate
affiliateCashPayoutsarrayAn array containing the customer’s cash payouts history
affiliateProductsSoldarrayAn array containing all the products this customer has sold as an affiliate
isOptInbooleanWhether the customer is part of the loyalty program.
optedInAtDateTime - ISO8601The date and time when the customer joined the loyalty program

Action History Item Object

AttributeTypeDescription
actionstringA short description of either the action/campaign completed or the redemption option earned/redeemed
createdAtdatetimeA timestamp when this item was created
completedAtdatetimeA timestamp when the customer completed the action
datedateThe date (without time) when this item was created
pointsintThe number of points that were either earned or redeemed
creditsstringIf using a variable redemption option, the amount of credit earned or used
statusstringFor campaigns this can either be Approved, Pending, Reversed, or a percentage complete. For coupons this will be the coupon code

Point Redemption Object

AttributeTypeDescription
amountintif redemption_option.type is “variable” then this will be the amount of points used
at_checkoutbooleanA flag for whether or not this redemption deducted the points from the customer’s balance before or after making a purchase. If true, then the points are removed after purchase otherwise they are removed upon redemption.
created_atdateThe timestamp of when this redemption was made
currencystringThe currency of the store
customer_idintThe internal id of the customer who made the redemption
external_urlstringIf the redemption is fulfilled externally and requires a link for the customer to claim then this can be used to store that URL.
idintThe internal id for this redemption
is_posbooleanA flag for whether or not this redemption happened on a Point of Sale system
perk_idintIf this redemption happened as part of completing a campaign this will hold the id of the perk responsible for rewarding the customer for completing that campaign.
redemption_optionobjectThe redemption option that was redeemed by the customer.
reward_textstringThe coupon code or other text presented to the customer for making the redemption.
visiblebooleanWhether or not this should show up in the customer’s history.

Redemption Option Object

AttributeTypeDescription
amountintHow many points this redemption option costs to redeem
discount_typestringThe type of discount this redemption option represents. Can be things like fixed_amount, variable, percentage, free_product.
namestringThe name given in the Swell admin for this redemption option (e.g. “$5 Off”)

Referral Object

AtributeTypeDescription
completedAtdatetimeWhen the referred customer made a purchase
customerIdintThe internal customer id for the referral
emailstringThe email address of the referred customer
idintAn internal id for this referral object
signedUpAtdatetimeWhen the referred customer created an account
sourcestringWhere the referred customer came from
sourceHoststringThe hostname the referred customer came from

VIP Tier Object

AttributeTypeDescription
idintAn internal id for this tier
namestringThe name of the tier
descriptionstringA short description of the tier requirements
pointsMultiplierdecimalThe points multiplier for the current tier
vipTierSubscriptionDatedatetimeThe date and time the customer subscribed to the VIP tier
vipTierExpirationDatedatetimeThe date/time at which the VIP tier will expire for the customer

VIP Tier Stats Object

AttributeTypeDescription
pointsEarnedintHow many points the customer has earned within the tier window
amountSpentCentsintHow many cents the customer has spent within the tier window
purchasesMadeintHow many purchases the customer has made within the tier window
referralsCompletedintHow many referrals the customer has made within the tier window

VIP Tier Status Object

AttributeTypeDescription
vip_tier_stats_needed_maintainintObject conveying the required thresholds for the customer to maintain their current tier
vip_tier_stats_neededintObject conveying the required thresholds for the customer to obtain the next tier

Cash Payout Object

AttributeTypeDescription
idintAn internal id for this tier
customer_idintThe internal customer id for the referral
payout_datedatetimeThe timestamp when the payout is scheduled to happen
amount_earnedfloatThe amount the customer earned for this cash payout
currencystringThe currency code for the cash payout (e.g “USD”)
statusstringThe status of this cash payout
emailstringThe paypal email this cash payout was or will be sent to
purchase_amountstringThe amount of the purchase made that triggered this cash payout
datedatetimeThe timestamp of when this cash payout was created

Affiliate Product Sold Object

AttributeTypeDescription
titlestringThe title of the product sold by an affiliate
revenue_generatedintThe amount of revenue generated in cents by the total sales of this product by this affiliate
number_of_itemsintHow many of this product has been sold by this affiliate