MashPulse API

Ingest events, attribute Stripe revenue, and query analytics.

Base URLhttps://mashpulse.com
cURL
curl -X POST https://mashpulse.com/api/event \
  -H "Origin: https://linkedmash.com" \
  -H "Content-Type: text/plain" \
  -d '{"s":"linkedmash","t":"pageview","u":"https://linkedmash.com/pricing?utm_source=x&utm_campaign=launch","r":"https://x.com/","w":1440}'
JavaScript (fetch / sendBeacon)
// Pageview from the browser. sendBeacon sets the Origin header for you.
const body = JSON.stringify({
  s: "linkedmash",
  t: "pageview",
  u: location.href,
  r: document.referrer,
  w: screen.width,
});
if (!navigator.sendBeacon("https://mashpulse.com/api/event", body)) {
  fetch("https://mashpulse.com/api/event", { method: "POST", body, keepalive: true });
}
+[ 01 / 05 ]

Basics

Authentication & basics

Three entry points, three ways to prove who is calling.

Server to server

Send your key as a bearer token.

Authorization: Bearer <MASHPULSE_API_KEY>

Browser beacons

POST /api/event needs no key. The request Origin is checked against the site's domains.

Stripe webhook

POST /api/stripe/webhook?site=<slug> is verified with the HMAC in the Stripe-Signature header.

Days roll over at midnight in Europe/Berlin by default, and the visitor hash rotates with them.

+[ 02 / 05 ]

Ingestion

Event ingestion

One endpoint for pageviews and goals. The payload uses short keys to keep the beacon small.

POST/api/event

KeyTypeRequiredDescription
sstringyesSite slug, 2 to 40 characters of a-z, 0-9 and dash.
t"pageview" | "goal"yesEvent type.
nstringgoal onlyGoal name, up to 64 characters of letters, digits and _ : . - or space.
ustringyesFull page URL, including UTM params. Only http and https are accepted.
rstringnoReferrer URL, up to 2048 characters.
wnumbernoScreen width in pixels.
pobjectnoCustom properties. Up to 2 KB serialized, 20 keys, key names up to 64 characters.

Responses

StatusBodyMeaning
200{ "v": "a91f3c07e8b24d19" }Stored. v is today's visitor id for this browser.
202{ "ignored": "bot" }Recognized as a bot and not stored.
400{ "error": "bad_json" }Invalid body. Other values: bad_body, bad_site, bad_type, bad_name, bad_url, bad_props, props_too_large.
403{ "error": "origin_not_allowed" }Unknown site, or the Origin is not one of the site's domains.
402{ "error": "event_limit_reached" }The site's owner is on the Free plan and used this month's events. Not stored; counting resumes next month or after an upgrade.
429{ "error": "rate_limited" }Too many events from one IP. Back off and retry.
500{ "error": "insert_failed" }Storage failed. Safe to retry.
curl: track a goal
curl -X POST https://mashpulse.com/api/event \
  -H "Origin: https://linkedmash.com" \
  -d '{"s":"linkedmash","t":"goal","n":"signup","u":"https://linkedmash.com/signup","p":{"plan":"pro"}}'
browser: window.mash.track
window.mash.track("signup", { plan: "pro" });
+[ 03 / 05 ]

Queries

Analytics & revenue queries

Read your numbers back. Realtime is a plain HTTP endpoint, the rest are also available to agents through MCP.

GET/dashboard/realtime?site=<slug>

response
{ "count": 12 }

Requires a signed-in session. Unknown sites return 404.

overview

Visitors, pageviews and a daily series for a range.

{ "visitors": 18412, "pageviews": 41230, "series": [{ "day": "2026-10-22", "visitors": 1204 }] }

breakdown

Top values for one dimension.

{ "dimension": "referrer_host", "rows": [{ "value": "x.com", "visitors": 5210 }, { "value": "google", "visitors": 2893 }] }

goals

Goal counts and unique visitors.

{ "goals": [{ "name": "signup", "count": 612, "visitors": 590 }] }

funnel

Drop-off across an ordered list of goals or pages.

{ "steps": [{ "step": "/pricing", "count": 9318 }, { "step": "signup", "count": 2840 }] }

visitors

Recent visitors by daily hash and what they did.

{ "visitors": [{ "hash": "a91f3c07e8b24d19", "events": 4, "referrer_host": "x.com" }] }

revenue

Stripe revenue by referrer, campaign or country.

{ "total": 214000, "currency": "usd", "rows": [{ "referrer_host": "x.com", "amount": 103000, "payments": 48 }] }

Breakdown dimensions

pathentry_pathexit_pathreferrer_hostutm_sourceutm_mediumutm_campaigncountrydevicebrowseros
+[ 04 / 05 ]

Revenue

Stripe revenue attribution webhook

Pass the visitor id into Checkout, and the payment lands on the referrer that earned it.

POST/api/stripe/webhook?site=<slug>

Create the Checkout Session
const session = await stripe.checkout.sessions.create({
  mode: "payment",
  line_items: [{ price: "price_123", quantity: 1 }],
  success_url: "https://linkedmash.com/thanks",
  metadata: { mash_visitor: window.mash?.vid },
});

Signature verification

MashPulse verifies Stripe-Signature with the secret in STRIPE_WEBHOOK_SECRET_<SITE> (the slug upper-cased, dashes as underscores), falling back to STRIPE_WEBHOOK_SECRET. A bad signature returns 400.

The payment is stored against the visitor, together with their first referrer and UTM campaign of the day.

Stripe eventHandling
checkout.session.completedAttributed to the visitor in metadata.mash_visitor. Deduplicated by the Stripe event and session id.
invoice.paidCounts subscription renewals (billing_reason subscription_cycle). Attributed to the subscription metadata visitor, or the original checkout's visitor. Other invoices are acknowledged with { received: true, ignored }.
charge.succeededAcknowledged with { received: true, ignored }. Covered by checkout.session.completed.
+[ 05 / 05 ]

Reference

Rate limits, error codes & privacy

What to expect when things go wrong, and what we never keep.

StatusMeaning
200Accepted and stored, or webhook received.
202Accepted but ignored (bot traffic).
400Malformed payload, missing signature or webhook not configured.
403Unknown site or Origin not allowed.
404Unknown site (webhook and realtime).
429Rate limited.
500Storage error. Retry with backoff.
LimitValue
Request body8 KB
Custom properties (p)2 KB serialized
Property keys20 per event, 64 characters each
Referrer (r)2048 characters
  • ✓No cookies and nothing stored in the browser.
  • ✓IP addresses are used once to compute the visitor hash and are never stored.
  • ✓The visitor hash rotates daily at midnight Berlin time, so no one is followed across days.