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

# Apply a payment transaction to a confirmed bill

> **Bills only.** Records a settlement allocation linking a payment transaction to a POSTED bill. Applying posts the payment if it's a draft (attach = confirm) and relieves its whole non-bank side onto the bill's accrual AP account with a reversible reclass correction — DRAFT or POSTED alike, no unconfirm needed; a split payment collapses onto AP. Unapplying deletes that correction and restores the payment's categorization; a linked transaction cannot be edited until unlinked. The allocation is derived from the payment (same-currency = the payment amount; cross-currency = posting base at the bill's accrual rate, optional guarded `amount` override). Each link may create its own realized-FX SYSTEM journal entry; `resolveWithAdjustment` books the remaining outstanding as a vendor-credit adjustment and closes the bill. Audited as an action_request.



## OpenAPI

````yaml /openapi.json post /api/documents/{id}/payments
openapi: 3.1.0
info:
  title: Equated API
  version: 1.0.0
  description: >-
    Agent-facing accounting API. Authenticate with a bearer token issued from
    Settings → API Tokens, or via the in-app session cookie when called from the
    web client.
servers:
  - url: https://app.equated.co
    description: API server
security: []
paths:
  /api/documents/{id}/payments:
    post:
      tags:
        - Documents
      summary: Apply a payment transaction to a confirmed bill
      description: >-
        **Bills only.** Records a settlement allocation linking a payment
        transaction to a POSTED bill. Applying posts the payment if it's a draft
        (attach = confirm) and relieves its whole non-bank side onto the bill's
        accrual AP account with a reversible reclass correction — DRAFT or
        POSTED alike, no unconfirm needed; a split payment collapses onto AP.
        Unapplying deletes that correction and restores the payment's
        categorization; a linked transaction cannot be edited until unlinked.
        The allocation is derived from the payment (same-currency = the payment
        amount; cross-currency = posting base at the bill's accrual rate,
        optional guarded `amount` override). Each link may create its own
        realized-FX SYSTEM journal entry; `resolveWithAdjustment` books the
        remaining outstanding as a vendor-credit adjustment and closes the bill.
        Audited as an action_request.
      parameters:
        - schema:
            type: integer
            minimum: 0
            exclusiveMinimum: true
          required: true
          name: id
          in: path
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                transactionId:
                  type: integer
                  minimum: 0
                  exclusiveMinimum: true
                amount:
                  type: string
                  pattern: ^\d+(\.\d+)?$
                  description: >-
                    Optional allocation in document currency. Omit to derive it
                    from the whole payment/collection.
                resolveWithAdjustment:
                  type: boolean
                  description: >-
                    Close a short payment through guarded realized FX or a
                    credit/discount adjustment.
              required:
                - transactionId
      responses:
        '200':
          description: Action execution result
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ActionExecuteResult'
      security:
        - bearerAuth: []
components:
  schemas:
    ActionExecuteResult:
      type: object
      properties:
        actionRequestId:
          type: string
          nullable: true
        status:
          type: string
        changed:
          type: boolean
          description: >-
            False when nothing was applied: the row was already in that state,
            or the preview was stale or expired.
        result:
          $ref: '#/components/schemas/ActionMutationResult'
        error:
          type: string
      required:
        - actionRequestId
        - status
        - changed
        - result
    ActionMutationResult:
      type: object
      nullable: true
      properties:
        journalEntryIds:
          type: array
          items:
            type: integer
            minimum: 0
            exclusiveMinimum: true
        documentRelationIds:
          type: array
          items:
            type: integer
            minimum: 0
            exclusiveMinimum: true
        deletedJournalEntryIds:
          type: array
          items:
            type: integer
            minimum: 0
            exclusiveMinimum: true
        voidedJournalEntryIds:
          type: array
          items:
            type: integer
            minimum: 0
            exclusiveMinimum: true
      required:
        - journalEntryIds
        - documentRelationIds
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: API token issued from the Equated app under Settings → API Tokens.

````