Audio Moments — developer guide
Audio Moments is rewarded audio for any app or site, on any stack. A listener opts in, hears a short message to the end with your app in the foreground, and the ad server issues a signed Listen Receipt. The same receipt unlocks the reward in your app, bills the advertiser and pays your share. Base URL: https://ads.mediaverse.ai/v1.
1. What a Moment is
A Moment (a placement) is the point in your app where a listener can opt in to hear a message for a reward. You define it once in the console, get a placementKey, and request an ad for it whenever that point is reached. Four templates cover the common cases; Custom is anything else. Every field can be changed.
| Template | momentType | When | Typical reward |
|---|---|---|---|
| Second chance | second_chance | After a miss, game over or failed attempt | continue × 1 — “Continue where you left off” |
| Double reward | double_reward | On a result screen, right after something was earned | double × 2 — “Double your reward” |
| Daily bonus | daily_bonus | Once a day, from the home screen | coins × 100 — once per listener per day |
| Between levels | between_levels | On a level-complete / next-step screen | coins × 25 — a small top-up |
| Custom | custom | Anything else in your app or site | your own type, amount and label |
Each Moment carries a reward { type, amount, label } (the label is what the listener sees on the opt-in sheet), a reward policy (cooldownS after a receipt, maxPerDay receipts per listener per UTC day, 0 = unlimited), a frequency cap (perDevicePerDay offers) and a maximum spot length (5–60 s). These are enforced by the server at decision time: the SDK simply gets an offer or a no-fill.
2. The flow: request → listen → receipt
Every integration, whichever SDK or none, is the same four steps. Authentication is your app's API key as a bearer token (am_live_…, or am_test_… for test apps). You get the key once, when you create the app in the console.
POST https://ads.mediaverse.ai/v1/ads/request Authorization: Bearer am_live_…
→ 200 { requestId, ad: { creativeId, advertiser, title, audioUrl, durationMs, companion? }, reward, offerTtlS, test? }
→ 204 no fill X-No-Fill-Reason: frequency_cap | cooldown | max_per_day | no_campaign | not_audible | placement_paused | app_paused
POST https://ads.mediaverse.ai/v1/ads/events { requestId, events: [ { type, clientTs, position?, audibility?, detail? } ] } → 202
type: offer_shown | offer_accepted | offer_declined | start | q1 | q2 | q3 | click | abort | error | background | foreground
POST https://ads.mediaverse.ai/v1/ads/complete { requestId, clientTs, position, audibility: { foreground, foregroundMs, volume?, silentSwitch?, outputRoute? } }
→ 200 { receipt, receiptId, claims, companion? } the Listen Receipt (compact JWS, ES256)
→ 409 { error: { code: "not_verified", reasons: [ "too_early", "foreground_too_short", … ] } } no receipt, attempt kept for statisticsThe server verifies the listen on its own clock: start within offerTtlS of the decision; complete at least durationMs − 1.5 s after start and no later than 3 × durationMs + 30 s; quartiles, when sent, in order and not before their position; the app in the foreground at start and at complete, with foregroundMs ≥ 90 % of the duration; and no measured audibility signal contradicting playback (volume 0, silent switch on, no output route). Only then is a receipt issued. Receipts are valid for a reward for 10 minutes (exp = iat + 600); the stored copy stays forever for audit.
3. Integration options
Pick the one that matches your stack. All four produce the same receipt and show up in the same reports.
a) React Native / Expo
The package shows the opt-in sheet, plays the spot, ducks your audio, tracks foreground and playback, sends the events and returns the receipt. Peer dependencies: react, react-native, expo-audio, @react-native-async-storage/async-storage.
npm install @mediaverse/audio-moments-rnimport { AudioMoments, AudioMomentsPlayer } from '@mediaverse/audio-moments-rn';
// once, at app start — the key comes from your server-side config, never from a public repo
AudioMoments.init({ apiKey: 'am_live_…', appVersion: '1.0.0', bundleId: 'com.example.app' });
// at the Moment
const offer = await AudioMoments.load('myapp_second_chance'); // null = no fill, see AudioMoments.lastLoadError()
{offer && (
<AudioMomentsPlayer
offer={offer}
onDuck={(on) => duckMusic(on)} // lower your own audio while the message plays
onResult={(r) => {
if (r.rewarded) grantOnServer(r.receipt); // verify on your server first — section 4
setOffer(null);
}}
/>
)}Prefer your own UI? AudioMoments.createPlayback(offer) is the headless controller: markOfferShown(), start(), decline(), cancel(), click(), subscribe(state ⇒ …) and a result promise. PlaybackResult is { rewarded: true, receipt, receiptId, claims } or { rewarded: false, reason: 'declined' | 'aborted' | 'not_verified' | 'error', detail? }.
b) Web SDK
One script for websites and web games. The key identifies your site; the receipt, verified on your server, is the proof — a key in a web page cannot be kept secret, and does not need to be.
<script src="https://ads.mediaverse.ai/sdk/audio-moments.js"></script>
<script>
AudioMoments.init({ apiKey: 'am_live_…' });
async function offerSecondChance() {
const offer = await AudioMoments.load('mysite_second_chance'); // null = no fill
if (!offer) return showPlainGameOver();
const result = await AudioMoments.show(offer); // opt-in sheet + player, resolves once
if (result.rewarded) {
await fetch('/api/reward', { method: 'POST', headers: { 'content-type': 'application/json' },
body: JSON.stringify({ receipt: result.receipt }) });
}
}
</script>c) VAST tag for an existing audio player
Already running a VAST-capable player (a podcast or radio app, a game with its own ad player)? Request the same decision as a VAST 4.2 document. Players cannot set headers, so the app key goes in the key query parameter, and the rotating listener id in listener.
GET https://ads.mediaverse.ai/v1/vast/{placementKey}?key=am_live_…&listener={listenerId}&os=ios&locale=en-US
→ 200 application/xml VAST 4.2: Impression, Tracking start / firstQuartile / midpoint / thirdQuartile / complete, ClickTracking, companion
→ 200 <VAST version="4.2"/> (empty = no fill) X-No-Fill-Reason: …
→ 401 bad key
Optional: &test=true forces the house test spot.The trackers inside the document point at https://ads.mediaverse.ai/v1/beacon/{requestId}/{event}?s=… (signed; the player fires them as usual). The complete beacon runs the same verification — with the audibility signals marked as not measured — and issues the receipt. Because the player cannot hand the receipt back, your server fetches it by the request id from the beacon URLs:
GET https://ads.mediaverse.ai/v1/ads/receipts?requestId={requestId} Authorization: Bearer am_live_…
→ 200 ReceiptRecord { receiptId, receipt, requestId, placementKey, momentType, listenerId, verifiedAt, test, … }
→ 404 no receipt for this request (yet, or not verified)d) The HTTP API directly
Native iOS / Android, Unity, a smart speaker — anything that can play audio and call HTTPS. You implement the three calls from section 2 and an opt-in step in your own UI. The request body:
{
"placementKey": "myapp_second_chance",
"listenerId": "c1f0…", // rotating per-install id you generate; never an advertising id (max 64 chars)
"sdk": { "name": "audio-moments-web", "version": "1.0.0" }, // one of audio-moments-rn | -ios | -android | -web
"app": { "version": "1.0.0", "bundleId": "com.example.app" },
"device": { "os": "ios", "osVersion": "18.1", "model": "iPhone15,2", "locale": "en-US",
"audio": { "volume": 0.8, "silentSwitch": false, "outputRoute": "speaker", "foreground": true } },
"consent": { "tcf": "…", "gpp": "…", "usPrivacy": "1---" }, // optional, passed through to demand
"test": false // true = house test spot, receipt flagged test
}Then send events in batches (max 50 per call; stamp each with your clientTs; the server uses its own clock for the rules), and claim completion when the file ends. On a 409 read error.reasons: too_early, too_late, no_start, offer_expired, quartiles_out_of_order, quartile_too_early, not_audible_at_start, not_audible_at_complete, background_at_start, background_at_complete, foreground_too_short, already_receipted.
4. Verifying receipts on your server
Treat the receipt as the only proof of a listen. The client-side rewarded flag is convenient for the UI; a reward worth anything is granted by your server after it checked the receipt. Two ways:
POST https://ads.mediaverse.ai/v1/ads/receipts/verify
{ "receipt": "<compact JWS>" }
→ 200 { valid, signatureValid, known, expired, test, claims, reason? } // 200 even when invalid: look at "valid"
reason: malformed | unknown_key | bad_signature | unknown_receiptimport { createRemoteJWKSet, jwtVerify } from 'jose';
const JWKS = createRemoteJWKSet(new URL('https://ads.mediaverse.ai/v1/.well-known/receipt-keys.json')); // current + previous key; "kid" selects
export async function verifyReceipt(receipt) {
const { payload } = await jwtVerify(receipt, JWKS, { issuer: 'ads.mediaverse.ai', algorithms: ['ES256'] }); // checks exp too
return payload; // claims: iss, jti, rid, pk, app, cr, lid, iat, exp, rw { type, amount, label }, v { completed, audible, foreground, timingOk, measured }, test
}Whichever you use, before granting:
- require
valid(option 1) or a passing signature (option 2), and notexpired: receipts are good for a reward for 10 minutes after issue; - check the claims match what you expect:
pkis the placement you showed,appyour app id,lidthe listener who is asking,ridthe request you made; - store
jti(the receipt id) and grant each receipt once; - look at
test: test receipts are real signed receipts that exercised the whole flow, but they never bill or pay — grant a test reward only in test builds; rwtells you what to grant (type,amount), so the reward cannot be changed on the client.
5. Reward webhooks
Instead of (or in addition to) the client handing you the receipt, register a webhook URL for your app in the console (app page → Reward webhook). The signing secret is shown once when you set the URL; rotate it from the same card. Every verified listen is then POSTed to your server:
POST https://your-server.example/audio-moments/webhook
Content-Type: application/json
X-AudioMoments-Event: listen.verified // or "test" for a test delivery from the console
X-AudioMoments-Delivery: 7d4e… // delivery id — idempotency key, stable across retries
X-AudioMoments-Signature: t=1760090000,v1=3f9a… // t = unix seconds, v1 = hex HMAC-SHA256 over "<t>.<raw body>" with your secret
{ "event": "listen.verified", "deliveryId": "7d4e…", "receiptId": "…", "receipt": { …receipt record… }, "receiptJws": "<compact JWS>", "test": false }Answer with any 2xx within 8 seconds; otherwise the server tries three times (immediately, after 10 s, after 60 s) with the same delivery id. Your handler should verify the signature, ignore delivery ids it has already processed, and grant the reward once:
import { createHmac, timingSafeEqual } from 'node:crypto';
export function verifyAudioMomentsSignature(rawBody, signatureHeader, secret, toleranceS = 300) {
const parts = Object.fromEntries(signatureHeader.split(',').map((kv) => kv.split('=')));
const t = Number(parts.t), v1 = parts.v1;
if (!t || !v1 || Math.abs(Date.now() / 1000 - t) > toleranceS) return false; // stale or malformed
const expected = createHmac('sha256', secret).update(`${t}.${rawBody}`).digest('hex');
return expected.length === v1.length && timingSafeEqual(Buffer.from(expected, 'hex'), Buffer.from(v1, 'hex'));
}
// e.g. Express: app.post('/audio-moments/webhook', express.raw({ type: 'application/json' }), (req, res) => {
// if (!verifyAudioMomentsSignature(req.body.toString('utf8'), req.get('X-AudioMoments-Signature') ?? '', process.env.AUDIO_MOMENTS_WEBHOOK_SECRET)) return res.sendStatus(401);
// const delivery = JSON.parse(req.body);
// if (delivery.event === 'listen.verified' && !(await seen(delivery.deliveryId))) await grant(delivery.receiptJws); // verify the JWS like any receipt
// res.sendStatus(200);
// });Use the raw request body for the HMAC (re-serialising JSON changes bytes). receiptJws is the same signed receipt the SDK returns, so section 4 applies to it unchanged. The console's “Send test delivery” posts an event: "test" payload with the same headers and shows the result (status, HTTP code, error) and the recent deliveries.
6. Test mode
A new app starts in test mode: every request gets the built-in house test spot and the full flow runs — events, verification, receipt — but the receipt carries test: true, is never billed and never paid. You can also force the test spot per request with test: true, with an am_test_… key, or by registering listener ids as test devices on the app. Test receipts show in Reports when you tick “Include test receipts”.
The onboarding checklist on each app walks you through it: key created → SDK connected (first request) → first test receipt → app-ads.txt verified → live → first live listen. Go live from the app page once your server verified a test receipt.
7. Privacy
- No advertising ids. The SDKs never read the IDFA / AAID and the server does not accept one.
- Rotating listener id. The React Native package generates a random UUID per install, stores it locally, rotates it every 30 days and never shares it across apps. A custom integration generates its own (max 64 characters). Frequency caps, cooldowns and daily limits key on it.
- No IP storage. Country comes from the device locale.
- Consent passthrough. Put your TCF / GPP / US-privacy strings in
consent; they are forwarded to programmatic demand. - Receipts contain the listener id, placement, app and creative — nothing about the person.
8. app-ads.txt
Buyers check that MediaVerse is authorised to sell your inventory. Add the seller line from your console Overview to the app-ads.txt on your developer domain (the domain listed in the app stores), or ads.txt for a website:
mediaverse.ai, <your seller id>, DIRECTUntil the line is found, your apps serve only the house test spot. The portal re-checks automatically and flips the app to “verified”. The same seller id is sent to programmatic buyers in the OpenRTB supply chain.
9. What is measured for audibility — and what is not
A receipt is only issued for a listen the server could verify. Every SDK reports what it can measure; a signal that is null (not measured) is not required, and the receipt's v.measured lists the signals that were actually checked so your server — and buyers — can tell.
| Signal | React Native package | VAST players | Meaning |
|---|---|---|---|
| foreground / foregroundMs | measured (AppState; playback pauses in the background) | not measured | app in the foreground at start and complete, ≥ 90 % of the duration |
| playback timing + quartiles | measured (player reached the end; q1–q3 positions) | measured through the beacons | checked on the server clock |
| volume | not measured (needs a native module) | not measured | > 0 when measured |
| silentSwitch (iOS) | not measured (needs a native module) | not measured | false when measured |
| outputRoute | not measured (needs a native module) | not measured | speaker / headphones / bluetooth; not none |
A host app with a native module can pass an audibilityProvider to AudioMoments.init in the React Native package; the values are merged into every audibility snapshot. Custom HTTP integrations send whatever they can measure in device.audio and in the audibility of start and complete.
10. Formats: pick your ad, attention check, in-app action
Three formats sit on top of the plain listen. None of them changes the receipt: the listen is verified and rewarded exactly as before. They add a signal the advertiser pays more for, with one tap or none from the player. See them side by side on the formats gallery.
- Pick your ad — a Moment setting (Let players pick between two messages). The request returns a second offer in
alternativefrom another advertiser; the SDK shows two cards, plays the one picked and sendsoffer_declinedwith detailunchosenfor the other, which is neither a request nor a fill in your reports. Advertisers see their pick rate. - Attention check — a creative setting.
ad.attentioncarries one question and 2–3 options; the right answer stays on the server. After the receipt the SDK asks once (the player can skip); the answer goes toPOST /v1/ads/attentionwithinwindowSseconds and is scored there. A correct answer bills the campaign's attention bonus and pays your share of it. Your server sees it in thelisten.attentionwebhook, in/v1/ads/receipts/verify(attention) and in the result the SDK hands you (result.attention). - In-app action — a creative setting.
ad.actionis a coupon code or a link; one tap saves it for the player without leaving your app. The SDK records anactionevent, keeps the offer underAudioMoments.savedOffers()and returns it inresult.action, so you can show a “my offers” screen.
Test mode carries all three: the house test spot has a question and a sample coupon, and a Moment with pick your ad offers it twice, so you can exercise every step before a real campaign exists.
11. Endpoint reference
| Endpoint | Auth | Purpose |
|---|---|---|
| POST /v1/ads/request | app key | ad decision for a Moment (200 offer / 204 no fill; `alternative` for a pick-your-ad Moment) |
| POST /v1/ads/events | app key | batched playback events for one request (max 50) |
| POST /v1/ads/complete | app key | claim completion; verifies and issues the Listen Receipt |
| POST /v1/ads/attention | app key | the player's answer to the attention check of a verified listen (scored server-side) |
| GET /v1/ads/receipts?requestId= | app key | the receipt of a request (VAST integrations) |
| GET /v1/ads/receipts/{receiptId} | app key | a stored receipt (audit) |
| POST /v1/ads/receipts/verify | none | verify a receipt's signature and look it up |
| GET /v1/.well-known/receipt-keys.json | none | JWKS with the receipt signing keys (current + previous) |
| GET /v1/vast/{placementKey}?key=&listener= | key in query | the decision as VAST 4.2 |
| GET /v1/beacon/{requestId}/{event}?s= | signed URL | trackers fired by a VAST player |
| GET /v1/health | none | liveness |
Errors are { error: { code, message, suggestion? } }. Receipt claims: iss (ads.mediaverse.ai), jti receipt id, rid request id, pk placement key, app, cr creative, lid listener, iat, exp (= iat + 600), rw reward, v verification flags, test.
Questions, a native SDK, or a stack not covered here? Write to the MediaVerse team from your console — the data model knows apps, Moments, listeners, campaigns and receipts, nothing that is specific to one app.