---
title: Syncing Commission Data via API and Callbacks
slug: article/kfgi-syncing-commission-data-via-api-and-callbacks
description: Learn how to obtain commission data using two methods: pulling data from the API or receiving callbacks. We recommend using callbacks for a synchronized system, but API calls serve as a backup. Get insights on callback body structure, key values for commi
docTags: WX-732KZOub96_R0NW2HX
createdAt: 2022-12-13T00:04:41.000Z
---

Once your users start generating sales, you'll want your system to sync the associated data so that you can show these sales to your users, send push notifications, etc. &#x20;

There are two ways to get this commission data: pull them from our **API or receive callbacks from our system**. Our recommendation is to call our API, caching results between every 1-6 hours but no less than 24 hours. Callbacks are an additional option, however, we do not re-attempt failed callbacks.

***

Commission Data via the Wildfire API

To see the API docs for how to fetch commission data en masse see the [API reference](https://documenter.getpostman.com/view/24961/RWgqVyV2#5cc69c1d-fb39-4231-894e-7acf25487c6f).

Features of commission API:

- Fetch up to 2000 records at a time
- Cursor-based requests to page through all results
- Request commissions between a date\_modified range to capture all changes

Notes:

- Commission API should only be called up to 1 time per 5 seconds (more frequent requests will be rejected).
- Whereas callbacks provide low-latency commission data, the batch API provides a guarantee of not missing any records (as callbacks are not retried).
- Requests to the commission API can timeout for a number of reasons (network connectivity, unplanned maintenance windows, etc.).  The HTTP response code and payload should be evaluated to ensure you received an expected response.  If an unexpected response was received, consider retrying with an [exponential backoff pattern](https://docs.aws.amazon.com/prescriptive-guidance/latest/cloud-design-patterns/retry-backoff.html).

## Commission Data via Callbacks

Callbacks offer nearly realtime updates as commission records are created or changed in the Wildfire platform. However, Callbacks are not retried and no longer the recommended method for syncing commission records.

To set up your callback URL, in your partner admin tool, select the application you want to configure and then select the gear icon.  Here you can enter a callback URL (please ensure it's an HTTPS endpoint) and a callback key. &#x20;

The callback key can be any value.  The purpose of the callback key is to ensure that the callback is valid (and that a rogue entity is not invoking your callback URL with false data).

### Callback Body

The content of the body is different depending on what version of the APIs your application is configured to use. 

By default, we subscribe an application when it is created to the most recent version of our APIs.  Wildfire will not auto-update your application to a new version of the APIs but you may request to have your application(s) upgraded. &#x20;

Please contact your Client Success Manager to determine your application's current API version and/or to request an upgrade. 

A V3 callback request will have a body similar to this:

```json
{
   "ID":"96d0a222-c84c-4b6b-8722-8fb8447f9565",
   "Type":"Commission",
   "Action":"create",
   "Payload":{
      "CommissionID":12345,
      "ApplicationID":0,
      "MerchantID":123456,
      "DeviceID":19283,
      "SaleAmount":{
         "Amount":"321",
         "Currency":"USD"
      },
      "Amount":{
         "Amount":"3.211",
         "Currency":"USD"
      },
      "Status":"PENDING",
      "TrackingCode":"012345-6780a-bcdef0-12345",
      "EventDate":"2019-09-12T01:22:33Z",
      "CreatedDate":"2019-09-13T02:22:33.987654Z",
      "ModifiedDate":"2019-09-13T02:22:33.987654Z",
      "MerchantOrderID":"397254095",
      "MerchantSKU":"465056245"
   },
   "CreatedDate":"2019-09-15T00:11:33.987654Z"
}
```

A V4 callback request will have a body similar to this:

```json
{
  "ID": "87f0a400-c84c-4b6b-8722-8fb8447f9565",
  "Type": "Commission",
  "Action": "create",
  "Payload": {
    "CommissionID": 775109,
    "ApplicationID": 0,
    "MerchantID": 98813,
    "DeviceID": 12345,
    "SaleAmount": {
      "Amount": "384.65",
      "Currency": "USD"
    },
    "Amounts": [
      {
        "Amount": "2.88475",
        "Currency": "USD",
        "SplitPart": "APPLICATION"
      },
      {
        "Amount": "5.7695",
        "Currency": "USD",
        "SplitPart": "DEVICE"
      }
    ],
    "Status": "PAID",
    "TrackingCode": "012345-6780a-bcdef0-74932",
    "EventDate": "2022-10-27T23:08:45Z",
    "LockingDate": "2022-10-27T23:08:45Z",
    "CreatedDate": "2022-10-27T23:08:45.898588Z",
    "ModifiedDate": "2022-10-27T23:13:45.898588Z",
    "MerchantOrderID": "1234582725",
    "MerchantSKU": "sku123nd"
  }
}
```

**V5 (Latest) Callback Response**

:::BlockQuote
\{
&#x20; "ID": "3d9f2b6a-1e4c-4a8f-9c2d-7b6e5f4a3d21",
&#x20; "Type": "Commission",
&#x20; "Action": "create",
&#x20; "Payload": \{
&#x20;   "CommissionID": 775109,
&#x20;   "ApplicationID": 0,
&#x20;   "MerchantID": 98813,
&#x20;   "DeviceID": 12345,
&#x20;   "DeviceXID": "3f9a8b2c-77d1-4e6a-9b0e-1a2b3c4d5e6f",
&#x20;   "SaleAmount": \{
&#x20;     "Amount": "384.65",
&#x20;     "Currency": "USD"
&#x20;   },
&#x20;   "Amounts": \[
&#x20;     \{
&#x20;       "Amount": "2.88475",
&#x20;       "Currency": "USD",
&#x20;       "SplitPart": "APPLICATION",
&#x20;       "BaseCommissionAmount": "2.50000",
&#x20;       "BoostedCommissionAmount": "0.38475"
&#x20;     },
&#x20;     \{
&#x20;       "Amount": "5.7695",
&#x20;       "Currency": "USD",
&#x20;       "SplitPart": "DEVICE",
&#x20;       "BaseCommissionAmount": "5.00000",
&#x20;       "BoostedCommissionAmount": "0.76950"
&#x20;     }
&#x20;   ],
&#x20;   "Status": "PAID",
&#x20;   "TrackingCode": "012345-6780a-bcdef0-74932",
&#x20;   "EventDate": "2022-10-27T23:08:45Z",
&#x20;   "LockingDate": "2022-10-27 23:08:45 +0000 UTC",
&#x20;   "CreatedDate": "2022-10-27T23:08:45.898588Z",
&#x20;   "ModifiedDate": "2022-10-27T23:13:45.898588Z",
&#x20;   "MerchantOrderID": "1234582725",
&#x20;   "MerchantSKU": "sku123nd",
&#x20;   "CouponCodes": "SAVE15OFF",
&#x20;   "ShoppingTripCode": "8f14e45f-ceea-467e-bd42-ee7b1b5f4e9c"
&#x20; },
&#x20; "CreatedDate": "2022-10-27T23:13:45.899123Z"
}
:::

- **New fields:** DeviceXID, CouponCodes, ShoppingTripCode on the payload; BaseCommissionAmount and BoostedCommissionAmount added to every entry in Amounts.
- **Status enum values:&#x20;**&#x50;ENDING, CONFIRMED, READY, PAID

:::hint{type="success"}
***Note**: \*Both of the above examples include whitespace/indentation for readability, but when generating the HMAC check to verify this callback came from Wildfire, the callback body must be evaluated without modification (i.e. it should contain no indentation/whitespace/formatting).*
:::

Example v3 body without whitespace:

```json
{"ID":"96d0a222-c84c-4b6b-8722-8fb8447f9565","Type":"Commission","Action":"create","Payload":{"CommissionID":12345,"ApplicationID":0,"MerchantID":123456,"DeviceID":19283,"SaleAmount":{"Amount":"321","Currency":"USD"},"Amount":{"Amount":"3.211","Currency":"USD"},"Status":"PENDING","TrackingCode":"012345-6780a-bcdef0-12345","EventDate":"2019-09-12T01:22:33Z","CreatedDate":"2019-09-13T02:22:33.987654Z","ModifiedDate":"2019-09-13T02:22:33.987654Z","MerchantOrderID":"397254095","MerchantSKU":"465056245"},"CreatedDate":"2019-09-15T00:11:33.987654Z"}
```

Example v4 body without whitespace:

```json
{"ID":"87f0a400-c84c-4b6b-8722-8fb8447f9565","Type":"Commission","Action":"create","Payload":{"CommissionID":775109,"ApplicationID":0,"MerchantID":98813,"DeviceID":12345,"SaleAmount":{"Amount":"384.65","Currency":"USD"},"Amounts":[{"Amount":"2.88475","Currency":"USD","SplitPart":"APPLICATION"},{"Amount":"5.7695","Currency":"USD","SplitPart":"DEVICE"}],"Status":"PAID","TrackingCode":"012345-6780a-bcdef0-74932","EventDate":"2022-10-27T23:08:45Z","LockingDate":"2022-10-27T23:08:45Z","CreatedDate":"2022-10-27T23:08:45.898588Z","ModifiedDate":"2022-10-27T23:13:45.898588Z","MerchantOrderID":"1234582725","MerchantSKU":"sku123nd"}
```

### Callback Key Values

**ID**: The callback ID.  Note that this is different from the commission ID.  Every callback request will have a unique callback ID, but it may have the same commission ID (i.e. in the case of an update).  There is a button in Partner Admin that allows a user to resend a callback to your callback receiver URL.  Every time that resend callback button is selected, a new callback will fire with a unique callback ID but the same commission ID.

**Type:** "Commission"

**Action:** "create", "update"

### Commission Payload Key Values

**CommissionID:** Unique ID for this commission, when updates are sent this ID will be the same.

**ApplicationID:** The ID of the application with which the purchase was made.

**DeviceID:** The ID for the user’s device that made the purchase.

**MerchantID:&#xA0;**&#x54;he ID for a merchant. This value can be used to match to a merchant in the JSON feed.

**SaleAmount** 

- **Amount:**  Reported sale amount from merchant. Note: Some merchants don't report sale amount, this can be 0.
- **Currency**: The original currency in which the purchase was made. This value is not converted to the application default currency.

**Amounts**: This is an array with up to two maps with data for the user’s earnings and the application’s earnings. If you pay your end user you will only see a map for the application SplitPart. If Wildfire pays your end users you will see two maps, one containing the user’s earnings and the other containing the application’s earnings.

- **Amount:&#xA0;**&#x54;he commission amount, this can be a negative number in the case of a canceled or returned order to offset the original commission (this will have a new ID).
- **Currency:** Commissions are always converted to your application's default currency (e.g. if your default currency is CAD, this value will be sent via API and callback in CAD).
- **SplitPart:&#xA0;**&#x41; split part is the amount of money allocated to one or two entities depending on the configuration of your application(s). In instances where you pay your end users directly, you will only ever see an *Application* split part. If Wildfire pays your end users on your behalf, this response will include both the *Application* SplitPart and the *Device* (end user) SplitPart.   Note: SplitPart was added in v4 of commission records.
  - **Application:** Represents your portion of a commission.
  - **Device:** Represents the end user's portion of a commission. Only present in cases where Wildfire is paying your end user.

**TrackingCode:** This is the value referred to [Tracking Code (TC) Parameter](docId\:r4SMk3A-lbpFBj1L2LUrb)

**EventDate:** Timestamp for when the order was placed.

**CreatedDate:** Timestamp for when the commission was entered into our database.

**ModifiedDate:** Timestamp for the last time this commission was modified in our database.

**LockingDate:** The period of time that the merchants give themselves to reverse or adjust a commission.

**MerchantOrderID:** Order ID provided by the merchant for this commission. Note\:This value may be blank, not every merchant reports an order ID.

**MerchantSKU:** SKU number for item purchased. Note: This value may be blank, not every merchant reports SKU values.

### Callback Headers

The headers for a callback will look like this:

```json
{
  "User-Agent": "Wildlink_Callback_Bot/1.0",
  "Content-Length": "412",
  "Cache-Control": "no-cache",
  "Content-Type": "application/json",
  "X-Wf-Signature": "sha256=c8abc5baf0a109d3365f90b1f783a9f71eaecd1746fcf39b9b4b1b3417b84cca",
  "Accept-Encoding": "gzip"
}
```

Note the "X-WF-Signature" value is the HMAC encoded value of the POST body using a sha256 encoding type and using the Callback Key value that you set.  A PHP example for how to generate this signature (to compare it to the one in the headers to verify that the request is authentic) looks like this:

```Text
$post_body = file_get_contents('php://input');
$signature = hash_hmac("sha256", $post_body, $callback_key);
```

:::hint{type="success"}
**Note:&#xA0;**&#x41;ltering the body of the callback sent by Wildfire will result in a mismatched signature.
:::

### Retry logic and ensuring against missed records

At the time of the writing of this article, Wildfire does not support retrying failed callbacks.  Because of this we recommend using the API calls (see [get all commissions](https://documenter.getpostman.com/view/24961/RWgqVyV2#5cc69c1d-fb39-4231-894e-7acf25487c6f)) on a regular basis (i.e. hourly) to compensate for the possibility of incomplete callbacks.

### How to get started with commission callbacks

If you would like to set up commission callbacks, you may do so via the Partner Admin under a given application's settings screen:

1. Navigate to https\://platform.wildlink.me/
2. Select the application you'd like to configure callbacks for.
3. Select the three dots overflow menu in the top right. (See Fig 1)
4. Select "Settings" from the menu.
5. Input the callback URL (this needs to be a full URL available to the public) and callback key (this can be any value you choose) you'd like to use. (See Fig 2)
6. Select the callback version you'd like to use (the newest version is usually preferred as it includes more details about each commission record).
7. Save.  Note: It can take a few minutes before the changes take effect.

Once you set up your callback settings, you'll be able to resend callbacks from the commission history to test your receiving script (See Fig 3).

![](https://api.archbee.com/api/optimize/wthfaKSfl2GjN63-tET7T/gLohWU1AxMKjma7oqmZqD_wildlink-partner-admin-1.png "Fig 1 - Navigating to the application settings")

![](https://api.archbee.com/api/optimize/wthfaKSfl2GjN63-tET7T/sQ28Hqtv54Ha286lvuB_R_wildlink-partner-admin-2.png "Fig 2 - Configuring callbacks for the application")

![](https://api.archbee.com/api/optimize/wthfaKSfl2GjN63-tET7T/RIqxrsitV4kkROsdiUb0w_wildlink-partner-admin.png "Fig 3 - Triggering callback re-sends for testing")

## Order-level vs. Order-item level Commission Records: Understanding the Differences

Understanding the relationship between orders and commissions is an important part of any partner integration process. It allows our partner to track earnings and determine the amount of commission that should be paid to users. There are two main types of commission reporting: order-level and order-item level.

### Order-Level Commission Reporting

Some merchants provide order-level commission reporting, where entire orders are grouped together as a single record. In these cases, returns are updated as amounts to the existing commission ID. The commission ID remains the same between the initial and updated records, but the modified date and amounts change.

Here is an example of an order-level commission report for an original purchase:

```json
{
    "CommissionID": 31870476,
    "ApplicationID": 104,
    "MerchantID": 5479397,
    "DeviceID": 15319832,
    "SaleAmount": {
        "Amount": "60.99",
        "Currency": "USD"
    },
    "Amounts": [
        {
            "Amount": "1.2500",
            "Currency": "USD",
            "SplitPart": "APPLICATION"
        }
    ],
    "Status": "PENDING",
    "EventDate": "2023-02-02T17:26:55Z",
    "LockingDate": "2023-05-01T05:00:00Z",
    "CreatedDate": "2023-02-02T18:53:58.106991Z",
    "ModifiedDate": "2023-02-02T18:53:58.106991Z",
    "MerchantOrderID": "6327180345",
    "MerchantSKU": ""
}
```

And here is an example of an order-level commission report for a partial return:

```json
{
    "CommissionID": 31870476,
    "ApplicationID": 104,
    "MerchantID": 5479397,
    "DeviceID": 15319832,
    "SaleAmount": {
        "Amount": "44.96",
        "Currency": "USD"
    },
    "Amounts": [
        {
            "Amount": "0.2925",
            "Currency": "USD",
            "SplitPart": "APPLICATION"
        }
    ],
    "Status": "PENDING",
    "EventDate": "2023-02-02T17:26:55Z",
    "LockingDate": "2023-05-01T05:00:00Z",
    "CreatedDate": "2023-02-02T18:53:58.106991Z",
    "ModifiedDate": "2023-03-25T10:44:56.526455Z",
    "MerchantOrderID": "6327180345",
    "MerchantSKU": ""
}
```

:::hint{type="info"}
Note that in this case the CommissionID and the MerchantOrderID (aka the Order ID) stays the same and only the SaleAmount and Amount (aka the Commission Amount) and ModifiedDate change to reflect the updated order.
:::

Most merchants, on the other hand, provide order-item level commission reporting. In this method, every item in an order is posted as a separate commission record. Items and returns are recorded separately, each with their order-item amounts and a separate commission ID. This method is often referred to as "ledger-style."

Here is an example of an order-item level commission report for an original purchase:

```json
{
     "CommissionID": 32736944,
     "ApplicationID": 156,
     "MerchantID": 5479868,
     "DeviceID": 18156054,
     "SaleAmount": {
         "Amount": "67.99",
         "Currency": "USD"
     },
     "Amounts": [
         {
             "Amount": "1.632",
             "Currency": "USD",
             "SplitPart": "APPLICATION"
         }
     ],
     "Status": "PENDING",
     "EventDate": "2023-03-04T21:04:00Z",
     "LockingDate": "0001-01-01T00:00:00Z",
     "CreatedDate": "2023-03-06T15:24:36.611096Z",
     "ModifiedDate": "2023-03-07T02:57:58.5251Z",
     "MerchantOrderID": "M2673245040",
     "MerchantSKU": "15406898"
 },
 {
     "CommissionID": 32736945,
     "ApplicationID": 156,
     "MerchantID": 5479868,
     "DeviceID": 18156054,
     "SaleAmount": {
         "Amount": "109",
         "Currency": "USD"
     },
     "Amounts": [
         {
             "Amount": "2.616",
             "Currency": "USD",
             "SplitPart": "APPLICATION"
         }
     ],
     "Status": "PENDING",
     "EventDate": "2023-03-04T21:04:00Z",
     "LockingDate": "0001-01-01T00:00:00Z",
     "CreatedDate": "2023-03-06T15:24:37.236906Z",
     "ModifiedDate": "2023-03-07T02:58:07.931103Z",
     "MerchantOrderID": "M2673245040",
     "MerchantSKU": "15453724"
 }
```

And here is an example of an order-item level commission report for a partial return:

```json
{
     "CommissionID": 33556694,
     "ApplicationID": 156,
     "MerchantID": 5479868,
     "DeviceID": 18156054,
     "SaleAmount": {
         "Amount": "-109",
         "Currency": "USD"
     },
     "Amounts": [
         {
             "Amount": "-2.616",
             "Currency": "USD",
             "SplitPart": "APPLICATION"
         }
     ],
     "Status": "PENDING",
     "EventDate": "2023-03-04T21:04:00Z",
     "LockingDate": "0001-01-01T00:00:00Z",
     "CreatedDate": "2023-04-01T23:40:45.361252Z",
     "ModifiedDate": "2023-04-01T23:40:45.361252Z",
     "MerchantOrderID": "M2673245040",
     "MerchantSKU": "15453724"
 }
```

## Order-level initial reporting with order-item level returns

Some merchants will describe the initial purchase as a single record but subsequent returns as separate records.  See below how the initial positive amount (purchase) lists all the SKUs in a single record but each of two partial returns are reported as separate records.

```json
  {
     "CommissionID": 32753768,
     "ApplicationID": 104,
     "MerchantID": 5507506,
     "DeviceID": 15815011,
     "SaleAmount": {
         "Amount": "163.6",
         "Currency": "USD"
     },
     "Amounts": [
         {
             "Amount": "3.1902",
             "Currency": "USD",
             "SplitPart": "APPLICATION"
         }
     ],
     "Status": "PENDING",
     "EventDate": "2023-03-06T23:24:12Z",
     "LockingDate": "2023-05-05T00:00:00Z",
     "CreatedDate": "2023-03-07T01:17:09.578311Z",
     "ModifiedDate": "2023-03-07T01:17:09.578311Z",
     "MerchantOrderID": "4042006870",
     "MerchantSKU": "99104147967,99104150039,99106898030,99106898040,99106898090,99107014510"
 }
```

And here is an example of an order-item level commission report for a partial return:

```json
 {
     "CommissionID": 32910383,
     "ApplicationID": 104,
     "MerchantID": 5507506,
     "DeviceID": 15815011,
     "SaleAmount": {
         "Amount": "-31.6",
         "Currency": "USD"
     },
     "Amounts": [
         {
             "Amount": "-0.6162",
             "Currency": "USD",
             "SplitPart": "APPLICATION"
         }
     ],
     "Status": "PENDING",
     "EventDate": "2023-03-06T23:24:12Z",
     "LockingDate": "2023-05-05T00:00:00Z",
     "CreatedDate": "2023-03-14T12:19:50.66962Z",
     "ModifiedDate": "2023-03-14T12:19:50.66962Z",
     "MerchantOrderID": "4042006870",
     "MerchantSKU": "99104150039"
 }
```

## Conclusion

Wildfire Systems is trying hard to make merchant data more normalized and though we have tried to standardize around order-item level reporting, some merchants don't provide enough detail to allow us to do that.  We are actively considering ways to make the data more normalized, including standardizing around order-level reporting.  In the meantime, it's appropriate to design your systems in such a way that they can work with the aforementioned use cases and reach out to us if you have any questions.

