Skip to navigation

Increase Customer Credit Balance

View as Markdown

Add a stated amount of credit to a customer’s balance and return the ledger entry recording it, plus balance_after_atom — the balance the write left behind, read in the same transaction.

Say how much to add, not what the balance should end up as. A delta means the same thing no matter what else moved the balance in the meantime — for example credit applied to an invoice that finalized between your read and your call.

No invoice is created. The increase is a ledger entry only: nothing appears in the customer’s invoice list and no invoice.* webhook is sent. It appears in GET /customers/{customer_id}/credit-notes with type: issued and a null invoice_id.

Expiring credit. Send expires_at (a future, timezone-aware timestamp) for a promotional grant that should lapse; omit it for credit that never expires. A past date is rejected with 422.

Optional precondition. Send expected_balance_atom with the balance you based the decision on and the increase is refused with 409 credit_balance_precondition_failed if it no longer matches. The body carries current_balance_atom so you can decide again without another read. An increase cannot overdraw, so this is the only business refusal.

Idempotency: send a stable Idempotency-Key header of at least 8 characters (shorter is rejected with 422). It behaves exactly as on POST /customers/{customer_id}/credit-balance/reduce: a duplicate still in flight is refused with 409, a completed request is replayed rather than run again, the replay record is written in the same transaction as the ledger entry, and the replay scope is (key, account, customer) — the same key sent for two different customers is two increases, one each. Replay is guaranteed for 24 hours. Never reuse a key for a genuinely new increase.

On an ambiguous response without an idempotency key, do not blind-retry. Read GET /customers/{customer_id}/credit-notes to see whether the entry landed.

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.
amount_atomintegerRequired

How much credit to add, in the smallest currency unit. Always positive — this endpoint only increases. To remove credit use POST /customers/{customer_id}/credit-balance/reduce.

currencyenumRequired

Currency of the balance to increase. Balances are tracked per currency; this increases only the named one.

reasonenumRequired

Machine-readable reason, stored on the ledger entry. Use manual_adjustment for a goodwill or promotional grant.

Allowed values:
memostring or nullOptional<=500 characters

Optional human-readable note, shown to the merchant in the credit history. A good place for the campaign or ticket this grant is for.

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. Omit for credit that never expires. Accepted only where the credit-expiry feature is enabled; otherwise 422.

expected_balance_atominteger or nullOptional

Optional optimistic-concurrency check. When set, the increase is applied only if the customer’s balance in this currency still reads as exactly this amount; otherwise the request is rejected with 409 and nothing is written. This is a check at read time, not a lock: it closes the gap between when you read the balance and when you call, but a change landing during the call itself is not excluded.

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
balance_after_atominteger
The customer's balance in this currency immediately after the increase was written, read from the ledger in the same transaction. Like every balance here it is the figure at that moment, not a lock on it.
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.

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

404
Not Found Error
409
Conflict Error
422
Unprocessable Entity Error