Skip to content

Integrating with PerksWallet

This guide covers the Embedded PerksWallet integration, for partners who want full control over the wallet experience within their own app or website.

Overview

This guide covers the Embedded PerksWallet integration, for partners who want full control over the wallet experience within their own app or website.

This document provides a detailed walkthrough for integrating PerksWallet into your product using our APIs or JavaScript SDKs.

Prerequisites

Before you begin, ensure the following:

  1. PerksWallet must be enabled for your account. Contact your MomentScience account manager to activate it.
  2. You need an API Key with access to “PerksWallet.” Refer to API Key Documentation to learn how to obtain one.

Understanding pub_user_id

The pub_user_id is a unique, non-PII identifier for each user. It plays a critical role in linking offers to individual users.

  • Ensure the pub_user_idremains consistent across sessions and devices.
  • Do not use personally identifiable information (PII) such as email addresses or phone numbers.
  • You can generate this identifier using any logic, as long as it’s unique for each user.

Embedded Integrating Methods

You can integrate PerksWallet into your product using one of the following methods:

  • Perkswall API
  • Moments API
  • Moments JS SDK
  • Perkswall SDK

The core requirement for all integrations is providing a pub_user_id, a stable user identifier that allows offers to be saved and retrieved across sessions and devices.

Integration via API

When integrating with Perkswall API or Moments API, the process is the same. The key step is ensuring the pub_user_idis included in the request body for both saving and retrieving offers.

Try It Out

Moments API

Fetch Offers (Moments API)

POST https://api.adspostx.com/native/v4/offers.json

Paste your API key into api_key and set pub_user_id in the body, then click Try it. Offers in the response include save_for_later_url when pub_user_id is sent and PerksWallet as a Service is enabled.

Query Parameters

Parameter Type Required Description
api_key string Yes Your API key with the Ads/Offers permission, from Profile Settings > API Keys in the dashboard.
loyaltyboost string No Controls LoyaltyBoost offers. 0 excludes them, 1 includes them if available, 2 returns only LoyaltyBoost offers.
creative string No Set to 1 to return only offers that have at least one image.
campaignId string No Return offers from one campaign only.

Body Parameters

Parameter Type Required Description
placement string Yes Where the offer is shown, for example checkout_confirmation_page.
ua string No The end user’s User-Agent. If you call from a server, pass through the user’s User-Agent.
ip string No The end user’s IP address, used for geo-targeting.
adpx_fp string No A persistent, anonymous user ID. Strongly recommended, it enables frequency capping and opt-out handling.
pub_user_id string No A unique, non-PII user ID. Required for PerksWallet-as-a-Service and User Selected Perks.
dev string No Set to 1 to return test offers. Ignores geo restrictions and disables tracking.

Request Examples

curl --request POST \
     --url 'https://api.adspostx.com/native/v4/offers.json?api_key=string' \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --data '{
     "placement": "string"
     }'
var request = require('request');
var options = {
   'method': 'POST',
   'url': 'https://api.adspostx.com/native/v4/offers.json?api_key=string',
   'headers': {
      'accept': 'application/json',
      'content-type': 'application/json'
   },
   body: JSON.stringify({
      "placement": "string"
   })

};
request(options, function (error, response) {
   if (error) throw new Error(error);
   console.log(response.body);
});
var myHeaders = new Headers();
myHeaders.append("accept", "application/json");
myHeaders.append("content-type", "application/json");

var raw = JSON.stringify({
   "placement": "string"
});

var requestOptions = {
   method: 'POST',
   headers: myHeaders,
   body: raw,
   redirect: 'follow'
};

fetch("https://api.adspostx.com/native/v4/offers.json?api_key=string", requestOptions)
   .then(response => response.text())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
import requests
import json

url = "https://api.adspostx.com/native/v4/offers.json?api_key=string"

