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

# Create P&L comparisons

> Compare Profit & Loss views across time periods and/or tags. This endpoint allows specifying multiple time periods (specified in months, years, or custom date ranges) and tags and will generate a comparison for every combination. Note that this endpoint is retrieval only, but uses a `POST` HTTP verb rather than `GET` because of the complexity of the parameters.



## OpenAPI

````yaml post /v1/businesses/{businessId}/reports/profit-and-loss-comparison
openapi: 3.0.1
info:
  title: API
  version: latest
servers: []
security:
  - BearerAuth: []
tags: []
externalDocs:
  url: /
paths:
  /v1/businesses/{businessId}/reports/profit-and-loss-comparison:
    post:
      tags: []
      summary: Create P&L comparisons
      description: >-
        Compare Profit & Loss views across time periods and/or tags. This
        endpoint allows specifying multiple time periods (specified in months,
        years, or custom date ranges) and tags and will generate a comparison
        for every combination. Note that this endpoint is retrieval only, but
        uses a `POST` HTTP verb rather than `GET` because of the complexity of
        the parameters.
      operationId: business.reports.comparison-profit-and-loss-summaries.post
      parameters:
        - name: businessId
          in: path
          description: The UUID of the business to fetch the profit and loss for.
          required: true
          schema:
            type: string
        - name: Content-Type
          in: header
          description: Content-Type must be set to application/json.
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ProfitAndLossComparisonRequest'
      responses:
        '200':
          description: ''
          headers: {}
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/ProfitAndLossComparisonResult'
        '400':
          description: >-
            P&L not yet reconciled: one or more of the requested time periods is
            not closed or reconciled and cannot be displayed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
        '404':
          description: >-
            Business id is not found. This indicates the business id is invalid
            or the business has been archived.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
      deprecated: false
