Draft a full or partial credit note
draft_credit_noteDraft a type-381 credit note from an existing invoice, for all lines or selected quantities.
Use to reverse an existing invoice's charges; use get_invoice_example for a synthetic credit-note example.
invoice must be the original generate_invoice input object, not extract_invoice output.
number and issue_date belong to the new credit note; the original number/date are copied into
preceding_invoices. Give number a distinct value and use YYYY-MM-DD dates. due_date replaces the
original deadline; omitting it removes that deadline rather than inheriting it.
Omit credit_lines to retain all original lines and amounts. Otherwise select distinct 1-based array
positions, not line ids: [{"line_index":1,"quantity":"2"}] credits two units of the first line.
Omitted lines are excluded; quantities cannot exceed the original. Prices and VAT rates are retained.
Selected-line mode clears original totals, prepayments, rounding and paid status for recalculation.
Document allowances/charges, or reduced quantities on adjusted lines or overridden net amounts,
need explicit allocation: these cases return an error; prepare a credit body for generate_invoice.
No prior-credit history is stored: the caller must prevent cumulative credits beyond the original.
Keep amounts positive: type 381 expresses the credit. Existing credit notes, a reused invoice number
or negative line amounts produce a tool error. Default payment remittance references follow the
new number; a custom reference is preserved. Returns invoice, type_code, preceding_invoice and next.
Pass the returned invoice to generate_invoice with the original profile to create the document.
No key or document quota is needed for drafting; nothing is stored, sent or refunded.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| number | Yes | Credit note number, different from the invoice number. Max 35 characters: letters, digits, and . _ / -. | |
| invoice | Yes | The original invoice object you passed to generate_invoice. Not an extract_invoice result. | |
| due_date | No | Optional due date. Omit it to drop the original invoice due date. | |
| issue_date | Yes | Credit note issue date, ISO 8601 (YYYY-MM-DD). | |
| credit_lines | No | Selected original line positions and quantities. Omit for a full credit; an empty list is invalid. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||