curl --request POST \
--url https://davinci-app.com/api/v2/projects/{projectId}/sessions/{sessionId}/stop \
--header 'Authorization: Bearer <token>'import os
from davinci_sdk import DavinciClient
with DavinciClient(api_key=os.environ["DAVINCI_API_KEY"]) as client:
session = client.sessions.resume(project_id, session_id)
result = session.stop()
print(result.stopped, result.status)
import { DavinciClient } from '@celedon/davinci-sdk';
const client = new DavinciClient({
apiKey: process.env.DAVINCI_API_KEY!,
});
const session = await client.sessions.get(projectId, sessionId);
const result = await session.stop();
console.log(result.stopped, result.status);
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch('https://davinci-app.com/api/v2/projects/{projectId}/sessions/{sessionId}/stop', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"sessionId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"taskId": "<string>",
"stopped": true,
"status": "no_session"
}{
"success": false,
"error": {
"code": "<string>",
"message": "<string>",
"details": {}
}
}{
"success": false,
"error": {
"code": "<string>",
"message": "<string>",
"details": {}
}
}{
"success": false,
"error": {
"code": "<string>",
"message": "<string>",
"details": {}
}
}{
"success": false,
"error": {
"code": "<string>",
"message": "<string>",
"details": {}
}
}{
"success": false,
"error": {
"code": "<string>",
"message": "<string>",
"details": {}
}
}{
"success": false,
"error": {
"code": "<string>",
"message": "<string>",
"details": {}
}
}Stop the agent without closing the session
Halts the current run. The session survives, the project stays open, and the
conversation so far is kept — so you can send a new prompt afterwards without
starting over. Use deleteSession when you actually want to finish.
Stopping when nothing is running is not an error; stopped is false and the
status is whatever it already was. That makes this safe to call defensively,
for instance when abandoning a run you may or may not have started.
curl --request POST \
--url https://davinci-app.com/api/v2/projects/{projectId}/sessions/{sessionId}/stop \
--header 'Authorization: Bearer <token>'import os
from davinci_sdk import DavinciClient
with DavinciClient(api_key=os.environ["DAVINCI_API_KEY"]) as client:
session = client.sessions.resume(project_id, session_id)
result = session.stop()
print(result.stopped, result.status)
import { DavinciClient } from '@celedon/davinci-sdk';
const client = new DavinciClient({
apiKey: process.env.DAVINCI_API_KEY!,
});
const session = await client.sessions.get(projectId, sessionId);
const result = await session.stop();
console.log(result.stopped, result.status);
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch('https://davinci-app.com/api/v2/projects/{projectId}/sessions/{sessionId}/stop', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"sessionId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"taskId": "<string>",
"stopped": true,
"status": "no_session"
}{
"success": false,
"error": {
"code": "<string>",
"message": "<string>",
"details": {}
}
}{
"success": false,
"error": {
"code": "<string>",
"message": "<string>",
"details": {}
}
}{
"success": false,
"error": {
"code": "<string>",
"message": "<string>",
"details": {}
}
}{
"success": false,
"error": {
"code": "<string>",
"message": "<string>",
"details": {}
}
}{
"success": false,
"error": {
"code": "<string>",
"message": "<string>",
"details": {}
}
}{
"success": false,
"error": {
"code": "<string>",
"message": "<string>",
"details": {}
}
}Authorizations
Personal access token. The scopes granted at issuance determine both which
operations the key may call and the ceiling on the resource permissions it
can exercise. Each scope family is a ladder: projects:manage implies
projects:write and projects:read; cards:manage implies cards:write
and cards:read; and teams:manage implies teams:write and teams:read.
These are named API capability bundles, not blanket domain roles:
manage exposes only the permissions enumerated for that scope and never
bypasses the acting user's current role-based access.
Path Parameters
Project id. May be compound in the form {projectId}--{branchName}.
1Session id from createSession.
Response
The run was halted, or there was none to halt.
False when there was no run to stop, which is not a failure — you asked for a state you already had.
no_session— the machine has no record of this session; it lapsed or the project restarted. Create a new one.project_not_running— the session is known but its project has unloaded.idle— the session is live and no run has been started.starting— a run is being set up.running— a run is in progress.paused— a run was stopped and can be continued with a new prompt.completed— the run finished.failed— the run ended in an error. The transcript says why.unknown— the machine could not be reached for this field. Retry; anything else in the same response is still valid.
paused, completed, and failed are terminal for a run.
no_session, project_not_running, idle, starting, running, paused, completed, failed, unknown