---
title: "Update an affiliate link"
method: PUT
path: "/links"
---

# Update an affiliate link

`PUT /links`

Renames an affiliate link's slug. Identify the link with either `id` or its current `link` slug, and give the new slug as `newLink`.

The new slug may contain only letters, numbers and hyphens, and must be unique within the program.

Renaming a slug breaks any referral URL already shared using the old slug — existing clicks, referrals and sales stay attached to the link, but new traffic on the old URL will not be tracked. Fires the `affiliate.updated` webhook for the link's owner.

## Request body

- AffiliateLinkUpdate
  - `id` string, uuid — The affiliate link to rename. Required unless `link` is supplied.
  - `link` string — The link's current slug. Required unless `id` is supplied.
  - `newLink` string, required — The new slug. Letters, numbers and hyphens only, and unique within the program.

## Response `200`

The updated affiliate link, with regenerated full URLs.

- AffiliateLink — An affiliate link as returned by the affiliate link endpoints. The counters and `fullURLs` are computed per request and are not stored on the link itself.
  - `id` string, uuid — The affiliate link ID
  - `link` string — The affiliate link string
  - `createdAt` string, date-time — Timestamp when the affiliate link was created
  - `updatedAt` string, date-time — Timestamp when the affiliate link was last updated
  - `affiliate` object, nullable — The affiliate who owns this link. `null` if the link has no owner.
    - `id` string, uuid — The affiliate ID
    - `name` string — Full name of the affiliate
    - `email` string, email — Email of the affiliate
  - `program` object, nullable — The program this link belongs to. `null` if the link has no program.
    - `id` string, uuid — The program ID
    - `name` string — Name of the affiliate program
    - `currency` string — Currency used by the program
  - `clicks` integer — Number of clicks on this affiliate link
  - `referrals` integer — Number of referrals generated by this link
  - `sales` integer — Number of sales generated by this link
  - `totalRevenue` number, float — Sum of `totalEarned` across every sale attributed to this link
  - `fullURLs` object[] — One entry per base URL configured on your program, with the affiliate's tracking parameter and any program URL parameters already applied. Share these directly.
    - `baseUrl` string — The base URL
    - `fullUrl` string — The complete affiliate URL with parameters

## Other responses

- `400` — `newLink` was missing, neither `id` nor `link` was supplied, the new slug contains characters other than letters, numbers and hyphens, or the new slug is already used in this program.
- `401` — The `Authorization` header is missing, is not a `Bearer` header, or the token is not valid.
- `403` — API access is not enabled for this account.
- `404` — No affiliate link matched the `id` or `link` supplied.
- `429` — Too many requests for this token on this endpoint. Please slow down.
- `500` — The affiliate link could not be updated.

---

[API](https://skmtc.net/referly/apis/referly-api.md) · [All operations](https://skmtc.net/referly/apis/referly-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/referly/referly-api/revisions/0f506d61b9c3/schema)
