---
title: "Create an affiliate link"
method: POST
path: "/links"
---

# Create an affiliate link

`POST /links`

Creates an additional referral link for an existing affiliate. An affiliate can own any number of links, which is useful for running separate campaigns under one affiliate.

Identify the affiliate with either `affiliateId` or `affiliateEmail` — a link cannot exist without an affiliate. The `link` slug may contain only letters, numbers and hyphens, and must be unique within the program.

Fires the `affiliate.updated` webhook for the link's owner.

## Request body

- NewAffiliateLink
  - `link` string, required — The slug for the new link. Letters, numbers and hyphens only, and unique within the program.
  - `affiliateId` string, uuid — The affiliate who will own this link. Required unless `affiliateEmail` is supplied.
  - `affiliateEmail` string, email — Email of the affiliate who will own this link. Required unless `affiliateId` is supplied.

## Response `200`

The created affiliate link, with counters at zero and its full URLs already generated.

- 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` — `link` was missing, neither `affiliateId` nor `affiliateEmail` was supplied, the affiliate was not found in this program, the slug contains characters other than letters, numbers and hyphens, or the 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` — The affiliate program this token belongs to no longer exists.
- `429` — Too many requests for this token on this endpoint. Please slow down.
- `500` — The affiliate link could not be created.

---

[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)
