Skip to content

Mercury: Categorize or split transactions

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

← Books operations · Get started

Operation mercury.categorizebookstransactions

Provider route: POST /books/transactions/categorize. 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"]["categorizeBooksTransactions"]>[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.categorizeBooksTransactions(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.categorize_books_transactions(arguments)
result = await call.wait()
return result.body_json()
FieldTypePresenceDescription and constraints
$objectRootAdditional keys: not allowed
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 Categorize or split transactions — request body — body

Referenced models: Categorize or split transactions — 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 Categorize or split transactions — response body

Referenced models: Categorize or split transactions — response body

Categorize or split transactions — response body
FieldTypePresenceDescription and constraints
$objectRootThe categorized transactions, in request order.
itemsarrayRequired within parentOne per request item, in request order.
items[]ModelEach itemExpand Categorize or split transactions — response body — items item

Referenced models: Categorize or split transactions — response body — items item

Categorize or split transactions — request body — body
FieldTypePresenceDescription and constraints
$objectRootRequest to categorize or split one or more transactions, all or nothing.
Additional keys: not allowed
itemsarrayRequired within parentThe transactions to categorize, from 1 to 100, each at most once. Across all items, the splits may name at most 100 distinct ledgers.
items[]ModelEach itemExpand Categorize or split transactions — request body — body items item

Referenced models: Categorize or split transactions — request body — body items item

Categorize or split transactions — response body — items item
FieldTypePresenceDescription and constraints
$objectRootA transaction's categorization after the request.
categorizationLinesarrayRequired within parentThe transaction's categorization lines, as the transaction's `categorizationLines` now list them.
categorizationLines[]ModelEach itemExpand Categorize or split transactions — response body — items item categorization Lines item
journalEntryIdstringRequired within parentThe `journalEntryId` of the transaction.
Format: base58 (max length 22)

Referenced models: Categorize or split transactions — response body — items item categorization Lines item

Categorize or split transactions — request body — body items item
FieldTypePresenceDescription and constraints
$objectRootThe new categorization of one transaction.
Additional keys: not allowed
journalEntryIdstringRequired within parentThe `journalEntryId` of the transaction to categorize.
Format: base58 (max length 22)
splitsarrayRequired within parentThe new categorization: one split per category. The splits replace every current categorization line.
Minimum items: 1
splits[]ModelEach itemExpand Categorize or split transactions — request body — body items item splits item

Referenced models: Categorize or split transactions — request body — body items item splits item

Categorize or split transactions — response body — items item categorization Lines item
FieldTypePresenceDescription and constraints
$objectRootA line of a transaction's journal entry other than its own line on the
source account's ledger. Its ledger is the transaction's category; a split
transaction has one line per category.
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, in dollars; `debitCredit` gives its direction.
debitCreditJSONRequired within parent
debitCredit (allOf 1)stringAll variants applyKnown values: debit, credit
debitCredit (allOf 2)JSONAll variants applyWhether the amount is a debit or a credit to the ledger.
ledgerIdstringRequired within parentThe identifier of the ledger (general ledger account) the line posts to, i.e. the category.
Format: base58 (max length 22)
ledgerNamestringRequired within parentThe display name of the ledger the line posts to.
lineEntryIdstringRequired within parentThe identifier of the categorization line entry.
Format: base58 (max length 22)

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

Categorize or split transactions — request body — body items item splits item
FieldTypePresenceDescription and constraints
$objectRootOne category of a transaction and the part of its amount that goes to it.
Additional keys: not allowed
amountJSONRequired within parent
amount (allOf 1)numberAll variants applyA dollar amount
Format: double
amount (allOf 2)JSONAll variants applyThe signed, nonzero part of the transaction's amount: a number of dollars with at most two decimal places, with the same sign convention as the transaction's `amount`. The splits of a transaction must add up to exactly its `amount`. A split with the opposite sign to the transaction, such as a refund netted against a purchase, posts on the other side.
descriptionJSONOptional
description (anyOf 1)stringAlternativeThe description of the categorization line. Omit to keep the description of the line it replaces, or for a new line, to use the transaction's description.
Format: size < 4001
description (anyOf 2)nullAlternative
ledgerIdstringRequired within parentThe ledger (general ledger account) to categorize this part of the transaction to, such as an expense or revenue account. It must be editable, and must not be an uncategorized ledger or a source account's ledger.
Format: base58 (max length 22)
tagIdsJSONOptional
tagIds (anyOf 1)arrayAlternativeThe tags of the categorization line. Omit to keep the tags of the line it replaces; a new line then has no tags.
tagIds (anyOf 1)[]stringEach itemunique id for a tag; emitted as base-58, but a base-16 UUID is also accepted
Format: base58 (max length 22)
tagIds (anyOf 2)nullAlternative
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.categorizebookstransactions. Catalog operation: mercury:categorizeBooksTransactions. 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.