# Postback

{% hint style="info" %}
What The Postback?

When a user successfully completes an offer, we immediately trigger a call to the Postback URL you have provided in your placement. This call contains all the relevant information required to credit your users, serving as a real-time notification to your server.
{% endhint %}

Postback Parameter

<table data-header-hidden data-full-width="false"><thead><tr><th width="168">Header 1</th><th width="428.3333333333333">Header 2</th><th>Header 3</th></tr></thead><tbody><tr><td>Parameter</td><td>DESCRIPTION</td><td>EXAMPLE</td></tr><tr><td>{user_id}</td><td>This is the unique identifier code of the user who completed action on your platform.</td><td>varchar (25)</td></tr><tr><td>{offer_name}</td><td>The Name of the offer completed.</td><td>varchar (255)<br></td></tr><tr><td>{amount}</td><td>The amount of your virtual currency to be credited to your user.</td><td>99999</td></tr><tr><td>{payout}</td><td>Amount in USD that you earned for this conversion.</td><td>100.5</td></tr><tr><td>{user_ip}</td><td>IP address of the user that completed the offer.</td><td>1.1.1.1</td></tr><tr><td>{txid}</td><td>Unique ID of the conversion generated by ClickWall.</td><td>sdf8sd7fs</td></tr><tr><td>{offer_id}</td><td>Display number in our system</td><td>varchar (50)</td></tr></tbody></table>

### Example Postback URL <a href="#example-postback-url" id="example-postback-url"></a>

```url
https://example.com/postback/clickwall.php?user_id={user_id}&payout={payout}&amount={amount}&offer_name={offer_name}&user_ip={user_ip}&txid={txid}
```

We expect a response with a status code of **Ok** or **1** to indicate that the retransmission was received successfully.

### PHP Example <a href="#php-example" id="php-example"></a>

```php
<?php
                    /*!
                     * ClickWall LLC
                     * http://clickwall.net
                     * mail@dclickwall.net
                     * Demo: https://example.com/postback/clickwall.php?user_id={user_id}&amount={amount}&offer_name={offer_name}&user_ip={user_ip}
                     */

                    // Include the initialization file
                    include_once("../admin/core/init.inc.php");

                    // Get data from the request
                    $user_id = $_REQUEST['user_id'];
                    $amount = $_REQUEST['amount'];
                    $offerName = $_REQUEST['offer_name'];
                    $user_ip = $_REQUEST['user_ip'];

                    // Get the current timestamp
                    $timeCurrent = time();

                    // Initialize the functions object
                    $configs = new functions($dbo);

                    // Define the event type
                    $type = "ClickWall: Offername: $offerName . IP: $user_ip";

                    // Create an account object and retrieve user data
                    $account = new account($dbo, 1);
                    $userdata = $account->getuserdata($user_id);

                    // Calculate the new user balance
                    $newBalance = $userdata['points'] + $amount;

                    // Update user Points
                    $sql = "UPDATE users SET points = '$newBalance' WHERE login = '$user_id'";
                    $stmt = $dbo->prepare($sql);
                    $stmt->execute();

                    // Update user Tracker
                    $sql = "INSERT INTO tracker(username, points, type, date) values ('$user_id', '$amount', '$type', '$timeCurrent')";
                    $stmt = $dbo->prepare($sql);
                    $stmt->execute();

                    if ($stmt) {
                        echo "OK";
                    }
                    

                    ?>
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.clickwall.net/postback.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
