Skip to main content

Overview

Use this endpoint if Segment is already your event hub and you want Affonso to process affiliate-relevant track events from it. Send requests to:
Use your Affonso API key in the request headers:
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 track events only
  • conversion events
  • lead events
  • trial events
  • milestone events
  • retry-safe requests using Segment messageId
Unsupported Segment payload types such as identify, group, page, and screen return a validation error.

Required Request Parts

Every request must include:
  • type: "track"
  • an event name
  • a stable messageId
  • at least one supported identifier
For conversion events, also include:
  • 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_type
  • properties.affonsoEventType
Allowed values are:
  • conversion
  • lead
  • trial
  • milestone
If a valid override is present, it wins over the built-in name mapping. If an invalid override is present, the request fails with 400 VALIDATION_ERROR.

Supported Identifiers

Affonso can match the request using one of these values:
  • userId
  • properties.customer_id
  • properties.referral_id
  • properties.affonso_id
  • properties.external_user_id
  • context.traits.external_user_id
If you send 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:
  1. external_user_id
  2. referral_id
  3. customer_id
If you send multiple identifiers, they must all resolve to the same referral or the request fails with a deterministic mismatch error.

Idempotency

Affonso uses Segment messageId 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:
  1. properties.revenue
  2. properties.amount
  3. properties.value
  4. properties.total
Currency is read from:
  • properties.currency
  • properties.sale_amount_currency

Example Request: Conversion

cURL

Example Request: Milestone

cURL

Example Request: Explicit customer_id

Use this pattern when userId 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
Use 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 supported
  • Segment track events require userId for external_user_id mapping, properties.referral_id, or an explicit properties.customer_id field
  • Segment 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

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