API reference · CashBack
Grant Cashback for External Order
https://api.sandbox.cws.digital/v1/cashback/external-orderIn homologationDescription
Grants cashback to a customer from an order that happened outside the CWS platform: a sale at your counter, in your own e-commerce or in another channel.
You inform who bought, the order number in your system, the partner that sold and the cashback value in reais, already calculated. Each call records one credit.
Request body
application/jsonRequired| Field | Type | Required | Description | Value |
|---|---|---|---|---|
| cpfCnpj | string | Conditional | Customer's CPF or CNPJ, with or without mask. Required when | |
| string | Conditional | Customer's login e-mail in your store. Required when | ||
| externalOrderId | string | Yes | Order number in your system. Cannot contain | |
| documentPartner | string | Yes | Document of the partner that sold the order, with or without mask. See | |
| value | number | Yes | Cashback value in reais, already calculated by you. See The cashback value is what you send. | |
| deliveryDate | string | Yes | Order delivery date, in the | |
| timeToReleasePoints | integer | No | Grace days before the credit is released. From 0 to 65535. When omitted or | |
| status | string | No | Initial status of the credit. When omitted, the credit is born Allowed values: TO_RELEASERELEASEDCANCELLEDINVALID_EXPIRED |
Business rules
One customer, by document or by e-mail
Send one of the two. If you send both, the cpfCnpj is the one that counts.
The customer must already exist in your store: a customer from another store, or a document without registration, is rejected.
One credit per external order and partner
The pair externalOrderId + documentPartner is unique in your store. A second call with the same pair is rejected, not duplicated: this is what protects you from granting cashback twice when a delivery is reprocessed.
Order sold by more than one partner: make one call per partner, with the same externalOrderId.
Use the real order number in your system, not a value generated at each attempt. It cannot contain /, because it goes in the route of Update External Order Cashback.
The cashback value is what you send
CWS records value as it came, rounded to two decimal places. There is no calculation by product, category or program percentage.
A value that becomes zero after rounding (below one cent) is rejected.
documentPartner and the marketplace sale
The informed document defines who sold the order.
When it is the document of your own store, nothing else is required. When it is the document of another partner, there must be an authorized marketplace partnership between your store and it; otherwise, the order is rejected.
Status and grace period
Without status, the credit is born TO_RELEASE and stays in the grace period. With RELEASED, it is born released, with today's release date.
Without timeToReleasePoints, or with 0, the grace period configured in the store's loyalty program applies.
A rejection brings a single reason
The validations stop at the first problem, and message brings only that one. When there is a rejection, nothing is recorded.
Responses
- 401
Missing, malformed or expired token.