Mercury: Retrieve a transaction
Mercury books.getBooksTransaction: arguments, response, policy and SDK examples.
← Books operations · Get started
Operation mercury.getbookstransaction
Provider route: GET /books/transaction/{transactionId}. 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"]["getBooksTransaction"]>[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.getBooksTransaction(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.get_books_transaction(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.transactionId | string | Required within parent | unique id for a transaction |
query | object | Required within parent | Additional keys: not allowed |
query.sourceAccountId | string | Required within parent | unique id for a source account; emitted as base-58, but a base-16 UUID is also accepted Format: base58 (max length 22) |
query.booksId | string | Optional | The Books instance to act on. Must be the token organization’s own instance, which it defaults to. Format: uuid |
query.enrich | boolean | Optional | Whether to add Mercury banking details, such as the note, counterparty, and attachments, to the transaction. Defaults to false. |
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 Retrieve a transaction — response body |
Referenced models: Retrieve a transaction — response body
Schemas
Section titled “Schemas”2 more schemas are linked from the tables above, on the schema pages.
Retrieve a transaction — response body
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | Response containing a single transaction. |
transaction | JSON | Required within parent | |
transaction (allOf 1) | Model | All variants apply | Expand List a source account's transactions — response body — transactions item |
transaction (allOf 2) | JSON | All variants apply | The requested transaction |
Referenced models: List a source account's transactions — response body — transactions item
List a source account's transactions — response body — transactions item
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | A transaction imported into Books from a source account (a bank, card, or other feed). Once posted, it has a journal entry with one line on the source account's ledger (`lineEntryId`) and one or more `categorizationLines`. To recategorize it, pass its `journalEntryId` and its current `categorizationLines` IDs as the expected categorization. |
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 signed amount, in dollars. A positive amount posts on the source account's `debitCredit` side, increasing its ledger balance; a negative amount posts on the opposite side. Positive is money in for a Mercury bank account and a charge for a Mercury credit card; other source accounts follow their `debitCredit` and the signs their transactions were imported with. |
attachments | JSON | Optional | |
attachments (anyOf 1) | array | Alternative | Files attached to the Mercury transaction, such as receipts. Only included with `enrich=true`. |
attachments (anyOf 1)[] | Model | Each item | Expand List a source account's transactions — response body — transactions item attachments array item |
attachments (anyOf 2) | null | Alternative | |
cardLastFourDigits | JSON | Optional | |
cardLastFourDigits (anyOf 1) | string | Alternative | The last four digits of the card used for the transaction. Only included with `enrich=true`. |
cardLastFourDigits (anyOf 2) | null | Alternative | |
categorizationLines | array | Required within parent | The line entries that categorize the transaction: every other line of its journal entry. Empty when the transaction has no journal entry. |
categorizationLines[] | Model | Each item | Expand Categorize or split transactions — response body — items item categorization Lines item |
categorizationMethod | JSON | Optional | |
categorizationMethod (anyOf 1) | JSON | Alternative | |
categorizationMethod (anyOf 1) (allOf 1) | string | All variants apply | Known values: ai, rules, similarity, transferBetweenAccounts, uncategorized, user |
categorizationMethod (anyOf 1) (allOf 2) | JSON | All variants apply | How the transaction got its current category: `uncategorized` when no categorizer matched it, `user` when a person categorized it, and otherwise the automatic categorizer. Omitted when the transaction has not been categorized. |
categorizationMethod (anyOf 2) | null | Alternative | |
counterpartyName | JSON | Optional | |
counterpartyName (anyOf 1) | string | Alternative | The name of the transaction's counterparty (who the money went to or came from). Only included with `enrich=true`. |
counterpartyName (anyOf 2) | null | Alternative | |
customCategoryId | JSON | Optional | |
customCategoryId (anyOf 1) | string | Alternative | The identifier of the Mercury custom category assigned to the transaction. Only included with `enrich=true`. |
customCategoryId (anyOf 2) | null | Alternative | |
customCategoryName | JSON | Optional | |
customCategoryName (anyOf 1) | string | Alternative | The name of the Mercury custom category assigned to the transaction. Only included with `enrich=true`. |
customCategoryName (anyOf 2) | null | Alternative | |
datetime | JSON | Required within parent | |
datetime (allOf 1) | string | All variants apply | Format: yyyy-mm-ddThh:MM:ssZ |
datetime (allOf 2) | JSON | All variants apply | When the transaction happened, in UTC. |
description | string | Required within parent | The transaction's description, as imported from its source. Format: size < 513 |
id | string | Required within parent | The unique identifier of the transaction. |
journalEntryId | JSON | Optional | |
journalEntryId (anyOf 1) | string | Alternative | The identifier of the transaction's journal entry. Omitted when the transaction has no journal entry, because it is not posted or its posting was deleted. Format: base58 (max length 22) |
journalEntryId (anyOf 2) | null | Alternative | |
ledgerId | JSON | Optional | |
ledgerId (anyOf 1) | string | Alternative | The identifier of the source account's ledger, which the transaction's own line entry posts to. Format: base58 (max length 22) |
ledgerId (anyOf 2) | null | Alternative | |
lineEntryId | JSON | Optional | |
lineEntryId (anyOf 1) | string | Alternative | The identifier of the transaction's own line entry, on the source account's ledger. Omitted when the transaction has no journal entry. Format: base58 (max length 22) |
lineEntryId (anyOf 2) | null | Alternative | |
merchantType | JSON | Optional | |
merchantType (anyOf 1) | string | Alternative | The display name of the merchant type (Mercury category) automatically assigned to the transaction, such as `Software`. Only included with `enrich=true`. |
merchantType (anyOf 2) | null | Alternative | |
note | JSON | Optional | |
note (anyOf 1) | string | Alternative | The note on the Mercury transaction. Only included with `enrich=true`. |
note (anyOf 2) | null | Alternative | |
personal | boolean | Required within parent | Whether the transaction is a personal (non-business) transaction. |
postedStatus | JSON | Required within parent | |
postedStatus (allOf 1) | string | All variants apply | Known values: notPosted, posted, deleted |
postedStatus (allOf 2) | JSON | All variants apply | Whether the transaction has been posted to the general ledger as a journal entry (`posted`), not yet (`notPosted`), or was posted and then deleted (`deleted`). |
reviewStatus | JSON | Required within parent | |
reviewStatus (allOf 1) | string | All variants apply | Known values: reviewed, unreviewed |
reviewStatus (allOf 2) | JSON | All variants apply | Whether the transaction's categorization has been reviewed. |
sourceAccountId | string | Required within parent | The identifier of the source account the transaction belongs to. Format: base58 (max length 22) |
teamMemberId | JSON | Optional | |
teamMemberId (anyOf 1) | string | Alternative | The identifier of the team member associated with the transaction, such as the cardholder. Only included with `enrich=true`. |
teamMemberId (anyOf 2) | null | Alternative | |
teamMemberName | JSON | Optional | |
teamMemberName (anyOf 1) | string | Alternative | The full name of the team member associated with the transaction. Only included with `enrich=true`. |
teamMemberName (anyOf 2) | null | Alternative | |
transactionMethodKind | JSON | Optional | |
transactionMethodKind (anyOf 1) | JSON | Alternative | |
transactionMethodKind (anyOf 1) (allOf 1) | Model | All variants apply | Expand List a source account's transactions — response body — transactions item transaction Method Kind string string |
transactionMethodKind (anyOf 1) (allOf 2) | JSON | All variants apply | The kind of Mercury transaction, such as a card payment or a wire. Only included with `enrich=true`. |
transactionMethodKind (anyOf 2) | null | Alternative |
Referenced models: Create a product — response body — unit Price value, List a source account's transactions — response body — transactions item transaction Method Kind string string, Categorize or split transactions — response body — items item categorization Lines item, List a source account's transactions — response body — transactions item attachments array item
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]+)?$ |
List a source account's transactions — response body — transactions item transaction Method Kind string string
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | string | Root | Known values: outgoingElectronicPayment, outgoingCheckPayment, endogenousOutgoingAchTransfer, endogenousIncomingAchTransfer, exogenousOutgoingAch, exogenousIncomingAch, incomingCredit, outgoingCredit, incomingDebit, outgoingDebit, internalTransfer, incomingCheck, outgoingInternationalWire, incomingInternationalWire, outgoingDomesticWire, incomingDomesticWire, wireFee, conversionFee, personalBankingSubscriptionFee, billingEngineSubscriptionFee, physicalCardUpgradeFee, exogenousOutgoingCheck, exogenousOutgoingWire, treasuryTransfer, investTransfer, currencyCloudReturn, internationalWirePartnerReturn, internalCreditAccountPayment, autoRoutingTransfer, ventureDebtFunding, ventureDebtRepayment, creditCashbackRewardsDeposit, externalCreditCashbackRewardsDeposit, interestPayment, outgoingProvisionalCredit, incomingProvisionalCredit, lineOfCreditFunding, lineOfCreditRepayment, lineOfCreditInterestRepayment, atmFeeReimbursement, atmFeeReimbursementReversal, expenseReimbursement, requestedPayment, exogenousWireDrawdown, incomingCreditAccountRepayment, cardIntlTransactionFee, cardIntlTransactionFeeRebate, cardIntlTransactionFeeReversal, cardIntlTransactionFeeRebateReversal, externalCreditAccountPayment, realtimePayment, outgoingRealTimePayment, balanceHold, linkedMercuryAccountTransfer |
Policy, approvals and errors
Section titled “Policy, approvals and errors”SDK function policy ID: mercury.getbookstransaction. Catalog operation: mercury:getBooksTransaction. 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.