API reference · CashBack

Grant Cashback for External Order

POSThttps://api.sandbox.cws.digital/v1/cashback/external-orderIn homologation

Description

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

Content-Typeapplication/jsonRequired
Edit the body with
FieldTypeRequiredDescriptionValue
cpfCnpjstringConditional

Customer's CPF or CNPJ, with or without mask. Required when email is not sent.

emailstringConditional

Customer's login e-mail in your store. Required when cpfCnpj is not sent.

externalOrderIdstringYes

Order number in your system. Cannot contain /. See One credit per external order and partner.

documentPartnerstringYes

Document of the partner that sold the order, with or without mask. See documentPartner and the marketplace sale.

valuenumberYes

Cashback value in reais, already calculated by you. See The cashback value is what you send.

deliveryDatestringYes

Order delivery date, in the YYYY-MM-DD format.

timeToReleasePointsintegerNo

Grace days before the credit is released. From 0 to 65535. When omitted or 0, the grace period of the store's loyalty program applies.

statusstringNo

Initial status of the credit. When omitted, the credit is born TO_RELEASE. See Status and grace period.

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.

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/v1/cashback/external-order' \
  --header 'Authorization: Bearer <access_token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "cpfCnpj": "466.935.373-08",
  "externalOrderId": "PED-EXT-900201",
  "documentPartner": "30.424.972/0001-74",
  "value": 12.34,
  "deliveryDate": "2026-09-10",
  "timeToReleasePoints": 30,
  "status": "TO_RELEASE"
}'

Response

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