How to add a Webhook notification to TokenDNS?

photo-1429051883746-afd9d56fbdaf

What is a Webhook?

A Webhook is a HTTP POST call that will send a message to your server or application. This is mainly used for deeper integrations. Lets say you have a DNS caching service running and need to flush the record that just got changed to have immediately access.
But basically everything is possible with a Webhook and thats why it was important to us that its available from the beginning.

What do I need to use a Webhook with TokenDNS?

First you need to have a HTTP/HTTPS endpoint where we can send the POST message to. Most of the time this is a webserver which should offer SSL.

How does the payload look like?

{
  "domain": "www22.blabladns.xyz",
  "content": "188.166.134.64",
  "message": "Record www22.blabladns.xyz reserved for A with 188.166.134.64"
}

Example Webhook in PHP:

<?php
$tokendns = json_decode(file_get_contents('php://input'));
$domain = $tokendns->{domain};
$content = $tokendns->{content};
$message = $tokendns->{message};
// do something....
?>

This is a very small example and should never go into production like this, but it will makes it very easy for you to integrate the webhook in your services.

How to enable a Webhook Notifications?

When you have your Webhook and script ready. Just head over to the BlaBlaDNS settings and select Webhook from the pulldown menu. Add your endpoint and be ready for some incoming data.

blabladns-add-notification

I want to use the API!

I hear you and like it. Easy as you know it:

curl --get "https://api.tokendns.co/v1/notifications" \
  -d apikey=${apikey} \
  -d action=add
  -d provider=webhook
  -d webhook=${webhook_url}

Leave a Reply

Your email address will not be published. Required fields are marked *