Skip to main content
POST
/
sales
Create a new sale
curl --request POST \
  --url https://www.referly.so/api/v1/sales \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "totalEarned": 123,
  "referralId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "email": "jsmith@example.com",
  "promoCode": "<string>",
  "name": "<string>",
  "externalId": "<string>",
  "externalInvoiceId": "<string>",
  "commissionRate": 123,
  "product": {
    "productId": "<string>",
    "quantity": 123,
    "price": 123,
    "name": "<string>"
  },
  "tax": 123,
  "shipping": 123
}
'
{
  "id": 123,
  "affiliateId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "referralId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "externalId": "<string>",
  "externalInvoiceId": "<string>",
  "name": "<string>",
  "email": "jsmith@example.com",
  "totalEarned": 123,
  "commissionRate": 123,
  "createdAt": "2023-11-07T05:31:56Z"
}
Optional fields tax and shipping can be provided to exclude these amounts from the commission calculation. When the affiliate program has “Automatically deduct tax from commission calculation” or “Automatically deduct shipping from commission calculation” enabled, these amounts will be subtracted from the total before computing the affiliate’s commission.

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json

Sale details

totalEarned
number<float>
required

Total amount earned from the sale

referralId
string<uuid>

The referral ID, or affiliate link or affiliate ID associated with the sale (required if email and promoCode are not provided)

email
string<email>

Email associated with the sale (required if referralId and promoCode are not provided)

promoCode
string

The promotional code associated with an affiliate (required if referralId and email are not provided). When used, the promo code will be validated and its redemption count will be incremented.

name
string

Name of the customer (required if not found via referralId or email)

externalId
string

The external ID of the sale. This is the ID of the sale in the external system or your database.

externalInvoiceId
string

The external invoice ID of the sale. This is the ID of the invoice in the external system or your database (Useful if you invoice your customers when they purchase your product).

commissionRate
number<float>

Commission rate for the sale (optional, defaults to affiliate's commission rate)

product
object

Product details for the sale

tax
number<float>

Optional tax amount to deduct from the commission calculation (when program has deduct tax enabled)

shipping
number<float>

Optional shipping amount to deduct from the commission calculation (when program has deduct shipping enabled)

Response

Sale created successfully

id
integer<int64>

The sale ID

affiliateId
string<uuid>

The affiliate ID associated with the sale

referralId
string<uuid>

The referral ID associated with the sale

externalId
string

The external ID of the sale. This is the ID of the sale in the external system or your database.

externalInvoiceId
string

The external invoice ID of the sale. This is the ID of the invoice in the external system or your database (Useful if you invoice your customers when they purchase your product)

name
string

Name of the customer who made the sale

email
string<email>

Email associated with the sale

totalEarned
number<float>

Total amount earned from the sale

commissionRate
number<float>

Commission rate for the sale

createdAt
string<date-time>

Creation timestamp of the sale