api-referencePOST

Automatic tracking available

If you use Stripe, LemonSqueezy, or Polar, you do not need this endpoint. Payments are tracked automatically when your payment provider is connected.
POSThttps://analytics.flowsery.com/analytics/api/v1/payments

Record a payment and attribute revenue. Send amount plus any identifiers you have, especially transactionId and visitorUid/sessionUid when available.

Bearer Token (workspace token or website API key)

Workspace tokens need a website selector

Workspace API tokens can access every website in the workspace. Pass either <code>websiteId</code> or <code>domain</code> so Flowsery knows which website to query or mutate. Website API keys are already scoped to one website, so the selector can be omitted.

Website selector

ParameterTypeDescription
websiteIdstringWebsite ID to use with a workspace API token. Include this field in the JSON body unless you provide domain. Omit when authenticating with a website API key.
domainstringWebsite domain to use with a workspace API token when websiteId is not provided. Include this field in the JSON body. Omit when authenticating with a website API key.

Request body

ParameterTypeDescription
amountnumberPayment amount. This should always be sent.
currencystringCurrency code such as "USD", "EUR", "GBP".
transactionIdstringStable transaction identifier used for deduplication.
visitorUidstringOptional Flowsery visitor ID, typically sourced from the _fs_vid cookie on your own backend.
sessionUidstringOptional Flowsery session ID, typically sourced from the _fs_sid cookie.
emailstringCustomer email address.
namestringCustomer name.
customerIdstringCustomer ID from your payment provider.
isRenewalbooleanSet to true for recurring payments. Defaults to false.
isRefundbooleanSet to true for refunded payments. Defaults to false.

The success payload contains a confirmation message only.

Example request (Node.js)
const handler = async (req, res) => {
  const _fs_vid = req.cookies._fs_vid;
  const _fs_sid = req.cookies._fs_sid;

  const response = await fetch(
    "https://analytics.flowsery.com/analytics/api/v1/payments",
    {
      method: "POST",
      headers: {
        Authorization: `Bearer ${FLOWSERY_API_KEY}`,
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        websiteId: process.env.FLOWSERY_WEBSITE_ID,
        amount: 29.99,
        currency: "USD",
        transactionId: "payment_456",
        visitorUid: _fs_vid,
        sessionUid: _fs_sid,
        email: "buyer@example.com",
      }),
    }
  );

  res.status(200).send("Payment tracked");
};
200
{
  "status": "success",
  "data": [{
    "message": "Payment recorded successfully"
  }]
}