← DocsOpen the console →

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.

TemplatemomentTypeWhenTypical reward
Second chancesecond_chanceAfter a miss, game over or failed attemptcontinue × 1 — “Continue where you left off”
Double rewarddouble_rewardOn a result screen, right after something was earneddouble × 2 — “Double your reward”
Daily bonusdaily_bonusOnce a day, from the home screencoins × 100 — once per listener per day
Between levelsbetween_levelsOn a level-complete / next-step screencoins × 25 — a small top-up
CustomcustomAnything else in your app or siteyour 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.

Lifecycle
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 statistics

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

Install
npm install @mediaverse/audio-moments-rn
App.tsx
import { 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.

index.html
<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.

VAST tag
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:

Receipt lookup
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:

POST /v1/ads/request
{
  "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:

Option 1 — ask the ad server (no auth)
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_receipt
Option 2 — verify the ES256 signature locally (Node, jose)
import { 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:

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:

Delivery
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:

Node — verify the signature over the raw body
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

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:

app-ads.txt
mediaverse.ai, <your seller id>, DIRECT

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

SignalReact Native packageVAST playersMeaning
foreground / foregroundMsmeasured (AppState; playback pauses in the background)not measuredapp in the foreground at start and complete, ≥ 90 % of the duration
playback timing + quartilesmeasured (player reached the end; q1–q3 positions)measured through the beaconschecked on the server clock
volumenot measured (needs a native module)not measured> 0 when measured
silentSwitch (iOS)not measured (needs a native module)not measuredfalse when measured
outputRoutenot measured (needs a native module)not measuredspeaker / 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.

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

EndpointAuthPurpose
POST /v1/ads/requestapp keyad decision for a Moment (200 offer / 204 no fill; `alternative` for a pick-your-ad Moment)
POST /v1/ads/eventsapp keybatched playback events for one request (max 50)
POST /v1/ads/completeapp keyclaim completion; verifies and issues the Listen Receipt
POST /v1/ads/attentionapp keythe player's answer to the attention check of a verified listen (scored server-side)
GET /v1/ads/receipts?requestId=app keythe receipt of a request (VAST integrations)
GET /v1/ads/receipts/{receiptId}app keya stored receipt (audit)
POST /v1/ads/receipts/verifynoneverify a receipt's signature and look it up
GET /v1/.well-known/receipt-keys.jsonnoneJWKS with the receipt signing keys (current + previous)
GET /v1/vast/{placementKey}?key=&listener=key in querythe decision as VAST 4.2
GET /v1/beacon/{requestId}/{event}?s=signed URLtrackers fired by a VAST player
GET /v1/healthnoneliveness

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.