> ## Documentation Index
> Fetch the complete documentation index at: https://docs.affonso.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Referral

> Retrieve a single referral by ID with optional expanded data and statistics

## Path Parameters

<ParamField path="id" type="string" required>
  The unique identifier of the referral to retrieve
</ParamField>

## Query Parameters

<ParamField query="expand" type="string">
  Comma-separated list of related data to include. Valid values: `affiliate`. Example: `expand=affiliate`.
</ParamField>

<ParamField query="include" type="string">
  Comma-separated list of additional data to include. Valid values: `stats`. Example: `include=stats`. The `stats` include provides aggregated statistics about the referral's transactions.
</ParamField>

## Response

The response includes the referral object with optional expanded/included data.

<ResponseField name="success" type="boolean">
  Always `true` for successful responses
</ResponseField>

<ResponseField name="data" type="object">
  The referral object.

  <Expandable title="Data Object Properties">
    <ResponseField name="id" type="string">
      Unique identifier for the referral
    </ResponseField>

    <ResponseField name="affiliate_id" type="string">
      The affiliate ID who referred this customer
    </ResponseField>

    <ResponseField name="program_id" type="string">
      The affiliate program ID
    </ResponseField>

    <ResponseField name="email" type="string | null">
      The customer's email address
    </ResponseField>

    <ResponseField name="customer_id" type="string | null">
      Your internal customer ID if provided
    </ResponseField>

    <ResponseField name="external_user_id" type="string | null">
      Your external user ID if this referral is linked to a user from your application
    </ResponseField>

    <ResponseField name="subscription_id" type="string | null">
      Your internal subscription ID if provided
    </ResponseField>

    <ResponseField name="status" type="string">
      The referral status (lowercase): `lead`, `trialing`, `customer`, `active`, `canceled`, `rejected`
    </ResponseField>

    <ResponseField name="name" type="string | null">
      The customer's name if provided
    </ResponseField>

    <ResponseField name="metadata" type="object | null">
      Custom key-value data if provided
    </ResponseField>

    <ResponseField name="created_at" type="string">
      ISO 8601 timestamp of when the referral was created
    </ResponseField>

    <ResponseField name="converted_at" type="string | null">
      ISO 8601 timestamp of when the referral was converted (set when status is not `lead`)
    </ResponseField>
  </Expandable>
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X GET "https://api.affonso.io/v1/referrals/ref_abc123" \
    -H "Authorization: Bearer sk_live_your_api_key"
  ```

  ```bash cURL with Expand & Include theme={null}
  curl -X GET "https://api.affonso.io/v1/referrals/ref_abc123?expand=affiliate&include=stats" \
    -H "Authorization: Bearer sk_live_your_api_key"
  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={null}
  {
    "success": true,
    "data": {
      "id": "ref_abc123",
      "affiliate_id": "aff_456def",
      "program_id": "prg_789ghi",
      "email": "customer@example.com",
      "customer_id": "cust_123",
      "external_user_id": "user_42",
      "subscription_id": null,
      "status": "customer",
      "name": "John Doe",
      "metadata": {
        "plan": "enterprise"
      },
      "created_at": "2024-01-20T15:30:00Z",
      "converted_at": "2024-01-20T15:30:00Z"
    }
  }
  ```

  ```json Response with Expand & Include theme={null}
  {
    "success": true,
    "data": {
      "id": "ref_abc123",
      "affiliate_id": "aff_456def",
      "program_id": "prg_789ghi",
      "email": "customer@example.com",
      "customer_id": "cust_123",
      "external_user_id": "user_42",
      "subscription_id": null,
      "status": "customer",
      "name": "John Doe",
      "metadata": {
        "plan": "enterprise"
      },
      "created_at": "2024-01-20T15:30:00Z",
      "converted_at": "2024-01-20T15:30:00Z",
      "affiliate": {
        "id": "aff_456def",
        "name": "John Doe",
        "email": "john@example.com",
        "tracking_id": "PARTNER123",
        "source": "api",
        "partnership_status": "APPROVED",
        "onboarding_completed": true,
        "program_id": "prg_789ghi",
        "group_id": null,
        "created_at": "2024-01-15T10:30:00Z"
      },
      "stats": {
        "total_revenue": 297.00,
        "total_commission": 29.70,
        "total_orders": 3,
        "last_order_at": "2024-01-25T10:00:00Z"
      }
    }
  }
  ```
</ResponseExample>
