Skip to content

Mercury: Match a transaction to bills or invoices

Mercury books.createBooksPaymentApplications: arguments, response, policy and SDK examples.

← Books operations · Get started

Operation mercury.createbookspaymentapplications

Provider route: POST /books/line-entry/{lineEntryId}/payment-applications. Alter supplies the connection’s credentials and routing.

Install @alter-ai/sdk @alter-ai/mercury with npm, or alter-sdk-mercury with pip. Supply your connected customer’s grant ID and the arguments described below.

import { App } from "@alter-ai/sdk";
import { MercuryIntegration } from "@alter-ai/mercury";
async function execute(input: Parameters<MercuryIntegration["books"]["createBooksPaymentApplications"]>[0]) {
const app = new App({ apiKey: process.env.ALTER_API_KEY! });
try {
const provider = new MercuryIntegration(app, { grantId: process.env.PROVIDER_GRANT_ID! });
const call = await provider.books.createBooksPaymentApplications(input);
const result = await call.wait();
return result.bodyJson();
} finally {
await app.close();
}
}
import os
from alter_sdk import App
from alter_sdk_mercury import MercuryIntegration
async def execute(arguments):
async with App(api_key=os.environ["ALTER_API_KEY"]) as app:
provider = MercuryIntegration(app, {"grant_id": os.environ["PROVIDER_GRANT_ID"]})
call = await provider.books.create_books_payment_applications(arguments)
result = await call.wait()
return result.body_json()
FieldTypePresenceDescription and constraints
$objectRootAdditional keys: not allowed
pathobjectRequired within parentAdditional keys: not allowed
path.lineEntryIdstringRequired within parentunique id for a line entry; emitted as base-58, but a base-16 UUID is also accepted
Format: base58 (max length 22)
queryobjectOptionalAdditional keys: not allowed
query.booksIdstringOptionalThe Books instance to act on. Must be the token organization’s own instance, which it defaults to.
Format: uuid
bodyModelOptionalExpand Match a transaction to bills or invoices — request body — body

Referenced models: Match a transaction to bills or invoices — request body — body

Response media type: application/json. The table describes the pinned successful response. Referenced models link to their complete fields.

FieldTypePresenceDescription and constraints
$ModelRootExpand Match a transaction to bills or invoices — response body

Referenced models: Match a transaction to bills or invoices — response body

Match a transaction to bills or invoices — response body
FieldTypePresenceDescription and constraints
$objectRootThe result of matching a line entry to bills or invoices, or of unmatching
it. Both operations return this shape.
billsarrayRequired within parentThe bills the request matched or unmatched. Empty when it matched or unmatched invoices.
bills[]ModelEach itemExpand Match a transaction to bills or invoices — response body — bills item
invoicesarrayRequired within parentThe invoices the request matched or unmatched. Empty when it matched or unmatched bills.
invoices[]ModelEach itemExpand Match a transaction to bills or invoices — response body — bills item
lineEntryJSONRequired within parent
lineEntry (allOf 1)ModelAll variants applyExpand Match a transaction to bills or invoices — response body — line Entry The line entry after the match or unmatch
lineEntry (allOf 2)JSONAll variants applyThe line entry.

Referenced models: Match a transaction to bills or invoices — response body — bills item, Match a transaction to bills or invoices — response body — line Entry The line entry after the match or unmatch

Match a transaction to bills or invoices — request body — body
FieldTypePresenceDescription and constraints
$objectRootRequest to match a line entry to bills or to invoices.
Additional keys: not allowed
adjustmentsJSONOptional
adjustments (anyOf 1)arrayAlternativeAdjustments on the line entry itself rather than on a bill or invoice, such as closing out an overpayment, at most 100.
adjustments (anyOf 1)[]ModelEach itemExpand Match a transaction to bills or invoices — request body — body adjustments array item
adjustments (anyOf 2)nullAlternative
applicationsarrayRequired within parentThe bills, or the invoices, the line entry pays, from 1 to 100, each at most once.
Minimum items: 1
applications[]ModelEach itemExpand Match a transaction to bills or invoices — request body — body applications item

Referenced models: Match a transaction to bills or invoices — request body — body applications item, Match a transaction to bills or invoices — request body — body adjustments array item

Match a transaction to bills or invoices — response body — bills item
FieldTypePresenceDescription and constraints
$objectRootA bill or invoice after the match or unmatch.
amountAdjustedJSONRequired within parent
amountAdjusted (allOf 1)ModelAll variants applyExpand Create a product — response body — unit Price value
amountAdjusted (allOf 2)JSONAll variants applyThe total of the adjustments booked against it, in dollars.
amountOutstandingJSONRequired within parent
amountOutstanding (allOf 1)ModelAll variants applyExpand Create a product — response body — unit Price value
amountOutstanding (allOf 2)JSONAll variants applyThe amount still owed, in dollars.
amountPaidJSONRequired within parent
amountPaid (allOf 1)ModelAll variants applyExpand Create a product — response body — unit Price value
amountPaid (allOf 2)JSONAll variants applyThe total of the payments applied to it, in dollars.
displayStatusJSONRequired within parent
displayStatus (allOf 1)stringAll variants applyKnown values: open, paid, draft, cancelled, overdue, partiallyPaid, processing
displayStatus (allOf 2)JSONAll variants applyThe status shown in Mercury, which also tells overdue and partially paid ones apart.
idstringRequired within parentThe ID of the bill or invoice.
Format: base58 (max length 22)
statusJSONRequired within parent
status (allOf 1)stringAll variants applyKnown values: open, paid, draft, cancelled, processing
status (allOf 2)JSONAll variants applyThe status of the bill or invoice.

