cURL
curl --request POST \ --url https://api.example.com/agents/{agentId}/stop \ --header 'Content-Type: <content-type>' \ --data ' { "graceful": true, "timeout": 123 } '
{ "success": true, "message": "<string>", "data": { "data.agentId": "<string>", "data.status": "<string>", "data.stoppedAt": 123 } }
Stop a running agent’s runtime
POST /agents/{agentId}/stop
application/json
inactive
curl -X POST http://localhost:3000/agents/550e8400-e29b-41d4-a716-446655440000/stop \ -H "Content-Type: application/json" \ -d '{}'
curl -X POST http://localhost:3000/agents/550e8400-e29b-41d4-a716-446655440000/stop \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_API_KEY" \ -d '{ "graceful": true, "timeout": 60000 }'
curl -X POST http://localhost:3000/agents/550e8400-e29b-41d4-a716-446655440000/stop \ -H "Content-Type: application/json" \ -d '{ "graceful": false }'
{ "success": true, "message": "Agent stopped successfully", "data": { "agentId": "550e8400-e29b-41d4-a716-446655440000", "status": "inactive", "stoppedAt": 1709683200000 } }
const agentId = "550e8400-e29b-41d4-a716-446655440000"; const response = await fetch( `http://localhost:3000/agents/${agentId}/stop`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ graceful: true, timeout: 30000 }) } ); const { success, message, data } = await response.json(); if (success) { console.log(message); console.log(`Agent status: ${data.status}`); }
import requests agent_id = "550e8400-e29b-41d4-a716-446655440000" response = requests.post( f'http://localhost:3000/agents/{agent_id}/stop', json={'graceful': True, 'timeout': 30000} ) data = response.json() if data['success']: print(data['message']) print(f"Agent status: {data['data']['status']}")
interface StopAgentRequest { graceful?: boolean; timeout?: number; } interface StopAgentResponse { success: boolean; message: string; data: { agentId: string; status: 'inactive'; stoppedAt: number; }; } const agentId = "550e8400-e29b-41d4-a716-446655440000"; const request: StopAgentRequest = { graceful: true, timeout: 30000 }; const response = await fetch( `http://localhost:3000/agents/${agentId}/stop`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(request) } ); const result: StopAgentResponse = await response.json();
{ "success": false, "error": "Agent not found" }
{ "success": false, "error": "Agent is not running" }
{ "success": false, "error": "Graceful shutdown timed out" }
{ "success": false, "error": "Failed to stop agent runtime" }
await fetch(`http://localhost:3000/agents/${agentId}/stop`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ graceful: true, timeout: 60000 }) });
await fetch(`http://localhost:3000/agents/${agentId}/stop`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ graceful: false }) });
// Stop all agents const agents = await fetch('http://localhost:3000/agents').then(r => r.json()); for (const agent of agents.data) { if (agent.status === 'active') { await fetch(`http://localhost:3000/agents/${agent.agentId}/stop`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ graceful: true }) }); } }
const stopIdleAgents = async () => { const agents = await getActiveAgents(); for (const agent of agents) { const lastActivity = await getLastActivityTime(agent.agentId); const idleTime = Date.now() - lastActivity; if (idleTime > 3600000) { // 1 hour await stopAgent(agent.agentId); } } };