PayclaveDocs

Payclave developers

Invoices

Draft, issue, send, remind, collect, and close itemized invoices.

Draft, review, and issue

Create an itemized draft with customer details and line items. Calculate the applicable tax in your application and supply the tax amounts. Review the totals, settlement destination, due date, and customer email before issuing the current version. An amount-only legacy request creates a payable invoice directly instead of an editable itemized draft.

A draft has a version. PATCH replaces the complete editable configuration, so omitted fields may be cleared. Re-read after INVOICE_VERSION_CONFLICT and merge the intended edit with the latest draft. Issued commercial fields are fixed.

bash
curl https://api.payclave.com/v1/invoices \  -H "Authorization: Bearer sk_test_..." \  -H "Content-Type: application/json" \  -H "Idempotency-Key: invoice_8431" \  -d '{    "customer": { "name": "Ada Lovelace", "email": "ada@example.com" },    "lines": [{      "description": "Implementation",      "quantity": "2.5",      "unitAmount": "10.00"    }],    "externalReference": "invoice_8431",    "metadata": { "plan": "pro" }  }'

Issue and send the invoice

Issue the current draft version to obtain its invoice number and hosted payment information. send:true also queues email to the supplied valid customer address. An email delivery is separate from payment confirmation. Keep the hostedInvoiceUrl from the response instead of constructing it from an internal ID.

bash
# Replace the id and version with the values in your draft response.curl https://api.payclave.com/v1/invoices/inv_example/issue \  -H "Authorization: Bearer sk_test_..." \  -H "Content-Type: application/json" \  -H "Idempotency-Key: issue_invoice_8431" \  -d '{ "version": 1, "send": true }'

Due dates, reminders, and remaining payments

The commercial due date and a checkout session's expiry are different. Read the invoice to find the current collectible remainder. A recovery checkout may reuse an active session and always uses the server-calculated remaining amount. Do not charge the original total again after a partial payment.

Reminder schedules need dueAt and can specify offsets before, on, and after the due date. Email operations have eligibility and cooldown rules. Inspect delivery records when an email fails rather than recreating the invoice.

Close collection without rewriting payment history

Void closes an unpaid invoice. Use void-remaining for an invoice with partial verified credit. Mark-uncollectible records the decision to stop collection. These actions do not reverse onchain transfers or send refunds.

Use the PDF endpoint for an authorized customer download; it returns PDF bytes rather than a JSON response. Use duplicate to create a new draft when commercial terms need to change, and issue that copy separately.

Itemized invoice fields

FieldContract
walletIdOptional explicit active settlement wallet belonging to this merchant and key mode. Omit to use the default. Issued invoices freeze the wallet, token, and chain snapshot.
linesRequired array of 1-100 items. Each item has description (1-500 UTF-8 bytes), quantity (positive decimal string), unitAmount (non-negative decimal string), and optional id and sku (up to 100 UTF-8 bytes). Numeric strings accept at most 6 fractional digits.
customerObject with optional name, email, company and billingAddress (string). A valid email is required to send or remind by email. Name and company are at most 200 UTF-8 bytes, email 320, billingAddress 1000 UTF-8 bytes.
discountOptional { type: 'fixed', amount } or { type: 'percentage', percentage }. Percentage is a decimal string between 0 and 100; discount cannot exceed subtotal. Use null to clear on draft replacement.
taxesOptional array of up to 100 lines with label, amount (non-negative decimal string), and optional id, jurisdiction, registrationReference. label is required and limited to 120 UTF-8 bytes; jurisdiction and registrationReference have the same limit. Supply calculated tax amounts; Payclave does not calculate jurisdictional tax rates.
currencyCodeOptional USDC or USDT, defaulting to the mode's settlement token. A different configured token returns CURRENCY_MISMATCH.
dueAtOptional RFC 3339 timestamp or null. The invoice due date is separate from each checkout session's expiry.
checkoutExpiresInMinutesOptional integer from 5 to 1440, default 30. This is named differently from expiresInMinutes on direct checkout creation.
paymentTerms, memo, footer, purchaseOrderNumberOptional strings limited to 4000, 2000, 2000 and 100 UTF-8 bytes respectively.
externalReference, metadataOptional externalReference up to 255 UTF-8 bytes. metadata is a JSON object up to 16 KiB. Do not store secrets in metadata.
successUrl, cancelUrlOptional absolute HTTP or HTTPS return URLs without credentials, at most 2048 UTF-8 bytes each. Use HTTPS URLs you control. A return to successUrl is not proof of payment.
reminderScheduleOptional object: enabled, daysBeforeDue, onDue, daysAfterDue. daysBeforeDue and daysAfterDue are arrays of integer offsets from 1 to 30, with at most six entries combined. Enabled schedules require dueAt. With no timings specified, defaults are 3 days before, on the due date and 7 days after.
issue, sendHTTP creation only: issue:true immediately issues the draft; send:true sends when issuing. With the server SDK 0.2.0, call createInvoiceDraft and then issueInvoice with send:true.

On this page