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

# Create an Affiliate

> Creates an affiliate in your program and gives them their first referral link.

`firstName`, `lastName` and `email` are required; the email must be unique within the program. If you do not send `affiliateLink`, a slug is generated from the email address. If you do send one and it is already taken, the request fails rather than silently picking another slug.

When `commissionRate` is omitted the affiliate inherits the program's default rate. When `affiliateStatus` is omitted, the program's auto-approve setting decides whether the affiliate starts active or pending.

Creating an affiliate also triggers the admin notification email, the affiliate welcome email (active affiliates only, unless `sendWelcomeEmail` is `false`), any automatic promo codes, and the `affiliate.created` webhook.



## OpenAPI

````yaml POST /affiliates
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:
  /affiliates:
    post:
      summary: Create an affiliate
      description: >-
        Creates an affiliate in your program and gives them their first referral
        link.


        `firstName`, `lastName` and `email` are required; the email must be
        unique within the program. If you do not send `affiliateLink`, a slug is
        generated from the email address. If you do send one and it is already
        taken, the request fails rather than silently picking another slug.


        When `commissionRate` is omitted the affiliate inherits the program's
        default rate. When `affiliateStatus` is omitted, the program's
        auto-approve setting decides whether the affiliate starts active or
        pending.


        Creating an affiliate also triggers the admin notification email, the
        affiliate welcome email (active affiliates only, unless
        `sendWelcomeEmail` is `false`), any automatic promo codes, and the
        `affiliate.created` webhook.
      requestBody:
        description: The affiliate to create
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/NewAffiliate'
        required: true
      responses:
        '200':
          description: >-
            The created affiliate, including its generated `affiliateLinks`
            entry.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Affiliate'
        '400':
          description: >-
            A required field is missing, an affiliate with this email already
            exists, the requested affiliate link is already in use,
            `commissionPlanId` or `affiliateGroupId` does not exist in this
            program, the commission plan does not belong to the given group, or
            the account has reached its affiliate limit.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/ProgramNotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
components:
  schemas:
    NewAffiliate:
      type: object
      required:
        - firstName
        - lastName
        - email
      properties:
        firstName:
          type: string
          description: First name of the affiliate
        lastName:
          type: string
          description: Last name of the affiliate
        email:
          type: string
          format: email
          description: Email of the affiliate
        commissionRate:
          type: number
          format: float
          description: Commission rate for the affiliate
        affiliateLink:
          type: string
          description: >-
            Optional slug for the affiliate's first referral link. If omitted, a
            slug is generated automatically.
        affiliateStatus:
          type: string
          enum:
            - active
            - inactive
          description: >-
            Status of the new affiliate. If omitted, the program's auto-approve
            setting decides whether the affiliate is created active or inactive.
        sendWelcomeEmail:
          type: boolean
          default: true
          description: >-
            Set to false to skip the affiliate welcome email. The welcome email
            is only sent when the affiliate is created active.
        commissionPlanId:
          type: string
          format: uuid
          description: >-
            Assign the affiliate to a commission plan in this program. Returns
            400 if the plan does not exist in this program.
        affiliateGroupId:
          type: string
          format: uuid
          description: >-
            Assign the affiliate to an affiliate group in this program. Returns
            400 if the group does not exist, or if commissionPlanId belongs to a
            different group.
    Affiliate:
      type: object
      properties:
        id:
          type: string
          format: uuid
          description: The affiliate ID
        firstName:
          type: string
          description: First name of the affiliate
        lastName:
          type: string
          description: Last name of the affiliate
        name:
          type: string
          nullable: true
          description: Full name of the affiliate (optional)
        email:
          type: string
          format: email
          description: Email of the affiliate
        password:
          type: string
          nullable: true
          description: Hashed Password of the affiliate (optional)
          deprecated: true
        emailVerified:
          type: boolean
          nullable: true
          description: Flag to indicate if the email has been verified
        image:
          type: string
          nullable: true
          description: Profile image URL of the affiliate
        detailsComplete:
          type: boolean
          description: Flag to indicate if affiliate details are complete
        programId:
          type: string
          format: uuid
          description: The program ID that the affiliate is associated with
        payoutEmail:
          type: string
          format: email
          description: Email to be used for payouts
        paymentMethod:
          type: string
          description: Payment method for the affiliate (e.g., WISE)
        commissionRate:
          type: number
          format: float
          description: Commission rate for the affiliate (0 - 100)
        link:
          type: string
          nullable: true
          deprecated: true
          description: >-
            Deprecated legacy field and almost always `null`. Read
            `affiliateLinks` instead.
        affiliateLinks:
          type: array
          description: >-
            All affiliate link records for this affiliate. This is the source of
            truth for referral link slugs.
          items:
            $ref: '#/components/schemas/AffiliateLinkRecord'
        status:
          type: string
          enum:
            - ACTIVE
            - INACTIVE
            - INVITED
            - DECLINED
            - DEACTIVATED
            - BANNED
          description: >-
            Affiliate status. `INACTIVE` is shown as **Pending** in the
            dashboard and is kept for backwards compatibility.
        createdAt:
          type: string
          format: date-time
          description: Timestamp when the affiliate was created
        updatedAt:
          type: string
          format: date-time
          description: Timestamp when the affiliate was last updated
        numberOfReferredUsers:
          type: integer
          description: Number of users referred by the affiliate
        numberOfClicks:
          type: integer
          description: Number of clicks generated by the affiliate
        totalCommissionEarned:
          type: number
          format: float
          description: Total commission earned by the affiliate
        source:
          type: string
          nullable: true
          description: >-
            How the affiliate joined. Affiliates created through this API have
            `API`.
        commissionPlanId:
          type: string
          format: uuid
          nullable: true
          description: The commission plan assigned to this affiliate, if any
        affiliateGroupId:
          type: string
          format: uuid
          nullable: true
          description: The affiliate group this affiliate belongs to, if any
    Error:
      type: object
      properties:
        error:
          type: string
          description: Human readable description of what went wrong
    AffiliateLinkRecord:
      type: object
      description: A single referral link belonging to an affiliate
      properties:
        id:
          type: string
          format: uuid
          description: Affiliate link record ID
        link:
          type: string
          description: Link slug (path segment) for this affiliate
        userId:
          type: string
          format: uuid
          nullable: true
          description: Affiliate user ID
        programId:
          type: string
          format: uuid
          nullable: true
          description: Affiliate program ID
        createdAt:
          type: string
          format: date-time
          description: When this link was created
        updatedAt:
          type: string
          format: date-time
          description: When this link was last updated
  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'
    ProgramNotFound:
      description: The affiliate program this token belongs to no longer exists.
      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

````