Skip to main content
PATCH
/
affiliate_sales
/
{id}
cURL
curl --request PATCH \
  --url https://api.growi.io/api/public/v1/affiliate_sales/{id} \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "total": 123,
  "subtotal": 123,
  "currency": "usd",
  "occurred_at": "<string>",
  "due_at": "<string>",
  "customer_email": "jsmith@example.com",
  "customer_name": "<string>",
  "commission": 123,
  "status": "unpaid"
}
'
{
  "data": {
    "id": 1947457,
    "external_id": "ORD-12345",
    "platform": "website",
    "status": "unpaid",
    "occurred_at": "2025-09-30T23:55:29.000Z",
    "total": 9999,
    "commission": 500,
    "currency": "usd"
  }
}
Updates an existing affiliate sale that was created via the Public API. Use this endpoint to modify sale details such as the total amount, commission, status, or customer information. Only sales created through the public API (POST /affiliate_sales) can be updated with this endpoint. Sales from other platforms (e.g., Shopify) cannot be modified via this API.

Important Behavior

  • Commission recalculation: If you update total without providing commission, the commission will be automatically recalculated based on campaign rules.
  • Audit logging: Every successful update is recorded in an internal audit log for support and debugging purposes.
  • Cancelled sales: Sales with status cancelled cannot be updated.

Path Parameters

ParameterTypeDescriptionRequired
idIntegerID of the affiliate sale to updateYes

Request Body

All fields are optional. Only include the fields you want to update.
FieldTypeDescription
totalIntegerTotal amount in cents. If provided without commission, commission is recalculated.
subtotalIntegerSubtotal in cents.
currencyStringCurrency code (e.g., usd, eur, gbp).
occurred_atStringWhen the sale occurred (ISO 8601 string or Unix timestamp).
due_atStringWhen the commission becomes due (ISO 8601 string or Unix timestamp).
customer_emailStringCustomer’s email address. Pass null to clear.
customer_nameStringCustomer’s name. Pass null to clear.
commissionIntegerCommission amount in cents. Omit to auto-recalculate when total is updated.
statusStringSale status: unpaid, paid, paid_externally, or cancelled.

Request Example

Update the total and let commission recalculate:
curl -X PATCH "https://api.growi.io/api/public/v1/affiliate_sales/1947458" \
     -H "Authorization: Bearer YOUR_PUBLIC_API_KEY" \
     -H "Content-Type: application/json" \
     -d '{
       "total": 12999
     }'
Update status to paid:
curl -X PATCH "https://api.growi.io/api/public/v1/affiliate_sales/1947458" \
     -H "Authorization: Bearer YOUR_PUBLIC_API_KEY" \
     -H "Content-Type: application/json" \
     -d '{
       "status": "paid"
     }'
Update multiple fields with explicit commission:
curl -X PATCH "https://api.growi.io/api/public/v1/affiliate_sales/1947458" \
     -H "Authorization: Bearer YOUR_PUBLIC_API_KEY" \
     -H "Content-Type: application/json" \
     -d '{
       "total": 15000,
       "commission": 750,
       "customer_email": "updated@example.com"
     }'

Response Example

200 OK - Sale updated successfully:
{
  "data": {
    "id": 1947458,
    "external_id": "ORD-12345",
    "platform": "website",
    "status": "unpaid",
    "occurred_at": "2025-09-30T12:00:00.000Z",
    "total": 12999,
    "commission": 650,
    "currency": "usd"
  }
}

Response Fields

FieldTypeDescription
dataObjectThe updated affiliate sale object
data.idIntegerUnique Growi identifier for the sale
data.external_idStringYour order ID
data.platformStringAlways website for sales updated via this endpoint
data.statusStringCurrent status: unpaid, paid, paid_externally, cancelled, or refunded
data.occurred_atStringISO 8601 timestamp when the sale occurred
data.totalIntegerTotal order amount in cents
data.commissionIntegerCommission amount in cents
data.currencyStringCurrency code

Error Responses

404 Not Found - Sale does not exist or does not belong to your organization:
{
  "error": "Sale not found"
}
422 Unprocessable Entity - Validation or business rule error:
{
  "error": "Only sales created via the public API (website platform) can be updated."
}
{
  "error": "Cancelled sales cannot be updated."
}

Use Cases

This endpoint is useful for:
  • Order Adjustments: Update the total when an order is modified (e.g., partial refund, add-ons)
  • Commission Corrections: Override the commission for special cases or promotions
  • Status Management: Mark sales as paid or cancelled
  • Data Corrections: Fix customer information or sale dates
  • Sync with External Systems: Keep Growi in sync when orders are modified in your system

Authorizations

Authorization
string
header
required

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

Path Parameters

id
integer
required

ID of the affiliate sale to update

Body

application/json
total
integer

Total amount in cents. If provided without commission, commission is recalculated automatically.

subtotal
integer

Subtotal in cents

currency
enum<string>

Currency code

Available options:
usd,
eur,
gbp
occurred_at
string

When the sale occurred (ISO 8601 string or Unix timestamp)

due_at
string

When the commission becomes due (ISO 8601 string or Unix timestamp)

customer_email
string<email> | null

Customer email address

customer_name
string | null

Customer name

commission
integer

Commission amount in cents. Omit to auto-recalculate when total is updated.

status
enum<string>

Sale status

Available options:
unpaid,
paid,
paid_externally,
cancelled

Response

Affiliate sale updated successfully

data
object