Overview
This playbook provides a high-level guide for implementing Moments in your mobile application using the MomentScience MomentPerks API.
What is a Moment?
A Moment is a contextual experience that presents one or more personalized offers at meaningful points in a user’s journey, such as after a purchase, upon completing a task, or during a key interaction. These Moments help you:
- Enhance user engagement with timely, relevant perks
- Drive incremental revenue by surfacing claimable offers
- Maintain full control over how and where offers appear in your app
Using the MomentPerks API , your app can fetch Moments dynamically and render them with your own UI components.
Integration Steps
The following steps outline the general integration flow for using the MomentPerks API . These steps apply to all mobile platforms and should be followed before implementing a platform-specific SDK (e.g., Flutter, iOS, Android, React Native).
Step 1: Create an API Key
Before making API requests, you need to generate an API key from the MomentScience dashboard.
To create an API key:
- Log In: Sign in to your MomentScience account.
- Go to Profile: Navigate to the Profile section in the dashboard.
- Generate API Key: Click the Generate API Key button.
- Name the Key: Enter a descriptive name (for example, “Test API Key” or “Production API Key”).
- Set Scopes: Select the appropriate access scopes. Make sure the Ads/Offers scope is selected.
- Generate: Click Generate to create the API key.
Pass this key in the api_key query parameter of every Moments API request, not in a header.
Learn more about how to obtain your API key.
Step 2. Call the Moments API
There are two common ways to call the Moments API, depending on your app architecture:
Option A: Direct Call from the App
Make the HTTP request from the client. Include all required headers
Option B: Proxy Through Your Backend
Send a request from your app to your backend. Then, have your backend forward the request to the Moments API and relay the response to your app.
Try it Out
Send a live request and see the response. Paste your API key into api_key in the console below, adjust the body if you like, and click Try it. The result shows in the Responses panel on the right.
Fetch Offers (Moments API)
POST https://api.adspostx.com/native/v4/offers.json
Returns personalized offers for one user. Paste your API key into api_key, adjust the body if you like, then click Try it.
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_bodySample 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."
}Learn more about MomentPerks API
Step 3: Parse the API Response
The Moments API returns a list of eligible offers in the data.offers[] array. Each offer contains all the data needed to render the unit, handle user interactions, and track performance. At a minimum, your integration should extract and use the title, image, CTA, click URL, impression pixel, and optional beacons.
Understanding Offer Anatomy
Each offer object in data.offers[] contains reusable fields for rendering offer units (e.g., Single Offer Unit or Multi Offer Unit). Here’s a quick reference to the most important ones:
| Field | Description |
|---|---|
offers[].title |
Main headline text. Use short_headline for compact layouts. |
offers[].description |
Primary offer copy. Use short_description for limited-space formats. |
offers[].image |
Main image URL for the offer. |
offers[].click_url |
URL to open when the user taps the positive CTA (label from cta_yes). |
offers[].cta_yes |
Label for the primary action (e.g., “Claim Now”). |
offers[].cta_no |
Label for the negative action (e.g., “No Thanks”). |
offers[].terms_and_conditions |
HTML-formatted terms. Render as HTML if present. |
offers[].pixel |
Impression tracking URL. Fire once when the offer becomes visible. |
offers[].adv_pixel_url |
Optional advertiser tracking pixel. Fire if provided. |
offers[].offerwall_url |
URL to launch Perkswall for selected offer. |
offers[].beacons.close |
Track when the user closes the offer unit. |
offers[].beacons.no_thanks_click |
Track when the user clicks the “No Thanks” button. |
creatives[] |
Optional array of additional creative assets, including dimensions and types. |
settings.offerwall_url |
(Optional) URL to launch Perkswall. Button label comes from settings.offerwall_cta. |
Step 4: Trigger Impression Beacons
Each offer returned by the MomentPerks API includes impression and interaction tracking URLs. These must be implemented to ensure proper reporting, advertiser compliance, and offer optimization.
Required Actions
- Trigger Impression Beacon: Fire a successful
GETrequest tooffers[].pixelwhen the offer is displayed. - **(If available) Trigger Advertiser Beacon: ** Fire a
GETrequest tooffers[].adv_pixel_urlto satisfy advertiser tracking. - Display Terms and Conditions: Render the offers[].terms_and_conditions field as HTML to show offer-specific rules. If the field is empty, no terms apply.
Additional Tracking
The following additional beacons and requirements are documented in the MomentPerks Integration Checklist .
- **
offers[].beacons.close: **Trigger when the user closes an offer unit. offers[].beacons.no_thanks_click: Trigger when the user opts out of an offer.adpx_fpattribute: Use to identify unique users for frequency control and reward tracking.- IP and User-Agent headers: Required when proxying requests to ensure valid targeting.
- LoyaltyBoost Support: Special implementation required for rewarded offers, including postbacks, loyalty identifiers, and payout handling.
Further Recommendations
Configure Moments Settings in the Dashboard
The number of Offers returned in the Moments API response can be configured in the MomentScience dashboard.
To configure offer count:
- Go to Settings -> Configuration.
- Locate the “Number of Offers” setting.
- Set your desired value.
- Press Save Configuration.
This setting limits how many offers the Moments API returns in each response.
Implement Postbacks for Conversion Tracking
Postbacks let you receive real-time notifications when a user converts on an Offer. These are sent to your designated endpoint and help track performance, optimize targeting, and power LoyaltyBoost rewards (if applicable).
Learn more about Handling Postback Events
📢 If you’re running into any issues while going through the integration process, feel free to contact us at help@momentscience.com