API reference · Credit Limit
Set or Update Credit Limits in Batch
https://api.sandbox.cws.digital/creditLimit/batchIn homologationDescription
Creates or updates the credit limit of up to 100 customers per request, in your store.
Each item is processed independently: the result of each one comes in the status field of the response, and a rejected item does not prevent the others.
Each item follows the rules of Set or Update Credit Limit for Customer, including the balance one: the value sent replaces the stored one.
The examples use the CREDITO-PADRAO type, the same one as in the example of Create Credit Limit Type: create it first in your store.
Request body
application/jsonRequired| Field | Type | Required | Description | Value |
|---|---|---|---|---|
| creditLimitRequest | array of object | Yes | The limits to store, from 1 to 100 items. A Fields in creditLimitRequest[] |
creditLimitRequest[]| Field | Type | Required | Description | Value |
|---|---|---|---|---|
| document | string | Yes | Customer's CPF or CNPJ, with or without mask. Up to 18 characters. | |
| creditCode | string | Yes | Code of a limit type of your store. Up to 18 characters. | |
| value | number | Yes | Total value of the limit. | |
| balance | number | Yes | Available balance, which replaces the stored balance. | |
| active | boolean | Yes |
| |
| withoutCreditLimit | boolean | Yes |
|
Business rules
Result of each item
status | Meaning |
|---|---|
CREATED | Limit created. |
UPDATED | Limit changed. |
UNCHANGED | Same as stored; nothing was stored. |
ERROR | Item rejected, with the reason in error and the code in errorCode. |
Item error codes
errorCode | When | What to do |
|---|---|---|
INVALID_FIELD | Missing field, too long or of the wrong type. | Fix the item. |
CREDIT_TYPE_NOT_FOUND | The creditCode is not a type of your store. | Create the type or fix the code. |
DUPLICATE_IGNORED | Item repeated with the same values; the first one was processed. | Nothing. |
DUPLICATE_CONFLICT | Item repeated with different values; none was processed. | Send the customer only once. |
INTERNAL_ERROR | Failure while storing the item. | Resend the item. |
Repeated items in the same batch
Send each customer and type only once per request. Items with the same document and the same creditCode are treated as repeated:
- with the same values, only the first one is processed;
- with different values, none of them is processed.
Resending the batch
Resending the same batch is safe: the items already stored come back as UNCHANGED.
Responses
- 401
Missing, malformed or expired token.