> ## Documentation Index
> Fetch the complete documentation index at: https://marinabox.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Session

> Create a new sandbox session using the MarinaBox SDK

## Create a New Session

Creates a new sandbox session with specified environment type and configuration using the MarinaBox SDK.

### Python SDK

```python theme={null}
from marinabox import MarinaboxSDK

sdk = MarinaboxSDK()
session = sdk.create_session(
    env_type="browser",      # Optional: 'browser' or 'desktop', defaults to 'browser'
    tag="Development",       # Optional: custom tag for the session
    kiosk=False,            # Optional: launch Chrome in kiosk mode (browser only)
    initial_url="https://example.com"  # Optional: initial URL to open (browser only)
)

# Example: Create a kiosk mode browser session with initial URL
kiosk_session = sdk.create_session(
    env_type="browser",
    tag="Kiosk Display",
    kiosk=True,
    initial_url="https://dashboard.example.com"
)
```

### Response Object

The method returns a `BrowserSession` object with the following attributes:

```python theme={null}
{
    "session_id": "abc123xyz",        # Unique identifier for the session
    "container_id": "abc123xyz789",   # Docker container ID
    "vnc_port": 5002,                 # Port number for VNC connection
    "created_at": "2024-12-14T10:30:00Z",  # Creation timestamp
    "env_type": "browser",            # Environment type
    "debug_port": 4002,               # Debug port (browser only)
    "status": "running",              # Session status
    "resolution": "1280x800x24",      # Screen resolution
    "tag": "Development",             # Custom tag
    "websocket_url": "ws://localhost:4002/devtools/browser/abc123xyz"  # Browser debugging URL
}
```

### Parameters

| Parameter    | Type | Required | Description                                                   |
| ------------ | ---- | -------- | ------------------------------------------------------------- |
| env\_type    | str  | No       | Environment type ('browser' or 'desktop'). Default: 'browser' |
| tag          | str  | No       | Custom tag for the session                                    |
| kiosk        | bool | No       | Launch Chrome in kiosk mode (browser only). Default: False    |
| initial\_url | str  | No       | Initial URL to open when browser starts (browser only)        |

### Error Handling

```python theme={null}
try:
    session = sdk.create_session(env_type="invalid")
except ValueError as e:
    print(f"Invalid environment type: {e}")
except Exception as e:
    print(f"Failed to create session: {e}")
```

***

### Get Support & Join Our Community

* Discord: [https://discord.gg/nAyFBSSU87](https://discord.gg/nAyFBSSU87)
* Email: [askmarinabox@gmail.com](mailto:askmarinabox@gmail.com)
