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

> Update an existing affiliate

## Path Parameters

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

## Body Parameters

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

<ParamField body="name" type="string">
  Update the affiliate's display name. Must be between 1 and 100 characters.
</ParamField>

<ParamField body="email" type="string">
  Update the affiliate's email address. Must be a valid email format. If the email is already in use by another user, the request will fail with a conflict error.
</ParamField>

<ParamField body="group_id" type="string | null">
  Affiliate group ID (null to remove).
</ParamField>

<ParamField body="company_name" type="string | null">
  Company name for invoice. Maximum 100 characters. Set to `null` to clear.
</ParamField>

<ParamField body="country_code" type="string | null">
  2-letter ISO country code. Set to `null` to clear.
</ParamField>

<ParamField body="payout_method" type="string">
  Payout method (none to remove). Valid values: `paypal`, `wise`, `payoneer`, `paxum`, `webmoney`, `skrill`, `wire_transfer`, `bitcoin`, `ethereum`, `alipay`, `wechat`, `manual`, `none`.
</ParamField>

<ParamField body="payout_details" type="object">
  Payout details (snake\_case fields). The required fields depend on the `payout_method`:

  * **Email-based methods** (`paypal`, `wise`, `payoneer`, `paxum`, `skrill`): `email` (string, valid email)
  * **ID-based methods** (`webmoney`, `alipay`, `wechat`): `account_id` (string)
  * **Crypto methods** (`bitcoin`, `ethereum`): `address` (string, wallet address)
  * **Wire transfer** (`wire_transfer`): `bank_name`, `account_number`, `swift_code`, `iban`, `routing_number`, `account_name` (all strings)
  * **Manual** (`manual`): No details required
</ParamField>

<ParamField body="status" type="string">
  Partnership approval status. Valid values: `pending`, `approved`, `rejected`.
</ParamField>

<ParamField body="external_user_id" type="string | null">
  Your external user ID for linking referral users to your own user system. Set to `null` to clear.
</ParamField>

<ParamField body="metadata" type="object | null">
  Custom key-value data for storing additional information about the affiliate. Set to `null` to clear.
</ParamField>

## Response

The response includes the updated affiliate object with the same structure as the create endpoint.

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

<ResponseField name="data" type="object">
  The updated affiliate object.

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

    <ResponseField name="name" type="string">
      The affiliate's display name
    </ResponseField>

    <ResponseField name="email" type="string">
      The affiliate's email address
    </ResponseField>

    <ResponseField name="tracking_id" type="string">
      Unique tracking ID for the affiliate
    </ResponseField>

    <ResponseField name="source" type="string">
      Source of the affiliate creation
    </ResponseField>

    <ResponseField name="partnership_status" type="string">
      Partnership status with the program: `"PENDING"`, `"APPROVED"`, `"REJECTED"`, or `null`
    </ResponseField>

    <ResponseField name="onboarding_completed" type="boolean">
      Whether the affiliate has completed their onboarding process
    </ResponseField>

    <ResponseField name="program_id" type="string">
      The affiliate program ID the affiliate is assigned to
    </ResponseField>

    <ResponseField name="group_id" type="string | null">
      The affiliate group ID if assigned, otherwise `null`
    </ResponseField>

    <ResponseField name="external_user_id" type="string | null">
      Your external user ID if set, otherwise `null`
    </ResponseField>

    <ResponseField name="metadata" type="object | null">
      Custom key-value data if set, otherwise `null`
    </ResponseField>

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

<RequestExample>
  ```bash cURL theme={null}
  curl -X PUT "https://api.affonso.io/v1/affiliates/cmj8pptm10002p3010z8mk9ak" \
    -H "Authorization: Bearer sk_live_your_api_key" \
    -H "Content-Type: application/json" \
    -d '{
      "company_name": "John LLC",
      "country_code": "US",
      "payout_method": "paypal",
      "payout_details": {
        "email": "john@example.com"
      },
      "status": "approved",
      "external_user_id": "user_456",
      "metadata": {
        "plan": "enterprise"
      }
    }'
  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={null}
  {
    "success": true,
    "data": {
      "id": "cmj8pptm10002p3010z8mk9ak",
      "name": "John Doe",
      "email": "john@example.com",
      "tracking_id": "john-doe",
      "source": "api",
      "partnership_status": "APPROVED",
      "onboarding_completed": false,
      "program_id": "cm7xutqbb0001yfkcrnpextmp",
      "group_id": null,
      "external_user_id": "user_456",
      "metadata": {
        "plan": "enterprise"
      },
      "created_at": "2024-01-15T10:30:00Z"
    }
  }
  ```
</ResponseExample>

**Note:** To retrieve updated related data like promo codes, commission overrides, invoice details, and payout methods, use `GET /v1/affiliates/{id}?expand=promoCodes,commissionOverrides,invoiceDetails,payoutMethod`.
