Conversions
Create Conversion
Create a server-side conversion and let Affonso calculate the commission automatically
POST
Use this endpoint for automatic server-side conversion tracking. Affonso will
resolve the referral, match the incentive, calculate the commission, and
create the earning when eligible.
Body Parameters
string
Affonso referral ID to credit directly. Optional if you provide
customer_id or external_user_id.string
The customer ID from your payment provider or billing system, such as a
Stripe customer ID. Optional if you provide
referral_id or
external_user_id.string
The user ID from your own product, app, or internal system. Optional if you
provide
referral_id or customer_id.string
Compatibility alias for
referral_id.number
required
Total sale amount for the purchase. Must be a positive number.
string
default:"USD"
Three-letter currency code for the sale amount, such as
USD or EUR. If
the sale currency differs from your team currency, Affonso converts the sale
amount and keeps the original values on the conversion.string[]
Optional product identifiers to help match product-specific incentives.
string[]
Optional price identifiers to help match price-based incentives.
string
Subscription interval for the conversion. Valid values:
monthly,
yearly.boolean
Whether the conversion comes from a subscription purchase.
string
required
Provider-side idempotency key for the conversion event. Use a stable unique
identifier from your system, such as an order ID, invoice ID, checkout
session ID, or payment event ID.
string
Optional commission status override. Valid values:
pending,
pending_manual_approval, ready_for_payment, processing_payout, paid,
declined, refunded, dispute. If omitted, Affonso derives the status
from the matched incentive’s approval settings.string
default:"complete"
Purchase status. Valid values:
open, complete, trialing, failed,
refunded, partial_refunded.string
Optional ISO 8601 timestamp for the conversion.
object
Optional metadata object stored on the created affiliate earning when a
commission is created.
Validation Rules
- At least one of
referral_id,customer_id, orexternal_user_idis required. affonso_idis also accepted instead ofreferral_idfor compatibility.- Older field-name variants continue to work for compatibility, but new integrations should standardize on
referral_id. - If you send more than one identifier, Affonso checks
external_user_idfirst, thenreferral_id, thencustomer_id. intervalshould only be sent for subscription conversions.- Reusing the same
external_event_idreturns the existing conversion instead of creating a duplicate.
Response
The response includes the created conversion object. On a duplicateexternal_event_id, the API returns the existing conversion with HTTP 200.
boolean
Always
true for successful responses.object
The conversion object.
Example Request
Example Response
When a conversion is accepted but no affiliate earning is created, the
response still succeeds with
commission_amount: 0,
commission_currency: null, earning_id: null,
commission_created: false, and activity_outcome: "sale_recorded".