MashPulse API
Ingest events, attribute Stripe revenue, and query analytics.
https://mashpulse.comcurl -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}'// 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 });
}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.
Ingestion
Event ingestion
One endpoint for pageviews and goals. The payload uses short keys to keep the beacon small.
POST/api/event
| Key | Type | Required | Description |
|---|---|---|---|
| s | string | yes | Site slug, 2 to 40 characters of a-z, 0-9 and dash. |
| t | "pageview" | "goal" | yes | Event type. |
| n | string | goal only | Goal name, up to 64 characters of letters, digits and _ : . - or space. |
| u | string | yes | Full page URL, including UTM params. Only http and https are accepted. |
| r | string | no | Referrer URL, up to 2048 characters. |
| w | number | no | Screen width in pixels. |
| p | object | no | Custom properties. Up to 2 KB serialized, 20 keys, key names up to 64 characters. |
Responses
| Status | Body | Meaning |
|---|---|---|
| 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 -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"}}'window.mash.track("signup", { plan: "pro" });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>
{ "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
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>
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 event | Handling |
|---|---|
| checkout.session.completed | Attributed to the visitor in metadata.mash_visitor. Deduplicated by the Stripe event and session id. |
| invoice.paid | Counts 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.succeeded | Acknowledged with { received: true, ignored }. Covered by checkout.session.completed. |
Reference
Rate limits, error codes & privacy
What to expect when things go wrong, and what we never keep.
| Status | Meaning |
|---|---|
| 200 | Accepted and stored, or webhook received. |
| 202 | Accepted but ignored (bot traffic). |
| 400 | Malformed payload, missing signature or webhook not configured. |
| 403 | Unknown site or Origin not allowed. |
| 404 | Unknown site (webhook and realtime). |
| 429 | Rate limited. |
| 500 | Storage error. Retry with backoff. |
| Limit | Value |
|---|---|
| Request body | 8 KB |
| Custom properties (p) | 2 KB serialized |
| Property keys | 20 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.