Authentication Methods
Dokploy supports two authentication methods:- API Key Authentication (Recommended for programmatic access)
- Session Authentication (Used by the web dashboard)
For API integrations, webhooks, and automation, always use API key authentication.
API Key Authentication
API keys are passed in thex-api-key header with every request:
How It Works
- Generate an API key from the Dokploy dashboard
- Include the API key in the
x-api-keyheader - The API validates the key and associates the request with your organization
- Rate limits and permissions are enforced based on the key configuration
Creating an API Key
API keys must be created through the Dokploy API by authenticated users.Create API Key Endpoint
Procedure:user.createApiKey
Method: POST
Request:
| Parameter | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Descriptive name for the API key |
prefix | string | No | Custom prefix for the key (e.g., “prod”, “dev”) |
expiresIn | number | No | Expiration time in milliseconds from now |
metadata.organizationId | string | Yes | Organization ID this key belongs to |
rateLimitEnabled | boolean | No | Enable rate limiting |
rateLimitTimeWindow | number | No | Time window in milliseconds |
rateLimitMax | number | No | Max requests per time window |
remaining | number | No | Initial request limit |
refillAmount | number | No | Requests to refill |
refillInterval | number | No | Refill interval in milliseconds |
Using API Keys
Once you have an API key, include it in all API requests:Example: List All Projects
Example: Create a New Application
Example: Deploy an Application
Managing API Keys
List Your API Keys
API keys are returned when fetching user information: Procedure:user.get
Delete an API Key
Procedure:user.deleteApiKey
Deleting an API key immediately revokes access. All requests using the deleted key will fail with a
401 UNAUTHORIZED error.Rate Limiting
API keys can be configured with rate limiting to prevent abuse and control usage.Rate Limit Configuration
When creating an API key, you can configure: Time-based Rate Limiting:rateLimitEnabled: Enable rate limitingrateLimitTimeWindow: Time window in milliseconds (e.g., 60000 = 1 minute)rateLimitMax: Maximum requests allowed in the time window
remaining: Initial number of requests availablerefillAmount: Number of requests to add on each refillrefillInterval: Milliseconds between refills
Example: API Key with Rate Limiting
- Allows 100 requests per minute (time-based)
- Starts with 1000 total requests
- Refills 100 requests every hour
Security Best Practices
1. Store Keys Securely
- Never commit API keys to version control
- Use environment variables or secure vaults
- Rotate keys regularly
2. Use Descriptive Names
Name your API keys based on their purpose:3. Set Expiration Dates
For temporary access, set expiration dates:4. Implement Rate Limiting
Always enable rate limiting for production keys:5. Use Specific Keys for Different Environments
Create separate keys for development, staging, and production:Authorization
API keys inherit the permissions of the user who created them. Authorization is based on:Organization Membership
API keys are scoped to a specific organization. The key can only access resources within that organization.User Roles
Dokploy has three user roles with different permissions:| Role | Permissions |
|---|---|
| Owner | Full access to all resources and settings |
| Admin | Manage resources, users, and settings (except billing) |
| Member | View and manage assigned resources |
Protected Procedures
Some API procedures require specific roles:adminProcedure: Requires Owner or Admin roleprotectedProcedure: Requires any authenticated userpublicProcedure: No authentication required
Authentication Errors
401 Unauthorized
Missing or invalid API key:- Missing
x-api-keyheader - Invalid or expired API key
- API key has been deleted
403 Forbidden
Authenticated but lacking permissions:- Insufficient role (e.g., Member trying to access Admin endpoint)
- Resource belongs to different organization
- API key doesn’t have required permissions
Example: Complete Authentication Flow
Here’s a complete example of creating and using an API key:Next Steps
API Introduction
Learn about the API architecture and available routers
Projects API
Create and manage projects via API
Applications API
Deploy and manage applications programmatically
Error Handling
Handle API errors effectively