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

# Get Sale(s)

> Returns sales for your program. Filter by a single sale with `id`, by the affiliate who earned it, by the referral it belongs to, or by the IDs the sale has in your own system (`saleExternalId` and `saleExternalInvoiceId`). With no parameters, every sale in the program is returned.

Every sale is returned with a `commissionEarned` field — the commission recorded for the affiliate credited with that sale.



## OpenAPI

````yaml GET /sales
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:
  /sales:
    get:
      summary: Get sale(s)
      description: >-
        Returns sales for your program. Filter by a single sale with `id`, by
        the affiliate who earned it, by the referral it belongs to, or by the
        IDs the sale has in your own system (`saleExternalId` and
        `saleExternalInvoiceId`). With no parameters, every sale in the program
        is returned.


        Every sale is returned with a `commissionEarned` field — the commission
        recorded for the affiliate credited with that sale.
      parameters:
        - name: id
          in: query
          description: The numeric sale ID. Returns a single sale.
          schema:
            type: integer
            format: int64
        - name: affiliateId
          in: query
          description: Return every sale credited to this affiliate UUID.
          schema:
            type: string
            format: uuid
        - name: affiliateEmail
          in: query
          description: Return every sale credited to the affiliate with this email address.
          schema:
            type: string
            format: email
        - name: referralId
          in: query
          description: Return every sale belonging to this referral UUID.
          schema:
            type: string
            format: uuid
        - name: saleExternalId
          in: query
          description: >-
            Return every sale whose `externalId` matches — the ID of the sale in
            your own system.
          schema:
            type: string
        - name: saleExternalInvoiceId
          in: query
          description: >-
            Return every sale whose `externalInvoiceId` matches — the ID of the
            invoice in your own system. Useful when you invoice customers on
            purchase.
          schema:
            type: string
      responses:
        '200':
          description: >-
            A single sale when filtering by `id` (`null` if no match), otherwise
            an array.
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: '#/components/schemas/Sale'
                  - type: array
                    items:
                      $ref: '#/components/schemas/Sale'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/ProgramNotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
components:
  schemas:
    Sale:
      type: object
      properties:
        id:
          type: integer
          format: int64
          description: The sale ID
        affiliateId:
          type: string
          format: uuid
          nullable: true
          description: The affiliate credited with this sale
        referralId:
          type: string
          format: uuid
          nullable: true
          description: The referral this sale belongs to
        affiliateProgramId:
          type: string
          format: uuid
          nullable: true
          description: The affiliate program this sale belongs to
        affiliateLinkId:
          type: string
          format: uuid
          nullable: true
          description: The affiliate link the sale was attributed to
        promotionalCodeId:
          type: string
          format: uuid
          nullable: true
          description: The promotional code used on this sale, if any
        externalId:
          type: string
          nullable: true
          description: The ID of this sale in your own system. Unique per program.
        externalInvoiceId:
          type: string
          nullable: true
          description: The ID of the invoice in your own system. Unique per program.
        name:
          type: string
          nullable: true
          description: Name of the customer
        email:
          type: string
          format: email
          nullable: true
          description: Email of the customer
        totalEarned:
          type: number
          format: float
          description: Gross value of the sale
        commissionRate:
          type: number
          format: float
          nullable: true
          description: Commission rate applied to this sale
        commissionEarned:
          type: number
          format: float
          nullable: true
          description: >-
            Commission recorded for the credited affiliate. Merged in by the API
            from the sale's commission record — it is not a column on the sale
            itself.
        taxAmount:
          type: number
          format: float
          description: Tax deducted before commission was calculated
        shippingAmount:
          type: number
          format: float
          description: Shipping deducted before commission was calculated
        productsBought:
          type: array
          items:
            type: string
          description: Product identifiers attached to this sale
        clicks:
          type: integer
          description: Clicks attributed to this sale
        status:
          type: string
          enum:
            - ACTIVE
            - REFUNDED
          description: Whether the sale is live or has been refunded
        refundedAt:
          type: string
          format: date-time
          nullable: true
          description: When the sale was marked refunded
        paymentTrigger:
          type: string
          enum:
            - SIGNUP
            - PURCHASE
            - BONUS
            - CONTENT_REWARD
          description: What triggered the commission for this sale
        source:
          type: string
          enum:
            - UNKNOWN
            - API
            - INTEGRATION
            - MANUAL
            - IMPORTED
            - AUTOMATED
          description: Where the sale came from. Sales created through this API have `API`.
        metadata:
          type: object
          nullable: true
          description: Arbitrary JSON you can attach to the sale
        createdAt:
          type: string
          format: date-time
          description: When the sale was recorded
    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'
    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

````