Wallgent
Guides

Invoices

Create invoices, accept payments via card, ACH, or USDC, and manage recurring billing.

Overview

Invoices let your AI agents bill customers for work completed. The flow is: create an invoice with line items, finalize it to generate a payment link, then the customer pays. Funds settle into the wallet after clearing.

Invoice lifecycle:

DRAFT → FINALIZED → PAID
                  → VOIDED
                  → UNCOLLECTIBLE

Creating Invoices

Create an Invoice

POST /v1/invoices

Request Body

FieldTypeRequiredDescription
walletIdstringYesWallet to receive funds
customerIdstringYesCustomer to bill
lineItemsarrayYesAt least one line item
memostringNoNote to the customer
dueDatestringNoISO 8601 due date
metadataobjectNoCustom key-value data

Line Item Object

FieldTypeRequiredDescription
descriptionstringYesLine item description
quantitynumberNoQuantity (default: 1)
unitPricestringYesPrice per unit
const invoice = await wg.invoices.create({
  walletId: 'wal_01J...',
  customerId: 'cus_01J...',
  lineItems: [
    { description: 'API calls (10,000)', unitPrice: '25.00' },
    { description: 'Data processing', quantity: 3, unitPrice: '15.00' },
  ],
  memo: 'Services for January 2026',
});

List Invoices

GET /v1/invoices?walletId=...&customerId=...&status=...

Filter by wallet, customer, or status (DRAFT, FINALIZED, PAID, VOIDED).

Get Invoice

GET /v1/invoices/:id

Finalize and Pay

Finalize an Invoice

POST /v1/invoices/:id/finalize

Transitions the invoice from DRAFT to FINALIZED. Generates a unique payment slug for the customer.

Get Checkout URL

POST /v1/invoices/:id/checkout

Returns a Stripe Checkout URL for card payments.

USDC Payment

POST /v1/invoices/pay/:slug/usdc

Returns a USDC deposit address for crypto payments. Public endpoint (no auth).


Auto-Charge

Skip the invoice flow and charge a customer's saved payment method directly.

POST /v1/invoices/charge

Request Body

FieldTypeRequiredDescription
walletIdstringYesWallet to receive funds
customerIdstringYesCustomer to charge
amountstringYesAmount to charge
descriptionstringYesCharge description
paymentMethodIdstringNoSpecific payment method (uses default if omitted)
recurringobjectNoSet up recurring charges

Recurring Object

FieldTypeRequiredDescription
intervalstringYesweekly, monthly, quarterly, yearly
endAtstringNoISO 8601 end date
await wg.invoices.charge({
  walletId: 'wal_01J...',
  customerId: 'cus_01J...',
  amount: '99.00',
  description: 'Monthly subscription',
  recurring: { interval: 'monthly' },
});

Void and Refund

Void an Invoice

POST /v1/invoices/:id/void

Cancels a FINALIZED invoice that has not been paid.

Refund an Invoice

POST /v1/invoices/:id/refund

Refunds a PAID invoice. Returns funds to the customer and debits your wallet.


Fee Breakdown

Fees depend on the payment method used:

MethodProvider FeeWallgent Fee
Card2.9% + $0.300.5%
ACH0.8% (max $5.00)0.25%
USDC$0.50 flat0.5%
WalletFree0.25%

Public Payment Routes

These routes require no authentication and are used by the customer paying the invoice.

RouteDescription
GET /v1/invoices/pay/:slugGet invoice details by slug
POST /v1/invoices/pay/:slug/checkoutGet Stripe Checkout URL
POST /v1/invoices/pay/:slug/usdcGet USDC payment address

Webhook Events

EventDescription
invoice.createdInvoice was created
invoice.finalizedInvoice was finalized and ready for payment
invoice.paidInvoice was paid successfully
invoice.payment_failedPayment attempt failed
invoice.voidedInvoice was voided
invoice.refundedInvoice was refunded
invoice.uncollectibleInvoice marked as uncollectible after retry failures
invoice.usdc_unmatchedUSDC payment received but couldn't be matched to an invoice

MCP Tools

ToolDescription
wallgent_create_invoiceCreate an invoice with line items
wallgent_list_invoicesList invoices with optional filters
wallgent_finalize_invoiceFinalize a draft invoice
wallgent_charge_customerAuto-charge a customer's saved payment method
wallgent_void_invoiceVoid an unpaid invoice
wallgent_refund_invoiceRefund a paid invoice

Permissions

PermissionRequired For
invoices:writeCreate, finalize, void, refund, charge
invoices:readList and get invoices

On this page