payload = json.dumps({
   "placement": "string"
})
headers = {
   'accept': 'application/json',
   'content-type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)
require "uri"
require "json"
require "net/http"

url = URI("https://api.adspostx.com/native/v4/offers.json?api_key=string")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["accept"] = "application/json"
request["content-type"] = "application/json"
request.body = JSON.dump({
   "placement": "string"
})

response = https.request(request)
puts response.read_body

Sample Responses

{
  "data": {
    "session_id": "abc123-def456-ghi789",
    "offers": [
      {
        "id": 12345,
        "campaign_id": 67890,
        "advertiser_name": "Premium Sports Store",
        "title": "Get 25% off athletic wear + free shipping",
        "description": "Save on top-brand athletic wear, running shoes, and gym equipment.",
        "click_url": "https://offers.momentscience.com/click/abc123",
        "cta_yes": "Shop Now",
        "cta_no": "No Thanks",
        "image": "https://cdn.momentscience.com/creatives/sports-banner.jpg",
        "pixel": "https://tracking.momentscience.com/impression/abc123",
        "beacons": {
          "close": "https://tracking.momentscience.com/close/abc123",
          "no_thanks_click": "https://tracking.momentscience.com/decline/abc123"
        }
      }
    ],
    "count": 1
  }
}
{
  "message": "Ain't no cake like that."
}

Perkswall API

Fetch Perkswall Offers

POST https://api.adspostx.com/native/v4/perkswall.json

Paste your API key into api_key and set pub_user_id in the body, then click Try it. Offers in the response include save_for_later_url when pub_user_id is sent and PerksWallet as a Service is enabled.

Query Parameters

Parameter Type Required Description
api_key string Yes Your API key with “Ads/Offers” permission. Must be generated from the MomentScience Dashboard.
loyaltyboost string No Controls inclusion of LoyaltyBoost-eligible offers in results: • 0: Exclude all LoyaltyBoost offers • 1: Include both standard and LoyaltyBoost offers (default) • 2: Return only LoyaltyBoost offers
creative string No Filter offers by creative availability: • 0: Return all matching offers regardless of creative availability (default) • 1: Only return offers with at least one creative asset

Header Parameters

Parameter Type Required Description
Content-Type string Yes Specifies the media type of the request. Must be set to application/json
Accept string No Optionally set to application/json

Body Parameters

Parameter Type Required Description
placement string Yes Identifies where the offer unit appears in your application or website. Used for segmentation, reporting, and offer targeting. Example: checkout_confirmation_page
ua string No End-user’s complete User-Agent string. When implementing via proxy architecture, ensure you forward the actual client UA rather than your server’s UA for accurate device targeting. Example: Mozilla/5.
ip string No End-user’s IP address for geographic and demographic targeting. Used to deliver location-relevant offers. Example: 203.0.113.45
adpx_fp string No Persistent, anonymous identifier for frequency capping, offer rotation, and honoring opt-out preferences. Should be consistent across sessions for the same user but doesn’t need to identify the user specifically.
pub_user_id string No Non-PII persistent identifier for the user. Required for PerksWallet as a Service and User Selected Perks.
dev string No Set to 1 to receive test offers that ignore geographic restrictions and suppress production tracking events. Use only in development environments. Example: 1
subid string No Free-form identifier to track specific implementations, variants, or traffic sources. Included in reporting and analytics.Example: mobile_android_app_post_transaction

Request Examples

curl --request POST \
    --url 'https://api.adspostx.com/native/v4/perkswall.json?api_key=REPLACE_WITH_YOUR_API_KEY' \
    --header 'Content-Type: application/json' \
    --data '{
        "placement": "checkout_confirmation_page",
        "ua": "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.6099.43 Mobile Safari/537.36",
        "ip": "203.0.113.45",
        "adpx_fp": "1234abcd-5678-efgh-9101-ijklmnopqrst",
        "pub_user_id": "1234abcd-5678-efgh-9101-ijklmnopqrst",
        "subid": "mobile_android_app_post_transaction"
    }'

Sample Responses

