> For the complete documentation index, see [llms.txt](https://trivonads.gitbook.io/trivonads-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://trivonads.gitbook.io/trivonads-docs/postback.md).

# Postback

Our server will make an HTTP GET request to your server, including the following parameters.

## Postback parameters

| Parameter    | Description                                                                                                                                                                          |
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| subId        | The unique identifier for the user who completed the offer.                                                                                                                          |
| transId      | Unique identification code of the transaction made by your user on Adjoemedia.                                                                                                       |
| reward       | The offer payout in dollars.                                                                                                                                                         |
| payout\_usd  | The offer payout in dollars.                                                                                                                                                         |
| signature    | MD5 hash to verify that the call has been made from our servers.                                                                                                                     |
| status       | Indicates whether to add or subtract the reward amount. "1" means adding virtual currency to the user, and "2" means subtracting it due to issues like fraud or data entry mistakes. |
| Ip           | The user's IP address who completed the action.                                                                                                                                      |
| campaign\_id | ID of the offer completed.                                                                                                                                                           |
| type         | Type of offer (Offers/Surveys/PTC/Shortlink).                                                                                                                                        |
| country      | Country (ISO2 form) where the lead comes from.                                                                                                                                       |
| uuid         | Unique identification code of the click made by your user on Adjoemedia.                                                                                                             |
| offer\_name  | Name of the offer completed.                                                                                                                                                         |
| sign         | secret key of your site                                                                                                                                                              |

{% hint style="info" %}
"Rewards" and "Payout" parameters are always absolute values. Check the "status" parameter to determine if you need to add or subtract that amount from your users.
{% endhint %}

## Custom postback parameters

To receive custom parameter names in your postbacks, specify them in the postback URL. You can use any of the parameters from the table above by enclosing them in `{}`.

Example:

```
https://postback.example.com/?custom={subId2}&nameOfCampaign={campaign_name}
```

Do not remove or change any query parameters we send.

## Security

Verify the signature received in the postback to ensure that the call comes from our servers. The `signature` parameter should match the MD5 hash of `subid`, `transactionid`, `reward`, and your secret key.

### PHP example for signature verification

{% code title="verify\_signature.php" %}

```
```

{% endcode %}

```php
<?php

$secret = ""; // Your secret key

$subId = isset($_GET['subId']) ? $_GET['subId'] : null;
$transId = isset($_GET['transId']) ? $_GET['transId'] : null;
$reward = isset($_GET['reward']) ? $_GET['reward'] : null;
$signature = isset($_GET['signature']) ? $_GET['signature'] : null;

// Validate signature
if (md5($subId . $transId . $reward . $secret) != $signature) {
    echo "ERROR: Signature doesn't match";
    return;
}

?>
```

## Postback response

Our server expects the following responses:

* "OK" when you receive a new transaction.
* "DUP" when you receive a duplicate transaction. This stops further attempts for that transaction.

Our servers wait for a response for a maximum of 60 seconds before a timeout. If a timeout occurs, the request will be retried up to five times in the following hours. Ensure the transaction ID sent to you is unique in your database to prevent duplicate virtual currency rewards.

## Postback example implementation

{% code title="postback\_handler.php" %}

```
```

{% endcode %}

```php
<?php

$secret = ""; // Your secret key
$userId = isset($_GET['subId']) ? $_GET['subId'] : null;
$transactionId = isset($_GET['transId']) ? $_GET['transId'] : null;
$points = isset($_GET['reward']) ? $_GET['reward'] : null;
$signature = isset($_GET['signature']) ? $_GET['signature'] : null;
$action = isset($_GET['status']) ? $_GET['status'] : null;
$ipuser = isset($_GET['userIp']) ? $_GET['userIp'] : "0.0.0.0";

// Validate signature
if (md5($userId . $transactionId . $points . $secret) != $signature) {
    echo "ERROR: Signature doesn't match";
    return;
}

if ($action == 2) { // action = 1 CREDITED // action = 2 REVOKED
    $points = -abs($points);
}

if (isNewTransaction($transactionId)) { // Check if the transaction is new
    processTransaction($userId, $points, $transactionId);
    echo "OK";
} else {
    // If the transaction already exists, please echo DUP.
    echo "DUP";
}

?>
```

{% hint style="warning" %}
Ensure the transaction ID you store is unique in your database to prevent duplicate rewards. Also ensure your server responds within 60 seconds to avoid retries.
{% endhint %}

## Image

![](/files/mZI2Rm2yWmIMqCrvbjCA)

{% hint style="info" %}
There is no need to put our parameters in the postback link because they are taken automatically.
{% endhint %}

Note: This guide was last updated 25/11/2024.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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://trivonads.gitbook.io/trivonads-docs/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.
