Create session chat
curl --request POST \
--url https://api.recoupable.dev/api/sessions/{sessionId}/chats \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"id": "<string>"
}
'import requests
url = "https://api.recoupable.dev/api/sessions/{sessionId}/chats"
payload = { "id": "<string>" }
headers = {
"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: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({id: '<string>'})
};
fetch('https://api.recoupable.dev/api/sessions/{sessionId}/chats', 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.recoupable.dev/api/sessions/{sessionId}/chats",
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([
'id' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"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.recoupable.dev/api/sessions/{sessionId}/chats"
payload := strings.NewReader("{\n \"id\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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.recoupable.dev/api/sessions/{sessionId}/chats")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"id\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.recoupable.dev/api/sessions/{sessionId}/chats")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"id\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"chat": {
"id": "<string>",
"sessionId": "<string>",
"title": "<string>",
"modelId": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"activeStreamId": "<string>",
"lastAssistantMessageAt": "2023-11-07T05:31:56Z"
}
}{
"error": "Invalid chat id"
}{
"status": "error",
"error": "<string>"
}{
"status": "error",
"error": "<string>"
}{
"status": "error",
"error": "<string>"
}{
"error": "Chat ID conflict"
}{
"status": "error",
"error": "<string>"
}Sessions
Create Session Chat
Creates a new chat inside the given session. Callers may pass { id } to claim a deterministic chat id — useful for optimistic UI flows where the client generates the id locally and then persists it. If a chat with that id already exists in this session the call is idempotent and returns the existing row; if it exists in another session, 409 is returned.
POST
/
api
/
sessions
/
{sessionId}
/
chats
Create session chat
curl --request POST \
--url https://api.recoupable.dev/api/sessions/{sessionId}/chats \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"id": "<string>"
}
'import requests
url = "https://api.recoupable.dev/api/sessions/{sessionId}/chats"
payload = { "id": "<string>" }
headers = {
"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: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({id: '<string>'})
};
fetch('https://api.recoupable.dev/api/sessions/{sessionId}/chats', 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.recoupable.dev/api/sessions/{sessionId}/chats",
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([
'id' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"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.recoupable.dev/api/sessions/{sessionId}/chats"
payload := strings.NewReader("{\n \"id\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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.recoupable.dev/api/sessions/{sessionId}/chats")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"id\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.recoupable.dev/api/sessions/{sessionId}/chats")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"id\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"chat": {
"id": "<string>",
"sessionId": "<string>",
"title": "<string>",
"modelId": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"activeStreamId": "<string>",
"lastAssistantMessageAt": "2023-11-07T05:31:56Z"
}
}{
"error": "Invalid chat id"
}{
"status": "error",
"error": "<string>"
}{
"status": "error",
"error": "<string>"
}{
"status": "error",
"error": "<string>"
}{
"error": "Chat ID conflict"
}{
"status": "error",
"error": "<string>"
}Authorizations
ApiKeyAuthBearerAuth
Path Parameters
The id of the parent session.
Body
application/json
Body for POST /api/sessions/{sessionId}/chats. Both an empty body and an omitted body are valid.
Optional client-supplied chat id (used for optimistic UI flows). When omitted, the server generates a UUID. When supplied, must be a non-empty string.
Minimum string length:
1Response
Chat created, or existing chat returned (idempotent on same-session reuse).
Show child attributes
Show child attributes
Was this page helpful?
⌘I