{
  "data": {
    "session_id": "sess_12345abcde67890",
    "offers": [
      {
        "id": 5576,
        "campaign_id": 2880,
        "title": "Get 25% off athletic wear + free shipping",
        "description": "Save on top-brand athletic wear with this exclusive discount. Orders over $50 qualify for free shipping to anywhere in the continental US.",
        "click_url": "https://offers.momentscience.com/click/abc123",
        "image": "https://cdn.momentscience.com/creatives/sports-banner.jpg",
        "mini_text": "Excludes sale items. Valid through 12/31/2025.",
        "terms_and_conditions": "<p><strong>Offer valid for online purchases only.</strong> Discount applies to regular-priced items. Cannot be combined with other promotions. Free shipping valid on orders over $50 shipped to the continental US. Expires 12/31/2025.</p>",
        "pixel": "https://tracking.momentscience.com/impression/abc123",
        "cta_yes": "Shop Now",
        "cta_no": "No Thanks",
        "useraction_cta": null,
        "useraction_url": null,
        "adv_pixel_url": "https://advertiser.com/track?id=xyz789",
        "beacons": {
          "close": "https://tracking.momentscience.com/close/abc123",
          "no_thanks_click": "https://tracking.momentscience.com/decline/abc123"
        },
        "creatives": [
          {
            "id": 1001,
            "url": "https://cdn.momentscience.com/creatives/sports-square.jpg",
            "height": 400,
            "width": 400,
            "type": "jpg",
            "is_primary": true,
            "aspect_ratio": 1.0,
            "creative_type": "offer_image"
          },
          {
            "id": 1002,
            "url": "https://cdn.momentscience.com/creatives/sports-banner.jpg",
            "height": 200,
            "width": 800,
            "type": "jpg",
            "is_primary": false,
            "aspect_ratio": 4.0,
            "creative_type": "hero_image"
          }
        ],
        "offerwall_enabled": true,
        "perkswallet_enabled": true,
        "short_description": "Save on top brands + free shipping over $50",
        "short_headline": "25% off athletic wear",
        "advertiser_name": "Premium Sports Store",
        "is_loyaltyboost": true,
        "loyaltyboost_requirements": "Complete purchase to earn 500 bonus points",
        "save_for_later_url": "https://api.momentscience.com/wallet/save",
        "tags": ["fitness", "apparel", "sports"],
        "campaign": {
          "campaign_images": [
            {
              "id": 1001,
              "url": "https://cdn.momentscience.com/creatives/sports-square.jpg",
              "height": 400,
              "width": 400,
              "type": "jpg",
              "creative_type": "offer_image",
              "is_primary": true,
              "aspect_ratio": 1.0,
              "user_id": 0
            },
            {
              "id": 1002,
              "url": "https://cdn.momentscience.com/creatives/sports-banner.jpg",
              "height": 200,
              "width": 800,
              "type": "jpg",
              "creative_type": "hero_image",
              "is_primary": false,
              "aspect_ratio": 4.0,
              "user_id": 0
            }
          ]
        },
        "offerwall_url": "https://get.perkswall.com/offerwall?accountId=abc123&themeId=Documentation-Example&session_id=sess_12345abcde67890",
        "qr_code_img": "data:image/png;base64,iVBORw0KGgqbJ5onKTxaTymx7WWtc8rLWueVhrXhOVrXfOw1rrmJyona3741jUPa61rHtZa1zysta55WGtd87DWuuZhrXXNw1rrmoe11jUPa61rHtZa1/w/EjW+ivrQS2EAAAAASUVORK5CYII="
      }
    ],
    "settings": {
      "featured_offer_list": [582, 723, 1154, 1693, 1576, 1863]
    },
    "count": 1
  }
}

Integration via JavaScript SDK

Moments

  1. Add the following script before the closing </head> tag
<script type="module">
    (function (window) {
        // Configure Moments with your account settings
        window.AdpxConfig = {
            accountId: 'fbe6000000f803ef4', // Replace with your unique account ID
            autoShow: true // Automatically show the Moments widget when loaded
        };

        // Define the user object using a stable pub_user_id
        window.AdpxUser = {
            pub_user_id: 'user-123' // Replace with your unique user ID
        };

    })(window.self !== window.top ? window.top : window);

    (async function (window) {
        const target = window.document.head || window.document.body;
        const script = window.document.createElement('script');
        script.type = 'text/javascript';
        script.src = 'https://cdn.pubtailer.com/launcher.min.js';
        script.importance = 'high';
        script.crossOrigin = 'anonymous';
        script.async = true;
        script.id = 'adpx-launcher';
        target.appendChild(script);
        await new Promise(function (resolve) {
            window.Adpx
                ? resolve()
                : window.document
                    .getElementById('adpx-launcher')
                    .addEventListener('load', function () { resolve(); });
        });
        window.Adpx.init(AdpxConfig);
    })(window.self !== window.top ? window.top : window);
</script>

Perkswall

  1. Add the container where the widget will be rendered:
<div id="adpx_container"></div>
  1. Add the following script before the closing </body> tag
<script>
  window.AdpxConfig = {
    accountId: "fbe6000000f803ef4", // Replace with your account ID
    themeId: "Standard-Theme",     // Replace with your theme ID
    containerId: "adpx_container"
  };

  window.AdpxUser = {
    // Include user info here
    pub_user_id: "user-123",     // Replace with your unique user ID
  };

  const adpx = document.createElement('script');
  adpx.type = 'text/javascript';
  adpx.async = true;
  adpx.src = 'https://cdn.adspostx.com/launcher.perkswall.js';
  document.getElementsByTagName('head')[0].appendChild(adpx);
</script>

Saving an Offer

When a user wants to save an offer for later, they can click the “Save for Later” CTA within the PerksWallet experience.

Saving via API

To save offers via the Moments API or Perkswall API, follow these steps:

  1. Include the pub_user_idin the API request body.
  2. Extract save_for_later_urlfrom the API response (offers[].save_for_later_url).
  3. On CTA click, make a POST request to save_for_later_url.

Once the POST request is made, the offer is saved to the user’s wallet and can be retrieved later using the same pub_user_id.

Saving via JavaScript SDK

If you are using the SDK, the saving process is automatically handled.

  • When a user clicks Save for Later, the SDK saves the offer and links it to the pub_user_id you passed in the user object. The button then shows your Saved Offer Text.
  • pub_user_id is required to save to Embedded PerksWallet. Hosted PerksWallet, the zero-code option, works without it. If you don’t pass pub_user_id and Hosted PerksWallet is enabled on your account, the SDK sends the user to Hosted PerksWallet instead. Otherwise the button is hidden.
  • Using a Custom Offer Unit (COU) theme? The button isn’t added for you. Add an element with data-ms-action="save-for-later" to your template, as described in Custom Offer Unit (COU).

