Retreive Booking Updates

We provide you with two tools to get up-to-date information about your Booking NFTs: a GET Request (A) or a webhook (B) that sends you events about important changes to your bookings (e.g. change of owner).

You will then need this information to update your systems and only provide your users with up-to-date information.

We suggest in general to implement the webhook system (more secure) and to use GET calls when necessary.

A - Checking NFT Status & Ownership via GET Request

People will be able to sell and buy NFTs on our platform. To retrieve information about the current guests of the NFT use this endpoint

We suggest creating a daily batch job to gather updated information about the NFT, or check the guests of the NFT after the lockDate. Note that takyon will send an email when the NFTs locks.

const URI = "https://staging-api.takyon.io/v2";
const nft_id = "503dda97-5a1b-4b17-a831-2f18a45c80ed"
const apikey = "1fed1306-3645-42d0-97d5-a39afa3195fa";

// SINGLE GET
(async () => {
  const rawRes = await fetch(URI + "/nft/" + nft_id, {
    headers: {
      API_KEY: apikey,
    },
  });

  const res = await rawRes.json();

  console.log(res);
})();

// PAGINATION GET
(async () => {
  const rawRes = await fetch(URI + "/nft/paginate" + '?page=1&size=5', {
    headers: {
      API_KEY: apikey,
    },
  });

  const res = await rawRes.json();

  console.log(res);
})();

// RESPONSE 

{
  ...,
  accessStatus: "OPEN" // OR "REDEEMED",
  owner: "cody.martin@gmail.com",
  guests: [
    {
      "firstName": "Cody",
      "secondName": "Martin",
      "email": "cody.martin@gmail.com"
    },
    ...
  ]
}

When the NFT is "REDEEMED" the owner will not change anymore, but the guests might do. If the NFT is "OPEN" it can be traded. If the guests array is empty, you should use the email in the owner key.

B - Retrieving Events regarding the Booking in the Takyon Platform via Webhook

You can create your custom webhooks from the Takyon dashboard. Visit /account/developer. Takyon will call the webhook whenever some crucial changes to the booking will occur. The payload of the request's body will be encrypted using AES. You can find the secret decrypting key by visiting /account/developer. The request will be a JSON, the information you need to decrypt will be in the "data" key of the body of the request.

If your system throws an error, or is not reachable, Takyon will try to resend the request up to 5 times, every 30 minutes. You can monitor the requests in /account/developer by clicking on "view webhook logs". You can also call the webhook manually from that section.

If you need help decrypting the data contact our support.

const CryptoJS = require("crypto-js");

function decrypt(data, key) {
  const bytes = CryptoJS.AES.decrypt(data, key);
  return JSON.parse(bytes.toString(CryptoJS.enc.Utf8));
}

app.post("/", function (req, res) {
  const decrypted_data = decrypt(req.body.data, "YOUR_WEBHOOK_SECRET_KEY_HERE");

  // do something with decrypted_data

  res.send({ status: "ok" }); // return anything you want
});

// The decrypted data will have this structure:

{
  event: 'DELETE',
  payload: {
    lang: 'en',
    sellStatus: 'NOT_FOR_SALE',
    accessStatus: 'REDEMEED',
    ownerType: 'ORIGINAL',
    _id: 'a6f1fc80-a185-4216-bab7-fe6295a2908b',
    collectionId: 'ce2bb8e9-ffde-4138-bc3a-bb00b879e9ec',
    collectionAlias: 'YOUR_COLLECTION_ALIAS', // if you set one
    gold: false,
    owner: 'cody.martin@test.com',
    lockDate: '2023-03-01T22:59:00.000Z',
    guests: [
      {
        "firstName": "Cody",
        "secondName": "Martin",
        "email": "cody.martin@test.com"
      },
      ...
    ],
    originalPrice: 555,
    payload: {
      reference: "1x123456",
      rooms: [...],
      hotel: 'Hotel Venecia',
      stars: '4',
      email: 'info@grandhotel.com',
      website: 'www.grandhotel.com',
      location: [...],
      note: 'Grand Hotel',
      checkin: '2023-03-01T23:00:00.000Z',
      checkout: '2023-03-03T22:59:00.000Z'
    },
    images: [...],
    _createdAt: '2023-02-01T21:14:18.498Z',
    _updatedAt: '2023-02-28T11:07:26.853Z'
  },
  _owner: {
    email: zac.martin@gmail.com,
    phone: "3472223344", // optional
    phonePrefix: "+39", // optional
    firstName: "Zac", // optional
    secondName: "Martin˙", // optional
  },
  _previousOwner: {
    email: cody.martin@gmail.com,
    phone: "34722234321", // optional
    phonePrefix: "+39", // optional
    firstName: "Cody", // optional
    secondName: "Martin˙", // optional
  },
  _originalOwner: {
    email: london.tipton@gmail.com,
    phone: "34722235533", // optional
    phonePrefix: "+39", // optional
    firstName: "London", // optional
    secondName: "Lipton", // optional
  }
}

Decrypted Data

The decrypted data will have this structure. Note: If you set a Collection Alias, the payload will include the Collection Alias you set.

You can monitor the status of the requests in /account/developer by clicking on "view webhook logs". From there you are able to check the status of each request and monitor the responses generated by your systems.

Last updated