# Processes affordability for the transactions supplied.

Processes affordability for the transactions supplied.

Endpoint: POST /insights-engine/v1/affordability
Version: all
Security: Bearer

## Query parameters:

  - `useLegacyCategorisation` (boolean)
    Flag whether to use the latest or legacy categorisation service

  - `confidenceFloor` (number)
    Value from 0.0 to 1.0 which will return transactions as uncategorised if the category confidence is below this value

## Request fields (application/json-patch+json):

  - `referenceId` (string, required)
    Unique identifier for the account to have the affordability calculated

  - `includeFlexibleCosts` (boolean)
    Includes flexible costs in the affordability calculation

  - `currencyCode` (string, required)
    Currency code for the transactions, currently supported codes are GBP and USD.

  - `countryCode` (string, required)
    Country code for the account of the transactions

  - `transactions` (array)

  - `transactions.transactionId` (string, required)
    Unique transaction id assigned by the provider

  - `transactions.description` (string, required)
    A description line for the transaction

  - `transactions.amount` (number, required)
    The quantity of money

  - `transactions.creditDebitIndicator` (string, required)
    Enum: "Credit", "Debit"

  - `transactions.status` (string, required)
    Enum: "Pending", "Booked"

  - `transactions.bookingDate` (string, required)
    ISO8601 formatted date string containing the date the transaction is expected to be settled(or did settle)

## Response 200 fields (application/json):

  - `referenceId` (string)
    Unique identifier for the categorisation request

  - `countryCode` (string)
    Country code for the account of the transactions

  - `currencyCode` (string)
    Currency code for the transactions, currently supported codes are GBP and USD.

  - `affordabilityMonths` (array)
    List of Month Affordability

  - `affordabilityMonths.month` (integer)

  - `affordabilityMonths.year` (integer)

  - `affordabilityMonths.monthDateTime` (string)

  - `affordabilityMonths.calculatedIncome` (number)
    Estimated income value derived from Income Verification process, used for calculating affordability.

This value will be the same for all months, as opposed to [DirectID.Data.API.Models.Affordability.Response.MonthAffordability.IncomeForMonth] that tracks actual
income recorded for a given month.

  - `affordabilityMonths.affordability` (number)
    Affordability value calculated by subtracting expenditure from [DirectID.Data.API.Models.Affordability.Response.MonthAffordability.CalculatedIncome].

As it's based on [DirectID.Data.API.Models.Affordability.Response.MonthAffordability.CalculatedIncome] which has the same value for all months, this doesn't
reflect the reality of affordability for the given month, but we use it for calculating the top level
aggregate value [DirectID.Data.API.Models.Affordability.Response.AffordabilityResponse] and sensible
to record it so that we can later reference / confirm the top level aggregate is being calculated correctly.

  - `affordabilityMonths.incomeForMonth` (number)
    Income recorded from all identified income sources for the given month

  - `affordabilityMonths.affordabilityForMonth` (number)
    Affordability value calculated by subtracting expenditure from [DirectID.Data.API.Models.Affordability.Response.MonthAffordability.IncomeForMonth]

  - `affordabilityMonths.fixedCosts` (number)

  - `affordabilityMonths.flexibleCosts` (number)

  - `affordabilityMonths.debtFees` (number)

  - `estimatedCalculatedIncome` (number)
    Calculated Income Estimate

  - `estimatedFixedCosts` (number)
    Calculated Fixed Cost Estimate

  - `estimatedFlexibleCosts` (number)
    Calculated Flexible Costs Estimate

  - `estimatedDebtFees` (number)
    Calculated Debt Fees Estimate

  - `estimatedAffordability` (number)
    Calculated Affordability Estimate

## Response 400 fields (application/json):

  - `code` (string)
    Error code.

  - `description` (string)
    Error message.

  - `details` (string)
    Error details.

  - `correlationId` (string)
    User transaction tracking Id

## Response 403 fields (application/json):

  - `code` (string)
    Error code.

  - `description` (string)
    Error message.

  - `details` (string)
    Error details.

  - `correlationId` (string)
    User transaction tracking Id

## Response 500 fields (application/json):

  - `code` (string)
    Error code.

  - `description` (string)
    Error message.

  - `details` (string)
    Error details.

  - `correlationId` (string)
    User transaction tracking Id

