# Generating a Session URL
UMI tip:
to generate a URL that you can embed in your website (if you are a partner or a GOLD user) you will use the same baseurl as seen in the getting started page
# Getting a game url
The game url is composed depending on your needs. the basic data needed will be
const requestData = { userId : UMI_PLAYER_ID, adminId: YOUR_PARTNER_ID}
//or if you don't want ot register users in UMI
const requestData = {externalUserId: YOUR_INTERNAL_USER_ID,
adminId: YOUR_PARTNER_ID }
//and
requestData.experienceId = EXPERIENCE_OR_GAME_ID;
requestData.publicKey = YOUR_API_KEY;
If you want to track the user (attaching the user to a organization) you will have to provide a parentId or a externalParentId.
Keep in mind that the publicKey provided must have permission to get both the user and the experience.
For example if you have the following hierarchy
Company: ACME1, isRoot: true
Company RECRE0, isRoot. false, child of ACME1
experience "SALES" by a RECRE0 user
Company PRONY child of RECRE0, in your company is named "PRONY-00"
- user GIANNI
If you want to create a session for the experience SALES for GIANNI, PRONY's publicKey wont be enough. You will need at least RECRE0 publicKey but you can use ACME1 publicKey.
// Example, we will use the fake names instead of uuids.
const requestData = { experienceId: "SALES", adminId: ACME1, externalParentId: "PRONY-00",
publicKey: RECRE0_OR_ACME1_PUBLIC_KEY, redirect: false
}
fetch(baseurl + "/sessions/?redirect=false", {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify(requestData)
});
//Or
let url = baseurl + "/sessions/?";
const segments = [];
for(const key in requestData){
segments.push(`${key}=${requestData[key]}`);
}
window.location.url = url + segments.join('&');