curl --request POST \
--url https://api.orion.file.ai/prod/v2/agent/sessions/{session_id}/stop \
--header 'Idempotency-Key: <idempotency-key>' \
--header 'x-api-key: <api-key>'import requests
url = "https://api.orion.file.ai/prod/v2/agent/sessions/{session_id}/stop"
headers = {
"Idempotency-Key": "<idempotency-key>",
"x-api-key": "<api-key>"
}
response = requests.post(url, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Idempotency-Key': '<idempotency-key>', 'x-api-key': '<api-key>'}
};
fetch('https://api.orion.file.ai/prod/v2/agent/sessions/{session_id}/stop', 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/{session_id}/stop",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"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"
"net/http"
"io"
)
func main() {
url := "https://api.orion.file.ai/prod/v2/agent/sessions/{session_id}/stop"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Idempotency-Key", "<idempotency-key>")
req.Header.Add("x-api-key", "<api-key>")
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/{session_id}/stop")
.header("Idempotency-Key", "<idempotency-key>")
.header("x-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.orion.file.ai/prod/v2/agent/sessions/{session_id}/stop")
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>'
response = http.request(request)
puts response.read_body{
"session_id": "665f1c2e8a1b4c0012ab34cd",
"stop_requested": true,
"run_status": "RUNNING",
"job_id": "sajob_9f2c1a4b7e8d4c1fa0b3",
"poll_url": "<string>"
}{
"type": "https://errors.file.ai/bad-request",
"title": "Bad request",
"status": 400,
"detail": "Idempotency-Key header is required on this endpoint.",
"instance": "/v1/{route}",
"code": "BAD_REQUEST",
"requestId": "0f1c8e03-978e-40d5-bc93-6894a57f9324",
"errors": [],
"message": "Idempotency-Key header is required on this endpoint.",
"error": "Bad Request",
"statusCode": 400
}{
"type": "https://errors.file.ai/validation-failed",
"title": "Validation failed",
"status": 422,
"detail": "One or more fields are invalid.",
"instance": "/v1/files/upload",
"code": "VALIDATION_FAILED",
"requestId": "0f1c8e03-978e-40d5-bc93-6894a57f9324",
"errors": [
{
"code": "REQUIRED",
"detail": "must not be empty",
"pointer": "#/fileName",
"parameter": "limit"
}
],
"message": "Validation failed",
"error": "Unprocessable Entity",
"statusCode": 422,
"retryAfter": 42
}{
"type": "https://errors.file.ai/validation-failed",
"title": "Validation failed",
"status": 422,
"detail": "One or more fields are invalid.",
"instance": "/v1/files/upload",
"code": "VALIDATION_FAILED",
"requestId": "0f1c8e03-978e-40d5-bc93-6894a57f9324",
"errors": [
{
"code": "REQUIRED",
"detail": "must not be empty",
"pointer": "#/fileName",
"parameter": "limit"
}
],
"message": "Validation failed",
"error": "Unprocessable Entity",
"statusCode": 422,
"retryAfter": 42
}{
"type": "https://errors.file.ai/not-found",
"title": "Not found",
"status": 404,
"detail": "No such session.",
"instance": "/v1/{route}",
"code": "NOT_FOUND",
"requestId": "0f1c8e03-978e-40d5-bc93-6894a57f9324",
"errors": [],
"message": "No such session.",
"error": "Not Found",
"statusCode": 404
}{
"type": "https://errors.file.ai/validation-failed",
"title": "Validation failed",
"status": 422,
"detail": "One or more fields are invalid.",
"instance": "/v1/files/upload",
"code": "VALIDATION_FAILED",
"requestId": "0f1c8e03-978e-40d5-bc93-6894a57f9324",
"errors": [
{
"code": "REQUIRED",
"detail": "must not be empty",
"pointer": "#/fileName",
"parameter": "limit"
}
],
"message": "Validation failed",
"error": "Unprocessable Entity",
"statusCode": 422,
"retryAfter": 42
}{
"type": "https://errors.file.ai/validation-failed",
"title": "Validation failed",
"status": 422,
"detail": "One or more fields are invalid.",
"instance": "/v1/files/upload",
"code": "VALIDATION_FAILED",
"requestId": "0f1c8e03-978e-40d5-bc93-6894a57f9324",
"errors": [
{
"code": "REQUIRED",
"detail": "must not be empty",
"pointer": "#/fileName",
"parameter": "limit"
}
],
"message": "Validation failed",
"error": "Unprocessable Entity",
"statusCode": 422,
"retryAfter": 42
}{
"type": "https://errors.file.ai/validation-failed",
"title": "Validation failed",
"status": 422,
"detail": "One or more fields are invalid.",
"instance": "/v1/files/upload",
"code": "VALIDATION_FAILED",
"requestId": "0f1c8e03-978e-40d5-bc93-6894a57f9324",
"errors": [
{
"code": "REQUIRED",
"detail": "must not be empty",
"pointer": "#/fileName",
"parameter": "limit"
}
],
"message": "Validation failed",
"error": "Unprocessable Entity",
"statusCode": 422,
"retryAfter": 42
}{
"type": "https://errors.file.ai/validation-failed",
"title": "Validation failed",
"status": 422,
"detail": "One or more fields are invalid.",
"instance": "/v1/files/upload",
"code": "VALIDATION_FAILED",
"requestId": "0f1c8e03-978e-40d5-bc93-6894a57f9324",
"errors": [
{
"code": "REQUIRED",
"detail": "must not be empty",
"pointer": "#/fileName",
"parameter": "limit"
}
],
"message": "Validation failed",
"error": "Unprocessable Entity",
"statusCode": 422,
"retryAfter": 42
}Stop the running turn
Asks the agent to stop this session’s run, and returns immediately.
The stop is a request, not a completion. The agent keeps working for about a second while it checkpoints, then ends the run itself — so the answer it had produced so far is kept, and the time and cost already incurred are still billed. Poll the job to see the run reach STOPPED.
A stop always races the run it is ending: if the run finished first, the response reports stop_requested false and nothing was forwarded.
The session stays open. The next turn continues the conversation from the checkpoint the agent wrote, so do not start a new session.
curl --request POST \
--url https://api.orion.file.ai/prod/v2/agent/sessions/{session_id}/stop \
--header 'Idempotency-Key: <idempotency-key>' \
--header 'x-api-key: <api-key>'import requests
url = "https://api.orion.file.ai/prod/v2/agent/sessions/{session_id}/stop"
headers = {
"Idempotency-Key": "<idempotency-key>",
"x-api-key": "<api-key>"
}
response = requests.post(url, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Idempotency-Key': '<idempotency-key>', 'x-api-key': '<api-key>'}
};
fetch('https://api.orion.file.ai/prod/v2/agent/sessions/{session_id}/stop', 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/{session_id}/stop",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"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"
"net/http"
"io"
)
func main() {
url := "https://api.orion.file.ai/prod/v2/agent/sessions/{session_id}/stop"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Idempotency-Key", "<idempotency-key>")
req.Header.Add("x-api-key", "<api-key>")
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/{session_id}/stop")
.header("Idempotency-Key", "<idempotency-key>")
.header("x-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.orion.file.ai/prod/v2/agent/sessions/{session_id}/stop")
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>'
response = http.request(request)
puts response.read_body{
"session_id": "665f1c2e8a1b4c0012ab34cd",
"stop_requested": true,
"run_status": "RUNNING",
"job_id": "sajob_9f2c1a4b7e8d4c1fa0b3",
"poll_url": "<string>"
}{
"type": "https://errors.file.ai/bad-request",
"title": "Bad request",
"status": 400,
"detail": "Idempotency-Key header is required on this endpoint.",
"instance": "/v1/{route}",
"code": "BAD_REQUEST",
"requestId": "0f1c8e03-978e-40d5-bc93-6894a57f9324",
"errors": [],
"message": "Idempotency-Key header is required on this endpoint.",
"error": "Bad Request",
"statusCode": 400
}{
"type": "https://errors.file.ai/validation-failed",
"title": "Validation failed",
"status": 422,
"detail": "One or more fields are invalid.",
"instance": "/v1/files/upload",
"code": "VALIDATION_FAILED",
"requestId": "0f1c8e03-978e-40d5-bc93-6894a57f9324",
"errors": [
{
"code": "REQUIRED",
"detail": "must not be empty",
"pointer": "#/fileName",
"parameter": "limit"
}
],
"message": "Validation failed",
"error": "Unprocessable Entity",
"statusCode": 422,
"retryAfter": 42
}{
"type": "https://errors.file.ai/validation-failed",
"title": "Validation failed",
"status": 422,
"detail": "One or more fields are invalid.",
"instance": "/v1/files/upload",
"code": "VALIDATION_FAILED",
"requestId": "0f1c8e03-978e-40d5-bc93-6894a57f9324",
"errors": [
{
"code": "REQUIRED",
"detail": "must not be empty",
"pointer": "#/fileName",
"parameter": "limit"
}
],
"message": "Validation failed",
"error": "Unprocessable Entity",
"statusCode": 422,
"retryAfter": 42
}{
"type": "https://errors.file.ai/not-found",
"title": "Not found",
"status": 404,
"detail": "No such session.",
"instance": "/v1/{route}",
"code": "NOT_FOUND",
"requestId": "0f1c8e03-978e-40d5-bc93-6894a57f9324",
"errors": [],
"message": "No such session.",
"error": "Not Found",
"statusCode": 404
}{
"type": "https://errors.file.ai/validation-failed",
"title": "Validation failed",
"status": 422,
"detail": "One or more fields are invalid.",
"instance": "/v1/files/upload",
"code": "VALIDATION_FAILED",
"requestId": "0f1c8e03-978e-40d5-bc93-6894a57f9324",
"errors": [
{
"code": "REQUIRED",
"detail": "must not be empty",
"pointer": "#/fileName",
"parameter": "limit"
}
],
"message": "Validation failed",
"error": "Unprocessable Entity",
"statusCode": 422,
"retryAfter": 42
}{
"type": "https://errors.file.ai/validation-failed",
"title": "Validation failed",
"status": 422,
"detail": "One or more fields are invalid.",
"instance": "/v1/files/upload",
"code": "VALIDATION_FAILED",
"requestId": "0f1c8e03-978e-40d5-bc93-6894a57f9324",
"errors": [
{
"code": "REQUIRED",
"detail": "must not be empty",
"pointer": "#/fileName",
"parameter": "limit"
}
],
"message": "Validation failed",
"error": "Unprocessable Entity",
"statusCode": 422,
"retryAfter": 42
}{
"type": "https://errors.file.ai/validation-failed",
"title": "Validation failed",
"status": 422,
"detail": "One or more fields are invalid.",
"instance": "/v1/files/upload",
"code": "VALIDATION_FAILED",
"requestId": "0f1c8e03-978e-40d5-bc93-6894a57f9324",
"errors": [
{
"code": "REQUIRED",
"detail": "must not be empty",
"pointer": "#/fileName",
"parameter": "limit"
}
],
"message": "Validation failed",
"error": "Unprocessable Entity",
"statusCode": 422,
"retryAfter": 42
}{
"type": "https://errors.file.ai/validation-failed",
"title": "Validation failed",
"status": 422,
"detail": "One or more fields are invalid.",
"instance": "/v1/files/upload",
"code": "VALIDATION_FAILED",
"requestId": "0f1c8e03-978e-40d5-bc93-6894a57f9324",
"errors": [
{
"code": "REQUIRED",
"detail": "must not be empty",
"pointer": "#/fileName",
"parameter": "limit"
}
],
"message": "Validation failed",
"error": "Unprocessable Entity",
"statusCode": 422,
"retryAfter": 42
}Idempotency-Key request header — omitting it
is a 400. See Idempotent requests.STOPPED. See Stopping a
run.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.
Path Parameters
Session whose run to stop.
Response
Stop request accepted, or reported as unnecessary when no run was live.
"665f1c2e8a1b4c0012ab34cd"
Whether a stop was forwarded to the agent.
False means there was nothing live to stop — the run had already finished. That is a normal answer, not an error: a stop always races the run it is trying to end.
true
Status of the run at the moment the stop was requested — deliberately unchanged. The run is still going; it reaches STOPPED only once the agent confirms on its own event stream.
QUEUED, RUNNING, COMPLETED, FAILED, STOPPED, STALE "RUNNING"
Job handle for the run being stopped. Null when the turn was asked in the app rather than through this API.
"sajob_9f2c1a4b7e8d4c1fa0b3"
URL of GET /v2/jobs/{job_id} — poll it until the job reports STOPPED (or the status the run reached on its own).