Account Credit
Carry a credit balance on a customer account, grant or withdraw it as dated and attributed movements, and expose the balance to the buyer.
Introduction
Account credit is a credit balance carried by a customer account. It lets an operator grant a commercial gesture — a goodwill credit, a compensation for a late delivery, a negotiated discount — directly on the platform instead of settling it off-platform on the next invoice.
Every variation of the balance is recorded as a movement: dated, attributed to its author, carrying its reason and the resulting balance. Nothing is ever edited or deleted, so the history stays auditable.
This page covers the administration APIs that read, open and move an account credit, and the StoreFront API that exposes the balance to the buyer.
Note: Account credit is governed by a tenant-level activation setting, inactive by default. As long as it is not enabled, every account credit endpoint is refused with a403(F-E-038) and no existing behaviour changes. Contact your DJUST contact to have it enabled on your tenant.
Key concepts
| Concept | Description |
|---|---|
| Account credit | A balance carried by one customer account in one currency. A customer account has at most one account credit per currency, and may carry several in parallel, each independent of the others. |
| Shared balance | The balance belongs to the customer account, not to one of its buyers. It is the same for every customer user attached to the account: the credit is granted to the client company. |
| Movement | A single variation of the balance. Its amount is always positive; the direction carries the sign. |
| Direction | CREDIT adds the amount to the balance, DEBIT withdraws it. |
| Nature | The origin of the movement: OPERATOR_GESTURE (recorded by an operator), ORDER_PAYMENT (charged when paying an order), RECREDIT (given back after a failed payment or a refund). |
| Author | Who produced the movement, frozen at the time it was recorded: OPERATOR with the operator's full name, or LOGISTIC_ORDER with the order reference. The label is never re-resolved at read time, so it stays readable even after the operator leaves. |
| Reference | A readable identifier of the form AC-0000123, unique on the tenant, assigned when the movement is recorded and never reused. Use it to quote a precise movement and reconcile it with the transaction that produced it. |
| Resulting balance | Each movement carries balanceAfter, the balance right after it was applied. |
Structural rules
- The balance can never become negative. A debit larger than the balance is refused and nothing is recorded.
- A movement is immutable: a mistake is corrected by a movement in the opposite direction, not by editing or deleting.
- A movement amount must be strictly positive and carry at most the number of decimals of its currency (2 for EUR, 0 for JPY).
- Deleting a customer account is refused while it carries a non-zero balance in any currency — through the API as well as through an import. Bring the balance back to zero with a debit movement first.
- Reading and writing are governed by two distinct rights:
ACCOUNT_CREDIT_READandACCOUNT_CREDIT_WRITE.
Typical workflow
flowchart LR
%% Styles (Readme)
classDef create fill:#e8f1ff,stroke:#2f6feb,stroke-width:2px,color:#0b3d91;
classDef read fill:#ede9fe,stroke:#7c3aed,stroke-width:2px,color:#1e1b4b;
classDef add fill:#ecfdf5,stroke:#10b981,stroke-width:2px,color:#064e3b;
classDef remove fill:#fee2e2,stroke:#ef4444,stroke-width:2px,color:#7f1d1d;
classDef decision fill:#fff4e5,stroke:#f59e0b,stroke-width:2px,color:#7a3e00;
classDef place fill:#dcfce7,stroke:#16a34a,stroke-width:2px,color:#14532d;
A[📘 Read the balances<br>ADM-ACCOUNT-553] --> B{Balance exists<br>in this currency}
B -->|No| C[🆕 Open the account credit<br>ADM-ACCOUNT-104]
B -->|Yes| D[➕ Record a movement<br>ADM-ACCOUNT-103]
C --> D
D --> E{Direction}
E -->|CREDIT| F[➕ Balance increased]
E -->|DEBIT| G[➖ Balance decreased]
F --> H[🧾 Read the history<br>ADM-ACCOUNT-554]
G --> H
H --> I[✅ Buyer sees the balance<br>ACCOUNT-507]
style A rx:8,ry:8
style I rx:8,ry:8
class A,H read
class C create
class D,F add
class G remove
class B,E decision
class I place
Step by step
- Read the balances of the customer account —
ADM-ACCOUNT-553returns one entry per currency in which an account credit has been opened, sorted by currency. A currency that was never opened is absent: its balance is zero. - Open the account credit in the currency, if needed —
ADM-ACCOUNT-104creates it with a zero balance and returns its identifier. The currency must be a known currency carrying an exchange rate on the tenant. - Record a movement —
ADM-ACCOUNT-103applies aCREDITor aDEBITon that account credit, with an optional reason. The connected operator is recorded as the author. The response carries the movement with its reference and the resulting balance. - Read the history when you need to justify a balance —
ADM-ACCOUNT-554returns the movements most recent first, paginated. - The buyer reads the balance of the account they act on —
ACCOUNT-507from the storefront, read-only.
Granting a commercial gesture
sequenceDiagram
participant Operator
participant DJUST
participant Buyer
Operator->>DJUST: GET /v1/customer-accounts/{id}/account-credits (dj-client OPERATOR)
DJUST-->>Operator: 200 OK - balances per currency
Operator->>DJUST: POST /v1/customer-accounts/{id}/account-credits (currency EUR)
DJUST-->>Operator: 201 Created - account credit opened, balance 0
Operator->>DJUST: POST .../account-credits/{accountCreditId}/movements (CREDIT 100.00)
DJUST-->>Operator: 201 Created - AC-0000123, balanceAfter 100.00
Buyer->>DJUST: GET /v1/shop/customer-accounts/account-credits (dj-client ACCOUNT)
DJUST-->>Buyer: 200 OK - EUR 100.00
Key endpoints involved
| Action | Method | Path | operationId | Access |
|---|---|---|---|---|
| List the balances of a customer account | GET | /v1/customer-accounts/{customerAccountId}/account-credits | ADM-ACCOUNT-553 | OPERATOR · ACCOUNT_CREDIT_READ |
| Open an account credit in a currency | POST | /v1/customer-accounts/{customerAccountId}/account-credits | ADM-ACCOUNT-104 | OPERATOR · ACCOUNT_CREDIT_WRITE |
| List the movements of an account credit | GET | /v1/customer-accounts/{customerAccountId}/account-credits/{accountCreditId}/movements | ADM-ACCOUNT-554 | OPERATOR · ACCOUNT_CREDIT_READ |
| Credit or withdraw an account credit | POST | /v1/customer-accounts/{customerAccountId}/account-credits/{accountCreditId}/movements | ADM-ACCOUNT-103 | OPERATOR · ACCOUNT_CREDIT_WRITE |
| Read the balances of the buyer's account | GET | /v1/shop/customer-accounts/account-credits | ACCOUNT-507 | Authenticated customer users (dj-client: ACCOUNT) |
Administration endpoints require the dj-client: OPERATOR and dj-api-key headers. The storefront endpoint requires an authenticated customer user.
Note: These operationIds ship with DJUST 3.141. Their API reference pages become available once the version is live on your environment.
Reading the balances
Administration — ADM-ACCOUNT-553
ADM-ACCOUNT-553GET /v1/customer-accounts/0000011748/account-credits
dj-client: OPERATOR
dj-api-key: {{apiKey}}Response — 200 OK
[
{
"id": "0000012001",
"currency": "EUR",
"balance": 250.00
},
{
"id": "0000012002",
"currency": "GBP",
"balance": 80.00
}
]| Field | Type | Description |
|---|---|---|
id | string | Identifier of the account credit — the balance of the account in one currency. Use it in the movement paths. |
currency | string | ISO 4217 code of the balance. |
balance | number | Credit available in this currency. Never negative. |
StoreFront — ACCOUNT-507
ACCOUNT-507The buyer reads the balances of the account they act on. The customer-account-id header is mandatory on this route: a request without the header, or with an empty header, is refused with a 400, as is an account that does not belong to the buyer.
GET /v1/shop/customer-accounts/account-credits
dj-client: ACCOUNT
customer-account-id: 0000011748
Authorization: Bearer {{token}}The response has the same shape as ADM-ACCOUNT-553. An account with no account credit at all returns an empty list:
[]
Warning:ACCOUNT-507is read-only. No movement can be recorded from the storefront, and the movement history is not exposed to the buyer — buyers already see the credit charged on each of their orders.
Warning: Always send the selected customer account in thecustomer-account-idheader onACCOUNT-507. This is a breaking change: front offices that omitted the header must be updated, so that a buyer attached to several accounts only sees the balance of the account they are browsing. The other storefront routes are unchanged: without the header, one of the buyer's accounts is still used by default.
Opening an account credit — ADM-ACCOUNT-104
ADM-ACCOUNT-104Creates the account credit of the customer account in a currency, with a zero balance. Movements are then recorded against the returned identifier.
POST /v1/customer-accounts/0000011748/account-credits
dj-client: OPERATOR
dj-api-key: {{apiKey}}
Content-Type: application/jsonRequest body
| Field | Type | Required | Description |
|---|---|---|---|
currency | string | Yes | ISO 4217 code. Must be a known currency and carry an exchange rate on the tenant. |
{
"currency": "EUR"
}Response — 201 Created
{
"id": "0000012001",
"currency": "EUR",
"balance": 0.00
}Errors
| HTTP | Code | Description |
|---|---|---|
| 400 | F-E-001 | currency is missing. |
| 400 | F-E-012 | currency is not a known currency. |
| 400 | — | The currency carries no exchange rate on the tenant. |
| 403 | F-E-038 | Account credit is not enabled on the tenant. |
| 403 | F-E-030 | The caller lacks the ACCOUNT_CREDIT_WRITE right. |
| 404 | — | The customer account does not exist. |
| 409 | F-E-003 | The customer account already has an account credit in this currency. |
For the complete list of error codes, refer to Error / Warning codes.
Recording a movement — ADM-ACCOUNT-103
ADM-ACCOUNT-103Applies a credit or a debit on an account credit, in its currency. The amount is always positive — direction carries the sign. The connected operator is recorded as the author, with the nature OPERATOR_GESTURE.
POST /v1/customer-accounts/0000011748/account-credits/0000012001/movements
dj-client: OPERATOR
dj-api-key: {{apiKey}}
Content-Type: application/jsonRequest body
| Field | Type | Required | Description |
|---|---|---|---|
amount | number | Yes | Strictly positive. At most the number of decimals of the account credit currency (2 for EUR, 0 for JPY). Upper bound: 999 999 999.9999. |
direction | string | Yes | CREDIT adds the amount, DEBIT withdraws it. |
reason | string | No | Why the movement was recorded. Up to 255 characters. Shown to the customer users of the account. |
{
"amount": 100.00,
"direction": "CREDIT",
"reason": "Commercial gesture for a late delivery"
}Response — 201 Created
{
"id": "0000012345",
"reference": "AC-0000123",
"createdAt": "2026-10-21T09:30:00Z",
"currency": "EUR",
"amount": 100.00,
"direction": "CREDIT",
"nature": "OPERATOR_GESTURE",
"reason": "Commercial gesture for a late delivery",
"author": {
"type": "OPERATOR",
"id": "0000000399",
"label": "Sophie Bernard"
},
"balanceAfter": 200.00
}Errors
| HTTP | Code | Description |
|---|---|---|
| 400 | F-E-001 | amount or direction is missing. |
| 400 | F-E-007 | amount is zero, negative or above the upper bound; a credit would push the balance above it; or a debit would push the balance below zero. The detail tells these cases apart — amount exceeds the account credit balance for the last one. |
| 400 | F-E-010 | reason exceeds 255 characters. |
| 400 | F-E-012 | direction is unknown, or amount has more decimals than the currency allows. |
| 403 | F-E-038 | Account credit is not enabled on the tenant. |
| 403 | F-E-030 | The caller lacks the ACCOUNT_CREDIT_WRITE right. |
| 404 | F-E-002 | The customer account does not exist, or the account credit is not on this account. |
| 409 | — | Another movement is still being applied on the same balance. The request can be retried. |
Warning: Concurrent movements on the same balance are applied one after the other, each evaluated against the balance left by the previous one. Two simultaneous debits of 80 € on a balance of 100 € cannot both succeed: one is accepted, the other is refused withF-E-007.
Reading the movement history — ADM-ACCOUNT-554
ADM-ACCOUNT-554Returns the movements of an account credit, most recent first.
GET /v1/customer-accounts/0000011748/account-credits/0000012001/movements?page=0&size=20
dj-client: OPERATOR
dj-api-key: {{apiKey}}Query parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
page | integer | No | Page number, 0-based. Default 0. |
size | integer | No | Movements per page. Default 20, maximum 100. |
sort | string | No | Format property:direction. Sortable fields: createdAt, id. Default createdAt:desc then id:asc. Unknown fields are silently ignored. Repeat the parameter to sort on several fields. |
Response — 200 OK
{
"content": [
{
"id": "0000012346",
"reference": "AC-0000124",
"createdAt": "2026-10-22T14:05:00Z",
"currency": "EUR",
"amount": 50.00,
"direction": "DEBIT",
"nature": "ORDER_PAYMENT",
"reason": null,
"author": {
"type": "LOGISTIC_ORDER",
"id": "0000045012",
"label": "Order #0000045012"
},
"balanceAfter": 150.00
},
{
"id": "0000012345",
"reference": "AC-0000123",
"createdAt": "2026-10-21T09:30:00Z",
"currency": "EUR",
"amount": 100.00,
"direction": "CREDIT",
"nature": "OPERATOR_GESTURE",
"reason": "Commercial gesture for a late delivery",
"author": {
"type": "OPERATOR",
"id": "0000000399",
"label": "Sophie Bernard"
},
"balanceAfter": 200.00
}
],
"numberOfElements": 2,
"number": 0,
"size": 20,
"first": true,
"last": true,
"empty": false
}Errors
| HTTP | Code | Description |
|---|---|---|
| 400 | F-E-010 | size exceeds the maximum (100). |
| 400 | F-E-008 | size is below 1, or page is negative. |
| 403 | F-E-038 | Account credit is not enabled on the tenant. |
| 403 | F-E-030 | The caller lacks the ACCOUNT_CREDIT_READ right. |
| 404 | F-E-002 | The account credit does not exist on this customer account. |
Paying an order with account credit
At checkout, a buyer can apply all or part of the account credit to a commercial order and pay the remainder with another payment method.
- PAY-501 returns an
accountCreditobject (balance,currency) alongside the available payment methods. It is returned only if account credit is enabled for the tenant, the balance is strictly positive in the order currency, and the platform is not in marketplace mode. - The chosen amount is sent as
accountCreditAmountto PAY-101. It must be strictly positive, at most the balance and the order total, and carry at most the decimals of the currency. Otherwise an explicit functional error is returned (insufficient balance, amount above the order total) and the order remains a draft. - The remainder is computed by DJUST; any amount sent by the front for the complementary payment is ignored.
- The order total is never modified: the order carries an account credit transaction and a transaction on the chosen payment method. If the account credit covers the whole order, no payment authorization is requested.
- Account credit and bank transfer cannot be combined.
- If the card authorization expires without capture (
AUTHORIZATION_EXPIRED), the account credit applied to the order is credited back to the customer account (movement of natureRECREDIT). The logistic order status is unchanged. See Managing card payments. - If the buyer abandons the payment flow before any authorization (
ABANDONED), the account credit applied to the order is credited back the same way (RECREDIT) and the order returns to draft. A new payment attempt applies the balance available at the time of that new attempt, which may differ from the amount applied to the abandoned attempt. See Managing card payments.
POST /v1/shop/payments{
"accountCreditAmount": 25.00,
"countryCode": "FR"
}
Note: Excerpt of the body of PAY-101: the other required fields and the payment method details returned by the Drop-in are omitted.
Example scenarios
Scenario 1 — First commercial gesture on a new account
A late delivery is compensated with 100 € on an account that has never carried credit.
GET /v1/customer-accounts/0000011748/account-credits→[], no balance opened yet.POST /v1/customer-accounts/0000011748/account-creditswith{"currency": "EUR"}→201, account credit0000012001at0.00.POST .../account-credits/0000012001/movements:
{
"amount": 100.00,
"direction": "CREDIT",
"reason": "Commercial gesture — delivery delayed by 8 days"
}→ 201, AC-0000123, balanceAfter: 100.00. Every customer user of the account now sees 100 € through ACCOUNT-507.
Scenario 2 — Correcting a mistake
An operator credits 1 000 € instead of 100 €. The movement cannot be edited — record the opposite movement:
{
"amount": 900.00,
"direction": "DEBIT",
"reason": "Correction of AC-0000125 — amount entered with one digit too many"
}Both movements stay in the history, so the correction is explicit and auditable.
Scenario 3 — Independent balances per currency
An account carries 250 € and 80 £. Crediting 20 £ touches only the GBP account credit:
POST /v1/customer-accounts/0000011748/account-credits/0000012002/movements{ "amount": 20.00, "direction": "CREDIT", "reason": "UK goodwill" }→ balanceAfter: 100.00 in GBP. The EUR balance stays at 250 €.
Scenario 4 — Debit larger than the balance
The balance is 50 €, an operator tries to withdraw 80 €:
{ "amount": 80.00, "direction": "DEBIT", "reason": "Credit note cancellation" }→ 400 (F-E-007), with the detail amount exceeds the account credit balance. No movement is recorded and the balance stays at 50 €.
Scenario 5 — Closing an account that carries credit
Deleting a customer account that still carries 50 € is refused, through the API as through an import. Record a debit of 50 € first with an explicit reason, then delete the account. This keeps a trace of the credit being written off instead of silently losing it.
Best practices
- Always read the balances first.
ADM-ACCOUNT-553tells you whether the currency is already open and gives you theaccountCreditIdyou need for every movement. - Open the currency once, then reuse its identifier. A second
ADM-ACCOUNT-104on the same currency returns409— treat it as "already open" rather than as a failure. - Always fill in
reason. It is the only free-text trace of why the balance moved, and it is shown to the customer users of the account. A reason referencing the order or the exchange that justified the gesture makes the history reconcilable months later. - Quote the
reference, not theid.AC-0000123is the readable, stable, never-reused handle to use in emails, tickets and accounting exports. - Use
balanceAfteras a consistency check. Every movement carries the balance it produced, so you can verify your own ledger against DJUST without re-reading the balance. - Correct with an opposite movement, never by deleting. Immutability is what makes the history trustworthy.
- Retry on
409when recording a movement. A concurrent movement on the same balance is a transient condition, not a validation failure. - Check the activation setting before building on account credit. On a tenant where it is off, every route answers
403(F-E-038).
Common mistakes
| Mistake | Consequence | How to avoid |
|---|---|---|
Sending a negative amount to express a withdrawal | 400 (F-E-007) | The amount is always positive — use direction: "DEBIT". |
Sending an amount with too many decimals, e.g. 33.333 in EUR | 400 (F-E-012) | Round to the currency precision before the call. DJUST rejects rather than rounding silently. |
| Expecting the balance to be per customer user | Buyers see a balance they did not expect | The balance belongs to the customer account and is shared by all its customer users. |
| Assuming a missing currency means an error | Unnecessary error handling | A currency never opened is simply absent from the response: its balance is zero. |
Calling ADM-ACCOUNT-104 again for an open currency | 409 (F-E-003) | Read the balances first and reuse the existing id. |
| Trying to edit or delete a movement | No such operation exists | Record a movement in the opposite direction. |
| Deleting a customer account that still carries credit | Deletion refused, by API and by import | Bring every balance to zero with a debit movement first. |
Omitting customer-account-id on ACCOUNT-507 | 400 — the request is refused | Always send the selected customer account in the header. |
| Trying to record a movement from the storefront | No such route | Movements are operator-only. ACCOUNT-507 is read-only. |
| Building on account credit without enabling it | Every route answers 403 (F-E-038) | Have the activation setting enabled on the tenant first. |
Updated 8 days ago

