# Rewards & Loyalty

### Rewards <a href="#rewards" id="rewards"></a>

#### `POST /rewards` <a href="#post-rewards" id="post-rewards"></a>

```
const issueReward = (customer: string, asset: string, notional: string) => {
  const body = `{
    underlying: ${underlying},
    quoted_currency: 'e₹',
    total: ${notional}
    participant_code: ${customer}
  }`
  const timestamp = Math.round(Date.now() / 1000)
  const payload = timestamp + 'POST' + '/rewards' + body
  const decodedSecret = Buffer.from(apiSecret, 'base64')
  const hmac = crypto.createHmac('sha256', decodedSecret)
  const signedPayload = hmac.update(payload).digest('base64')

  // SET HEADERS
  const headers = {
    'X-NDAX-API-KEY': 'public_key',
    'X-NDAX-SIGNED': signedPayload,
    'X-NDAX-TIMESTAMP': timestamp,
    'X-NDAX-PASSPHRASE': 'passphrase'
  }
  const options = {
    headers,
    body,
    json: true
  }

  return request.post(`https://api.ndax.in/rewards`, options)
}
```

> Sample Response

```
{
  "request_id": "14f8ebb8-7530-4aa4-bef9-9d73d56313f3",
  "quote": {
    "request_id": "ce819fe8-b1d7-43bb-961c-e09ede0988d3",
    "participant_code": "CUST01",
    "underlying_currency": "BTC",
    "quoted_currency": "e₹",
    "side": "BUY",
    "quantity": "1",
    "price": "11430.90",
    "quote_id": "5cd07738b861c31e3bd61467BTC1Buy1568311644602",
    "expire_ts": 1568311649602,
    "obo_participant":{
      "participant_code":"20XRLH",
      "account_group":"WRD1K0",
      "account_label":"general"
    },
    "transaction_timestamp": 1568311649600
  },
  "trade_id": "ba97133e-ab15-4c86-86c1-86671b8420bc",
  "status": "Completed"
}
```

Executes a trade to issue a reward in a certain asset. See one-pager [here](https://seedcx.zendesk.com/hc/en-us/articles/4403782906771) for more details.

Optional request header include:

<table><thead><tr><th width="183.33333333333331">Parameter</th><th width="392">Description</th><th>Type</th></tr></thead><tbody><tr><td>X-REQUEST-ID</td><td>Include a X-REQUEST-ID in the request header to ensure idempotent rewards requests</td><td>UUID</td></tr></tbody></table>

Body parameters include:

* `underlying` (required) the underlying asset for to be rewarded.
* `quoted_currency` (required) the quoted asset for purchase of the reward
* `quantity` (optional) the desired amount of the `underlying` for the quote (either `quantity` or `total` must be provided)
* `total` (optional) the desired amount of the `quoted_currency` for the quote (either `quantity` or `total` must be provided)
* `participant_code` (required) the participant that is receiving the reward. This is the platform's customer.
* `account_label` (optional) the account label associated with the account.

Response:

<table><thead><tr><th width="140.33333333333331">Parameter</th><th width="508">Description</th><th>Type</th></tr></thead><tbody><tr><td>request_id</td><td>The identifier of the RFQ</td><td>string</td></tr><tr><td>quote</td><td>The quote object that was executed</td><td>quote</td></tr><tr><td>trade_id</td><td>The unique identifier assigned to the trade, which is the same <code>trade_id</code> as found in a <code>GET /trades</code> request<br>Note: the <code>quote_id</code> will be saved as the <code>client_trade_id</code></td><td>string</td></tr><tr><td>status</td><td>The status of the trade, e.g. <code>Completed</code></td><td>string</td></tr></tbody></table>
