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

# Get all sales



## OpenAPI

````yaml https://dev.flextell.ai/docs/api.json get /v1/sales
openapi: 3.1.0
info:
  title: Flextell API
  version: 0.0.1
  description: '## Flextell API'
servers:
  - url: https://dev.flextell.ai/api
security:
  - oauth2: []
  - bearer: []
paths:
  /v1/sales:
    get:
      tags:
        - Sales
      summary: Get all sales
      operationId: sales.index
      parameters:
        - name: search
          in: query
          description: The search query.
          schema:
            type:
              - string
              - 'null'
            maxLength: 255
        - name: per_page
          in: query
          description: The number of items per page.
          schema:
            type:
              - integer
              - 'null'
            minimum: 1
            maximum: 100
        - name: page
          in: query
          description: The page number.
          schema:
            type:
              - integer
              - 'null'
            minimum: 1
        - name: sort_by
          in: query
          description: The field to sort by.
          schema:
            type:
              - string
              - 'null'
            enum:
              - created_at
              - updated_at
              - status
        - name: sort_order
          in: query
          description: The sort direction (asc or desc).
          schema:
            type:
              - string
              - 'null'
            enum:
              - asc
              - desc
        - name: customer_id
          in: query
          description: Filter by customer ID.
          schema:
            type:
              - integer
              - 'null'
        - name: user_id
          in: query
          description: Filter by user ID.
          schema:
            type:
              - integer
              - 'null'
        - name: status
          in: query
          description: Filter by status.
          schema:
            type:
              - string
              - 'null'
            enum:
              - draft
              - completed
              - cancelled
              - invoiced
              - pending
        - name: created_at_from
          in: query
          description: Filter records created on or after this date.
          schema:
            type:
              - string
              - 'null'
            format: date-time
        - name: created_at_to
          in: query
          description: Filter records created on or before this date.
          schema:
            type:
              - string
              - 'null'
            format: date-time
        - name: trashed
          in: query
          description: Include only soft-deleted records.
          schema:
            type:
              - boolean
              - 'null'
        - name: X-Tenant
          in: header
          required: true
          description: >-
            Tenant identifier. Send the Tenant ID in the `X-Tenant` header to
            scope API requests to a specific tenant.
          schema:
            type: number
      responses:
        '200':
          description: Paginated set of `SaleResource`
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/SaleResource'
                  links:
                    type: object
                    properties:
                      first:
                        type:
                          - string
                          - 'null'
                      last:
                        type:
                          - string
                          - 'null'
                      prev:
                        type:
                          - string
                          - 'null'
                      next:
                        type:
                          - string
                          - 'null'
                    required:
                      - first
                      - last
                      - prev
                      - next
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                        minimum: 1
                      from:
                        type:
                          - integer
                          - 'null'
                        minimum: 1
                      last_page:
                        type: integer
                        minimum: 1
                      links:
                        type: array
                        description: Generated paginator links.
                        items:
                          type: object
                          properties:
                            url:
                              type:
                                - string
                                - 'null'
                            label:
                              type: string
                            active:
                              type: boolean
                          required:
                            - url
                            - label
                            - active
                      path:
                        type:
                          - string
                          - 'null'
                        description: Base path for paginator generated URLs.
                      per_page:
                        type: integer
                        description: Number of items shown per page.
                        minimum: 0
                      to:
                        type:
                          - integer
                          - 'null'
                        description: Number of the last item in the slice.
                        minimum: 1
                      total:
                        type: integer
                        description: Total number of items being paginated.
                        minimum: 0
                    required:
                      - current_page
                      - from
                      - last_page
                      - links
                      - path
                      - per_page
                      - to
                      - total
                required:
                  - data
                  - links
                  - meta
        '401':
          $ref: '#/components/responses/AuthenticationException'
        '403':
          $ref: '#/components/responses/AuthorizationException'
        '422':
          $ref: '#/components/responses/ValidationException'
