> ## Documentation Index
> Fetch the complete documentation index at: https://docs.shakesco.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Process Cashback

> Record a customer purchase and auto-credit cashback if they hit the threshold

<span style={{display:"none"}}>For the complete documentation index, see [llms.txt](/llms.txt).</span>

Adds `spent_amount` to the customer's cashback progress. If the cumulative spend reaches the configured threshold, `reward_tokens` are credited automatically and the counter rolls over (overflow carries into the next cycle).

Call this after every customer purchase. Returns `404` if you haven't set up a cashback program yet via [`/set-cashback`](/api-reference/tokens/governance/set-cashback).

<Info>
  Treat this as a transaction. If you don't get a response, check [`/cashback-progress`](/api-reference/tokens/governance/cashback-progress) before retrying. Duplicate calls will inflate the customer's progress.
</Info>

### Request Body

<ParamField body="customer_ref" type="string" required>
  Your unique identifier for this customer
</ParamField>

<ParamField body="spent_amount" type="number" required>
  Amount the customer just spent, in `currency`
</ParamField>

<ParamField body="currency" type="string" required>
  Currency of the spent amount. [See codes](/api-reference/general/codes)
</ParamField>

### Response

<ResponseField name="tx_hash" type="string">
  Reference identifier for this purchase
</ResponseField>

```javascript theme={null}
await fetch("https://tokens.shakesco.com/process-cashback", {
  method: "POST",
  headers: { Authorization: `Bearer ${API_KEY}`, "Content-Type": "application/json" },
  body: JSON.stringify({
    customer_ref: "customer-123",
    spent_amount: 600,
    currency: "KES",
  }),
});
```

<ResponseExample>
  ```json 200 OK theme={null}
  { "tx_hash": "0xabc..." }
  ```

  ```json 404 Cashback Not Configured theme={null}
  { "error": "Cashback not configured for this business" }
  ```
</ResponseExample>
