The Mercury Invoices API — accounts-receivable invoices.
Summary
Functions
Cancels an invoice. This action is irreversible. POST /invoices/{id}/cancel
Creates a new invoice. attrs accepts snake_case keys, e.g.
Downloads an invoice as a PDF, returning the raw bytes. GET /invoices/{id}/pdf
Returns a single invoice by ID. GET /invoices/{id}
Returns one page of invoices. GET /invoices
Returns every attachment on an invoice. GET /invoices/{id}/attachments
A lazy, auto-paginating stream of every invoice.
Updates an existing invoice. PUT /invoices/{id}
Functions
@spec cancel(client :: Mercury.Client.t(), invoice_id :: String.t()) :: {:ok, Mercury.Invoice.t()} | {:error, Exception.t()}
Cancels an invoice. This action is irreversible. POST /invoices/{id}/cancel
@spec cancel!(client :: Mercury.Client.t(), invoice_id :: String.t()) :: Mercury.Invoice.t()
@spec create(client :: Mercury.Client.t(), attrs :: map() | keyword()) :: {:ok, Mercury.Invoice.t()} | {:error, Exception.t()}
Creates a new invoice. attrs accepts snake_case keys, e.g.:
Mercury.Invoices.create(client, %{
amount: 500.0,
recipient_id: recipient_id,
due_date: "2026-08-01",
line_items: [%{description: "Consulting", quantity: 5, unit_price: 100.0}]
})POST /invoices
@spec create!(client :: Mercury.Client.t(), attrs :: map() | keyword()) :: Mercury.Invoice.t()
@spec download_pdf(client :: Mercury.Client.t(), invoice_id :: String.t()) :: {:ok, binary()} | {:error, Exception.t()}
Downloads an invoice as a PDF, returning the raw bytes. GET /invoices/{id}/pdf
@spec download_pdf!(client :: Mercury.Client.t(), invoice_id :: String.t()) :: binary()
@spec get(client :: Mercury.Client.t(), invoice_id :: String.t()) :: {:ok, Mercury.Invoice.t()} | {:error, Exception.t()}
Returns a single invoice by ID. GET /invoices/{id}
@spec get!(client :: Mercury.Client.t(), invoice_id :: String.t()) :: Mercury.Invoice.t()
@spec list(client :: Mercury.Client.t(), opts :: keyword()) :: {:ok, Mercury.Page.t(Mercury.Invoice.t())} | {:error, Exception.t()}
Returns one page of invoices. GET /invoices
@spec list!(client :: Mercury.Client.t(), opts :: keyword()) :: Mercury.Page.t(Mercury.Invoice.t())
@spec list_attachments(client :: Mercury.Client.t(), invoice_id :: String.t()) :: {:ok, [Mercury.InvoiceAttachment.t()]} | {:error, Exception.t()}
Returns every attachment on an invoice. GET /invoices/{id}/attachments
@spec list_attachments!(client :: Mercury.Client.t(), invoice_id :: String.t()) :: [ Mercury.InvoiceAttachment.t() ]
@spec stream(client :: Mercury.Client.t(), opts :: keyword()) :: Enumerable.t()
A lazy, auto-paginating stream of every invoice.
@spec update( client :: Mercury.Client.t(), invoice_id :: String.t(), attrs :: map() | keyword() ) :: {:ok, Mercury.Invoice.t()} | {:error, Exception.t()}
Updates an existing invoice. PUT /invoices/{id}
@spec update!( client :: Mercury.Client.t(), invoice_id :: String.t(), attrs :: map() | keyword() ) :: Mercury.Invoice.t()