> ## Documentation Index
> Fetch the complete documentation index at: https://www.referly.so/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Update Affiliate Link

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



## OpenAPI

````yaml PUT /links
openapi: 3.0.1
info:
  title: Referly API
  description: >-
    REST API for managing affiliates, referrals, sales, affiliate links, coupons
    and promotional codes in your Referly affiliate program.


    Every request must send `Authorization: Bearer <YOUR_API_KEY>`. The token is
    scoped to a single affiliate program, so no program ID is ever required in
    the request — every read and write is automatically limited to that program.


    Requests are rate limited per token, per endpoint and per method.
  version: 1.0.0
servers:
  - url: https://www.referly.so/api/v1
security:
  - bearerAuth: []
paths:
  /links:
    put:
      summary: Update an affiliate link
      description: >-
        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.
      requestBody:
        description: The rename to apply
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AffiliateLinkUpdate'
        required: true
      responses:
        '200':
          description: The updated affiliate link, with regenerated full URLs.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AffiliateLink'
        '400':
          description: >-
            `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.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          description: No affiliate link matched the `id` or `link` supplied.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          description: The affiliate link could not be updated.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    AffiliateLinkUpdate:
      type: object
      required:
        - newLink
      properties:
        id:
          type: string
          format: uuid
          description: The affiliate link to rename. Required unless `link` is supplied.
        link:
          type: string
          description: The link's current slug. Required unless `id` is supplied.
        newLink:
          type: string
          description: >-
            The new slug. Letters, numbers and hyphens only, and unique within
            the program.
          example: winter-campaign
    AffiliateLink:
      type: object
      properties:
        id:
          type: string
          format: uuid
          description: The affiliate link ID
        link:
          type: string
          description: The affiliate link string
        createdAt:
          type: string
          format: date-time
          description: Timestamp when the affiliate link was created
        updatedAt:
          type: string
          format: date-time
          description: Timestamp when the affiliate link was last updated
        affiliate:
          type: object
          properties:
            id:
              type: string
              format: uuid
              description: The affiliate ID
            name:
              type: string
              description: Full name of the affiliate
            email:
              type: string
              format: email
              description: Email of the affiliate
          nullable: true
          description: The affiliate who owns this link. `null` if the link has no owner.
        program:
          type: object
          properties:
            id:
              type: string
              format: uuid
              description: The program ID
            name:
              type: string
              description: Name of the affiliate program
            currency:
              type: string
              description: Currency used by the program
          nullable: true
          description: The program this link belongs to. `null` if the link has no program.
        clicks:
          type: integer
          description: Number of clicks on this affiliate link
        referrals:
          type: integer
          description: Number of referrals generated by this link
        sales:
          type: integer
          description: Number of sales generated by this link
        totalRevenue:
          type: number
          format: float
          description: Sum of `totalEarned` across every sale attributed to this link
        fullURLs:
          type: array
          description: >-
            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.
          items:
            type: object
            properties:
              baseUrl:
                type: string
                description: The base URL
              fullUrl:
                type: string
                description: The complete affiliate URL with parameters
      description: >-
        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.
    Error:
      type: object
      properties:
        error:
          type: string
          description: Human readable description of what went wrong
  responses:
    Unauthorized:
      description: >-
        The `Authorization` header is missing, is not a `Bearer` header, or the
        token is not valid.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Forbidden:
      description: API access is not enabled for this account.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    RateLimited:
      description: Too many requests for this token on this endpoint. Please slow down.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````