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

# Get Sale(s)

> Returns a list of sales based on the affiliate program, filtered by optional sale ID, affiliate ID, affiliate email, referral ID, or external ID



## OpenAPI

````yaml GET /sales
openapi: 3.0.1
info:
  title: Referly API
  description: API for managing affiliates, referrals, and sales for SaaS businesses
  version: 1.0.0
servers:
  - url: https://www.referly.so/api/v1
security:
  - bearerAuth: []
paths:
  /sales:
    get:
      summary: Get all sales or by ID, affiliate, referral, or external ID
      description: >-
        Returns a list of sales based on the affiliate program, filtered by
        optional sale ID, affiliate ID, affiliate email, referral ID, or
        external ID
      parameters:
        - name: id
          in: query
          description: The ID of the sale to retrieve
          schema:
            type: integer
            format: int64
        - name: affiliateId
          in: query
          description: The affiliate ID associated with the sale
          schema:
            type: string
            format: uuid
        - name: affiliateEmail
          in: query
          description: The email of the affiliate associated with the sale
          schema:
            type: string
            format: email
        - name: referralId
          in: query
          description: The referral ID associated with the sale
          schema:
            type: string
            format: uuid
        - name: saleExternalId
          in: query
          description: >-
            The external ID of the sale. This is the ID of the sale in the
            external system or your database.
          schema:
            type: string
      responses:
        '200':
          description: A list of sales or a single sale
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Sale'
        '400':
          description: Unexpected error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    Sale:
      type: object
      properties:
        id:
          type: integer
          format: int64
          description: The sale ID
        affiliateId:
          type: string
          format: uuid
          description: The affiliate ID associated with the sale
        referralId:
          type: string
          format: uuid
          description: The referral ID associated with the sale
        externalId:
          type: string
          description: >-
            The external ID of the sale. This is the ID of the sale in the
            external system or your database.
        externalInvoiceId:
          type: string
          description: >-
            The external invoice ID of the sale. This is the ID of the invoice
            in the external system or your database (Useful if you invoice your
            customers when they purchase your product)
        name:
          type: string
          description: Name of the customer who made the sale
        email:
          type: string
          format: email
          description: Email associated with the sale
        totalEarned:
          type: number
          format: float
          description: Total amount earned from the sale
        commissionRate:
          type: number
          format: float
          description: Commission rate for the sale
        createdAt:
          type: string
          format: date-time
          description: Creation timestamp of the sale
    Error:
      type: object
      properties:
        error:
          type: integer
          description: Error code
        message:
          type: string
          description: Error message
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````