---
title: "Record a payment, renewal or refund"
method: POST
path: "/payments"
tags: ["Events"]
---

# Record a payment, renewal or refund

`POST /payments`

## Request

- Base URL: `https://analytics.flowsery.com/analytics/api/v1`
- URL: `https://analytics.flowsery.com/analytics/api/v1/payments`
- Auth: HTTP bearer

Attributes revenue to a visitor so it shows up in revenue metrics and the visitor profile. Set `isRenewal` for recurring charges and `isRefund` to reverse one.

## Headers

- `X-Workspace-Id` string

## Request body

- TrackPaymentRequest
  - `amount` number, required: Major units, e.g. 49.90. On a refund, the amount refunded; `0` clears an earlier refund.
  - `currency` string: ISO 4217 code. Defaults to `USD`.
  - `transactionId` string: Your own payment id, unique across Flowsery. A second payment with the same id answers 409. Required to refund or delete the payment later.
  - `email` string
  - `name` string
  - `customerId` string
  - `isRenewal` boolean: Marks a recurring charge.
  - `isRefund` boolean: Reverses an earlier payment.
  - `timestamp` string, date-time: Defaults to now.
  - `websiteId` string
  - `domain` string
  - `visitorUid` string
  - `sessionUid` string
  - `timezone` string

## Response `200`

Payment recorded

- MessageResponse
  - `status` 'success', required
  - `data` object[], required
    - `message` string

## Other responses

- `400`: Validation error, such as a missing `amount`, or a refund whose `transactionId` belongs to a payment on another website
- `401`: Missing, invalid, expired or revoked API key or access token. `code: token_issuer_lost_access` means the member who created the API key was deactivated or lost access to the workspace: ask a workspace admin for a new key
- `403`: The credentials are valid but cannot be used here. `code: permission_denied`: the workspace role behind the API key or OAuth sign-in lacks `flowsery.write`; `role`, `keyRole` and `issuerRole` say which role fell short. `code: subscription_required`: the organization plan does not include API access. `code: workspace_access_denied`: `X-Workspace-Id` names a workspace the caller cannot reach, or an API key was sent to a workspace other than its own
- `404`: Website not found
- `409`: A payment with this `transactionId` was already recorded. Send `isRefund: true` to refund it
- `429`: Rate limit exceeded

---

[API](https://skmtc.dev/flowsery/apis/flowsery-analytics-public-api.md) · [All operations](https://skmtc.dev/flowsery/apis/flowsery-analytics-public-api/llms.txt) · [OpenAPI document](https://skmtc.dev/flowsery/apis/flowsery-analytics-public-api/revisions/8f23583fdf0e?raw)
