Skip to content

Mercury: List a source account's transactions

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

← Books operations · Get started

Operation mercury.getbookstransactions

Provider route: GET /books/transactions. 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"]["getBooksTransactions"]>[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.getBooksTransactions(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.get_books_transactions(arguments)
result = await call.wait()
return result.body_json()
FieldTypePresenceDescription and constraints
$objectRootAdditional keys: not allowed
queryobjectRequired within parentAdditional keys: not allowed
query.sourceAccountIdstringRequired within parentunique id for a source account; emitted as base-58, but a base-16 UUID is also accepted
Format: base58 (max length 22)
query.booksIdstringOptionalThe Books instance to act on. Must be the token organization’s own instance, which it defaults to.
Format: uuid
query.startDatestringRequired within parentFormat: date
query.endDatestringRequired within parentFormat: date
query.reviewStatusstringRequired within parentOne of: reviewed, unreviewed
query.pageTokenstringOptionalThe nextPageToken (or prevPageToken) of a previous response, to fetch that page. Send the same sourceAccountId, startDate, endDate, and reviewStatus as that request. Omit for the first page.
query.enrichbooleanOptionalWhether to add Mercury banking details, such as the note, counterparty, and attachments, to each transaction. Defaults to false.

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

FieldTypePresenceDescription and constraints
$ModelRootExpand List a source account’s transactions — response body

Referenced models: List a source account’s transactions — response body

2 more schemas are linked from the tables above, on the schema pages.

List a source account's transactions — response body
FieldTypePresenceDescription and constraints
$objectRootOne page of a source account's transactions.
nextPageTokenJSONOptional
nextPageToken (anyOf 1)stringAlternativePresent when more transactions match the request. Pass it back as `pageToken`, with the same other parameters, to fetch the next page, and keep doing so until a response has no `nextPageToken`; only then have you seen every transaction in the range.
nextPageToken (anyOf 2)nullAlternative
prevPageTokenJSONOptional
prevPageToken (anyOf 1)stringAlternativePresent when there is an earlier page. Pass it back as `pageToken`, with the same other parameters, to fetch the previous page.
prevPageToken (anyOf 2)nullAlternative
transactionsarrayRequired within parentThe transactions on this page: at most one page, whose size Books decides, so not necessarily every transaction in the date range.
transactions[]ModelEach itemExpand List a source account's transactions — response body — transactions item

Referenced models: List a source account's transactions — response body — transactions item

