Configuring Webhooks

Live events from the TonicPow API

TonicPow will send events related to your application to the webhook URL you specify when creating an application. You can expect webhooks to arrive as a POST request to the endpoint you provide, and it should return a 200 when called.

Method: POST
Expected Response: 200 (StatusOK)

Action Types

The following are the various action types you can expect to receive from the TonicPow API via webhook, and the structure of the data contained in the request.

Clicks

Click webhook will be triggered after a click that was batched has been processed and a txid was broadcasted to the Bitcoin network.

{
  "type": "click",
  "data": {
    "amount": number,        // amount in satoshis
    "campaign_id": number,   // associated campaign id
    "campaign_slug": string, // campaign URL slug
    "tncpw_session": string, // visitor session
    "tx_id": string,         // payout tx_id
  }
}

Conversions

Conversion webhook will be triggered after a conversion that was batched has been processed and a txid was broadcasted to the Bitcoin network.

{
  "type": "conversion",
  "data": {
    "amount": number,        // amount in satoshis
    "campaign_id": number,   // associated campaign id
    "campaign_slug": string, // campaign URL slug
    "tncpw_session": string, // visitor session
    "tx_id": string,         // payout tx_id
    "goal_id": number,       // associated goal id
  }
}

Testing Your Webhook

Once you have a webhook added to your application, you can manually trigger test events to preview what a valid webhook would send you when triggered. To do this, you can click the "Test Click" and "Test Conversion" buttons from the app details page.

When testing a webhook, you will receive a payload that is identical in format to what will be sent, except the "type" field will be prefixed with "test_", so testing a click will produce a payload that looks like a typical click, but will have a dummy value for campaign ID, and "test_click" for the payload type.


Next: Firing Conversions

Subscribe to our newsletter

The latest news, articles, and resources, sent to your inbox weekly.

© 2021 TonicPow, Inc. All rights reserved.