Introduction to Kayna

Embedded Insurance Infrastructure enabling Distribution through Vertical SaaS

Kayna provides the technology & data orchestration layer between Carriers and Brokers and any Vertical SaaS platform to distribute insurance products that are directly relevant to platform customers.

  • Platforms leverage data to unlock new revenue streams and add value for customers.
  • Customers get accurate, data-led, right-sized insurance with automated quote, renewal, claims process.
  • Carriers/Brokers gain new Insurance distribution channels.

Getting Started

To get started, you must request credentials for your organisation. Please send a mail to dev-access@kayna.io containing the following information:

  • Company's Name
  • Company's Website
  • Company's Details (Tell us a little about your company, what you do, your customers etc)
  • Contact Name
  • Contact Email Address
  • Contact Number

Request Access

Widget Integration

The Kayna Widget documentation provides a quick guide to seamlessly integrate insurance products into Vertical SaaS platforms.

Fetching the Token

Widget Integration Get Token Endpoint Setup​

Important Note: It’s important to keep your platform credentials secure, make sure to not expose your Access Key and Secret in your client side code. The Access Key and Secret should only be used from your secure servers. You can create a new endpoint on your servers that returns a token to your client side code.

Create a new 'authorizer' API on your Platform serverIn the API, call Kayna's authorizer API with the following payload:'accessKey' - Get it from Kayna Dashboard'secret' - Get it from Kayna Dashboard'extCustomerId' - This is a unique identifier for each of your customers. This identifier will be a shared reference between Kayna and your systems. You can use an existing ID or you can create a new ID to share with Kayna. You can choose the format of this identifier and it should be stored in your systems for future reference.Return the received 'token' as a response from the API

Important: Just a reminder, it's crucial to integrate this API on your server and not on the client side. This precaution ensures that the keys used to acquire the token remain hidden and secure, preventing their exposure in the developer tools.

Get Token

 
POST https://staging-api.kayna.io/authorizer/token

Payload

Parameter Type Description
accessKey string Required. Your Platform's Access key
secret string Required. Your Platform's Secret key
extCustomerId string Required. The ID of the Platform user

Response

Parameter Type Description
token string Token that will initialize the widget

If you would like to see an example of how this can be implemented, we have made an example here

Adding Kayna Widget

  • Place the Kayna widget CDN link in your web page
  • Call your Authorizer API to securely generate a token
  • Use the Generated Token to create the kaynaKeys object
  • Initialise the Kayna widget passing the required style, data and keys objects

Kayna Config

Parameters

const kaynaParams = {
  extCustomerName: '...',
  extCustomerEmail: '...',
  extCustomerID: customerID,
  productId: '...', // given by kayna
  applicationFormData: {...}
};

Keys

const keys = {
  token: token,
  platformId: "...", // obtained from kayna dashboard
};

Styles

const style = {
  width: "...",
  height: "...",
  primaryColor: "...",
  secondaryColor: "...",
};

Adding Widget

Add an empty div

<div id="kayna"></div>

Include the widget

<script
  type="text/javascript"
  src="https://staging-widget.kayna.io/kayna.js"
  defer
</script>


Get the token

const response = await fetch(`${apiUrl}/authorizer/token`, {...})


Initialize the widget

window.Kayna.init(kaynaParams, {
  style,
  keys,
});

Great news! Your widget has been successfully integrated!

If you would like to see an example of how this can be implemented, we have made an example here

Widget Demo

Let's discover Kayna Widget.

You can make changes to the data passed to the widget by changing the values in the following JSON and then click Update
{
  "params": {
    "extCustomerName": "John Doe",
    "extCustomerEmail": "john@doe.com",
    "extCustomerID": "a22d6384c51b",
    "productId": "7",
    "applicationFormData": {
      "contact": {
        "firstName": "John",
        "lastName": "Doe",
        "businessName": "ABC Limited",
        "phone": "(254) 234-2453"
      },
      "quote": {
        "partners": 1
      },
      "equity partners": {
        "partnerName0": "Jane Doe",
        "partnerEquity0": 50,
        "partnerTaxId0": "789123 ABC"
      },
      "questions": []
    }
  },
  "style": {
    "width": "100%",
    "height": "455px",
    "primaryColor": "#6768f6",
    "secondaryColor": "#ffffff",
    "theme": "night"
  },
  "keys": {
    "token": null,
    "widgetType": "kayna",
    "platformId": "14"
  }
}

