# How to Verify Custom Reward From Your Website with Callback Verification

Creating a Custom Reward will allow you to auto-distribute any rewards from your websites.

<mark style="color:blue;">For example:</mark>&#x20;

Let's say you wish to provide winners with a $50 coupon reward after they have won the giveaway.&#x20;

Upon successful integration of API callbacks between your site and **Giveaway**, the participants will receive their rewards automatically according to the method you have specified.

However, the $50 coupon reward is just one of the reward examples, because you can create any type of rewards distributed from your websites.&#x20;

<mark style="color:blue;">Why and how is it auto-distributed?</mark>

Following the successful integration of the API callback, winners will be able to claim their rewards via a specific URL containing their track\_id and eligibility. Regardless of the method of delivery, the reward will be automatically sent to the winner. In this way, you are not required to manually distribute rewards on your website.&#x20;

**Please follow the steps to create custom rewards and to integrate API callback:**

**Step 1:**

Enter a reward name, number of winners, and upload an image of that reward.

<figure><img src="https://2708562487-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyVxbiaRQCsKiTgC61a7e%2Fuploads%2FXlGtDOHoJBI2EnLtklK0%2Fimage.png?alt=media&#x26;token=a018fe45-5751-4f4b-9c94-588c2dadb0b9" alt=""><figcaption></figcaption></figure>

**Step 2:**

After that, you will need to get url params (something like <mark style="color:green;">track\_id=MVNHLLEEwIR</mark>) from your website and parse out the trackId.

<figure><img src="https://2708562487-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyVxbiaRQCsKiTgC61a7e%2Fuploads%2Fx4CG1pEKvTXrPZfO2NJ1%2Fimage.png?alt=media&#x26;token=df75573c-b8da-481a-97da-74c65de63d75" alt=""><figcaption></figcaption></figure>

<mark style="color:blue;">**About track\_id:**</mark>

TrackId is necessary to detect the user's participation in the task and to verify it. We will detect when a user clicks to participate in the task, the *<mark style="color:green;">**?trackId={{trackId}}**</mark>* will be used for detection.

You will see the *<mark style="color:green;">**?trackId={{trackId}}**</mark>* applied to your website link:

**If your website link is**

```
http://example.com
```

**the visitors may come to your site via the link**

```
http://example.com/?track_id=12345_67890&send=true
```

**Step 3:**

Next, please copy the API key we provide you to integrate it with your website.

<figure><img src="https://2708562487-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyVxbiaRQCsKiTgC61a7e%2Fuploads%2Fm5H9DYOwKNGWGFawQuoa%2Fimage.png?alt=media&#x26;token=1bd37dcd-2f72-4a3e-820f-eca02b2196b6" alt=""><figcaption></figcaption></figure>

Then enter the parameters according to the rules of const data, and encrypt the whole const data using the standard **HmacSHA256** algorithm.

```
const data = `track_id=${track_id}&event=send&remark=${remark}`; // remark is optional.
```

**Step 4:**

After the user completes the verification task, he will be directed to your reward website. You need to call our API interface to verify <https://giveaway.com/public/v1/giveaway/player/status>. The ID carried by the user has been completed. The verification process will be completed if the interface is returned correctly. Now you can distribute your rewards to the users who have completed the task based on our return results.

**Official API**&#x20;

<https://giveaway.com/public/v1/giveaway/player/status>

```javascript
const api_key = "{{your api_key}}";
const {track_id} = queryString.parse(window.location.search); // url search
const data = `track_id=${track_id}`;
const sign = crypto.HmacSHA256(data, api_key).toString(); // HmacSHA256
fetch("https://giveaway.com/public/v1/giveaway/player/status", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    track_id,
    sign,
  }),
}).then(async (res) => {
  console.log(await res.json());
  /**
{
  "code": 10000,
  "msg": "Success",
  "data": {
    "status": {
      "task_completed": true, // Whether the task is completed
      "won": true // Whether to win the lottery
    },
    "reward_tag": "custom_reward1" // Reward label
  },
}
   */
});
```

**Step 5:**

After the above steps are completed, enter your website link and click the ‘**Check API callback**’ to test it.

<figure><img src="https://2708562487-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyVxbiaRQCsKiTgC61a7e%2Fuploads%2Fy9EneyUfF8qM372GFmZb%2Fimage.png?alt=media&#x26;token=14599b8f-b4f5-4700-82c4-4083b89ca801" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
Each project you create on **Giveaway** will have a unique API key, and it will not change. So you only need to integrate once for a website. Also, you will be able to create custom rewards on multiple websites if you need to.
{% endhint %}
