Optional Parameters
stack_id
session_id
service_name
Get Container Session
Retrieves container session information for debugging and troubleshooting purposes. Returns either a specific session by ID or the most recent session for a specified service.
Session Lookup
The endpoint supports two lookup methods:
- By Session ID - Use
session_id
parameter to get a specific session - By Service Name - Use
service_name
parameter to get the most recent session for that service
If both parameters are provided, session_id
takes precedence.
Container Sessions
Sessions allow users to establish interactive connections to running containers for:
- Debugging applications - Inspect running processes and logs
- Troubleshooting issues - Examine container filesystem and configuration
- Interactive shell access - Execute commands inside containers
- Performance monitoring - Monitor container resource usage
Access Requirements
- SSH Key Download Permission - User must have SSH key download permissions on the stack
- Container Stacks Only - Sessions are only available for container-based stacks
- Active Sessions - Returns information about currently active sessions
Connection Information
The response includes connection details needed to establish the session:
- Connection host and port
- Authentication credentials
- Container and service identifiers
- Session status and metadata
This endpoint only works with container-based stacks. Traditional server stacks do not support container sessions.
Error Responses
Status Code | Description |
---|---|
400 | Insufficient permissions - User lacks SSH key download permissions Invalid stack type - Stack is not container-based Invalid session - Session not found or inaccessible |
Request
curl -X GET \
"https://app.cloud66.com/api/3/stacks/:stack_id/sessions/fetch" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json"
Response
{
"id": 123,
"service_name": "web",
"container_name": "web-container-abc123",
"status": "active",
"connection_info": {
"host": "session.cloud66.com",
"port": 22,
"username": "session_user"
},
"created_at": "2023-01-15T10:30:00Z",
"updated_at": "2023-01-15T10:30:00Z"
}
Optional Parameters
stack_id
service_name
Create Container Session
Creates a new interactive container session for the specified service. This enables debugging and troubleshooting by providing shell access to running containers.
Session Creation Process
- Validation - Verifies user permissions and stack type
- Service Verification - Confirms the service exists and is running
- Session Limits - Checks current session count (max 15 per service)
- Async Creation - Starts session creation as a background task
- Connection Setup - Establishes secure connection to container
Session Management
- Session Limits - Maximum of 15 concurrent sessions per service
- Automatic Cleanup - Oldest sessions are stopped when limit is exceeded
- Background Processing - Session creation is handled asynchronously
- Secure Access - Sessions use secure authentication mechanisms
Use Cases
- Application Debugging - Inspect running applications and processes
- Log Investigation - Examine application and system logs directly
- Configuration Changes - Temporary configuration modifications for testing
- Performance Analysis - Monitor resource usage and system performance
- Troubleshooting - Diagnose issues in production environments
Session Lifecycle
- Pending - Session creation initiated but not yet ready
- Active - Session is established and ready for use
- Stopped - Session has been terminated or expired
- Failed - Session creation or maintenance failed
Access Requirements
- SSH Key Download Permission - User must have SSH key download permissions
- Container Stacks Only - Sessions are only supported on container-based stacks
- Valid Service - Specified service must exist in the active rollout variant
Session creation is performed asynchronously. Monitor the returned AsyncAction to track session creation progress.
Error Responses
Status Code | Description |
---|---|
400 | Insufficient permissions - User lacks SSH key download permissions Invalid stack type - Stack is not container-based Invalid service - Service not found in active rollout variant Too many session open! - Maximum concurrent sessions exceeded Invalid session - Session creation failed |
Request
curl -X POST \
"https://app.cloud66.com/api/3/stacks/:stack_id/sessions" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json"
Response
{
"id": 456,
"user_id": 123,
"resource_type": "stack",
"action": "create_session",
"status": "pending",
"started_at": "2023-01-15T10:30:00Z",
"finished_at": null,
"created_at": "2023-01-15T10:30:00Z",
"updated_at": "2023-01-15T10:30:00Z"
}