curl -X DELETE "$ATAI_API_ENDPOINT/agents/sessions/ses_01jcf4p9r6wy3nv8s5m7jcae0b" \
-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.delete(
f"{base_url}/agents/sessions/ses_01jcf4p9r6wy3nv8s5m7jcae0b",
headers={"Authorization": f"Bearer {api_key}"},
)
if response.status_code == 204:
print("Session deleted")
else:
print(f"Error: {response.json()['errors']}")
const response = await fetch(
`${process.env.ATAI_API_ENDPOINT}/agents/sessions/ses_01jcf4p9r6wy3nv8s5m7jcae0b`,
{
method: 'DELETE',
headers: {
'Authorization': `Bearer ${process.env.ATAI_API_KEY}`
}
}
);
if (response.status === 204) {
console.log('Session deleted');
} else {
const body = await response.json();
console.error('Error:', body.errors);
}
Sessions
Delete Session
Delete a session that has ended, with its event log
DELETE
/
api
/
agents
/
sessions
/
{session_id}
curl -X DELETE "$ATAI_API_ENDPOINT/agents/sessions/ses_01jcf4p9r6wy3nv8s5m7jcae0b" \
-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.delete(
f"{base_url}/agents/sessions/ses_01jcf4p9r6wy3nv8s5m7jcae0b",
headers={"Authorization": f"Bearer {api_key}"},
)
if response.status_code == 204:
print("Session deleted")
else:
print(f"Error: {response.json()['errors']}")
const response = await fetch(
`${process.env.ATAI_API_ENDPOINT}/agents/sessions/ses_01jcf4p9r6wy3nv8s5m7jcae0b`,
{
method: 'DELETE',
headers: {
'Authorization': `Bearer ${process.env.ATAI_API_KEY}`
}
}
);
if (response.status === 204) {
console.log('Session deleted');
} else {
const body = await response.json();
console.error('Error:', body.errors);
}
Requires version 2.0.1 or later of the Archetype platform.
Overview
This endpoint deletes a session that has ended (completed, failed, or cancelled),
with its event log.
A session that is still pending or running returns 409. Cancel
it first.
Request
Response
Returns204 No Content with an empty body on success.
curl -X DELETE "$ATAI_API_ENDPOINT/agents/sessions/ses_01jcf4p9r6wy3nv8s5m7jcae0b" \
-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.delete(
f"{base_url}/agents/sessions/ses_01jcf4p9r6wy3nv8s5m7jcae0b",
headers={"Authorization": f"Bearer {api_key}"},
)
if response.status_code == 204:
print("Session deleted")
else:
print(f"Error: {response.json()['errors']}")
const response = await fetch(
`${process.env.ATAI_API_ENDPOINT}/agents/sessions/ses_01jcf4p9r6wy3nv8s5m7jcae0b`,
{
method: 'DELETE',
headers: {
'Authorization': `Bearer ${process.env.ATAI_API_KEY}`
}
}
);
if (response.status === 204) {
console.log('Session deleted');
} else {
const body = await response.json();
console.error('Error:', body.errors);
}
Important Notes
- A
409means the session has not ended. Cancel it first. - 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. - A deployment can be deleted only once it has no sessions left. See Delete Deployment.
Was this page helpful?