Overview
Dokploy API supports two authentication methods:- API Keys - Recommended for programmatic access and automation
- Session Cookies - Used by the web interface
API Key Authentication
Creating an API Key
To create an API key:- Log in to your Dokploy dashboard
- Navigate to Settings → API Keys
- Click Create API Key
- Provide a name and select the organization
- Copy the generated key (you won’t be able to see it again)
Using API Keys
Include your API key in theX-API-Key header with every request:
API Key Format
API keys are generated with metadata that includes:- Organization ID: Links the key to a specific organization
- User ID: Associates actions with your user account
- Creation timestamp: Tracks when the key was created
API Key Permissions
API keys inherit the permissions of the user who created them. The key has access to:- All resources within the associated organization
- The same role-based permissions as the creating user
- Only the organization specified during key creation
Session Cookie Authentication
Session cookies are primarily used by the Dokploy web interface. This method is less common for API integrations but may be useful for custom web applications.How It Works
- User logs in through the web interface
- Server creates a session and returns a session cookie
- Browser automatically includes the cookie in subsequent requests
Session Configuration
Sessions in Dokploy have the following properties:- Expiry: 3 days (259,200 seconds)
- Update Age: 24 hours (86,400 seconds)
- Security: HTTP-only cookies with SameSite protection
Authentication Flow
API Key Validation Process
When you make a request with an API key:Implementation Details
The authentication system (packages/server/src/lib/auth.ts) handles:
-
API Key Verification
- Validates the key exists and is active
- Retrieves associated user and organization
- Checks user membership in the organization
-
Session Creation
- Creates a mock session context for the request
- Injects organization and user information
- Applies role-based access controls
Making Authenticated Requests
Example: Get All Projects
Example: Create an Application
Error Handling
Authentication Errors
401 Unauthorized Occurs when:- API key is missing
- API key is invalid or expired
- API key doesn’t exist in the database
- User lacks permissions for the requested resource
- Organization access is denied
- Resource belongs to a different organization
Security Best Practices
Store API keys securely
Store API keys securely
- Never commit API keys to version control
- Use environment variables or secret management systems
- Rotate keys regularly
- Delete unused keys immediately
Use HTTPS only
Use HTTPS only
- Always use HTTPS for API requests
- Never send API keys over unencrypted connections
- Configure your Dokploy instance with SSL certificates
Limit API key scope
Limit API key scope
- Create separate API keys for different applications
- Use the principle of least privilege
- Monitor API key usage regularly
Implement rate limiting
Implement rate limiting
- Add client-side rate limiting to prevent abuse
- Handle 429 (Too Many Requests) responses gracefully
- Implement exponential backoff for retries
Organization Context
Each API key is associated with a specific organization. All API requests using that key operate within the context of that organization:- You can only access resources within the associated organization
- Multi-organization setups require separate API keys per organization
- Organization membership and roles are enforced for all requests
Next Steps
API Overview
Learn about the API architecture and available endpoints
Application Management
Start managing applications via the API
Docker Operations
Control containers and images programmatically
Project API
Manage projects and environments