Start, restart and stop sessions programmatically. These endpoints authenticate with your API key, verify session ownership, and publish launch/cancel commands to your connected client via Redis SSE.
Base URL: https://api.b337.ai
Launch a session. The command is delivered to your connected client in real time via SSE.
POST /api/start_session
| Parameter | Type | Required | Description |
|---|---|---|---|
| session_id | string | Yes | The session ID to launch |
curl -X POST https://api.b337.ai/api/start_session \ -H "X-API-Key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{"session_id": "abc-123"}'
import requests response = requests.post( "https://api.b337.ai/api/start_session", headers={ "X-API-Key": "YOUR_API_KEY", "Content-Type": "application/json", }, json={"session_id": "abc-123"}, ) print(response.json())
{ "status": "success", "session_status": "launching", "delivered": true }
Cancels a running session and immediately re-launches it.
POST /api/restart_session
| Parameter | Type | Required | Description |
|---|---|---|---|
| session_id | string | Yes | The session ID to restart |
curl -X POST https://api.b337.ai/api/restart_session \ -H "X-API-Key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{"session_id": "abc-123"}'
import requests response = requests.post( "https://api.b337.ai/api/restart_session", headers={ "X-API-Key": "YOUR_API_KEY", "Content-Type": "application/json", }, json={"session_id": "abc-123"}, ) print(response.json())
{ "status": "success", "session_status": "launching", "delivered": true }
Stops one of your own running sessions. Stopping is never blocked by your subscription status, so you can always stop a running bot.
POST /v3/stop_session
| Parameter | Type | Required | Description |
|---|---|---|---|
| session_id | string | Yes | The session ID to stop |
| revoke | bool | No | Default false. If true, the stop also reaches a client that is offline right now: it stops the session as soon as it reconnects. The flag is cleared by your next start of that session |
curl -X POST https://api.b337.ai/v3/stop_session \ -H "X-API-Key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{"session_id": "abc-123"}'
import requests response = requests.post( "https://api.b337.ai/v3/stop_session", headers={ "X-API-Key": "YOUR_API_KEY", "Content-Type": "application/json", }, json={"session_id": "abc-123"}, ) print(response.json())
{ "status": "stopped", "session_id": "abc-123", "delivered": true }
delivered: false means your desktop client is not connected, so the stop did not reach it live. Send "revoke": true to make sure it stops when it reconnects.
| Field | Type | Description |
|---|---|---|
| status | string | Start/restart: "success" or "error". Stop: "stopped" |
| session_status | string | Start/restart only. The session's new status (e.g. "launching") |
| session_id | string | Stop only. The session that was stopped |
| delivered | bool | Whether the command was delivered to a connected client. false means no client is currently connected via SSE |
X-API-Key header is validatedverify_session_ownershipget_complete_session_data| Status Code | Description |
|---|---|
| 400 | Stop only: body is not JSON, or session_id is missing |
| 401 | Invalid or missing API key |
| 403 | Session does not belong to your account, or (start/restart only) your account has no active subscription |
| 404 | Session not found |
| 500 | Internal server error |
Error Response Example:
{ "status": "error", "message": "Session not found" }
delivered field indicates real-time delivery status. If false, your desktop client is not connected - the session will not start until a client connects"revoke": true keeps an offline client from resuming, and your next start clears it