Referenced models: Create a product — response body — unit Price value

Match a transaction to bills or invoices — response body — line Entry The line entry after the match or unmatch
FieldTypePresenceDescription and constraints
$objectRootThe line entry after the match or unmatch.
amountJSONRequired within parent
amount (allOf 1)ModelAll variants applyExpand Create a product — response body — unit Price value
amount (allOf 2)JSONAll variants applyThe unsigned amount of the line entry, in dollars.
amountAdjustedJSONRequired within parent
amountAdjusted (allOf 1)ModelAll variants applyExpand Create a product — response body — unit Price value
amountAdjusted (allOf 2)JSONAll variants applyHow much of the line entry is booked as line-level adjustments. 0 after an unmatch.
amountAppliedJSONRequired within parent
amountApplied (allOf 1)ModelAll variants applyExpand Create a product — response body — unit Price value
amountApplied (allOf 2)JSONAll variants applyHow much of the line entry is applied to bills or invoices. 0 after an unmatch.
idstringRequired within parentThe ID of the line entry, the one in the request path.
Format: base58 (max length 22)
journalEntryIdstringRequired within parentThe ID of the line entry's journal entry.
Format: base58 (max length 22)
transactionIdJSONOptional
transactionId (anyOf 1)stringAlternativeThe ID of the transaction the line entry belongs to, as `getBooksTransaction` takes it. Omitted when the line entry isn't a transaction's.
transactionId (anyOf 2)nullAlternative

Referenced models: Create a product — response body — unit Price value

Match a transaction to bills or invoices — request body — body applications item
FieldTypePresenceDescription and constraints
$objectRootThe part of the line entry's amount applied to one bill or invoice.
Additional keys: not allowed
adjustmentsJSONOptional
adjustments (anyOf 1)arrayAlternativeAdjustments booked against this bill or invoice, at most 100.
adjustments (anyOf 1)[]ModelEach itemExpand Match a transaction to bills or invoices — request body — body adjustments array item
adjustments (anyOf 2)nullAlternative
amountJSONRequired within parent
amount (allOf 1)numberAll variants applyA dollar amount
Format: double
amount (allOf 2)JSONAll variants applyThe positive amount applied to the bill or invoice: a number of dollars with at most two decimal places.
billIdJSONOptional
billId (anyOf 1)stringAlternativeThe bill to pay. Give exactly one of `billId` and `invoiceId`, and the same one in every application.
Format: base58 (max length 22)
billId (anyOf 2)nullAlternative
invoiceIdJSONOptional
invoiceId (anyOf 1)stringAlternativeThe invoice paid. Give exactly one of `billId` and `invoiceId`, and the same one in every application.
Format: base58 (max length 22)
invoiceId (anyOf 2)nullAlternative

Referenced models: Match a transaction to bills or invoices — request body — body adjustments array item

Match a transaction to bills or invoices — request body — body adjustments array item
FieldTypePresenceDescription and constraints
$objectRootAn adjustment booked with a payment application, such as a bank fee or a
discount that closes the rest of a bill or invoice, or an overpayment left
on the line entry.
Additional keys: not allowed
amountJSONRequired within parent
amount (allOf 1)numberAll variants applyA dollar amount
Format: double
amount (allOf 2)JSONAll variants applyThe positive amount of the adjustment: a number of dollars with at most two decimal places.
ledgerIdstringRequired within parentThe ledger (general ledger account) the adjustment posts to. It must be in the Books instance and editable.
Format: base58 (max length 22)
Create a product — response body — unit Price value
FieldTypePresenceDescription and constraints
$JSONRoot
$ (anyOf 1)numberAlternativeA dollar amount
Format: double
$ (anyOf 2)stringAlternativePattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$

SDK function policy ID: mercury.createbookspaymentapplications. Catalog operation: mercury:createBooksPaymentApplications. Rules can name either ID; function rules distinguish managed calls and conservatively cover raw calls sharing the route. Existing grant permissions and policy rules apply. wait() returns an immediate result or waits for a required approval; it never approves the request itself. Persist the approval ID to resume after a restart.

Provider errors retain their response; JSON decoding raises ProviderAPIError for provider failures. ManagedOperationError identifies contract/input/retention errors. See error handling and provider-specific behavior. Sensitive input may be refused before approval storage. A decoding error never resubmits a write.

Official provider source

Report an issue with this page

Necessary

Required for sign-in, security, authorization, and remembering your choices.

Always active

Analytics

Helps us understand how our website, product, and documentation are used.

Performance diagnostics

Uses performance tracing and privacy-masked session replay to diagnose problems.

Advertising

Shares visits and sign-ups with Meta, Reddit, and X so we can measure which of our ads work.

You can change these choices at any time from Cookie settings.