メインコンテンツへスキップ
PATCH
/
api
/
v0
/
sessions
/
{sessionId}
Update a session
curl --request PATCH \
  --url https://api.factory.ai/api/v0/sessions/{sessionId} \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "sessionSettings": {
    "model": "<string>",
    "specModeModel": "<string>",
    "runInWorktree": true,
    "providerLockTimestamp": "<string>",
    "assistantActiveTimeMs": 123,
    "childInclusiveTokenUsageBySessionId": {},
    "archivedAt": "<string>",
    "tags": [
      {
        "name": "<string>",
        "metadata": {}
      }
    ],
    "enabledToolIds": [
      "<string>"
    ],
    "disabledToolIds": [
      "<string>"
    ],
    "compactionModel": "current-model",
    "compactionThresholdCheckEnabled": true
  }
}
'
import requests

url = "https://api.factory.ai/api/v0/sessions/{sessionId}"

payload = { "sessionSettings": {
"model": "<string>",
"specModeModel": "<string>",
"runInWorktree": True,
"providerLockTimestamp": "<string>",
"assistantActiveTimeMs": 123,
"childInclusiveTokenUsageBySessionId": {},
"archivedAt": "<string>",
"tags": [
{
"name": "<string>",
"metadata": {}
}
],
"enabledToolIds": ["<string>"],
"disabledToolIds": ["<string>"],
"compactionModel": "current-model",
"compactionThresholdCheckEnabled": True
} }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}

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

print(response.text)
const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
sessionSettings: {
model: '<string>',
specModeModel: '<string>',
runInWorktree: true,
providerLockTimestamp: '<string>',
assistantActiveTimeMs: 123,
childInclusiveTokenUsageBySessionId: {},
archivedAt: '<string>',
tags: [{name: '<string>', metadata: {}}],
enabledToolIds: ['<string>'],
disabledToolIds: ['<string>'],
compactionModel: 'current-model',
compactionThresholdCheckEnabled: true
}
})
};

fetch('https://api.factory.ai/api/v0/sessions/{sessionId}', 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.factory.ai/api/v0/sessions/{sessionId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'sessionSettings' => [
'model' => '<string>',
'specModeModel' => '<string>',
'runInWorktree' => true,
'providerLockTimestamp' => '<string>',
'assistantActiveTimeMs' => 123,
'childInclusiveTokenUsageBySessionId' => [

],
'archivedAt' => '<string>',
'tags' => [
[
'name' => '<string>',
'metadata' => [

]
]
],
'enabledToolIds' => [
'<string>'
],
'disabledToolIds' => [
'<string>'
],
'compactionModel' => 'current-model',
'compactionThresholdCheckEnabled' => true
]
]),
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.factory.ai/api/v0/sessions/{sessionId}"

payload := strings.NewReader("{\n \"sessionSettings\": {\n \"model\": \"<string>\",\n \"specModeModel\": \"<string>\",\n \"runInWorktree\": true,\n \"providerLockTimestamp\": \"<string>\",\n \"assistantActiveTimeMs\": 123,\n \"childInclusiveTokenUsageBySessionId\": {},\n \"archivedAt\": \"<string>\",\n \"tags\": [\n {\n \"name\": \"<string>\",\n \"metadata\": {}\n }\n ],\n \"enabledToolIds\": [\n \"<string>\"\n ],\n \"disabledToolIds\": [\n \"<string>\"\n ],\n \"compactionModel\": \"current-model\",\n \"compactionThresholdCheckEnabled\": true\n }\n}")

req, _ := http.NewRequest("PATCH", 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.patch("https://api.factory.ai/api/v0/sessions/{sessionId}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"sessionSettings\": {\n \"model\": \"<string>\",\n \"specModeModel\": \"<string>\",\n \"runInWorktree\": true,\n \"providerLockTimestamp\": \"<string>\",\n \"assistantActiveTimeMs\": 123,\n \"childInclusiveTokenUsageBySessionId\": {},\n \"archivedAt\": \"<string>\",\n \"tags\": [\n {\n \"name\": \"<string>\",\n \"metadata\": {}\n }\n ],\n \"enabledToolIds\": [\n \"<string>\"\n ],\n \"disabledToolIds\": [\n \"<string>\"\n ],\n \"compactionModel\": \"current-model\",\n \"compactionThresholdCheckEnabled\": true\n }\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.factory.ai/api/v0/sessions/{sessionId}")

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

request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"sessionSettings\": {\n \"model\": \"<string>\",\n \"specModeModel\": \"<string>\",\n \"runInWorktree\": true,\n \"providerLockTimestamp\": \"<string>\",\n \"assistantActiveTimeMs\": 123,\n \"childInclusiveTokenUsageBySessionId\": {},\n \"archivedAt\": \"<string>\",\n \"tags\": [\n {\n \"name\": \"<string>\",\n \"metadata\": {}\n }\n ],\n \"enabledToolIds\": [\n \"<string>\"\n ],\n \"disabledToolIds\": [\n \"<string>\"\n ],\n \"compactionModel\": \"current-model\",\n \"compactionThresholdCheckEnabled\": true\n }\n}"

response = http.request(request)
puts response.read_body
{
  "sessionId": "<string>",
  "messageCount": 123,
  "createdAt": 123,
  "updatedAt": 123,
  "title": "<string>",
  "completedAt": 123,
  "computerId": "<string>",
  "sessionSettings": {
    "model": "<string>",
    "specModeModel": "<string>",
    "runInWorktree": true,
    "providerLockTimestamp": "<string>",
    "assistantActiveTimeMs": 123,
    "tokenUsage": {
      "inputTokens": 123,
      "outputTokens": 123,
      "cacheCreationTokens": 123,
      "cacheReadTokens": 123,
      "thinkingTokens": 123,
      "factoryCredits": 123
    },
    "inclusiveTokenUsage": {
      "inputTokens": 123,
      "outputTokens": 123,
      "cacheCreationTokens": 123,
      "cacheReadTokens": 123,
      "thinkingTokens": 123,
      "factoryCredits": 123
    },
    "childInclusiveTokenUsageBySessionId": {},
    "archivedAt": "<string>",
    "tags": [
      {
        "name": "<string>",
        "metadata": {}
      }
    ],
    "enabledToolIds": [
      "<string>"
    ],
    "disabledToolIds": [
      "<string>"
    ],
    "compactionModel": "current-model",
    "compactionThresholdCheckEnabled": true
  }
}
{
"detail": "<string>",
"status": 123,
"title": "<string>",
"metadata": {}
}
{
"detail": "<string>",
"status": 123,
"title": "<string>",
"metadata": {}
}
{
"detail": "<string>",
"status": 123,
"title": "<string>",
"metadata": {}
}
{
"detail": "<string>",
"status": 123,
"title": "<string>",
"metadata": {}
}
{
"detail": "<string>",
"status": 123,
"title": "<string>",
"metadata": {}
}

承認

Authorization
string
header
必須

Factory API key or JWT token for authentication

パスパラメータ

sessionId
string
必須

Session ID

ボディ

application/json
sessionSettings
object

レスポンス

Response for status 200

sessionId
string
必須

Session ID

status
enum<string>
必須

Current session execution status

利用可能なオプション:
idle,
pending,
running
messageCount
integer
必須

Number of messages in session

createdAt
integer
必須

Creation timestamp (Unix ms)

updatedAt
integer
必須

Last update timestamp (Unix ms)

title
string

Session title

completedAt
integer

Completion timestamp (Unix ms)

computerId
string

Connected computer ID

sessionSettings
object