Overview
Use Affonso’s server-side tracking endpoints when your backend already knows that something happened and you want Affonso to:- resolve the correct referral
- match the correct incentive rule
- calculate commissions automatically when applicable
- advance referral lifecycle state from trusted backend events
- process full or partial refunds
- enforce idempotency on retries
- emit the standard transaction webhooks
If you want to integrate a custom payment provider with your own backend, see
the step-by-step Helpcenter guide:
Custom Backend Payment Provider Integration.
If your backend events already flow through Segment, use the dedicated
Segment adapter guide:
Segment Track Events.
Which Endpoint to Use
UsePOST /conversions when:
- you want Affonso to calculate the commission for you
- you have a billing event, order, invoice, or checkout completion on your server
- you want retry-safe idempotency with
external_event_id
POST /events when:
- you want to send a normalized event from your backend
- the event may represent a conversion, lead, trial, or milestone
- you want one endpoint for both revenue and non-revenue lifecycle events
POST /conversions/{id}/refund when:
- you already recorded a conversion in Affonso
- you need to apply a full or partial refund
- you want Affonso to update the transaction and commission state for you
POST /commissions when:
- you already know the exact commission amount
- you are importing historical payouts or backfilling data
- you need a manual override rather than incentive-based calculation
What You Usually Need To Send
Most server-side requests include:- an identifier that already matches a referral in Affonso
- the event or conversion details from your backend
- a stable
external_event_idwhen you want retry-safe delivery
sale_amountsale_amount_currency
Idempotency and Retries
external_event_id is the provider-side idempotency key whenever you want
retry-safe ingestion. Use a stable unique identifier from your system, such as:
- order ID
- invoice ID
- checkout session ID
- payment event ID Behavior by endpoint:
-
POST /conversionsstays idempotent onexternal_event_id -
POST /eventsis idempotent whenexternal_event_idis present -
POST /conversions/{id}/refundis idempotent whenexternal_event_idis present
external_event_id when retrying the same upstream event.
Choosing the Identifier
Use the identifier you can trust most in your integration:external_user_id: best when you sync the user ID from your own product or app into Affonsoreferral_id: best when you already know the Affonso referral ID to creditcustomer_id: best when you want to match using the customer ID from your payment provider or billing system, such as Stripeaffonso_id: still works if your existing integration already uses it
Recommended choice
- Start with
external_user_idwhen your backend has a stable user ID from your own product or app - Use
referral_idwhen you already know the Affonso referral ID - Use
customer_idwhen you want to match with the customer ID from your payment provider or billing system - If your existing integration already uses
affonso_id, you can keep using it - If you send more than one identifier, they must all point to the same referral
Request Signing
Request signing is optional and non-breaking. When no signing secret is configured, standard Bearer API-key requests continue to work without extra headers.Environment Variables
S2S_REQUEST_SIGNING_SECRET
Required Headers for Signed Requests
X-Affonso-Timestamp: Unix timestamp in secondsX-Affonso-Signature: hexHMAC_SHA256(secret, "<timestamp>.<raw_body>")
What Affonso Does With These Requests
When the request is valid and the identifier matches an existing referral, Affonso uses the endpoint you chose to:- record conversions from trusted backend events
- process lead, trial, and milestone events
- apply full or partial refunds to existing conversions
- calculate commissions automatically when the selected endpoint supports it
Example Flows
Backend purchase
cURL
POST /events instead when you want one backend endpoint for non-revenue
events such as leads, trials, or milestones.
Tracking Examples With POST /events
Use these examples when you want to send normalized backend events through one
Affonso endpoint.
Example: track a signup as lead
cURL
Example: track a downstream step as trial
cURL
Example: track a product-specific purchase as conversion
cURL
Example: track a product milestone as milestone
cURL
Use
trial for non-revenue trial starts. Use conversion when revenue
happened or when you need product-specific incentive matching with
product_ids or price_ids.Next Steps
Conversions API Reference
Full request and response field reference for POST /conversions
Events API Reference
Send normalized conversion, lead, trial, and milestone events
Segment Track Events
Send Segment track payloads to Affonso using the dedicated source endpoint
Refund Conversion
Apply a full or partial refund to an existing conversion
Manual Commissions
Use the manual endpoint when you need to set the commission amount yourself