Retrieving User’s Wallet

To fetch offers saved by a user, use the following API endpoint. This applies whether you’re integrating via the Moments API or Perkswall API.

Using the API

Path Parameters:

Parameter Type Description
pub_user_id String The unique identifier of the user whose wallet you want to retrieve.

Header Parameter

Parameter **Type ** Description
pwaas-api-key String API key with access permission to PerksWallet. Required to authenticate and authorize the request.

Response Parameters

Parameter Type Description
data array List of saved offers for the user. If no offers are saved, this will be an empty array.
data[].id integer Unique ID of the saved offer.
data[].user_id string Unique identifier for the user who saved the offer.
data[].campaign_id string ID of the campaign associated with the offer.
data[].publisher_id string The partner’sID from which the user saved the offer
data[].session_id string Unique session identifier when the offer was saved.
data[].converted_at string/null Timestamp of when the offer was claimed (if applicable). Returns nullif not yet claimed.
data[].created_at string Timestamp of when the offer was saved, in ISO 8601 format (YYYY-MM-DDTHH:MM:SSZ).
data[].updated_at string Timestamp of the last update to the saved offer record.
data[].campaign object Details of the campaign associated with the saved offer.
data[].campaign.id integer Unique campaign ID.
data[].campaign.advertiser_name string Name of the advertiser providing the offer.
data[].campaign.description string Full description of the offer.
data[].campaign.short_description string Shorter version of the offer description.
data[].campaign.headline string Primary offer headline.
data[].campaign.short_headline string A more concise version of the headline.
data[].campaign.positive_cta string Call-to-action text for the offer (e.g., “Start My Free Trial”).
data[].campaign.primary_creative string URL to the primary creative (image) of the offer.
data[].campaign.is_active boolean Indicates whether the offer is still active (true or false).
data[].click_url string URL to claim the offer.
{
  "data": [
    {
      "id": 1000,
      "user_id": "200",
      "campaign_id": "100",
      "publisher_id": "2222",
      "session_id": "a21cec...",
      "converted_at": null,
      "created_at": "2025-04-03T10:47:27.404+00:00",
      "updated_at": "2025-04-03T10:47:27.404+00:00",
      "campaign": {
        "id": 100,
        "advertiser_name": "Ancestry",
        "description": "...",
        "short_description": "...",
        "headline": "Discover Your Roots - Free Ancestry Trial!",
        "short_headline": "Discover Your Roots - Free Trial!",
        "positive_cta": "Start My Free Trial",
        "mini_text": "<p><br></p>",
        "primary_creative": "https://...",
        "is_active": true,
        "last_sync_at": "2025-02-07T05:03:17.049Z",
        "created_at": "2025-02-07T05:03:17.049+00:00",
        "updated_at": "2025-02-07T05:03:17.049+00:00"
      },
      "click_url": "https://trk.pubtailer.com/sdk/offer-click?o_id=4460&c_id=1753&sess_id=a21cec89008306ec70d4315f6d55a045ae8761fc&p_id=3065"
    }
  ]
}

Showing User’s Wallet with SDK

Add this container element where you want the Saved Offers widget to appear

  1. Add this container element where you want the Saved Offers widget to appear
<div id="adpx_container"></div>
  1. Add the following script before the closing </body>tag
<script>
  window.PwaasConfig = {
    accountId: "fbe6000000f803ef4", // Replace with your account ID
    pub_user_id: "user-123", // Replace with your user's unique ID
    containerId: "adpx_container"
  };

  const adpx = document.createElement('script');
  adpx.type = 'text/javascript';
  adpx.async = true;
  adpx.src = 'https://cdn.adspostx.com/launcher.pwaas.js';
  document.getElementsByTagName('head')[0].appendChild(adpx);
</script>

Deleting Saved Offers

Using the API

To delete a saved offer, use the following API request:

Path Parameters:

Parameter Type Description
pub_user_id String The unique identifier of the user requesting deletion.
campaign_id String The ID of the offer the user wants to remove.

Header Parameter

Parameter **Type ** Description
pwaas-api-key String API key with access permission to PerksWallet. Required to authenticate and authorize the request.

If the request is successful, the API will return a confirmation message indicating the offer has been deleted.

Using SDK

If you are implementing using the SDK, deletion is handled automatically.

  • The user will see a delete icon next to each saved offer.
  • Upon clicking the icon, a confirmation message will appear.
  • If the user confirms, the offer will be deleted from their saved list.

📢 If you’re running into any issues while going through the integration process, feel free to contact us at help@momentscience.com

Type to search…

↑↓ navigate↵ selectEsc close