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.
Call through Alter
Section titled “Call through Alter”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 osfrom alter_sdk import Appfrom 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()| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | Additional keys: not allowed |
path | object | Required within parent | Additional keys: not allowed |
path.lineEntryId | string | Required within parent | unique id for a line entry; emitted as base-58, but a base-16 UUID is also accepted Format: base58 (max length 22) |
query | object | Optional | Additional keys: not allowed |
query.booksId | string | Optional | The Books instance to act on. Must be the token organization’s own instance, which it defaults to. Format: uuid |
body | Model | Optional | Expand Match a transaction to bills or invoices — request body — body |
Referenced models: Match a transaction to bills or invoices — request body — body
Response
Section titled “Response”Response media type: application/json. The table describes the pinned successful response. Referenced models link to their complete fields.
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | Model | Root | Expand Match a transaction to bills or invoices — response body |
Referenced models: Match a transaction to bills or invoices — response body
Schemas
Section titled “Schemas”Match a transaction to bills or invoices — response body
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | The result of matching a line entry to bills or invoices, or of unmatching it. Both operations return this shape. |
bills | array | Required within parent | The bills the request matched or unmatched. Empty when it matched or unmatched invoices. |
bills[] | Model | Each item | Expand Match a transaction to bills or invoices — response body — bills item |
invoices | array | Required within parent | The invoices the request matched or unmatched. Empty when it matched or unmatched bills. |
invoices[] | Model | Each item | Expand Match a transaction to bills or invoices — response body — bills item |
lineEntry | JSON | Required within parent | |
lineEntry (allOf 1) | Model | All variants apply | Expand Match a transaction to bills or invoices — response body — line Entry The line entry after the match or unmatch |
lineEntry (allOf 2) | JSON | All variants apply | The 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
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | Request to match a line entry to bills or to invoices. Additional keys: not allowed |
adjustments | JSON | Optional | |
adjustments (anyOf 1) | array | Alternative | Adjustments on the line entry itself rather than on a bill or invoice, such as closing out an overpayment, at most 100. |
adjustments (anyOf 1)[] | Model | Each item | Expand Match a transaction to bills or invoices — request body — body adjustments array item |
adjustments (anyOf 2) | null | Alternative | |
applications | array | Required within parent | The bills, or the invoices, the line entry pays, from 1 to 100, each at most once. Minimum items: 1 |
applications[] | Model | Each item | Expand 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
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | A bill or invoice after the match or unmatch. |
amountAdjusted | JSON | Required within parent | |
amountAdjusted (allOf 1) | Model | All variants apply | Expand Create a product — response body — unit Price value |
amountAdjusted (allOf 2) | JSON | All variants apply | The total of the adjustments booked against it, in dollars. |
amountOutstanding | JSON | Required within parent | |
amountOutstanding (allOf 1) | Model | All variants apply | Expand Create a product — response body — unit Price value |
amountOutstanding (allOf 2) | JSON | All variants apply | The amount still owed, in dollars. |
amountPaid | JSON | Required within parent | |
amountPaid (allOf 1) | Model | All variants apply | Expand Create a product — response body — unit Price value |
amountPaid (allOf 2) | JSON | All variants apply | The total of the payments applied to it, in dollars. |
displayStatus | JSON | Required within parent | |
displayStatus (allOf 1) | string | All variants apply | Known values: open, paid, draft, cancelled, overdue, partiallyPaid, processing |
displayStatus (allOf 2) | JSON | All variants apply | The status shown in Mercury, which also tells overdue and partially paid ones apart. |
id | string | Required within parent | The ID of the bill or invoice. Format: base58 (max length 22) |
status | JSON | Required within parent | |
status (allOf 1) | string | All variants apply | Known values: open, paid, draft, cancelled, processing |
status (allOf 2) | JSON | All variants apply | The 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
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | The line entry after the match or unmatch. |
amount | JSON | Required within parent | |
amount (allOf 1) | Model | All variants apply | Expand Create a product — response body — unit Price value |
amount (allOf 2) | JSON | All variants apply | The unsigned amount of the line entry, in dollars. |
amountAdjusted | JSON | Required within parent | |
amountAdjusted (allOf 1) | Model | All variants apply | Expand Create a product — response body — unit Price value |
amountAdjusted (allOf 2) | JSON | All variants apply | How much of the line entry is booked as line-level adjustments. 0 after an unmatch. |
amountApplied | JSON | Required within parent | |
amountApplied (allOf 1) | Model | All variants apply | Expand Create a product — response body — unit Price value |
amountApplied (allOf 2) | JSON | All variants apply | How much of the line entry is applied to bills or invoices. 0 after an unmatch. |
id | string | Required within parent | The ID of the line entry, the one in the request path. Format: base58 (max length 22) |
journalEntryId | string | Required within parent | The ID of the line entry's journal entry. Format: base58 (max length 22) |
transactionId | JSON | Optional | |
transactionId (anyOf 1) | string | Alternative | The 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) | null | Alternative |
Referenced models: Create a product — response body — unit Price value
Match a transaction to bills or invoices — request body — body applications item
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | The part of the line entry's amount applied to one bill or invoice. Additional keys: not allowed |
adjustments | JSON | Optional | |
adjustments (anyOf 1) | array | Alternative | Adjustments booked against this bill or invoice, at most 100. |
adjustments (anyOf 1)[] | Model | Each item | Expand Match a transaction to bills or invoices — request body — body adjustments array item |
adjustments (anyOf 2) | null | Alternative | |
amount | JSON | Required within parent | |
amount (allOf 1) | number | All variants apply | A dollar amount Format: double |
amount (allOf 2) | JSON | All variants apply | The positive amount applied to the bill or invoice: a number of dollars with at most two decimal places. |
billId | JSON | Optional | |
billId (anyOf 1) | string | Alternative | The 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) | null | Alternative | |
invoiceId | JSON | Optional | |
invoiceId (anyOf 1) | string | Alternative | The invoice paid. Give exactly one of `billId` and `invoiceId`, and the same one in every application. Format: base58 (max length 22) |
invoiceId (anyOf 2) | null | Alternative |
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
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | An 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 |
amount | JSON | Required within parent | |
amount (allOf 1) | number | All variants apply | A dollar amount Format: double |
amount (allOf 2) | JSON | All variants apply | The positive amount of the adjustment: a number of dollars with at most two decimal places. |
ledgerId | string | Required within parent | The 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
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | JSON | Root | |
$ (anyOf 1) | number | Alternative | A dollar amount Format: double |
$ (anyOf 2) | string | Alternative | Pattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$ |
Policy, approvals and errors
Section titled “Policy, approvals and errors”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.