JavaScript
import Mobilerun from '@mobilerun/sdk';
const client = new Mobilerun({
apiKey: process.env['MOBILERUN_CLOUD_API_KEY'], // This is the default and can be omitted
});
const conversation = await client.assistant.conversations.create({ title: 'x' });
console.log(conversation.session);import os
from mobilerun_sdk import Mobilerun
client = Mobilerun(
api_key=os.environ.get("MOBILERUN_CLOUD_API_KEY"), # This is the default and can be omitted
)
conversation = client.assistant.conversations.create(
title="x",
)
print(conversation.session)curl --request POST \
--url https://api.mobilerun.ai/v1/assistant/chat/sessions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"title": "<string>",
"agent": "<string>",
"description": "<string>"
}
'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.mobilerun.ai/v1/assistant/chat/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' => '<string>',
'agent' => '<string>',
'description' => '<string>'
]),
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://api.mobilerun.ai/v1/assistant/chat/sessions"
payload := strings.NewReader("{\n \"title\": \"<string>\",\n \"agent\": \"<string>\",\n \"description\": \"<string>\"\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://api.mobilerun.ai/v1/assistant/chat/sessions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"title\": \"<string>\",\n \"agent\": \"<string>\",\n \"description\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.mobilerun.ai/v1/assistant/chat/sessions")
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 \"title\": \"<string>\",\n \"agent\": \"<string>\",\n \"description\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"session": {
"agent": "<string>",
"basePromptTokens": 123,
"contextExhaustedAt": "<string>",
"costCents": 123,
"costUsd": 123,
"createdAt": "<string>",
"description": "<string>",
"id": "<string>",
"lastActiveAt": "<string>",
"peakPromptTokens": 123,
"pinned": true,
"promptStatus": "ready",
"status": "<string>",
"title": "<string>",
"turnActive": true,
"turnStartedAt": "<string>",
"createdBy": "<string>"
}
}Chat
Create a named chat session
Creates a titled agent session. Setup may occur on the first prompt. Idempotent via the Idempotency-Key header — a duplicate submit by the same authenticated caller within the 24-hour idempotency window returns the already-created session instead of a second one.
POST
/
assistant
/
chat
/
sessions
JavaScript
import Mobilerun from '@mobilerun/sdk';
const client = new Mobilerun({
apiKey: process.env['MOBILERUN_CLOUD_API_KEY'], // This is the default and can be omitted
});
const conversation = await client.assistant.conversations.create({ title: 'x' });
console.log(conversation.session);import os
from mobilerun_sdk import Mobilerun
client = Mobilerun(
api_key=os.environ.get("MOBILERUN_CLOUD_API_KEY"), # This is the default and can be omitted
)
conversation = client.assistant.conversations.create(
title="x",
)
print(conversation.session)curl --request POST \
--url https://api.mobilerun.ai/v1/assistant/chat/sessions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"title": "<string>",
"agent": "<string>",
"description": "<string>"
}
'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.mobilerun.ai/v1/assistant/chat/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' => '<string>',
'agent' => '<string>',
'description' => '<string>'
]),
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://api.mobilerun.ai/v1/assistant/chat/sessions"
payload := strings.NewReader("{\n \"title\": \"<string>\",\n \"agent\": \"<string>\",\n \"description\": \"<string>\"\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://api.mobilerun.ai/v1/assistant/chat/sessions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"title\": \"<string>\",\n \"agent\": \"<string>\",\n \"description\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.mobilerun.ai/v1/assistant/chat/sessions")
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 \"title\": \"<string>\",\n \"agent\": \"<string>\",\n \"description\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"session": {
"agent": "<string>",
"basePromptTokens": 123,
"contextExhaustedAt": "<string>",
"costCents": 123,
"costUsd": 123,
"createdAt": "<string>",
"description": "<string>",
"id": "<string>",
"lastActiveAt": "<string>",
"peakPromptTokens": 123,
"pinned": true,
"promptStatus": "ready",
"status": "<string>",
"title": "<string>",
"turnActive": true,
"turnStartedAt": "<string>",
"createdBy": "<string>"
}
}Authorizations
Bearer token via Authorization header
Headers
Optional client key. Reusing the same key with the same request body by the same authenticated caller within 24 hours returns the already-created session instead of a second one.
Body
application/json
Response
Created session
Show child attributes
Show child attributes
Was this page helpful?
⌘I