Create Session
curl --request POST \
--url https://api.pathors.com/project/{projectId}/session \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"session_id": "<string>",
"variables": {},
"provider": "<string>"
}
'import requests
url = "https://api.pathors.com/project/{projectId}/session"
payload = {
"session_id": "<string>",
"variables": {},
"provider": "<string>"
}
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({session_id: '<string>', variables: {}, provider: '<string>'})
};
fetch('https://api.pathors.com/project/{projectId}/session', 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.pathors.com/project/{projectId}/session",
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([
'session_id' => '<string>',
'variables' => [
],
'provider' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"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.pathors.com/project/{projectId}/session"
payload := strings.NewReader("{\n \"session_id\": \"<string>\",\n \"variables\": {},\n \"provider\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
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.pathors.com/project/{projectId}/session")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"session_id\": \"<string>\",\n \"variables\": {},\n \"provider\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.pathors.com/project/{projectId}/session")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"session_id\": \"<string>\",\n \"variables\": {},\n \"provider\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"sessionId": "<string>",
"pathwayId": "<string>"
}Deprecated APIs
Create Session
Create a new session with optional initial variables for conversation continuity.
POST
/
project
/
{projectId}
/
session
Create Session
curl --request POST \
--url https://api.pathors.com/project/{projectId}/session \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"session_id": "<string>",
"variables": {},
"provider": "<string>"
}
'import requests
url = "https://api.pathors.com/project/{projectId}/session"
payload = {
"session_id": "<string>",
"variables": {},
"provider": "<string>"
}
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({session_id: '<string>', variables: {}, provider: '<string>'})
};
fetch('https://api.pathors.com/project/{projectId}/session', 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.pathors.com/project/{projectId}/session",
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([
'session_id' => '<string>',
'variables' => [
],
'provider' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"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.pathors.com/project/{projectId}/session"
payload := strings.NewReader("{\n \"session_id\": \"<string>\",\n \"variables\": {},\n \"provider\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
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.pathors.com/project/{projectId}/session")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"session_id\": \"<string>\",\n \"variables\": {},\n \"provider\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.pathors.com/project/{projectId}/session")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"session_id\": \"<string>\",\n \"variables\": {},\n \"provider\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"sessionId": "<string>",
"pathwayId": "<string>"
}Deprecated. This endpoint is deprecated and will be sunset on 2026-07-11. It still works until then. Migrate to the V1 path — see the migration guide for the old -> new path table.
Base URL
https://api.pathors.com
Create Session
POST https://api.pathors.com/project/{projectId}/session
Path Parameters
string
required
The ID of your project
Request Headers
string
required
Bearer token authentication using your Project API Key (starts with
sk_). Format: Bearer {your-api-key}Request Body
string
required
A unique identifier for the session. This can be any string you choose to identify the conversation session.
object
Optional initial session variables that can be used within the pathway. These variables can be referenced in your pathway configuration.
string
Optional provider specification for the session (e.g., “api”, “web”)
Response
string
The created session ID (same as the one provided in the request)
string
The pathway ID for this project
Example
Request
curl -X POST https://api.pathors.com/project/{projectId}/session \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"session_id": "user-123-session-456",
"variables": {
"userName": "John Doe",
"userRole": "admin",
"customData": "value"
},
"provider": "api"
}'
Response
{
"sessionId": "user-123-session-456",
"pathwayId": "project-id-xxx"
}
Usage Notes
- Session ID: Choose a unique identifier for each conversation. This could be a UUID, user ID + timestamp, or any other unique string.
- Variables: Session variables can be used within your pathway logic. They persist throughout the session and can be referenced in conversation flows.
- Reusability: Once created, the session can be used in multiple completion requests by including the
session_idparameter orX-Session-IDheader.
Error Responses
| Status Code | Description |
|---|---|
| 400 | Missing or invalid session_id |
| 401 | Invalid authentication |
| 500 | Internal server error |
{
"error": "session_id is required"
}
{
"error": {
"message": "Invalid authentication"
}
}
Related APIs
- End Session - End an existing session when the conversation is complete
