• Docs
  • MCP
  • Pricing
Live demo
Get started
  • Get started in 3 steps
  • Track custom goals
  • Use tracking parameters
  • Filter your data
Installation guides
  • All guides
  • Next.js
  • React, Vite and React Router
  • Vue.js
  • Astro
  • WordPress
  • Shopify
  • Webflow
  • Framer
  • Squarespace
  • Wix
  • Google Tag Manager
  • Lovable, Bolt and v0
Revenue attribution
  • Connect a provider
  • Attribution guide
  • Stripe Checkout API
  • Stripe PaymentIntent API
  • Stripe Payment Links
  • Stripe other methods
  • Polar Checkout API
  • Polar Checkout Links
  • Polar other methods
  • Lemon Squeezy Checkout API
  • Lemon Squeezy Payment Links
  • Lemon Squeezy other methods
  • Paddle Checkout API
  • Paddle Overlay Checkout
  • Paddle other methods
  • Dodo Payments
  • Payment API
Proxy guides
  • Get started
  • Next.js
  • Vercel
  • Netlify
  • Cloudflare
  • Nginx
  • Managed proxy
Advanced features
  • Script configuration
  • GDPR and cookieless tracking
  • User identification
  • Exclude visits
  • Error tracking
  • Session replay
  • Bot traffic tracking
  • Export data
  • Public embed
  • Metrics explained
  • Cross-domain tracking
MCP
  • Get started
  • Tool reference
  • OAuth reference
API reference
  • Get started
  • Authentication and scopes
Account
  • Get account
Websites
  • List websites
  • Get website
Analytics
  • Get metadata
  • Get overview
  • Get time series
  • Get realtime
  • Get realtime map
  • Get goals
Breakdowns
  • Get pages
  • Get referrers
  • Get campaigns
  • Get countries
  • Get regions
  • Get cities
  • Get browsers
  • Get operating systems
  • Get devices
Errors
  • List errors
Bot traffic
  • Get bot traffic summary
  • Get bot traffic pages
  • Report a crawler request
Visitors
  • List visitors
  • Get visitor
Payments
  • Create a payment
  • Delete a payment
Troubleshooting
  • Fix CSP blocking the script
  • No data showing
  • Duplicate payments
Docs menu
Get started
  • Get started in 3 steps
  • Track custom goals
  • Use tracking parameters
  • Filter your data
Installation guides
  • All guides
  • Next.js
  • React, Vite and React Router
  • Vue.js
  • Astro
  • WordPress
  • Shopify
  • Webflow
  • Framer
  • Squarespace
  • Wix
  • Google Tag Manager
  • Lovable, Bolt and v0
Revenue attribution
  • Connect a provider
  • Attribution guide
  • Stripe Checkout API
  • Stripe PaymentIntent API
  • Stripe Payment Links
  • Stripe other methods
  • Polar Checkout API
  • Polar Checkout Links
  • Polar other methods
  • Lemon Squeezy Checkout API
  • Lemon Squeezy Payment Links
  • Lemon Squeezy other methods
  • Paddle Checkout API
  • Paddle Overlay Checkout
  • Paddle other methods
  • Dodo Payments
  • Payment API
Proxy guides
  • Get started
  • Next.js
  • Vercel
  • Netlify
  • Cloudflare
  • Nginx
  • Managed proxy
Advanced features
  • Script configuration
  • GDPR and cookieless tracking
  • User identification
  • Exclude visits
  • Error tracking
  • Session replay
  • Bot traffic tracking
  • Export data
  • Public embed
  • Metrics explained
  • Cross-domain tracking
MCP
  • Get started
  • Tool reference
  • OAuth reference
API reference
  • Get started
  • Authentication and scopes
Account
  • Get account
Websites
  • List websites
  • Get website
Analytics
  • Get metadata
  • Get overview
  • Get time series
  • Get realtime
  • Get realtime map
  • Get goals
Breakdowns
  • Get pages
  • Get referrers
  • Get campaigns
  • Get countries
  • Get regions
  • Get cities
  • Get browsers
  • Get operating systems
  • Get devices
Errors
  • List errors
Bot traffic
  • Get bot traffic summary
  • Get bot traffic pages
  • Report a crawler request
Visitors
  • List visitors
  • Get visitor
Payments
  • Create a payment
  • Delete a payment
Troubleshooting
  • Fix CSP blocking the script
  • No data showing
  • Duplicate payments
Datasense

Cookieless analytics with live visitors, console errors and exports, served from your own domain.

Product

  • Features
  • Error tracking
  • AI crawler tracking
  • Revenue attribution
  • Ad-block proxy
  • Pricing
  • Live demo

Docs

  • Get started
  • Install guides
  • Growth guides
  • Ad-block proxy
  • MCP server
  • REST API

Compare

  • vs Google Analytics
  • vs Plausible
  • vs DataFast
  • vs Fathom
  • All alternatives

Company

  • FAQ
  • Terms
  • Privacy
  • Refunds
  • Cookies
  • DPA
© 2026 DatasenseNo cookies were set on this page.

Create a payment

Record a successful payment and attribute it to the visit that led to it.

POST https://usedatasense.com/api/v1/payments

Takes a website key, or an account token with payments:write and websiteId in the body or query. Server-side only: there's no CORS.

sh
curl -X POST https://usedatasense.com/api/v1/payments \
  -H "Authorization: Bearer $DATASENSE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "amount": 29.99,
    "currency": "USD",
    "transaction_id": "pi_3PZx…",
    "datasense_session_id": "lq2k9x…"
  }'
Field Type Required Notes
amount number Yes Major units (29.99, not 2999). Zero or more.
currency string Yes 3-letter code such as USD. Converted into the site's reporting currency at the day's rate.
transaction_id string Yes The payment's ID at your provider. Repeats are de-duplicated.
datasense_session_id string No The datasense_sid cookie, or window.datasense.sessionId() at checkout. Credits the payment to that visit.
datasense_visitor_id string No The datasense_vid cookie (cookie script). Attributes to the visitor's latest visit when there's no session.
customer_id string No Your provider's customer ID. A renewal without a session is credited to the visit that won the customer.
email string No The customer's email, matched against datasense("payment", { email }) calls. Stored only as a hash.
renewal boolean No true for subscription renewals.
refunded boolean No Send the payment again with true to record a refund.
is_free_trial boolean No true for a $0 trial start.
timestamp string No ISO 8601. Defaults to now; can't be in the future.
websiteId string With an account token The website the payment belongs to.

Response

json
{ "message": "Payment recorded and attributed", "transaction_id": "pi_3PZx…", "attributed": true, "matched_by": "metadata" }

message is one of "Payment recorded and attributed", "Payment recorded without attribution", "Payment updated", "Refund recorded", "Duplicate payment ignored" or "Refund ignored" (no payment with that transaction_id). matched_by says how the visit was found: metadata, return_page, customer, email, or empty. Errors answer { "error": "…" } with 400, 401, 403, 429 or 503.

Read this page as markdownllms.txt
PreviousGet visitorNext Delete a payment
Sign in