Overview
Use this endpoint if Segment is already your event hub and you want Affonso to process affiliate-relevanttrack events from it.
Send requests to:
This page is the technical reference for the Segment endpoint. For a setup
walkthrough and troubleshooting checklist, see the
Segment Helpcenter guide.
What This Endpoint Accepts
- Segment
trackevents only - conversion events
- lead events
- trial events
- milestone events
- retry-safe requests using Segment
messageId
identify, group, page, and
screen return a validation error.
Required Request Parts
Every request must include:type: "track"- an
eventname - a stable
messageId - at least one supported identifier
- a revenue value in
properties - a currency in
properties
Explicit event_type Override
If your internal Segment event names should stay unchanged, you can override the
derived Affonso event type with either:
properties.affonso_event_typeproperties.affonsoEventType
conversionleadtrialmilestone
400 VALIDATION_ERROR.
Supported Identifiers
Affonso can match the request using one of these values:userIdproperties.customer_idproperties.referral_idproperties.affonso_idproperties.external_user_idcontext.traits.external_user_id
userId, Affonso treats it as your external_user_id.
If you want to send customer_id through the Segment adapter, send it
explicitly in properties.customer_id or properties.customerId. Use this
for the customer ID from your payment provider or billing system, such as
Stripe.
external_user_id is for the user ID from your own product, app, or internal
system.
If you want to resolve a referral directly, use
properties.referral_id. If you already use properties.affonso_id in an
existing integration, that is also accepted.
Older field-name variants continue to work for compatibility, but new
integrations should standardize on referral_id.
If you send both top-level userId and an explicit external-user field, both
values must match.
If none of those identifiers is present, the request fails.
How Matching Works
The identifier you send must already match an existing referral in your team. If no referral matches, Affonso rejects the request instead of creating a new attribution automatically. Affonso checks identifiers in this order:external_user_idreferral_idcustomer_id
Idempotency
Affonso uses SegmentmessageId to prevent duplicates.
Reusing the same messageId for the same event is safe and does not create a
duplicate conversion or milestone.
Revenue Fields For Conversions
For conversion events, Affonso looks for the sale amount in this order:properties.revenueproperties.amountproperties.valueproperties.total
properties.currencyproperties.sale_amount_currency
Example Request: Conversion
cURL
Example Request: Milestone
cURL
Example Request: Explicit customer_id
Use this pattern whenuserId should remain the user ID from your product or
app, but you also want to send a separate customer ID from your payment
provider:
cURL
Example Request: Resolve by affonso_id
Use this pattern when you already know the Affonso referral ID you want to credit:cURL
Tracking Examples
Use these example payloads when you want to trigger different Affonso event types through the Segment adapter.Example Request: Signup tracked as lead
cURL
Example Request: Downstream step tracked as trial
cURL
Example Request: Specific product tracked as conversion
cURL
trial only when the event should behave as a trial milestone. If you want
to match a product-specific incentive, send the event as a conversion and
include the matching product_ids or price_ids.
Common Errors
Only Segment track payloads are supportedSegment track events require userId for external_user_id mapping, properties.referral_id, or an explicit properties.customer_id fieldSegment userId must match the explicit external_user_id value when both are provided- identifier did not resolve to a referral in your team
- conversion validation errors when revenue or currency is missing
Related Docs
Segment Helpcenter Guide
Setup walkthrough and troubleshooting checklist
Server-Side Tracking
Choose the right backend tracking endpoint
Events API Reference
Reference for the core events endpoint
