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

# Create loan product accounting profile

> Configures the accounting profile for a loan product version that belongs to the path loan product.



## OpenAPI

````yaml /es/openapi/v3-current/lender.yaml post /api/v1/loan-products/{id}/accounting-profiles
openapi: 3.1.0
info:
  contact:
    email: contact@lerian.studio
    name: Lerian Studio
    url: https://lerian.studio
  description: >-
    Code-first OpenAPI 3.1 surface for the Lender service. Routes that move
    money are at-most-once per X-Idempotency: when one answers 5xx, the
    X-Idempotency-Fenced response header says whether that key is now refusing
    resends (true) or free to retry (false or absent). See
    docs/contracts/money-route-idempotency.md.
  license:
    name: Lerian Studio General License
  title: Lender API
  version: 1.0.0
servers:
  - url: https://lender.sandbox.lerian.net
security:
  - BearerAuth: []
tags:
  - description: >-
      Caller session projection: validated subject and effective permissions for
      the presented token.
    name: Session
  - description: >-
      Ledger accounting operations: journal entries and accrual postings for
      loan accounts.
    name: Accounting
  - description: >-
      Loan application intake and lifecycle: submission, decisioning, and
      status.
    name: LoanApplications
  - description: >-
      Loan product catalog: definition, versioning, and activation of lending
      products.
    name: LoanProducts
  - description: >-
      Loan account servicing operations: balances, schedules, and account-level
      actions.
    name: Loan Accounts
  - description: >-
      Portfolio dashboard read operations: aggregated portfolio and performance
      views.
    name: Dashboard
  - description: >-
      Jurisdiction registry: supported jurisdiction profiles and their
      capabilities.
    name: Jurisdictions
  - description: >-
      Jurisdiction-specific loan application operations (Brazil origination
      surface).
    name: Loan Applications
  - description: >-
      Tax computation operations for jurisdiction-specific lending (e.g. Brazil
      IOF).
    name: Tax
  - description: >-
      Brazil consignado privado operations: contract lifecycle, exclusion
      repair, and compensating adjustments.
    name: Consignado
  - description: >-
      Credit-instrument document template registry: versioned drafting and
      publication of CCB clausulado.
    name: DocumentTemplates