components:
  schemas:
    SaleResource:
      type: object
      properties:
        id:
          type: integer
        tenant_id:
          type: integer
        user_id:
          type: integer
        customer_id:
          type: integer
        appointment_id:
          type:
            - integer
            - 'null'
        currency_id:
          type: integer
        exchange_rate:
          type: number
        notes:
          type:
            - string
            - 'null'
        status:
          type:
            - string
            - 'null'
        total_price:
          type: number
        remaining_balance:
          type: number
        customer:
          $ref: '#/components/schemas/RelatedCustomerResource'
        user:
          $ref: '#/components/schemas/RelatedUserResource'
        currency:
          $ref: '#/components/schemas/RelatedCurrencyResource'
        items:
          type: array
          items:
            $ref: '#/components/schemas/SaleItemResource'
        created_at:
          type:
            - string
            - 'null'
          format: date-time
        updated_at:
          type:
            - string
            - 'null'
          format: date-time
        deleted_at:
          type:
            - string
            - 'null'
          format: date-time
      required:
        - id
        - tenant_id
        - user_id
        - customer_id
        - appointment_id
        - currency_id
        - exchange_rate
        - notes
        - status
        - total_price
        - remaining_balance
        - created_at
        - updated_at
        - deleted_at
      title: SaleResource
    RelatedCustomerResource:
      type: object
      properties:
        id:
          type: integer
        first_name:
          type:
            - string
            - 'null'
        last_name:
          type:
            - string
            - 'null'
        phone_number:
          type:
            - string
            - 'null'
        email:
          type:
            - string
            - 'null'
      required:
        - id
        - first_name
        - last_name
        - phone_number
        - email
      title: RelatedCustomerResource
    RelatedUserResource:
      type: object
      properties:
        id:
          type: integer
        name:
          type: string
      required:
        - id
        - name
      title: RelatedUserResource
    RelatedCurrencyResource:
      type: object
      properties:
        id:
          type: integer
        code:
          type:
            - string
            - 'null'
        symbol:
          type:
            - string
            - 'null'
        name:
          type: string
      required:
        - id
        - code
        - symbol
        - name
      title: RelatedCurrencyResource
    SaleItemResource:
      type: object
      properties:
        id:
          type: integer
        sale_id:
          type: integer
        staff_id:
          type:
            - integer
            - 'null'
        order:
          type: integer
        itemable_type:
          type:
            - string
            - 'null'
        itemable_id:
          type:
            - integer
            - 'null'
        warehouse_id:
          type:
            - integer
            - 'null'
        quantity:
          type: number
        tax_rate:
          type: number
        unit_price:
          type: number
        cost_price:
          type: number
        discount_amount:
          type: number
        discount_percentage:
          type: number
        sub_total:
          type: number
        total_discount:
          type: number
        total_tax:
          type: number
        total_price:
          type: number
        staff:
          $ref: '#/components/schemas/RelatedUserResource'
        itemable:
          anyOf:
            - $ref: '#/components/schemas/RelatedItemableResource'
            - type: 'null'
      required:
        - id
        - sale_id
        - staff_id
        - order
        - itemable_type
        - itemable_id
        - warehouse_id
        - quantity
        - tax_rate
        - unit_price
        - cost_price
        - discount_amount
        - discount_percentage
        - sub_total
        - total_discount
        - total_tax
        - total_price
      title: SaleItemResource
    RelatedItemableResource:
      type: object
      properties:
        id:
          type: string
        name:
          type:
            - string
            - 'null'
      required:
        - id
        - name
      title: RelatedItemableResource
  responses:
    AuthenticationException:
      description: Unauthenticated
      content:
        application/json:
          schema:
            type: object
            properties:
              message:
                type: string
                description: Error overview.
            required:
              - message
    AuthorizationException:
      description: Authorization error
      content:
        application/json:
          schema:
            type: object
            properties:
              message:
                type: string
                description: Error overview.
            required:
              - message
    ValidationException:
      description: Validation error
      content:
        application/json:
          schema:
            type: object
            properties:
              message:
                type: string
                description: Errors overview.
              errors:
                type: object
                description: A detailed description of each field that failed validation.
                additionalProperties:
                  type: array
                  items:
                    type: string
            required:
              - message
              - errors
  securitySchemes:
    oauth2:
      type: oauth2
      flows:
        authorizationCode:
          authorizationUrl: https://dev.flextell.ai/oauth/authorize
          tokenUrl: https://dev.flextell.ai/oauth/token
          scopes:
            '*': all
    bearer:
      type: http
      scheme: bearer

````