Create / Update Booking [HOTEL]

Booking NFT Creation Request

To make your first request, send an authenticated request to the endpoint. This will create a Booking NFT.

Take a look at how you might call this method using the technology of your choice:

const URI = "https://staging-api.takyon.io/v2"

const nftdata = 
{
  "collectionId": "ce2bb8e9-ffde-4138-bc3a-bb00b879e9ec", // or your internal ID
  "owner": "cody.martin@gmail.com",
  "originalPrice": 599,
  "images": [
    "https://www.yourhosting.com/image.png",
    "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAADHQA...",
  ],
  "lockDate": "2023-02-14T22:59:00.000Z",
  "guests": [
    {
      "firstName": "Cody",
      "secondName": "Martin",
      "email": "cody.martin@gmail.com"
    },
    {
      "firstName": "Zac",
      "secondName": "Martin",
      "email": "zac.martin@gmail.com"
    }
  ],
  "lang": "en",
  "webhook": "https://your-webhook.com/",
  "payload": {
    "type": "hotel",
    "reference": "x123456",
    "checkin": "2023-02-14T23:00:00.000Z",
    "checkout": "2023-02-20T22:59:00.000Z",
    "board": "RO", // RO, BNB, HB, FB, AI
    "rooms": [
      {
        "name": "Suite",
        "guestsAdults": 2,
        "guestsKids": 1,
        "amenities": "WiFi"
      },
      {
        "name": "Junior Suite",
        "guestsAdults": 1,
        "guestsKids": 0,
        "amenities": "Television"
      }
    ],
    "extra": "Write here extra information about the booking"
  }
}

const apikey = "1fed1306-3645-42d0-97d5-a39afa3195fa";

(async () => {
  const rawRes = await fetch(URI + "/nft", {
    method: "post",
    headers: {
      "Content-Type": "application/json",
      "Authorization": `API_KEY ${apikey}`,
    },
    body: JSON.stringify(nftdata),
  });

  const res = await rawRes.json();

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

To avoid saving the Takyon collection ID in your systems you can set a custom ALIAS in /account/developer.

Keep note that the payload is customizable. We recommend using the structure provided in this example, but is possible to add information with custom keys or avoid some of the fields.

You might want to omit some of the fields of the payload (ex Hotel Name, location, website, stars ...), since this information will be customizable directly by the hotel in the Takyon dashboard and automatically placed inside the NFT.

Update an existent booking

You can update a Booking NFT simply by calling the Create Endpoint and adding "id" as a parameter of the nftData. You'll get it in the response of the Create Endpoint, after the creation call, and you can store it in your systems. Alternatively, if you don't want to save the "_id" you can also use the same "payload.reference".

Last updated