Skip to main content
POST
/
external
/
v1
/
ai
/
agent_graph
/
init
Init Session
curl --request POST \
  --url https://api.example.com/external/v1/ai/agent_graph/init \
  --header 'Content-Type: application/json' \
  --data '
{
  "businessId": "<string>",
  "clientKey": "<string>"
}
'
import requests

url = "https://api.example.com/external/v1/ai/agent_graph/init"

payload = {
"businessId": "<string>",
"clientKey": "<string>"
}
headers = {"Content-Type": "application/json"}

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

print(response.text)
const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({businessId: '<string>', clientKey: '<string>'})
};

fetch('https://api.example.com/external/v1/ai/agent_graph/init', 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://api.example.com/external/v1/ai/agent_graph/init",
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([
'businessId' => '<string>',
'clientKey' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"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://api.example.com/external/v1/ai/agent_graph/init"

payload := strings.NewReader("{\n \"businessId\": \"<string>\",\n \"clientKey\": \"<string>\"\n}")

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

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://api.example.com/external/v1/ai/agent_graph/init")
.header("Content-Type", "application/json")
.body("{\n \"businessId\": \"<string>\",\n \"clientKey\": \"<string>\"\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.example.com/external/v1/ai/agent_graph/init")

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

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"businessId\": \"<string>\",\n \"clientKey\": \"<string>\"\n}"

response = http.request(request)
puts response.read_body
{
  "response.sessionId": "<string>"
}
Call this endpoint before sending any messages to a Connectly AI agent. It creates a new conversation session scoped to a specific customer and returns a sessionId you must pass to every subsequent invoke and close request.

Endpoint

POST https://api.connectly.ai/external/v1/ai/agent_graph/init

Request body

businessId
string
required
Your Connectly business identifier.
clientKey
string
required
A unique identifier for the customer starting the conversation. Use a stable ID from your own system (e.g. a customer ID or phone number) so you can correlate sessions with users.

Response

response.sessionId
string
The unique identifier for this conversation session. Save this value — you must include it in all subsequent invoke and close calls for this conversation. Sessions are isolated; events from one session never affect another.
Store the sessionId immediately after calling this endpoint. Without it you cannot send messages or close the session.

Example

POST /external/v1/ai/agent_graph/init HTTP/1.1
Host: api.connectly.ai
x-api-key: YOUR_API_KEY
Content-Type: application/json

{ "businessId": "your-business-id", "clientKey": "customer-123" }
{
  "response": {
    "sessionId": "b6bed81c-5fda-486d-b96c-1ff3af36219a"
  }
}