Support

If you ever find yourself in need of support or have any questions, please know that we're here for you. Don't hesitate to reach out to us via email at info@kayna.io.

At Kayna, our dedicated team is committed to providing assistance that goes above and beyond. Whether you have inquiries about creating an account, completing forms, or any other aspect of our service, we're ready to provide timely and thoughtful responses. Your satisfaction is our top priority, and we're excited to be a part of your journey with Kayna.

Feel free to connect with us; we're always here to help make your experience as smooth as possible.

Create endpoint to fetch token (Example Implementation)

Create a new endpoint in your server:

Important: To safeguard the security of the keys used for token acquisition and prevent their exposure in developer tools, it's crucial to integrate this API on the server side. This underscores the need to create a new endpoint on the server for this purpose.
npm install express body-parser axios dotenv

.env

TOKEN_ENDPOINT="https://staging-api.kayna.io/authorizer/token"
ACCESS_KEY="..."
SECRET_KEY="..."
const express = require("express");
const axios = require("axios");
require("dotenv").config();

const app = express();
const port = 3000;

const tokenEndpoint = process.env.TOKEN_ENDPOINT;
const accessKey = process.env.ACCESS_KEY;
const secretKey = process.env.SECRET_KEY;

async function fetchToken(extCustomerId) {
  const response = await axios.post(tokenEndpoint, {
    accessKey: accessKey,
    secret: secretKey,
    extCustomerId: extCustomerId,
  });

  return response.data.token;
}

app.post("/authorizer/token", async (req, res) => {
  try {
    const { extCustomerId } = req.body;

    const token = await fetchToken(extCustomerId);

    res.json({ token });
  } catch (error) {
    console.error("Error fetching token:", error);
    res.status(500).json({ error: "Internal Server Error" });
  }
});

app.listen(port, () => {
  console.log(`Server is running on http://localhost:${port}`);
});

Just a heads up, this is just an example of how you might add a new endpoint to fetch a token via the API using JS and EXPRESS. Keep in mind that the actual steps could vary depending on the platform's technology stack. Feel free to adapt it as needed!

Adding Kayna Widget (Example Implementation)

<html>
  <head>
    <!-- Add your head elements here -->
  </head>
  <body>
    <!-- Add your body content here -->
    <div id="kayna"></div>
    
    <script type="text/javascript" src="https://staging-widget.kayna.io/kayna.js" defer></script>
    
    <script type="text/javascript">
      const apiUrl = "..."; // your Authorizer API url
      const customerID = "..."; // your customers ID

      const body = document.querySelector('body');
      body.onload = async function () {
        try {
          const response = await fetch(`${apiUrl}/authorizer/token`, {
            method: 'POST',
            headers: {
              'Content-Type': 'application/json',
            },
            body: JSON.stringify({
              extCustomerID: customerID
            }),
          });

          if (!response.ok) {
            throw new Error('Failed to fetch token');
          }

          const data = await response.json();
          const token = data.token;

          const kaynaParams = {
            extCustomerName: '...',
            extCustomerEmail: '...',
            extCustomerID: customerID,
            productId: '...', // given by kayna
            applicationFormData: {...}
          };

          const style = {
            width: '...',
            height: '...',
            primaryColor: '...',
            secondaryColor: '...',
          };

          const keys = {
            token: token,
            platformId: '...' // obtained from kayna dashboard
          };

          window.Kayna.init(kaynaParams, {
            style,
            keys
          });
        } catch (error) {
          console.error('Error during initialization:', error);
        }
      };
    </script>
  </body>
</html>

Great news! Your widget has been successfully integrated!

Just a heads up, this is just an example of how you might integrate a widget using HTML and JS. Keep in mind that the actual steps could vary depending on the platform's technology stack. Feel free to adapt it as needed!