API reference · Credit Limit

Set or Update Credit Limits in Batch

POSThttps://api.sandbox.cws.digital/creditLimit/batchIn homologation

Description

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

Content-Typeapplication/jsonRequired
Edit the body with
FieldTypeRequiredDescriptionValue
creditLimitRequestarray of objectYes

The limits to store, from 1 to 100 items. A null item is ignored.

Fields in creditLimitRequest[]

Items of creditLimitRequest[]
creditLimitRequest[]
FieldTypeRequiredDescriptionValue
documentstringYes

Customer's CPF or CNPJ, with or without mask. Up to 18 characters.

creditCodestringYes

Code of a limit type of your store. Up to 18 characters.

valuenumberYes

Total value of the limit.

balancenumberYes

Available balance, which replaces the stored balance.

activebooleanYes

true keeps the limit active; false leaves the limit inactive.

withoutCreditLimitbooleanYes

true allows the customer to buy even without balance.

Business rules

Result of each item

statusMeaning
CREATEDLimit created.
UPDATEDLimit changed.
UNCHANGEDSame as stored; nothing was stored.
ERRORItem rejected, with the reason in error and the code in errorCode.

Item error codes

errorCodeWhenWhat to do
INVALID_FIELDMissing field, too long or of the wrong type.Fix the item.
CREDIT_TYPE_NOT_FOUNDThe creditCode is not a type of your store.Create the type or fix the code.
DUPLICATE_IGNOREDItem repeated with the same values; the first one was processed.Nothing.
DUPLICATE_CONFLICTItem repeated with different values; none was processed.Send the customer only once.
INTERNAL_ERRORFailure 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.

Try it

Sandbox

Language

Credentials

Access token: saved in this tab and used on every endpoint.

Each token only reaches the partner's own data and that of the branches with an authorized link.

Don't have sandbox credentials yet? See how to request them

Request

cURL
curl --request POST \
  --url 'https://api.sandbox.cws.digital/creditLimit/batch' \
  --header 'Authorization: Bearer <access_token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "creditLimitRequest": [
    {
      "document": "57.578.030/0001-05",
      "creditCode": "CREDITO-PADRAO",
      "value": 5000,
      "balance": 5000,
      "active": true,
      "withoutCreditLimit": false
    },
    {
      "document": "466.935.373-08",
      "creditCode": "CREDITO-PADRAO",
      "value": 1500,
      "balance": 1200,
      "active": true,
      "withoutCreditLimit": false
    }
  ]
}'

Response

Click Try it to see the real response here, or pick a documented example: