Introduction
The Dockhand API provides programmatic access to all Docker management functionality. Use it to automate container operations, manage stacks, configure environments, and integrate Dockhand into your workflows.Base URL
All API requests are made to your Dockhand instance:The API is served from the same domain as the web interface on the
/api path.Request Format
HTTP Methods
The API uses standard HTTP methods:GET- Retrieve resourcesPOST- Create resources or trigger actionsPUT/PATCH- Update resourcesDELETE- Remove resources
Content Type
All requests with a body must useapplication/json:
Query Parameters
Many endpoints accept query parameters for filtering and configuration:Environment ID to scope the request to a specific Docker environment
Response Format
Success Responses
Successful responses return JSON with appropriate HTTP status codes:Resource Lists
List endpoints return arrays:Error Responses
Errors return JSON with an error message and appropriate status code:HTTP Status Codes
Dockhand uses standard HTTP status codes:Request succeeded
Resource created successfully
Invalid request parameters or body
Authentication required or session expired
Insufficient permissions or enterprise license required
Resource or environment not found
Rate limit exceeded (login attempts)
Server error or Docker operation failed
Error Handling
Standard Error Format
All errors follow a consistent format:Human-readable error message
Additional error details when available
Common Error Scenarios
Docker Connection Errors
When a Docker environment is offline or unreachable, most endpoints return empty arrays or specific error messages:Permission Errors
When authentication is enabled and the user lacks required permissions:Validation Errors
When request parameters are invalid:API Resources
The Dockhand API provides access to:Core Resources
- Containers - Create, start, stop, and manage Docker containers
- Images - Pull, build, tag, and inspect Docker images
- Networks - Manage Docker networks
- Volumes - Create and manage Docker volumes
- Stacks - Deploy and manage Docker Compose stacks
Management
- Environments - Configure remote Docker connections
- Users - Manage user accounts (when authentication is enabled)
- Roles - Configure RBAC permissions (Enterprise)
- Settings - Application configuration and preferences
Git Integration
- Git Repositories - Connect to Git repositories for automated deployments
- Git Stacks - Deploy stacks from Git with automatic sync
- Webhooks - Configure automated deployments via Git webhooks
Monitoring
- Events - Stream Docker events in real-time
- Stats - Container and system metrics
- Health - System health checks
- Audit Logs - View security audit logs (Enterprise)
Streaming Responses
Some endpoints use Server-Sent Events (SSE) for real-time updates:- Container stats streaming
- Build output
- Stack deployment progress
- Docker events
Example: Streaming Events
Streaming endpoints require maintaining an open connection and return
Content-Type: text/event-stream.Rate Limiting
Rate limiting is applied to authentication endpoints:- Login attempts: 5 failed attempts per IP/username combination
- Lockout duration: Exponential backoff (5-60 seconds)
Environment Context
Most Docker-related operations require an environment ID to specify which Docker daemon to target:The ID of the Docker environment (1 for local, or remote environment IDs)
When no environment is configured, Dockhand connects to the local Docker daemon with
env=1.Pagination
Currently, the API does not implement pagination. All list endpoints return complete result sets.For large deployments, consider filtering by environment or using query parameters to reduce response sizes.
Versioning
The API currently does not use versioning. Breaking changes are avoided, and new fields are added in a backward-compatible manner.Example Requests
List Containers
Create Container
List Stacks
Deploy Stack
Best Practices
Authentication
- Always check if authentication is enabled via
/api/auth/session - Obtain session cookies via
/api/auth/login - Include session cookies in all subsequent requests
- Handle 401 responses by redirecting to login
Error Handling
- Always check HTTP status codes
- Parse error messages from response JSON
- Handle Docker connection errors gracefully
- Implement retry logic for transient failures
Environment Management
- Always specify the
envparameter for Docker operations - Handle 404 errors when environments are deleted
- Check environment health before operations
- Cache environment IDs on the client side
Performance
- Use streaming endpoints for long-running operations
- Filter results using query parameters
- Avoid polling - use event streams when available
- Implement client-side caching for static data
Support
For API issues or questions:- Check the GitHub repository for known issues
- Review the source code in
src/routes/api/for implementation details - Submit bug reports or feature requests via GitHub Issues
