Skip to content

Mercury: Create a bill (accounts payable)

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

← Books operations · Get started

Operation mercury.createbooksbill

Provider route: POST /books/bills. 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"]["createBooksBill"]>[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.createBooksBill(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_bill(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. Required for agent organization tokens; defaults to the token organization’s instance.
Format: uuid
headersobjectOptionalAdditional keys: not allowed
headers.Idempotency-KeystringOptional
bodyModelOptionalExpand Create a bill (accounts payable) — request body — body

Referenced models: Create a bill (accounts payable) — 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 Edit a bill (accounts payable) — response body

Referenced models: Edit a bill (accounts payable) — response body

1 more schema is linked from the tables above, on the schema pages.

Edit a bill (accounts payable) — response body
FieldTypePresenceDescription and constraints
$objectRootA bill (accounts payable) recorded in Books, with its lines and the
payments applied to it.
amountRemainingJSONRequired within parent
amountRemaining (allOf 1)ModelAll variants applyExpand Create a product — response body — unit Price value
amountRemaining (allOf 2)JSONAll variants applyThe amount still owed after applied payments, 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 as shown to users, derived from `status`, the due date, and payments: also `overdue` (open and past due) and `partiallyPaid` (open with some payment applied).
dueDateJSONOptional
dueDate (anyOf 1)JSONAlternative
dueDate (anyOf 1) (allOf 1)stringAll variants applyFormat: date
dueDate (anyOf 1) (allOf 2)JSONAll variants applyThe due date. Omitted when none is set.
dueDate (anyOf 2)nullAlternative
effectiveDateJSONRequired within parent
effectiveDate (allOf 1)stringAll variants applyFormat: date
effectiveDate (allOf 2)JSONAll variants applyThe bill date.
grossAmountJSONRequired within parent
grossAmount (allOf 1)ModelAll variants applyExpand Create a product — response body — unit Price value
grossAmount (allOf 2)JSONAll variants applyThe total of all lines, in dollars.
idstringRequired within parentThe identifier of the bill.
Format: base58 (max length 22)
linesarrayRequired within parentThe line items.
lines[]ModelEach itemExpand Edit a bill (accounts payable) — response body — lines item
notesJSONOptional
notes (anyOf 1)stringAlternativeThe bill's notes or memo. Omitted when it has none.
notes (anyOf 2)nullAlternative
paymentApplicationsarrayRequired within parentThe payments applied. Empty when none.
paymentApplications[]ModelEach itemExpand Edit a bill (accounts payable) — response body — payment Applications item
referenceNumberJSONOptional
referenceNumber (anyOf 1)stringAlternativeThe bill number. Omitted when it has none.
referenceNumber (anyOf 2)nullAlternative
statusJSONRequired within parent
status (allOf 1)stringAll variants applyKnown values: open, paid, draft, cancelled, processing
status (allOf 2)JSONAll variants applyThe stored lifecycle status: `draft`, `open`, `processing`, `paid`, or `cancelled`.
vendorJSONOptional
vendor (anyOf 1)JSONAlternative
vendor (anyOf 1) (allOf 1)ModelAll variants applyExpand Edit a bill (accounts payable) — response body — vendor id, name id, name
vendor (anyOf 1) (allOf 2)JSONAll variants applyThe vendor the bill is owed to. Omitted when the bill has no vendor.
vendor (anyOf 2)nullAlternative

Referenced models: Create a product — response body — unit Price value, Edit a bill (accounts payable) — response body — lines item, Edit a bill (accounts payable) — response body — payment Applications item, Edit a bill (accounts payable) — response body — vendor id, name id, name

Create a bill (accounts payable) — request body — body
FieldTypePresenceDescription and constraints
$objectRootA request to create a single bill (accounts payable).
Additional keys: not allowed
dueDateJSONRequired within parent
dueDate (allOf 1)stringAll variants applyFormat: date
dueDate (allOf 2)JSONAll variants applyDate the bill is due.
effectiveDateJSONRequired within parent
effectiveDate (allOf 1)stringAll variants applyFormat: date
effectiveDate (allOf 2)JSONAll variants applyEffective date of the bill (e.g. the bill date).
linesarrayRequired within parentLine items for the bill. At least one is required.
Minimum items: 1
lines[]ModelEach itemExpand Create a bill (accounts payable) — request body — body lines item
notesJSONOptional
notes (anyOf 1)stringAlternativeOptional notes or memo for the bill.
notes (anyOf 2)nullAlternative
referenceNumberstringOptionalHuman-readable reference number (e.g. the vendor's bill number). Optional;
an omitted, null, empty, or whitespace-only value is treated as absent, and
leading and trailing whitespace is stripped.
Maximum length: 299
vendorJSONRequired within parent
vendor (allOf 1)ModelAll variants applyExpand Create a bill (accounts payable) — request body — body vendor value
vendor (allOf 2)JSONAll variants applyThe vendor the bill is owed to.

Referenced models: Create a bill (accounts payable) — request body — body lines item, Create a bill (accounts payable) — request body — body vendor value

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]+)?$
Edit a bill (accounts payable) — response body — lines item
FieldTypePresenceDescription and constraints
$objectRootA line item of a bill.
amountJSONRequired within parent
amount (allOf 1)ModelAll variants applyExpand Create a product — response body — unit Price value
amount (allOf 2)JSONAll variants applyThe line's amount, in dollars.
descriptionstringRequired within parentThe line's description.
idstringRequired within parentThe identifier of the line.
Format: base58 (max length 22)
ledgerIdstringRequired within parentThe identifier of the ledger (general ledger account) the line posts to, such as an expense ledger.
Format: base58 (max length 22)

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

Edit a bill (accounts payable) — response body — payment Applications item
FieldTypePresenceDescription and constraints
$objectRootA payment applied to a bill: part or all of a journal entry line entry,
such as a bank transaction's, matched against it.
amountJSONRequired within parent
amount (allOf 1)ModelAll variants applyExpand Create a product — response body — unit Price value
amount (allOf 2)JSONAll variants applyThe amount of the line entry applied to this bill, in dollars.
lineEntryIdstringRequired within parentThe identifier of the line entry applied as payment.
Format: base58 (max length 22)

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

Edit a bill (accounts payable) — response body — vendor id, name id, name
FieldTypePresenceDescription and constraints
$objectRootThe vendor a bill is owed to. The id is the Books counterparty id (never a
Bill Pay recipient id); the name is inlined because there is no public
counterparties endpoint yet, so a bare id would be unusable.
idJSONRequired within parent
id (allOf 1)stringAll variants applyID for this books counterparty
Format: uuid
id (allOf 2)JSONAll variants applyThe Books counterparty ID of the vendor. This is not a recipient ID.
namestringRequired within parentThe vendor's name. When the counterparty is linked to a Bill Pay
recipient, this is the recipient's current name; otherwise it falls back to
the name snapshotted on the Books counterparty.
Create a bill (accounts payable) — request body — body lines item
FieldTypePresenceDescription and constraints
$objectRootA bill line item to create.
Additional keys: not allowed
amountJSONRequired within parent
amount (allOf 1)numberAll variants applyA dollar amount
Format: double
amount (allOf 2)JSONAll variants applyAmount for this line item. May be negative (e.g. a discount line).
Zero-amount lines are ignored; at least one line must be non-zero, and the
combined total of all lines must be greater than zero (enforced by Teal).
descriptionstringRequired within parentDescription of the line item. Required and non-empty; leading and trailing
whitespace is stripped.
Maximum length: 1024
Minimum length: 1
ledgerIdstringRequired within parentThe ledger account (expense account) to book this line against.
Format: base58 (max length 22)

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