List a source account's transactions — response body — transactions item
FieldTypePresenceDescription and constraints
$objectRootA 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.
amountJSONRequired within parent
amount (allOf 1)ModelAll variants applyExpand Create a product — response body — unit Price value
amount (allOf 2)JSONAll variants applyThe 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.
attachmentsJSONOptional
attachments (anyOf 1)arrayAlternativeFiles attached to the Mercury transaction, such as receipts. Only included with `enrich=true`.
attachments (anyOf 1)[]ModelEach itemExpand List a source account's transactions — response body — transactions item attachments array item
attachments (anyOf 2)nullAlternative
cardLastFourDigitsJSONOptional
cardLastFourDigits (anyOf 1)stringAlternativeThe last four digits of the card used for the transaction. Only included with `enrich=true`.
cardLastFourDigits (anyOf 2)nullAlternative
categorizationLinesarrayRequired within parentThe line entries that categorize the transaction: every other line of its journal entry. Empty when the transaction has no journal entry.
categorizationLines[]ModelEach itemExpand Categorize or split transactions — response body — items item categorization Lines item
categorizationMethodJSONOptional
categorizationMethod (anyOf 1)JSONAlternative
categorizationMethod (anyOf 1) (allOf 1)stringAll variants applyKnown values: ai, rules, similarity, transferBetweenAccounts, uncategorized, user
categorizationMethod (anyOf 1) (allOf 2)JSONAll variants applyHow 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)nullAlternative
counterpartyNameJSONOptional
counterpartyName (anyOf 1)stringAlternativeThe name of the transaction's counterparty (who the money went to or came from). Only included with `enrich=true`.
counterpartyName (anyOf 2)nullAlternative
customCategoryIdJSONOptional
customCategoryId (anyOf 1)stringAlternativeThe identifier of the Mercury custom category assigned to the transaction. Only included with `enrich=true`.
customCategoryId (anyOf 2)nullAlternative
customCategoryNameJSONOptional
customCategoryName (anyOf 1)stringAlternativeThe name of the Mercury custom category assigned to the transaction. Only included with `enrich=true`.
customCategoryName (anyOf 2)nullAlternative
datetimeJSONRequired within parent
datetime (allOf 1)stringAll variants applyFormat: yyyy-mm-ddThh:MM:ssZ
datetime (allOf 2)JSONAll variants applyWhen the transaction happened, in UTC.
descriptionstringRequired within parentThe transaction's description, as imported from its source.
Format: size < 513
idstringRequired within parentThe unique identifier of the transaction.
journalEntryIdJSONOptional
journalEntryId (anyOf 1)stringAlternativeThe 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)nullAlternative
ledgerIdJSONOptional
ledgerId (anyOf 1)stringAlternativeThe identifier of the source account's ledger, which the transaction's own line entry posts to.
Format: base58 (max length 22)
ledgerId (anyOf 2)nullAlternative
lineEntryIdJSONOptional
lineEntryId (anyOf 1)stringAlternativeThe 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)nullAlternative
merchantTypeJSONOptional
merchantType (anyOf 1)stringAlternativeThe display name of the merchant type (Mercury category) automatically assigned to the transaction, such as `Software`. Only included with `enrich=true`.
merchantType (anyOf 2)nullAlternative
noteJSONOptional
note (anyOf 1)stringAlternativeThe note on the Mercury transaction. Only included with `enrich=true`.
note (anyOf 2)nullAlternative
personalbooleanRequired within parentWhether the transaction is a personal (non-business) transaction.
postedStatusJSONRequired within parent
postedStatus (allOf 1)stringAll variants applyKnown values: notPosted, posted, deleted
postedStatus (allOf 2)JSONAll variants applyWhether the transaction has been posted to the general ledger as a journal entry (`posted`), not yet (`notPosted`), or was posted and then deleted (`deleted`).
reviewStatusJSONRequired within parent
reviewStatus (allOf 1)stringAll variants applyKnown values: reviewed, unreviewed
reviewStatus (allOf 2)JSONAll variants applyWhether the transaction's categorization has been reviewed.
sourceAccountIdstringRequired within parentThe identifier of the source account the transaction belongs to.
Format: base58 (max length 22)
teamMemberIdJSONOptional
teamMemberId (anyOf 1)stringAlternativeThe identifier of the team member associated with the transaction, such as the cardholder. Only included with `enrich=true`.
teamMemberId (anyOf 2)nullAlternative
teamMemberNameJSONOptional
teamMemberName (anyOf 1)stringAlternativeThe full name of the team member associated with the transaction. Only included with `enrich=true`.
teamMemberName (anyOf 2)nullAlternative
transactionMethodKindJSONOptional
transactionMethodKind (anyOf 1)JSONAlternative
transactionMethodKind (anyOf 1) (allOf 1)ModelAll variants applyExpand List a source account's transactions — response body — transactions item transaction Method Kind string string
transactionMethodKind (anyOf 1) (allOf 2)JSONAll variants applyThe kind of Mercury transaction, such as a card payment or a wire. Only included with `enrich=true`.
transactionMethodKind (anyOf 2)nullAlternative

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
FieldTypePresenceDescription and constraints
$JSONRoot
$ (anyOf 1)numberAlternativeA dollar amount
Format: double
$ (anyOf 2)stringAlternativePattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$
List a source account's transactions — response body — transactions item attachments array item
FieldTypePresenceDescription and constraints
$objectRootA file attached to the Mercury banking transaction behind a Books transaction.
downloadUrlstringRequired within parentA presigned URL for downloading the attachment, valid for 1 hour.
fileNamestringRequired within parentThe file name of the attachment.
idstringRequired within parentThe unique identifier of the attachment.

SDK function policy ID: mercury.getbookstransactions. Catalog operation: mercury:getBooksTransactions. 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.