---
title: "Change the referral code. Allowed exactly once, then locked (R10)."
method: POST
path: "/api/v1/affiliate/code"
tags: ["Affiliate"]
---

# Change the referral code. Allowed exactly once, then locked (R10).

`POST /api/v1/affiliate/code`

## Request

- Base URL: `https://api.avatarfactory.io` (the document declares no server; this is the origin it was published from)
- URL: `https://api.avatarfactory.io/api/v1/affiliate/code`
- Auth: one of:
  - API key in cookie `session`
  - HTTP bearer

## Request body

- CodeRequest: The one-time referral-code rename. The service validates the format.
  - `code` string, required

## Response `200`

OK

- AffiliateMeResponse: Everything the portal needs for its first paint. `code`, `link` and `payout_details` mirror the same fields on `affiliate` so the link card and the profile form do not have to unwrap a nullable object. `affiliate` is null for a user who never applied.
  - `affiliate` AffiliateView: The caller's own affiliate row. Payout details are masked here too.
    - `applied_at` string, date-time, nullable
    - `channels` string[]
    - `code` string, required
    - `code_renamed` boolean, required
    - `commission_rate_bps` integer, required
    - `decided_at` string, date-time, nullable
    - `decline_reason` string, nullable
    - `email` string, required
    - `full_name` string, required
    - `id` integer, required
    - `payout_details` object
    - `payout_method` string, required
    - `phone` string, nullable
    - `status` string, required
    - `terms_accepted_at` string, date-time, nullable
    - `terms_version` string, nullable
  - `balances` BalancesView
    - `available_cents` integer
    - `lifetime_cents` integer
    - `paid_cents` integer
    - `pending_cents` integer
  - `code` string, nullable
  - `link` string, nullable
  - `needs_terms_acceptance` boolean
  - `payout_details` object
  - `terms_version` string, required

## Other responses

- `404`: Not Found
- `409`: Conflict
- `422`: Unprocessable Entity

---

[API](https://skmtc.dev/avatarfactory/apis/avatarfactory-api.md) · [All operations](https://skmtc.dev/avatarfactory/apis/avatarfactory-api/llms.txt) · [OpenAPI document](https://skmtc.dev/avatarfactory/apis/avatarfactory-api/revisions/66fc7aa3f296?raw)
