# Postback

{% hint style="success" %}
**Key Insight:** Once a user successfully completes an offer, our system instantly initiates a call to the Postback URL specified in your placement. This call includes all relevant details required to reward your users and serves as a real-time notification to your server.
{% endhint %}

### Postback Parameters

<table data-full-width="false"><thead><tr><th>PARAMETER</th><th>DESCRIPTION</th><th>EXAMPLE</th></tr></thead><tbody><tr><td><strong>{user_id}</strong></td><td>The id of your user, the one you have placed in the iframe integration. This id should not be empty or 0.</td><td><code>user1</code></td></tr><tr><td><strong>{payout}</strong></td><td>Complete payment in USD, paid to the publisher.</td><td><code>0.01</code></td></tr><tr><td><strong>{user_ip}</strong></td><td>IP Address of the user when the click happened.</td><td><code>192.168.1.1</code></td></tr><tr><td><strong>{offerName}</strong></td><td>Name of the completed offer.</td><td>Pitchium  <code>- Sign up and Earn</code></td></tr><tr><td><strong>{reward}</strong></td><td>User reward in app currency. You can configure it in the currency settings.</td><td><code>500</code></td></tr><tr><td><strong>{country}</strong></td><td>The country the user took the offer from as ISO2 Code.</td><td><code>US</code></td></tr><tr><td><strong>{status}</strong></td><td>Determines whether to add or subtract the amount of the reward. "1" is when the virtual currency should be added to the user and "2" when it should be subtracted.</td><td><code>1 (valid) / 2 (chargeback)</code></td></tr><tr><td><strong>{debug}</strong></td><td>Check if it’s a test or a live postback call.</td><td><code>1 (test) / 0 (live)</code></td></tr></tbody></table>

### Examples

This is how we call your Postback URL&#x20;

{% code overflow="wrap" %}

```
https://offerwall.pitchium.com?user_id={user_id}&payout{payout}&user_ip={user_ip}&offerName={offerName}&reward={reward}&country={country}&status={status}&debug={debug}
```

{% endcode %}

<br>

{% tabs %}
{% tab title="Completed  ✅ " %}
{% hint style="success" %}
{% code overflow="wrap" %}

```
https://offerwall.pitchium.com?user_id=user1&payout=0.01&user_ip=192.168.1.1&offerName=pitchium%20-%20Sign%20up%20and%20Earn&reward=500&country=US&status=1
```

{% endcode %}
{% endhint %}
{% endtab %}

{% tab title="Chargeback💸" %}
{% hint style="danger" %}
{% code overflow="wrap" fullWidth="false" %}

```
https://offerwall.pitchium.com?user_id=user1&payout=0.01&user_ip=192.168.1.1&offerName=pitchium%20-%20Sign%20up%20and%20Earn&reward=500&country=US&status=2
```

{% endcode %}
{% endhint %}
{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Important Reminder:**&#x20;

For a successful interaction, our servers anticipate an HTTP Status Code 200 from your Postback URL. If this response is not received, we'll make up to five additional attempts, with a one-hour interval between each. After the fifth attempt, an email indicating Postback failure will be sent.

Please note that the response message from your postback endpoint should not contain error-related terms like "fail" or "error." Any inclusion of such messages will be regarded as a postback failure.
{% endhint %}

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

```php
<?php

// Retrieve the parameters from the request
$user_id = $_REQUEST['user_id'] ?? '';
$payout = $_REQUEST['payout'] ?? '';
$user_ip = $_REQUEST['user_ip'] ?? '';
$offerName = $_REQUEST['offerName'] ?? '';
$reward = $_REQUEST['reward'] ?? '';
$country = $_REQUEST['country'] ?? '';
$status = $_REQUEST['status'] ?? '';

// Check if it's a chargeback
$isChargeback = ($status === '2');

// Apply chargeback adjustments
if ($isChargeback) {
    $reward = -$reward;
    $payout = -$payout;
}

// Apply user points logic
// In this example, let's assume you have a user points system
$userPoints = getUserPoints($user_id); // Replace with your logic to fetch user points

if ($userPoints !== false) {
    // Update user points based on reward
    $userPoints += $reward;

    // Update user points in the database or wherever it's stored
    updateUserPoints($user_id, $userPoints); // Replace with your logic to update user points
}

// Send a response to acknowledge receipt
http_response_code(200);
echo 'Postback successfully received.';

// Function to simulate fetching user points (replace with actual logic)
function getUserPoints($userId) {
    // Simulate fetching user points from a database
    // Replace this with your actual logic to fetch user points
    // Return user points or false if user not found
    return 1000; // For example
}

// Function to simulate updating user points (replace with actual logic)
function updateUserPoints($userId, $newPoints) {
    // Simulate updating user points in a database
    // Replace this with your actual logic to update user points
    // Return true if update successful, or false if not
    return true; // For example
}

```

{% endtab %}

{% tab title="Node JS" %}

```javascript
const http = require('http');
const url = require('url');

const server = http.createServer((req, res) => {
    const parsedUrl = url.parse(req.url, true);
    const query = parsedUrl.query;

    const { user_id, payout, user_ip, offerName, reward, country, status } = query;

    // Check if it's a chargeback
    const isChargeback = (status === '2');

    // Apply chargeback adjustments
    let adjustedReward = parseFloat(reward);
    if (isChargeback) {
        adjustedReward *= -1;
    }

    // Apply user points logic
    // In this example, you could update user points in your database
    // Replace this with your actual logic

    // Send a response to acknowledge receipt
    res.statusCode = 200;
    res.end('Postback successfully received.\n');
});

const port = 3000;
server.listen(port, () => {
    console.log(`Server is running on port ${port}`);
});

```

{% endtab %}

{% tab title="ASP.NET" %}

```aspnet
using System;
using System.Web.Mvc;

namespace PostbackExample.Controllers
{
    public class PostbackController : Controller
    {
        [HttpPost]
        public ActionResult Index(FormCollection form)
        {
            string user_id = form["user_id"];
            string payout = form["payout"];
            string user_ip = form["user_ip"];
            string offerName = form["offerName"];
            string reward = form["reward"];
            string country = form["country"];
            string status = form["status"];

            // Check if it's a chargeback
            bool isChargeback = (status == "2");

            // Apply chargeback adjustments
            int updatedReward = Convert.ToInt32(reward);
            if (isChargeback)
            {
                updatedReward = -updatedReward;
            }

            // Apply user points logic
            // In this example, you could update user points in your database
            // Replace this with your actual logic

            // Send a response to acknowledge receipt
            return new HttpStatusCodeResult(200);
        }
    }
}

```

{% endtab %}
{% endtabs %}


---

# 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.pitchium.com/monetization/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.
