Skip to main content
POST
/
v1
/
sessions
/
{session_id}
/
pause
Pause Session
curl --request POST \
  --url https://api.example.com/v1/sessions/{session_id}/pause \
  --header 'Authorization: <authorization>'
{
  "success": true,
  "message": "Session paused successfully"
}

Overview

Pause a running task temporarily. The session remains active and can be resumed later. Useful for rate limiting, user verification, or temporary interruptions.

Request

session_id
string
required
The UUID of the session
Authorization
string
required
Bearer token for authentication

Response

success
boolean
Whether the operation completed successfully
message
string
Result message
{
  "success": true,
  "message": "Session paused successfully"
}

Example

curl -X POST https://api.agi.tech/v1/sessions/<session_id>/pause \
  -H "Authorization: Bearer $AGI_API_KEY"

Use Cases

Rate Limiting

# Pause during rate limit, resume after cooldown
def handle_rate_limit(session_id, cooldown=60):
    pause_session(session_id)
    print(f"Pausing for {cooldown}s due to rate limit")
    time.sleep(cooldown)
    resume_session(session_id)

User Verification

# Pause for user approval before proceeding
pause_session(session_id)
print("Agent wants to make a purchase. Approve? (y/n)")
approval = input()

if approval.lower() == 'y':
    resume_session(session_id)
else:
    cancel_session(session_id)

Temporary Interruption

# Pause to adjust task parameters
pause_session(session_id)

# Send updated instructions
send_message(session_id, "Also check Amazon for comparison")

# Resume with new context
resume_session(session_id)

Error Handling

def safe_pause(session_id):
    """Pause with error handling"""
    try:
        result = pause_session(session_id)
        return result["success"]
    except requests.HTTPError as e:
        if e.response.status_code == 404:
            print("Session not found")
        elif "already_paused" in str(e.response.text):
            print("Session already paused")
        else:
            raise
        return False

Best Practices

Pausing doesn’t preserve browser state permanently. For long pauses, consider deleting and recreating the session.
Use pause/resume for temporary interruptions. Use cancel if you want to abandon the current task entirely.
A paused session can be resumed with the resume endpoint or cancelled with the cancel endpoint.