---
title: "Update a sale"
method: PUT
path: "/sales"
---

# Update a sale

`PUT /sales`

Updates a sale identified by `saleId`, and fires the `sale.updated` webhook.

`commissionEarned` is handled separately from the other fields: it updates the commission record for the affiliate credited with the sale, not the sale itself. Every other field you send is applied directly to the sale, so sending a field that is not listed below will fail the request.

## Request body

- SaleUpdate
  - `saleId` integer, required — The sale to update
  - `name` string — Name of the customer
  - `email` string, email — Email of the customer
  - `totalEarned` number, float — Gross value of the sale
  - `commissionRate` number, float — Commission rate recorded on the sale
  - `commissionEarned` number, float — Sets the commission recorded for the credited affiliate. Applied to the commission record rather than the sale.
  - `externalId` string — The ID of this sale in your own system
  - `externalInvoiceId` string — The ID of the invoice in your own system
  - `metadata` object — Arbitrary JSON to attach to the sale

## Response `200`

The updated sale, including its recalculated `commissionEarned`.

- Sale
  - `id` integer — The sale ID
  - `affiliateId` string, uuid, nullable — The affiliate credited with this sale
  - `referralId` string, uuid, nullable — The referral this sale belongs to
  - `affiliateProgramId` string, uuid, nullable — The affiliate program this sale belongs to
  - `affiliateLinkId` string, uuid, nullable — The affiliate link the sale was attributed to
  - `promotionalCodeId` string, uuid, nullable — The promotional code used on this sale, if any
  - `externalId` string, nullable — The ID of this sale in your own system. Unique per program.
  - `externalInvoiceId` string, nullable — The ID of the invoice in your own system. Unique per program.
  - `name` string, nullable — Name of the customer
  - `email` string, email, nullable — Email of the customer
  - `totalEarned` number, float — Gross value of the sale
  - `commissionRate` number, float, nullable — Commission rate applied to this sale
  - `commissionEarned` number, float, nullable — Commission recorded for the credited affiliate. Merged in by the API from the sale's commission record — it is not a column on the sale itself.
  - `taxAmount` number, float — Tax deducted before commission was calculated
  - `shippingAmount` number, float — Shipping deducted before commission was calculated
  - `productsBought` string[] — Product identifiers attached to this sale
  - `clicks` integer — Clicks attributed to this sale
  - `status` 'ACTIVE' | 'REFUNDED' — Whether the sale is live or has been refunded
  - `refundedAt` string, date-time, nullable — When the sale was marked refunded
  - `paymentTrigger` 'SIGNUP' | 'PURCHASE' | 'BONUS' | 'CONTENT_REWARD' — What triggered the commission for this sale
  - `source` 'UNKNOWN' | 'API' | 'INTEGRATION' | 'MANUAL' | 'IMPORTED' | 'AUTOMATED' — Where the sale came from. Sales created through this API have `API`.
  - `metadata` object, nullable — Arbitrary JSON you can attach to the sale
  - `createdAt` string, date-time — When the sale was recorded

## Other responses

- `400` — `saleId` was missing, or the request contained a field that cannot be updated.
- `401` — The `Authorization` header is missing, is not a `Bearer` header, or the token is not valid.
- `403` — API access is not enabled for this account.
- `404` — No sale with that ID exists in this program.
- `429` — Too many requests for this token on this endpoint. Please slow down.

---

[API](https://skmtc.net/referly/apis/referly-api.md) · [All operations](https://skmtc.net/referly/apis/referly-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/referly/referly-api/revisions/0f506d61b9c3/schema)
