POST
/
track
/
sale
import { Dub } from "dub";

const dub = new Dub({
  token: "DUB_API_KEY",
});

async function run() {
  const result = await dub.track.sale();

  // Handle the result
  console.log(result);
}

run();
{
  "eventName": "<string>",
  "customer": {
    "id": "<string>",
    "name": "<string>",
    "email": "<string>",
    "avatar": "<string>",
    "externalId": "<string>"
  },
  "sale": {
    "amount": 123,
    "currency": "<string>",
    "paymentProcessor": "<string>",
    "invoiceId": "<string>",
    "metadata": {}
  }
}

Authorizations

Authorization
string
header
required

Default authentication mechanism

Body

application/json
amount
integer
required

The amount of the sale. Should be passed in cents.

Required range: x >= 0
paymentProcessor
enum<string>
required

The payment processor via which the sale was made.

Available options:
stripe,
shopify,
paddle
externalId
string
default:

This is the unique identifier for the customer in the client's app. This is used to track the customer's journey.

Maximum length: 100
customerId
string | null
deprecated

This is the unique identifier for the customer in the client's app. This is used to track the customer's journey.

Maximum length: 100
eventName
string
default:Purchase

The name of the sale event. It can be used to track different types of event for example 'Purchase', 'Upgrade', 'Payment', etc.

Maximum length: 50
Example:

"Purchase"

invoiceId
string | null

The invoice ID of the sale.

currency
string
default:usd

The currency of the sale. Accepts ISO 4217 currency codes.

metadata
object | null

Additional metadata to be stored with the sale event.

Response

200
application/json
A sale was tracked.
eventName
string
required
customer
object
required
sale
object
required