components:
  schemas:
    ProfitAndLossComparisonRequest:
      type: object
      properties:
        periods:
          $ref: '#/components/schemas/ProfitAndLossComparisonPeriods'
        tag_filters:
          type: array
          items:
            $ref: '#/components/schemas/TagComparisons'
          nullable: true
        reporting_basis:
          $ref: '#/components/schemas/ReportingBasis'
          nullable: true
        structure:
          $ref: '#/components/schemas/PnlTemplates'
          nullable: true
    ProfitAndLossComparisonResult:
      type: object
      properties:
        pnls:
          type: array
          items:
            $ref: '#/components/schemas/ComparisonPnlEntry'
    ApiError:
      type: object
      description: An error object returned in API error responses.
      properties:
        type:
          $ref: '#/components/schemas/ApiErrorType'
          description: >-
            A fixed category for the error, helpful for categorizing and
            processing errors.
        description:
          type: string
          description: A human-readable error description.
        error_enum:
          $ref: '#/components/schemas/ApiEnumErrorType'
          description: >-
            A stable, machine-readable identifier for programmatically handling
            specific error conditions. Only present for 4xx client errors—not
            included for 5xx server errors. Use this instead of parsing the
            description field, as enum values remain stable across API versions.
          nullable: true
        meta:
          type: object
          description: Optional additional information about the error.
          nullable: true
      required:
        - type
        - description
    ProfitAndLossComparisonPeriods:
      type: object
      oneOf:
        - $ref: '#/components/schemas/Months'
        - $ref: '#/components/schemas/Years'
        - $ref: '#/components/schemas/DateRanges'
      discriminator:
        propertyName: type
        mapping:
          Comparison_Months:
            $ref: '#/components/schemas/Months'
          Comparison_Years:
            $ref: '#/components/schemas/Years'
          Comparison_DateRanges:
            $ref: '#/components/schemas/DateRanges'
    TagComparisons:
      type: object
      properties:
        required_tags:
          type: array
          items:
            $ref: '#/components/schemas/TagKeyValue'
    ReportingBasis:
      type: string
      enum:
        - ACCRUAL
        - CASH
    PnlTemplates:
      type: string
      enum:
        - DEFAULT
        - TRUCKING
        - MEDSPA
        - MEDSPA_NO_LICENSING
        - CITRUS
        - CITRUS_NO_LICENSING
        - FLORIST
    ComparisonPnlEntry:
      type: object
      properties:
        period:
          $ref: '#/components/schemas/ProfitAndLossComparisonPeriods'
        tag_filter:
          $ref: '#/components/schemas/TagFilter'
        pnl:
          $ref: '#/components/schemas/ProfitAndLoss'
    ApiErrorType:
      type: string
      enum:
        - ResourceArchived
        - AuthFailure
        - Plaid
        - Stripe
        - InvalidState
        - ResourceNotFound
        - InvalidParameters
        - JsonSerialization
        - Unknown
        - BadRequest
        - PaginationCursor
        - Conflict
        - LedgerOperationFailed
    ApiEnumErrorType:
      type: string
      description: >-
        Stable enum values for programmatic error handling. Only present in 4xx
        error responses.
      enum:
        - AccessCodeInvalid
        - BalanceSheetDoesNotBalance
        - BalanceSheetMissingAccount
        - BankStatementParserError
        - BillStateError
        - BulkCategorizeFailure
        - BulkMatchFailure
        - BusinessTaskAlreadyCompleted
        - BusinessTaskDeleted
        - CalendlyOAuthError
        - CallBookingError
        - CantUpdateTransactionInCustomerPayout
        - CantUpdateTransactionInVendorPayout
        - CheckPayrollConfigNotFound
        - CheckPayrollServiceNotFound
        - ClerkUserAlreadyExists
        - ConflictingQueryParams
        - CustomAccountAlreadyExists
        - CustomTransactionCsvParsingError
        - CustomTransactionUploadFailure
        - CustomerPayoutInputFormatError
        - DoesNotMatchExistingEntity
        - EmptyBatchRequest
        - ExpenseParserError
        - ExternalAccountBalanceReconciliationError
        - ExternalIdConflict
        - InvalidCategory
        - InvalidEffectiveDate
        - InvalidLedgerOperation
        - InvalidMonthlyAverageRange
        - InvalidMultiPartRequest
        - InvalidPaginationCursor
        - InvalidPayload
        - InvoiceDeleted
        - InvoiceNotFound
        - InvoiceReferenceMismatch
        - InvoiceStateError
        - ManualRateLimit
        - MultipleTagKeyFiltersUnsupported
        - NoCognitoUserFound
        - NoOpeningBalanceFound
        - NotYetReconciled
        - OnePasswordApiError
        - OnePasswordItemNotFound
        - OnePasswordVaultNotFound
        - OpenAICategorizationError
        - PaymentLinkInvalid
        - PayrollStateError
        - PeriodIsClosed
        - PeriodNotClosed
        - PhoneNumberAlreadyRegistered
        - PlaidApiError
        - PlaidConnectionBroken
        - PlaidCreateLinkTokenError
        - PlaidCredentialsNotConfigured
        - PlaidExchangePublicTokenError
        - PlaidGetInstitutionByIdError
        - PlaidGetItemError
        - PlaidInvalidEnvironment
        - PlaidItemAlreadyExists
        - PlaidItemNotFound
        - PlaidProcessorApiError
        - PlaidUnlinkItemError
        - QueryParamFormat
        - QueryParamMissing
        - QuickbooksBrokenConnection
        - QuickbooksConnectionAlreadyExists
        - QuickbooksConnectionAlreadySyncing
        - QuickbooksConnectionMissing
        - QuickbooksConnectionNotActivated
        - QuickbooksInvalidRequest
        - QuickbooksInvalidState
        - QuickbooksNoMatchingAccount
        - QuickbooksNonPostingAccountType
        - QuickbooksNotConfigured
        - QuickbooksOAuthCallbackInvalid
        - QuickbooksOAuthError
        - QuickbooksTokenExpired
        - ResourceArchived
        - ScheduleCNotConfigured
        - SmsNotEnabled
        - SpecifiedBadRequest
        - SpecifiedIdNotFound
        - SplitTransactionError
        - StepEvaluationBadRequest
        - StripeConnectAccountIdNotFound
        - StripeCredentialsNotConfigured
        - StripeGetBalanceForConnectAccountFailure
        - StripeRedirectOrRefreshUrlNotConfigured
        - TagFilterNotFound
        - UnexpectedQueryParam
        - UnitAccountsInUse
        - WrongAnswerType
    Months:
      type: object
      properties:
        type:
          type: string
          enum:
            - Comparison_Months
        months:
          type: array
          items:
            $ref: '#/components/schemas/Month'
    Years:
      type: object
      properties:
        type:
          type: string
          enum:
            - Comparison_Years
        years:
          type: array
          items:
            $ref: '#/components/schemas/Year'
    DateRanges:
      type: object
      properties:
        type:
          type: string
          enum:
            - Comparison_Date_Ranges
        date_ranges:
          type: array
          items:
            $ref: '#/components/schemas/DateRange'
    TagKeyValue:
      type: object
      description: >-
        A TagKeyValue holds key=value data related to a tag. This is used when
        creating or updating taggable entities (transactions, invoices, etc.).
      properties:
        key:
          type: string
          description: The tag dimension key (e.g., "department", "project", "location").
          example: department
        dimension_display_name:
          type: string
          nullable: true
          description: >-
            If the TagDimension doesn't exist, providing this value specifies
            the display name upon database insertion. Otherwise, it is left as
            null on the TagDimension.
          example: Department
        value:
          type: string
          description: The tag value (e.g., "sales", "marketing", "engineering").
          example: sales
        value_display_name:
          type: string
          nullable: true
          description: >-
            If the TagValueDefinition doesn't exist, providing this value
            specifies the display name upon database insertion. Otherwise, it is
            left as null on the TagValueDefinition.
          example: Sales Department
      required:
        - key
        - value
    TagFilter:
      type: object
      properties:
        key:
          type: string
        value:
          type: array
          items:
            type: string
    ProfitAndLoss:
      type: object
      properties:
        business_id:
          type: string
          format: uuid
        start_date:
          type: string
          format: date-time
        end_date:
          type: string
          format: date-time
        income:
          $ref: '#/components/schemas/LineItem'
        cost_of_goods_sold:
          $ref: '#/components/schemas/LineItem'
        gross_profit:
          type: integer
          format: int64
        expenses:
          $ref: '#/components/schemas/LineItem'
        profit_before_taxes:
          type: integer
          format: int64
        taxes:
          $ref: '#/components/schemas/LineItem'
        net_profit:
          type: integer
          format: int64
        other_outflows:
          $ref: '#/components/schemas/LineItem'
          nullable: true
        personal_expenses:
          $ref: '#/components/schemas/LineItem'
        fully_categorized:
          type: boolean
    Month:
      type: object
      properties:
        year:
          type: integer
          format: int32
          example: 2024
        month:
          type: integer
          format: int32
          example: 12
    Year:
      type: object
      properties:
        year:
          type: integer
          format: int32
          example: 2024
    DateRange:
      type: object
      properties:
        start_date:
          type: string
          format: date-time
        end_date:
          type: string
          format: date-time
    LineItem:
      type: object
      properties:
        name:
          type: string
        display_name:
          type: string
        value:
          type: integer
          format: int64
        line_items:
          type: array
          items:
            $ref: '#/components/schemas/LineItem'
        is_contra:
          type: boolean
      required:
        - name
        - display_name
        - value
        - is_contra
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````