curl -X POST "$ATAI_API_ENDPOINT/agents/sessions/ses_01jcf4p9r6wy3nv8s5m7jcae0b/cancel" \
-H "Authorization: Bearer $ATAI_API_KEY"
import os
import requests
base_url = os.environ["ATAI_API_ENDPOINT"]
api_key = os.environ["ATAI_API_KEY"]
response = requests.post(
f"{base_url}/agents/sessions/ses_01jcf4p9r6wy3nv8s5m7jcae0b/cancel",
headers={"Authorization": f"Bearer {api_key}"},
)
if response.status_code == 200:
print(response.json()["status"])
else:
print(f"Error: {response.json()['errors']}")
const response = await fetch(
`${process.env.ATAI_API_ENDPOINT}/agents/sessions/ses_01jcf4p9r6wy3nv8s5m7jcae0b/cancel`,
{
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.ATAI_API_KEY}`
}
}
);
const body = await response.json();
if (response.ok) {
console.log(body.status);
} else {
console.error('Error:', body.errors);
}
{
"id": "ses_01jcf4p9r6wy3nv8s5m7jcae0b",
"deployment_id": "dpl_01jcf3n8q5vx2mt7r4k6hbzd9a",
"package_id": "pkg_01jcb2x7m4qv8n3h5t6rk9dzs0",
"org_id": "org_01jc8m5r2vq9xt4bn7h3kdzs6w",
"project_id": "prj_01jcd4m8t2vq6xn3r7k5hbzw9e",
"created_by": "usr_01jc8m6t3wr0yv5cp8j4mezt7x",
"kind": "batch",
"status": "cancelled",
"connectors": {
"source": [{"type": "file", "id": "file_abc123", "format": "csv"}]
},
"job_id": "job_01jcf4q2s7xz4pw9t6n8kdbf1c",
"error": null,
"created_at": "2026-10-29T16:05:00Z",
"started_at": "2026-10-29T16:05:02Z",
"completed_at": "2026-10-29T16:07:15Z"
}
Sessions
Cancel Session
Cancel a pending or running session and stop its work
POST
/
api
/
agents
/
sessions
/
{session_id}
/
cancel
curl -X POST "$ATAI_API_ENDPOINT/agents/sessions/ses_01jcf4p9r6wy3nv8s5m7jcae0b/cancel" \
-H "Authorization: Bearer $ATAI_API_KEY"
import os
import requests
base_url = os.environ["ATAI_API_ENDPOINT"]
api_key = os.environ["ATAI_API_KEY"]
response = requests.post(
f"{base_url}/agents/sessions/ses_01jcf4p9r6wy3nv8s5m7jcae0b/cancel",
headers={"Authorization": f"Bearer {api_key}"},
)
if response.status_code == 200:
print(response.json()["status"])
else:
print(f"Error: {response.json()['errors']}")
const response = await fetch(
`${process.env.ATAI_API_ENDPOINT}/agents/sessions/ses_01jcf4p9r6wy3nv8s5m7jcae0b/cancel`,
{
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.ATAI_API_KEY}`
}
}
);
const body = await response.json();
if (response.ok) {
console.log(body.status);
} else {
console.error('Error:', body.errors);
}
{
"id": "ses_01jcf4p9r6wy3nv8s5m7jcae0b",
"deployment_id": "dpl_01jcf3n8q5vx2mt7r4k6hbzd9a",
"package_id": "pkg_01jcb2x7m4qv8n3h5t6rk9dzs0",
"org_id": "org_01jc8m5r2vq9xt4bn7h3kdzs6w",
"project_id": "prj_01jcd4m8t2vq6xn3r7k5hbzw9e",
"created_by": "usr_01jc8m6t3wr0yv5cp8j4mezt7x",
"kind": "batch",
"status": "cancelled",
"connectors": {
"source": [{"type": "file", "id": "file_abc123", "format": "csv"}]
},
"job_id": "job_01jcf4q2s7xz4pw9t6n8kdbf1c",
"error": null,
"created_at": "2026-10-29T16:05:00Z",
"started_at": "2026-10-29T16:05:02Z",
"completed_at": "2026-10-29T16:07:15Z"
}
Requires version 2.0.1 or later of the Archetype platform.
Overview
This endpoint cancels a session that ispending or running, stops its work, and returns the
session. The deployment and its other sessions are not affected.
For a serving session, the answer can take up to 15 seconds while its in-flight work winds down.
The cancel stands even if that cannot be confirmed. cancelled is a terminal status.
A cancelled session cannot be resumed or restarted. To run the same input again, open a new
session with Create Session.
Request
Response
Returns200 OK with the cancelled session, with the same fields as Get
Session returns. Its status is cancelled and
completed_at is set.
curl -X POST "$ATAI_API_ENDPOINT/agents/sessions/ses_01jcf4p9r6wy3nv8s5m7jcae0b/cancel" \
-H "Authorization: Bearer $ATAI_API_KEY"
import os
import requests
base_url = os.environ["ATAI_API_ENDPOINT"]
api_key = os.environ["ATAI_API_KEY"]
response = requests.post(
f"{base_url}/agents/sessions/ses_01jcf4p9r6wy3nv8s5m7jcae0b/cancel",
headers={"Authorization": f"Bearer {api_key}"},
)
if response.status_code == 200:
print(response.json()["status"])
else:
print(f"Error: {response.json()['errors']}")
const response = await fetch(
`${process.env.ATAI_API_ENDPOINT}/agents/sessions/ses_01jcf4p9r6wy3nv8s5m7jcae0b/cancel`,
{
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.ATAI_API_KEY}`
}
}
);
const body = await response.json();
if (response.ok) {
console.log(body.status);
} else {
console.error('Error:', body.errors);
}
{
"id": "ses_01jcf4p9r6wy3nv8s5m7jcae0b",
"deployment_id": "dpl_01jcf3n8q5vx2mt7r4k6hbzd9a",
"package_id": "pkg_01jcb2x7m4qv8n3h5t6rk9dzs0",
"org_id": "org_01jc8m5r2vq9xt4bn7h3kdzs6w",
"project_id": "prj_01jcd4m8t2vq6xn3r7k5hbzw9e",
"created_by": "usr_01jc8m6t3wr0yv5cp8j4mezt7x",
"kind": "batch",
"status": "cancelled",
"connectors": {
"source": [{"type": "file", "id": "file_abc123", "format": "csv"}]
},
"job_id": "job_01jcf4q2s7xz4pw9t6n8kdbf1c",
"error": null,
"created_at": "2026-10-29T16:05:00Z",
"started_at": "2026-10-29T16:05:02Z",
"completed_at": "2026-10-29T16:07:15Z"
}
Important Notes
- A
409means the session has already ended ascompleted,failed, orcancelled. - A
403means you can see the session’s project but cannot modify it. - A
404means the session does not exist, belongs to another organization, or is in a project you cannot see. - Stopping a deployment cancels every session on it that has not ended.
Was this page helpful?