Save a snapshot and set it as the default environment in one step:
JavaScript
Python
HTTPie
Copy
// Save snapshot and set as defaultawait fetch(`https://api.agi.tech/v1/sessions/${sessionId}?save_snapshot_mode=filesystem&save_as_default=true`, { method: 'DELETE', headers: { 'Authorization': `Bearer ${apiKey}` }});
Copy
# Save snapshot and set as defaultrequests.delete( f"https://api.agi.tech/v1/sessions/{session_id}", headers={"Authorization": f"Bearer {api_key}"}, params={ "save_snapshot_mode": "filesystem", "save_as_default": "true" })
Copy
# Save snapshot and set as defaulthttp DELETE "https://api.agi.tech/v1/sessions/$SESSION_ID?save_snapshot_mode=filesystem&save_as_default=true" \ Authorization:"Bearer $AGI_API_KEY"
When save_as_default=true:
✅ The snapshot is saved to the environment associated with the session
✅ The environment is set as the user’s default environment
✅ Future session creations can automatically restore from this snapshot
A default environment is an environment snapshot that is automatically restored when creating new sessions. The system uses the following precedence order:
restore_from_session_id - Explicitly restore from a specific session ID (highest priority)
restore_default_environment_from_user_id - Restore from user’s default environment (lower priority)
This saves the snapshot and sets it as the user’s default environment. Future session creations can then automatically restore from this snapshot using restore_default_environment_from_user_id.
// Step 1: Create a sessionconst sessionResponse = await fetch('https://api.agi.tech/v1/sessions', { method: 'POST', headers: { 'Authorization': `Bearer ${API_KEY}`, 'Content-Type': 'application/json' }, body: JSON.stringify({ agent_name: 'agi-0' })});const { session_id } = await sessionResponse.json();// Step 2: Use the session (login, navigate, etc.)// ... perform actions that establish authentication ...// Step 3: Save snapshot and set as defaultawait fetch(`https://api.agi.tech/v1/sessions/${session_id}?save_snapshot_mode=filesystem&save_as_default=true`, { method: 'DELETE', headers: { 'Authorization': `Bearer ${API_KEY}` }});
Copy
import requests# Step 1: Create a sessionsession_response = requests.post( "https://api.agi.tech/v1/sessions", headers={ "Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json" }, json={"agent_name": "agi-0"})session_id = session_response.json()["session_id"]# Step 2: Use the session (login, navigate, etc.)# ... perform actions that establish authentication ...# Step 3: Save snapshot and set as defaultrequests.delete( f"https://api.agi.tech/v1/sessions/{session_id}", headers={"Authorization": f"Bearer {API_KEY}"}, params={ "save_snapshot_mode": "filesystem", "save_as_default": "true" })
Copy
# Step 1: Create a sessionSESSION_ID=$(http POST https://api.agi.tech/v1/sessions \ Authorization:"Bearer $API_KEY" \ agent_name=agi-0 | jq -r '.session_id')# Step 2: Use the session (login, navigate, etc.)# ... perform actions that establish authentication ...# Step 3: Save snapshot and set as defaulthttp DELETE "https://api.agi.tech/v1/sessions/$SESSION_ID?save_snapshot_mode=filesystem&save_as_default=true" \ Authorization:"Bearer $API_KEY"