paths:
  /api/v1/loan-products/{id}/accounting-profiles:
    post:
      tags:
        - LoanProducts
      summary: Create loan product accounting profile
      description: >-
        Configures the accounting profile for a loan product version that
        belongs to the path loan product.
      operationId: createLoanProductAccountingProfile
      parameters:
        - description: Loan product identifier.
          in: path
          name: id
          required: true
          schema:
            description: Loan product identifier.
            examples:
              - 550e8400-e29b-41d4-a716-446655440000
            format: uuid
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ConfigureAccountingProfileHumaInputBody'
        required: true
      responses:
        '201':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AccountingProfileHumaBody'
          description: Created
        '401':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Unauthorized
        '403':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Forbidden
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Unprocessable Entity
        '500':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Internal Server Error
        '503':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Service Unavailable
        default:
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Error
components:
  schemas:
    ConfigureAccountingProfileHumaInputBody:
      additionalProperties: false
      properties:
        accountingMode:
          description: Accounting recognition mode.
          enum:
            - accrual
            - cash
          examples:
            - accrual
          type: string
        loanProductVersionId:
          description: Loan product version identifier.
          examples:
            - 550e8400-e29b-41d4-a716-446655440001
          format: uuid
          type: string
        midazLedgerId:
          description: >-
            Optional per-product Midaz ledger the profile's postings route into;
            both-or-neither with midazOrganizationId. Required under
            multi-tenant mode; empty single-tenant profiles fall back to the env
            default.
          examples:
            - ledger-def
          maxLength: 128
          type: string
        midazOrganizationId:
          description: >-
            Optional per-product Midaz organization the profile's postings route
            into; both-or-neither with midazLedgerId. Required under
            multi-tenant mode; empty single-tenant profiles fall back to the env
            default.
          examples:
            - org-abc
          maxLength: 128
          type: string
        postingRules:
          description: >-
            Non-null GL account mappings per accounting event. New profiles
            require disbursement, repayment, prepayment, accrual,
            collection_unapplied, collection_reapply, and collection_refund;
            accrual_tax, accrual_fee_amortization, assignment_derecognition,
            assignment_retained_settlement, assignment_repurchase,
            refinance_payoff, refinance_payoff_reversal, provision_constitution,
            provision_reversal, renegotiation_gain, renegotiation_loss,
            renegotiation_derecognition and renegotiation_recognition are
            optional. A product whose receivables are ever assigned to a fund
            MUST carry assignment_derecognition: the cession flip and its
            write-off are both-or-nothing, so an acceptance over a product
            without it refuses and queues an exception case. It MUST also carry
            assignment_retained_settlement to be sellable mid-cycle: an
            instalment that fell due before the cession cut stays with the
            assignor, and this rule names the account it is reclassified into at
            acceptance and liquidated out of when its payroll repasse lands.
            Without it an acceptance over a receivable that retains one refuses
            instead of selling flow the fund did not buy. A product whose sold
            receivables can be settled early by the bancarizador (a refinance)
            MUST carry assignment_repurchase: without it the fund-settlement
            receipt is refused, because flipping the contract back onto this
            book with nothing to recognize the asset against is the failure the
            both-or-nothing rule exists to stop. A product that is refinanced
            MUST also carry refinance_payoff and refinance_payoff_reversal,
            which discharge the old contract against the bancarizador warehouse
            advance and restore it if the rail undoes the swap inside its regret
            window. A product that retains an origination fee at disbursement
            MUST carry accrual_fee_amortization, and its disbursement rule MUST
            carry the optional origination_fee component credit leg: the fee is
            withheld from the borrower's cash at t0 and earned back as yield
            over the life, so without them the fee has no account to be deferred
            in and none to be earned out of, and every centavo of it is refused
            rather than falling back onto the borrower's interest receivable. A
            product booked under Brazilian credit-loss rules MUST carry
            provision_constitution and provision_reversal: the engine measures
            every contract's provision on every business date and posts the
            movement against the previous measurement, so a product without them
            accrues a measured provision that never reaches the ledger. A
            product whose contracts are renegotiated under Res. CMN 4.966/2021
            art. 22 MUST carry renegotiation_gain and renegotiation_loss: a
            NON-substantial modification settles the difference between the
            modified payments and the carrying amount immediately, and a product
            with neither computes an adjustment with nowhere to book it. It MUST
            carry renegotiation_derecognition and renegotiation_recognition to
            be renegotiated SUBSTANTIALLY: that modification ends the old
            contract and mints a new one, so the two halves post separately
            against a bridge account, and a product missing either would
            derecognise a contract with nothing recognised in its place.
          items:
            $ref: '#/components/schemas/PostingRuleHumaInputBody'
          maxItems: 20
          minItems: 7
          type: array
      required:
        - loanProductVersionId
        - accountingMode
        - postingRules
      type: object
    AccountingProfileHumaBody:
      additionalProperties: false
      properties:
        accountingMode:
          description: Accounting recognition mode (accrual|cash).
          examples:
            - accrual
          type: string
        createdAt:
          description: Creation timestamp (RFC3339, UTC).
          examples:
            - '2026-06-14T12:00:00Z'
          type: string
        effectiveFrom:
          description: >-
            First civil day (YYYY-MM-DD) this chart of accounts governs, always
            a month start. A posting is booked against the chart in force for
            the competência it belongs to, never the day the run happened. A
            version configured before dated configuration reads 1900-01-01,
            because it was the only chart that version ever had.
          examples:
            - '1900-01-01'
          type: string
        id:
          description: Server-assigned accounting profile identifier (uuid).
          examples:
            - 550e8400-e29b-41d4-a716-446655440003
          type: string
        loanProductVersionId:
          description: Loan product version this profile is configured for (uuid).
          examples:
            - 550e8400-e29b-41d4-a716-446655440001
          type: string
        postingRules:
          description: Persisted GL account mappings, one per accounting event.
          items:
            $ref: '#/components/schemas/AccountingPostingRuleHumaBody'
          type:
            - array
            - 'null'
      required:
        - id
        - loanProductVersionId
        - accountingMode
        - postingRules
        - effectiveFrom
        - createdAt
      type: object
    Detail:
      additionalProperties: false
      properties:
        code:
          description: >-
            Stable, machine-readable domain error code scoped to the emitting
            service (format: <SERVICE>-NNNN).
          type: string
        detail:
          description: >-
            A human-readable explanation specific to this occurrence of the
            problem.
          examples:
            - Property foo is required but is missing.
          type: string
        errors:
          description: Optional list of individual error details
          items:
            $ref: '#/components/schemas/ErrorDetail'
          type:
            - array
            - 'null'
        instance:
          description: >-
            A URI reference that identifies the specific occurrence of the
            problem.
          examples:
            - https://example.com/error-log/abc123
          format: uri
          type: string
        status:
          description: HTTP status code
          examples:
            - 400
          format: int64
          type: integer
        title:
          description: >-
            A short, human-readable summary of the problem type. This value
            should not change between occurrences of the error.
          examples:
            - Bad Request
          type: string
        type:
          default: about:blank
          description: A URI reference to human-readable documentation for the error.
          examples:
            - https://example.com/errors/example
          format: uri
          type: string
        upstream:
          $ref: '#/components/schemas/Upstream'
          description: >-
            RFC 9457 extension member: the error a proxied third-party provider
            reported. Absent unless the emitting service explicitly surfaced
            one.
      type: object
    PostingRuleHumaInputBody:
      additionalProperties: false
      properties:
        eventType:
          description: Accounting event type.
          enum:
            - disbursement
            - repayment
            - prepayment
            - accrual
            - accrual_tax
            - accrual_fee_amortization
            - collection_unapplied
            - collection_reapply
            - collection_refund
            - assignment_derecognition
            - assignment_retained_settlement
            - assignment_repurchase
            - refinance_payoff
            - refinance_payoff_reversal
            - provision_constitution
            - provision_reversal
            - renegotiation_gain
            - renegotiation_loss
            - renegotiation_derecognition
            - renegotiation_recognition
          examples:
            - disbursement
          type: string
        legs:
          description: >-
            Non-null ordered posting legs. Prepayment requires exactly five legs
            in this component order: cash, charge_rebate, iof_refund, principal,
            iof_due; cash is a required debit, principal is a required credit,
            and the three component legs are optional with the corresponding
            sides. Assignment_derecognition requires exactly five legs in this
            component order: cash, assignment_loss, principal,
            assignment_interest, assignment_gain; cash is a required debit,
            principal is a required credit, and the assignment_interest credit
            and the two result legs are optional with the corresponding sides.
            The assignment_interest leg names the account the accrual rule
            debits: a sold receivable leaves at its amortized cost, which is
            principal plus the interest already recognized as income and not yet
            received, so both positions are relieved by the write-off.
            Assignment_retained_settlement requires exactly two legs in this
            order: a required cash debit and a required assignment_retained
            credit. Assignment_repurchase mirrors assignment_derecognition and
            requires exactly four legs in this order: a required principal
            debit, an optional assignment_loss debit, a required counterparty
            credit and an optional assignment_gain credit. Refinance_payoff
            requires exactly two legs in this order: a required counterparty
            debit and a required principal credit; refinance_payoff_reversal
            requires the mirror, a required principal debit and a required
            counterparty credit. Accrual_fee_amortization requires exactly two
            legs in this order: a required origination_fee component debit and a
            required interest role credit, neither optional. The debit account
            MUST be the same account the disbursement rule credits under its
            optional origination_fee component leg, because that is where the
            retained fee was parked at t0 and the only account releasing it can
            close. Renegotiation_gain requires exactly two legs in this order: a
            required principal debit and a required renegotiation_gain credit;
            renegotiation_loss requires the mirror, a required
            renegotiation_loss debit and a required principal credit.
            Renegotiation_derecognition requires exactly three legs in this
            component order: counterparty, renegotiation_loss,
            renegotiation_gain; the counterparty debit is required and the two
            result legs are optional with the corresponding sides. It names NO
            asset leg, deliberately: which accounts a contract stops holding
            when it leaves the book is read from the ledger on the day, one leg
            per account that holds anything, so it cannot be declared here. The
            counterparty leg carries what moves to the replacement contract; on
            a contract a non-substantial renegotiation has already re-carried,
            the ledger holds more than the borrower owes and the result legs
            carry the difference, which is why a product cannot map this event
            without naming both result accounts. Every position a borrower can
            carry must be mapped to a per-operation account, or this event is
            refused at posting time because the ledger cannot say what one
            contract holds; renegotiation_recognition requires exactly two legs
            in this order: a required principal debit and a required
            counterparty credit. Other events require at least one debit and one
            credit.
          items:
            $ref: '#/components/schemas/PostingLegHumaInputBody'
          maxItems: 16
          minItems: 2
          type: array
        metadata:
          additionalProperties:
            type: string
          description: Optional metadata.
          type: object
      required:
        - eventType
        - legs
      type: object
    AccountingPostingRuleHumaBody:
      additionalProperties: false
      properties:
        eventType:
          description: Accounting event type, one of the values the request body admits.
          examples:
            - disbursement
          type: string
        legs:
          description: Persisted ordered posting legs.
          items:
            $ref: '#/components/schemas/AccountingPostingLegBody'
          type: array
        metadata:
          additionalProperties:
            type: string
          description: Optional metadata carried with the rule.
          type: object
      required:
        - eventType
        - legs
        - metadata
      type: object
    ErrorDetail:
      additionalProperties: false
      properties:
        location:
          description: >-
            Where the error occurred, e.g. 'body.items[3].tags' or
            'path.thing-id'
          type: string
        message:
          description: Error message text
          type: string
        value:
          description: The value at the given location
      type: object
    Upstream:
      additionalProperties: false
      properties:
        code:
          description: The upstream provider's own error code, verbatim.
          examples:
            - E4001
          type: string
        message:
          description: >-
            The upstream provider's own error message, verbatim (bounded, never
            its raw response body).
          examples:
            - account not found at provider
          type: string
      type: object
    PostingLegHumaInputBody:
      additionalProperties: false
      properties:
        account:
          description: GL account for this leg.
          examples:
            - 1100.10.001
          maxLength: 128
          type: string
        component:
          description: Open withholding component code (e.g. "iof"); set this XOR role.
          examples:
            - iof
          maxLength: 64
          type: string
        optional:
          description: >-
            Whether a component amount may be omitted or zero at posting time.
            Permitted only on component legs; omitted defaults to false.
          type: boolean
        perOperation:
          description: >-
            Whether this leg books into a per-operation account (borrower
            position) instead of one aggregated per product. When true,
            "account" is a prefix limited to 17 characters of letters, digits,
            '_', '.' and '-'; omitted defaults to false (aggregated).
          type: boolean
        role:
          description: Reserved economic role of this leg; set this XOR component.
          enum:
            - principal
            - interest
            - iof
            - tax
            - cash
            - unapplied_cash
            - counterparty
            - suspense
          examples:
            - principal
          type: string
        side:
          description: Whether this leg debits or credits the account.
          enum:
            - debit
            - credit
          examples:
            - debit
          type: string
      required:
        - account
        - side
      type: object
    AccountingPostingLegBody:
      additionalProperties: false
      properties:
        account:
          description: GL account for this leg.
          examples:
            - 1100.10.001
          type: string
        component:
          description: Open withholding component code (set XOR role).
          examples:
            - iof
          type: string
        optional:
          description: >-
            Whether the component amount may be absent or zero for a generated
            posting.
          type: boolean
        perOperation:
          description: >-
            Whether this leg books into a per-operation account (borrower
            position) rather than one aggregated per product.
          type: boolean
        role:
          description: Reserved economic role of this leg (set XOR component).
          enum:
            - principal
            - interest
            - iof
            - tax
            - cash
            - unapplied_cash
            - counterparty
            - suspense
          examples:
            - principal
          type: string
        side:
          description: Whether this leg debits or credits the account.
          enum:
            - debit
            - credit
          examples:
            - debit
          type: string
      required:
        - account
        - side
        - optional
        - perOperation
      type: object
  securitySchemes:
    BearerAuth:
      bearerFormat: JWT
      description: JWT bearer token issued by the identity provider.
      scheme: bearer
      type: http

````