Usage and Billing Portal
Get Session Token
2 min
to interact with amberflo via the api, ui kit, or amberflosdk, you first need to create a session token the recommended approach is to retrieve this token from an endpoint on your server on the client side—especially in single page applications built with frameworks like react—you can then use the browser’s fetch function to request the token this setup ensures security and smooth integration between your frontend and amberflo services for more information check api reference this example shows how to create the server endpoint that serves the client secret const express = require('express'); const app = express(); const request = require('request'); app get('/amberflo session', async (req, res) => { request({ method 'post', uri 'https //app amberflo io/session', body { "customerid" "{{desired customer id}}, "expirationepochmilliseconds" {{expiration date in milliseconds}} }, headers { "x api key" "{{your api key}}" } }, function (error, response, body) { if (!error && response statuscode == 200) { res json({ sessiontoken response sessiontoken }) } } ); }) 📘 the above example is in node js you can get x api key from amberflo site inside settings > account > api keys you can also get the customerid from amberflo site inside customers → click on a customer → copy customer id this example demonstrate how to fetch the session token with javascript in the client side const response = fetch('/amberflo session') then(function(response) { return response json(); }) then(function(responsejson) { const sessiontoken = responsejson sessiontoken })