Skip to navigation

Create Customer Credit Note

View as Markdown

Create a granular credit note for a customer with explicit reason, memo, amount, currency, and optional invoice association. Issues the ledger entry, creates a companion credit-note invoice, and refreshes the credit-balance cache.

This endpoint only ADDS credit — it cannot reduce a balance. amount_atom must be greater than zero, so a negative amount is rejected with 422 rather than posting a debit. To take credit off a balance use POST /customers/{customer_id}/credit-balance/reduce, which adds the balance precondition and overdraw refusal this endpoint has no need for.

Idempotency: like every other POST/PUT under /api/{account_id}/..., this endpoint is idempotent via the standard Idempotency-Key header. Clients that may retry (network blips, ambiguous responses) MUST send a stable Idempotency-Key of at least 8 characters; the response is replayed for the same (key, account, endpoint) for 24 hours — do not rely on it beyond that, and never reuse a key for a new credit note. The customer id is not part of the replay scope, so a key reused across two customers replays the first customer’s note for the second: key per customer. Without the header there is no dedup — a double-submit will issue two credit notes.

Authentication

AuthorizationBearer

Bearer authentication of the form Bearer <token>, where token is your auth token.

Path parameters

customer_idstringRequired
account_idstringRequired

Headers

Idempotency-Keystring or nullOptional>=8 characters
A unique key for this request. A retry with the same key returns the first response instead of running again, for 24 hours. Keys are per caller.

Request

This endpoint expects an object.
reasonenumRequired

Machine-readable reason. PaymentKit writes auto_apply, debit_settlement, void_reversal and credit_expired itself for ledger bookkeeping, and expiry_clawback describes credit being reclaimed rather than issued; none of the five can be set here.

Allowed values:
amount_atomintegerRequired<=9007199254740991

Credit amount in smallest currency unit (positive)

currencyenumRequired

3-letter currency code

memostring or nullOptional<=500 characters

Optional human-readable note

invoice_idstring or nullOptional
Optional ID of the invoice this credit note is associated with.
expires_atdatetime or nullOptional

Optional. When this credit stops being spendable. Must be a timezone-aware timestamp in the future. From that instant the credit is excluded from invoice application, and PaymentKit reclaims whatever is still unused, writing a credit_expired ledger entry and emitting a credit_note.expired event, which you can subscribe to directly as credit_note.expired or through the credit_note.* prefix. Omit for credit that never expires — the default, and unchanged behaviour. Accepted only where the credit-expiry feature is enabled; otherwise 422.

Response

Successful Response
idstring
ID of the credit note
customer_idstring
ID of the customer
amount_atominteger

Positive = issued, negative = applied/voided

currencyenum
ISO 4217 currency codes.
typeenum
Transaction type
Allowed values:
reasonstring

Machine-readable reason

created_atdatetime
updated_atdatetime
invoice_idstring or nullOptional
ID of the related invoice
memostring or nullOptional

Human-readable note

expires_atdatetime or nullOptional

When this credit stops being spendable. Null = never.

expired_atdatetime or nullOptional

When PaymentKit reclaimed the unused remainder of this credit. Null = not (yet) expired. Only ever set on entries that carry an expires_at.

remaining_atominteger or nullOptional

How much of this credit is still unused, in the smallest currency unit. Reported only for entries whose consumption has been tracked from the moment they were issued (every entry with an expires_at, and every entry issued after the customer first held expiring credit in that currency), excluding debit settlements. Null otherwise. Credit past its expires_at is no longer applicable even while this still reports a value; it becomes 0 once PaymentKit closes the entry out, whatever the reclaim was able to take.

metamap from strings to any or nullOptional

Context PaymentKit attached when it wrote this entry itself; you cannot set it. Null on most entries. Known keys: refund_id (the refund behind a refund_reversal), restored_from_credit_note (the expiring grant a void_reversal or refund_reversal puts credit back on), expired_credit_note (the grant a credit_expired entry closed out). Treat the set of keys as open. Who made a manual entry is reported as created_by, not here.

entry_numberinteger or nullOptional

This entry’s place in the customer’s credit history, 1 being the oldest (all currencies), in the order the entries were created. An entry whose write started earlier but committed later moves the numbers after it. Set on the customer’s credit-notes list; null elsewhere.

balance_after_atominteger or nullOptional

The customer’s balance in this currency right after this entry, in the smallest currency unit: the running sum of the credit history, oldest first (so it moves with entry_number). Negative is a debit balance. Set on the customer’s credit-notes list and on the credit-balance/reduce response; null elsewhere (for example, the POST credit-notes response).

created_bystring or nullOptional

Who made this entry, as a display label, not an identifier: the dashboard user’s current email (else their name, or their user id if the user was deleted), or ‘API key “<description>”’ (‘API key’ when it has none). Null for an entry PaymentKit wrote itself (applying credit to an invoice, an expiry) and for an entry made before this was recorded. Filled on the customer’s credit-notes list; other responses may leave it null (the credit-balance reduce response fills it). Do not parse it.

Errors

422
Unprocessable Entity Error