# Setup Postback

When a user successfully completes an offer, Playtime SDK will send a **postback** to your server with the reward details.\
This ensures that rewards are delivered securely and accurately.

{% code overflow="wrap" %}

```
// Example Postback 

https://www.example.com/postbacks/postback_file_name.php?user_id={user_id}&offer_id={offer_id}&offer_name={offer_name}&payout={payout}&signature={signature}&event={event}&sub1={sub1}&sub2={sub2}&sub3={sub3}&sub4={sub4}&sub5={sub5}&sub6={sub6}&sub7={sub7}&sub8={sub8}&sub9={sub9}&sub10={sub10}&gaid={users_advertising_id}&clickIp={clickIpaddress}&clickDatetime={clickDatetime}&conversionDatetime={conversionDatetime}&timeZone={timeZone}&callback_type={callback_type}&currency_name={currency_name}&appKey={appKey}&amount={amount}
```

{% endcode %}

## Postback Parameters

| Parameter            | Description                                                                                      |
| -------------------- | ------------------------------------------------------------------------------------------------ |
| `user_id`            | Unique identifier of the user from your app (mentioned in iFrame url).                           |
| `offer_id`           | Unique ID of the campaign/offer.                                                                 |
| `offer_name`         | Name of the campaign (URL encoded).                                                              |
| `payout`             | Publisher payout amount in USD.                                                                  |
| `signature`          | Security hash to validate authenticity.                                                          |
| `event`              | Event Name (e.g., `install`, `signup`, `complete_level_2`).                                      |
| `sub1` - `sub10`     | Custom tracking parameters (optional).                                                           |
| `gaid`               | Google Advertising ID of the user (if available).                                                |
| `clickIp`            | IP address of the user when clicking the offer.                                                  |
| `clickDatetime`      | Timestamp of the click (in `YYYY_MM_DD HH:MM:SS` format).                                        |
| `conversionDatetime` | Timestamp when conversion occurred.                                                              |
| `timeZone`           | Time zone of conversion (e.g., IST).                                                             |
| `callback_type`      | Type of callback (e.g., `1 = Api Callback`, `2 = Direct offer Callback`, `3 = iFrame Callback`). |
| `amount`             | Reward coins/points to be credited to the user in your app.                                      |
| `appKey`             | Unique App Key assigned to your app.                                                             |
| `currency_name`      | Name of your inapp currency which you have set.                                                  |

### Sample code to validate signature

{% tabs %}
{% tab title="PHP" %}

<pre class="language-php"><code class="lang-php"> // Signature Authentication
 
 $userId = $_REQUEST['user_id'];
 $offer_id = $_REQUEST['offer_id'];
 $coin_amount = (int)$_REQUEST['amount'];
 $signature = $_REQUEST['signature'];
 $event= $_REQUEST['event'];

 $calculated_signature = sha1($<a data-footnote-ref href="#user-content-fn-1">userId</a>.$<a data-footnote-ref href="#user-content-fn-2">offer_id</a>.$event."<a data-footnote-ref href="#user-content-fn-3">YOUR_APPLICATION_KEY</a>"."<a data-footnote-ref href="#user-content-fn-4">YOUR_APPLICATION_SECRET_KEY</a>");
 
 if($signature === $calculated_signature){
 // Request is valid
 }
</code></pre>

{% endtab %}
{% endtabs %}

## Test Callback Tool

We provide a dedicated **Test Callback Tool** so you can safely verify your callback configuration before going live.

<figure><img src="https://3792453041-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDAvJwGUkFBKS31rzOrgN%2Fuploads%2FHfJlDB5uXGQmJakiLYOR%2Fimage.png?alt=media&#x26;token=bf26074e-f737-4c4e-9790-bd6ed21e3b68" alt=""><figcaption></figcaption></figure>

**Key Features:**

* Safely test your callback URL without affecting live data.
* Instantly simulate user actions and reward payouts.
* Debug and validate parameters directly from the dashboard.

#### Input Fields:

* **User ID** → Simulates a user session.
* **Custom Parameters** → sub1=abc\&sub2=123\&sub5=xyz

<figure><img src="https://3792453041-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDAvJwGUkFBKS31rzOrgN%2Fuploads%2FvDfBPYJQlT9UaaK6JJM3%2Fimage.png?alt=media&#x26;token=2cf50e9a-61da-4c71-91de-5c937d239206" alt=""><figcaption></figcaption></figure>

#### How It Works:

1. Enter the **User ID** (this must match the User ID used in your SDK initialization).
2. Enter the **Custom Parameters** ( This is extra params which you can use to track conversions )&#x20;
3. Click **Send** **Test Postback**.

ℹ️ **Note**: Make sure the callback endpoint is correctly configured to receive and validate all required parameters.

[^1]: Your application `unique_id` set while initializing the SDK.

[^2]: The identifier of the offer for which the user receives a postback.

[^3]: Your Unique Application ID, which you get from manage App section in publisher panel.

[^4]: Your Application Secret Key, which you get from manage App section in your publisher panel. **This key is diffrent for all applications.**
