curl --request POST \
--url https://api.orion.file.ai/prod/v2/agent/sessions \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: <idempotency-key>' \
--header 'x-api-key: <api-key>' \
--data '
{
"title": "Q3 supplier invoices"
}
'import requests
url = "https://api.orion.file.ai/prod/v2/agent/sessions"
payload = { "title": "Q3 supplier invoices" }
headers = {
"Idempotency-Key": "<idempotency-key>",
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'Idempotency-Key': '<idempotency-key>',
'x-api-key': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({title: 'Q3 supplier invoices'})
};
fetch('https://api.orion.file.ai/prod/v2/agent/sessions', 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.orion.file.ai/prod/v2/agent/sessions",
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([
'title' => 'Q3 supplier invoices'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"Idempotency-Key: <idempotency-key>",
"x-api-key: <api-key>"
],
]);
$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.orion.file.ai/prod/v2/agent/sessions"
payload := strings.NewReader("{\n \"title\": \"Q3 supplier invoices\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Idempotency-Key", "<idempotency-key>")
req.Header.Add("x-api-key", "<api-key>")
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.orion.file.ai/prod/v2/agent/sessions")
.header("Idempotency-Key", "<idempotency-key>")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"title\": \"Q3 supplier invoices\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.orion.file.ai/prod/v2/agent/sessions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Idempotency-Key"] = '<idempotency-key>'
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"title\": \"Q3 supplier invoices\"\n}"
response = http.request(request)
puts response.read_body{
"session_id": "665f1c2e8a1b4c0012ab34cd",
"title": "New Chat",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"last_active_at": "2023-11-07T05:31:56Z"
}Create an agent session
Opens a conversational session owned by this API key’s workspace and returns the session_id every other agent route takes.
The session starts empty. Creating one runs no agent work — a turn is only enqueued when you ask a question.
Idempotency-Key is required, so a retry after a timeout can never leave you with two sessions.
curl --request POST \
--url https://api.orion.file.ai/prod/v2/agent/sessions \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: <idempotency-key>' \
--header 'x-api-key: <api-key>' \
--data '
{
"title": "Q3 supplier invoices"
}
'import requests
url = "https://api.orion.file.ai/prod/v2/agent/sessions"
payload = { "title": "Q3 supplier invoices" }
headers = {
"Idempotency-Key": "<idempotency-key>",
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'Idempotency-Key': '<idempotency-key>',
'x-api-key': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({title: 'Q3 supplier invoices'})
};
fetch('https://api.orion.file.ai/prod/v2/agent/sessions', 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.orion.file.ai/prod/v2/agent/sessions",
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([
'title' => 'Q3 supplier invoices'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"Idempotency-Key: <idempotency-key>",
"x-api-key: <api-key>"
],
]);
$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.orion.file.ai/prod/v2/agent/sessions"
payload := strings.NewReader("{\n \"title\": \"Q3 supplier invoices\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Idempotency-Key", "<idempotency-key>")
req.Header.Add("x-api-key", "<api-key>")
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.orion.file.ai/prod/v2/agent/sessions")
.header("Idempotency-Key", "<idempotency-key>")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"title\": \"Q3 supplier invoices\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.orion.file.ai/prod/v2/agent/sessions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Idempotency-Key"] = '<idempotency-key>'
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"title\": \"Q3 supplier invoices\"\n}"
response = http.request(request)
puts response.read_body{
"session_id": "665f1c2e8a1b4c0012ab34cd",
"title": "New Chat",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"last_active_at": "2023-11-07T05:31:56Z"
}Idempotency-Key request header — omitting it
is a 400. See Idempotent requests.Authorizations
API key for authentication
Headers
Required opaque key (max 255 chars, UUIDv4 recommended) making this request idempotent for 24h: a retry with the same key and body replays the original response with Idempotent-Replayed: true. Omitting it is a 400; reusing a key with a different body is a 422; retrying while the first request is still in flight is a 409.
Body
Human-readable name for the session.
Omit it — or send a blank string — and the session is titled "New Chat" until the agent generates a name from its first turn.
200"Q3 supplier invoices"
Response
Session created.
Opaque session identifier used by the other agent routes.
"665f1c2e8a1b4c0012ab34cd"
The submitted title, or the placeholder the agent replaces when it names the session on its first turn.
"New Chat"
When a turn was last enqueued on this session.