> ## 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.

# Update Referral

> Update an existing referral's email, customer ID, subscription ID, or status

## Path Parameters

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

## Body Parameters

All body parameters are optional. Only include the fields you want to update.

<ParamField body="email" type="string">
  Update the customer's email address. Must be a valid email format.
</ParamField>

<ParamField body="customer_id" type="string">
  Update your internal customer ID. Set to `null` to clear.
</ParamField>

<ParamField body="subscription_id" type="string">
  Update your internal subscription ID. Set to `null` to clear.
</ParamField>

<ParamField body="status" type="string">
  Update the referral status. Valid values: `lead`, `trialing`, `customer`, `active`, `canceled`, `rejected`. If changing from `lead` to any other status, `convertedAt` will be automatically set. Status changes may trigger webhook events (`referral.converted`).
</ParamField>

<ParamField body="name" type="string">
  Update the customer's name.
</ParamField>

<ParamField body="metadata" type="object">
  Update the custom key-value data. Pass a new object to replace the existing metadata.
</ParamField>

## Response

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

<ResponseField name="data" type="object">
  The updated 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
    </ResponseField>

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

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

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

    <ResponseField name="metadata" type="object | null">
      Custom key-value data
    </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
    </ResponseField>
  </Expandable>
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X PUT "https://api.affonso.io/v1/referrals/ref_abc123" \
    -H "Authorization: Bearer sk_live_your_api_key" \
    -H "Content-Type: application/json" \
    -d '{
      "status": "customer"
    }'
  ```
</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",
      "subscription_id": null,
      "status": "customer",
      "name": "John Doe",
      "metadata": {
        "plan": "enterprise"
      },
      "created_at": "2024-01-20T15:30:00Z",
      "converted_at": "2024-01-20T16:00:00Z"
    }
  }
  ```
</ResponseExample>
