Skip to main content
POST
/
ui
/
initSession
Init Session
curl --request POST \
  --url https://partner.peaka.studio/api/v1/ui/initSession \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "timeoutInSeconds": 300,
  "projectId": "projectId",
  "theme": "dark",
  "themeOverride": true,
  "featureFlags": {
    "feature1": true,
    "feature2": false
  }
}
'
import requests

url = "https://partner.peaka.studio/api/v1/ui/initSession"

payload = {
"timeoutInSeconds": 300,
"projectId": "projectId",
"theme": "dark",
"themeOverride": True,
"featureFlags": {
"feature1": True,
"feature2": False
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
timeoutInSeconds: 300,
projectId: 'projectId',
theme: 'dark',
themeOverride: true,
featureFlags: {feature1: true, feature2: false}
})
};

fetch('https://partner.peaka.studio/api/v1/ui/initSession', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://partner.peaka.studio/api/v1/ui/initSession",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'timeoutInSeconds' => 300,
'projectId' => 'projectId',
'theme' => 'dark',
'themeOverride' => true,
'featureFlags' => [
'feature1' => true,
'feature2' => false
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://partner.peaka.studio/api/v1/ui/initSession"

payload := strings.NewReader("{\n \"timeoutInSeconds\": 300,\n \"projectId\": \"projectId\",\n \"theme\": \"dark\",\n \"themeOverride\": true,\n \"featureFlags\": {\n \"feature1\": true,\n \"feature2\": false\n }\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://partner.peaka.studio/api/v1/ui/initSession")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"timeoutInSeconds\": 300,\n \"projectId\": \"projectId\",\n \"theme\": \"dark\",\n \"themeOverride\": true,\n \"featureFlags\": {\n \"feature1\": true,\n \"feature2\": false\n }\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://partner.peaka.studio/api/v1/ui/initSession")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"timeoutInSeconds\": 300,\n \"projectId\": \"projectId\",\n \"theme\": \"dark\",\n \"themeOverride\": true,\n \"featureFlags\": {\n \"feature1\": true,\n \"feature2\": false\n }\n}"

response = http.request(request)
puts response.read_body
{
  "sessionUrl": "https://partner.peaka.studio/api/v1/ui/session?code=2eccdbf31efa110943b470b9023e9a52587c166e4d1c21f23fabbcd7de5b74ab"
}

Authorizations

Authorization
string
header
required

Use the Authorization header with the value 'Bearer ' to authenticate. Partner API Keys have full access; Project API Keys are limited to their project scope. Learn more: https://docs.peaka.com/api-reference/authentication

Body

application/json

Session Initialization Request

projectId
string

The project ID.

theme
string

The theme to be used.

sessionMode
enum<string>

The session mode, determining the type of session to be initialized.

Available options:
CONNECTOR_MODAL_ONLY,
FULL_STUDIO
themeOverride
boolean

Flag indicating whether the theme should be overridden.

timeoutInSeconds
integer<int32>

The timeout duration in seconds.

Response

200 - */*

Session created successfully

sessionUrl
string

The URL of the Embedded Peaka session to be followed.

It is a one-time use URL that will redirect the user to the Peaka session.

partnerOrigin
string

The origin of the partner that the embedded studio is coming from.