Skip to content

Mercury: Edit an invoice (accounts receivable)

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

← Books operations · Get started

Operation mercury.updatebooksinvoice

Provider route: PATCH /books/invoice/{invoiceId}. 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"]["updateBooksInvoice"]>[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.updateBooksInvoice(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.update_books_invoice(arguments)
result = await call.wait()
return result.body_json()
FieldTypePresenceDescription and constraints
$objectRootAdditional keys: not allowed
pathobjectRequired within parentAdditional keys: not allowed
path.invoiceIdstringRequired within parentThe ID of the invoice to edit, as returned by getBooksInvoices or createBooksInvoice.
Format: base58 (max length 22)
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 Edit an invoice (accounts receivable) — request body — body

Referenced models: Edit an invoice (accounts receivable) — 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
$JSONRoot
$ (anyOf 1)ModelAlternativeExpand Edit an invoice (accounts receivable) — response body — amount Remaining, customer, display Status, due Date, effective Date, gross Amount, id, lines, notes, payment Applications, reference Number, status
$ (anyOf 2)ModelAlternativeExpand Edit an invoice (accounts receivable) — response body — id, message, sync Status

Referenced models: Edit an invoice (accounts receivable) — response body — amount Remaining, customer, display Status, due Date, effective Date, gross Amount, id, lines, notes, payment Applications, reference Number, status, Edit an invoice (accounts receivable) — response body — id, message, sync Status

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

Edit an invoice (accounts receivable) — response body — amount Remaining, customer, display Status, due Date, effective Date, gross Amount, id, lines, notes, payment Applications, reference Number, status
FieldTypePresenceDescription and constraints
$objectRootAn invoice (accounts receivable) 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.
customerJSONOptional
customer (anyOf 1)JSONAlternative
customer (anyOf 1) (allOf 1)ModelAll variants applyExpand Create an invoice (accounts receivable) — response body — customer, due Date, effective Date, gross Amount, message, reference Number, sync Status customer id, name
customer (anyOf 1) (allOf 2)JSONAll variants applyThe customer the invoice is billed to. Omitted when the invoice has no customer.
customer (anyOf 2)nullAlternative
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 invoice 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 invoice.
Format: base58 (max length 22)
linesarrayRequired within parentThe line items.
lines[]ModelEach itemExpand Edit an invoice (accounts receivable) — response body — amount Remaining, customer, display Status, due Date, effective Date, gross Amount, id, lines, notes, payment Applications, reference Number, status lines item
notesJSONOptional
notes (anyOf 1)stringAlternativeThe invoice's note, as shown in the Note field of the Books invoice in Mercury. Omitted when it has none.
notes (anyOf 2)nullAlternative
paymentApplicationsarrayRequired within parentThe payments applied. Empty when none.
paymentApplications[]ModelEach itemExpand Edit an invoice (accounts receivable) — response body — amount Remaining, customer, display Status, due Date, effective Date, gross Amount, id, lines, notes, payment Applications, reference Number, status payment Applications item
referenceNumberJSONOptional
referenceNumber (anyOf 1)stringAlternativeThe invoice number, as shown in the Invoice number field of the Books invoice in Mercury (for example `INV-1042`). 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`.

Referenced models: Create a product — response body — unit Price value, Create an invoice (accounts receivable) — response body — customer, due Date, effective Date, gross Amount, message, reference Number, sync Status customer id, name, Edit an invoice (accounts receivable) — response body — amount Remaining, customer, display Status, due Date, effective Date, gross Amount, id, lines, notes, payment Applications, reference Number, status lines item, Edit an invoice (accounts receivable) — response body — amount Remaining, customer, display Status, due Date, effective Date, gross Amount, id, lines, notes, payment Applications, reference Number, status payment Applications item

Edit an invoice (accounts receivable) — response body — id, message, sync Status
FieldTypePresenceDescription and constraints
$objectRootAn edit to an invoice synced with Mercury Invoicing that was saved there
but has not synced to Books yet. Returned with HTTP 202.
idstringRequired within parentThe ID of the edited invoice.
Format: base58 (max length 22)
messagestringRequired within parentWhat happened and when to read the invoice back.
syncStatusJSONRequired within parent
syncStatus (allOf 1)stringAll variants applyKnown values: pending
syncStatus (allOf 2)JSONAll variants applyAlways `pending`. An edit that has synced returns the updated invoice instead.
Edit an invoice (accounts receivable) — request body — body
FieldTypePresenceDescription and constraints
$objectRootA request to edit a single invoice (accounts receivable). Every field is
optional; an omitted field is left unchanged.
Additional keys: not allowed
customerJSONOptional
customer (anyOf 1)JSONAlternative
customer (anyOf 1) (allOf 1)stringAll variants applyThe customer who will receive the invoice. Use the /api/v1/ar/customers endpoint to list your customers and find the corresponding id, or create a new customer first.
Format: uuid
customer (anyOf 1) (allOf 2)JSONAll variants applyThe customer to bill: a Mercury Invoicing customer ID of this organization, from the Mercury Invoicing customers API (`/ar/customers`). An invoice synced with Mercury Invoicing accepts only its current customer.
customer (anyOf 2)nullAlternative
dueDateJSONOptional
dueDate (anyOf 1)JSONAlternative
dueDate (anyOf 1) (allOf 1)stringAll variants applyFormat: date
dueDate (anyOf 1) (allOf 2)JSONAll variants applyA new due date, YYYY-MM-DD.
dueDate (anyOf 2)nullAlternative
effectiveDateJSONOptional
effectiveDate (anyOf 1)JSONAlternative
effectiveDate (anyOf 1) (allOf 1)stringAll variants applyFormat: date
effectiveDate (anyOf 1) (allOf 2)JSONAll variants applyA new invoice date, YYYY-MM-DD.
effectiveDate (anyOf 2)nullAlternative
lineChangesJSONOptional
lineChanges (anyOf 1)JSONAlternative
lineChanges (anyOf 1) (allOf 1)ModelAll variants applyExpand Edit an invoice (accounts receivable) — request body — body line Changes Changes to the invoice's line items create, delete, update
lineChanges (anyOf 1) (allOf 2)JSONAll variants applyChanges to the invoice's line items.
lineChanges (anyOf 2)nullAlternative
notesJSONOptional
notes (anyOf 1)stringAlternativeA new note for the invoice.
notes (anyOf 2)nullAlternative
referenceNumberJSONOptional
referenceNumber (anyOf 1)stringAlternativeA new invoice number, the number the customer sees (for example `INV-1042`). 1 to 299 characters; leading and trailing whitespace is stripped. Clearing it is not supported.
Maximum length: 299
Minimum length: 1
referenceNumber (anyOf 2)nullAlternative

Referenced models: Edit an invoice (accounts receivable) — request body — body line Changes Changes to the invoice's line items create, delete, update

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]+)?$
Create an invoice (accounts receivable) — response body — customer, due Date, effective Date, gross Amount, message, reference Number, sync Status customer id, name
FieldTypePresenceDescription and constraints
$objectRootThe customer an invoice is billed to. The id is a Mercury Invoicing
customer id, the one the Invoicing customers API (`/ar/customers`) returns;
the name is inlined so a caller needs no second lookup.
idJSONRequired within parent
id (allOf 1)stringAll variants applyThe customer who will receive the invoice. Use the /api/v1/ar/customers endpoint to list your customers and find the corresponding id, or create a new customer first.
Format: uuid
id (allOf 2)JSONAll variants applyThe Mercury Invoicing customer ID of the customer.
namestringRequired within parentThe customer's current name in Mercury Invoicing, also for a customer
that has since been deleted there.

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