Getting your API key
Sign up or log in
Go to app.daytona.io and create an account or log in
Navigate to API keys
Click on your profile and go to Dashboard > API Keys
Configuration methods
There are two main ways to configure the SDK with your API key:Environment variables (recommended)
The simplest and most secure method is to use environment variables:Configuration object
You can also pass the API key directly in your code:Environment variables reference
| Variable | Description | Required | Default |
|---|---|---|---|
DAYTONA_API_KEY | Your Daytona API key | Yes | - |
DAYTONA_API_URL | The Daytona API endpoint | No | https://app.daytona.io/api |
DAYTONA_TARGET | Target region for sandboxes | No | us |
Using .env files
For local development, you can use a.env file to store your API key:
Production best practices
For production deployments:Use environment variables
Use environment variables
Always use environment variables or a secrets manager (AWS Secrets Manager, HashiCorp Vault, etc.) instead of hardcoding API keys.
Rotate keys regularly
Rotate keys regularly
Generate new API keys periodically and revoke old ones:
- Generate a new key in the dashboard
- Update your production environment
- Revoke the old key after confirming the new one works
Use separate keys per environment
Use separate keys per environment
Create different API keys for development, staging, and production:
Monitor API key usage
Monitor API key usage
Regularly check your API key usage in the Daytona dashboard to detect:
- Unusual activity patterns
- Compromised keys
- Rate limit issues
Verifying authentication
To verify your API key is working correctly:Troubleshooting
401 Unauthorized error
401 Unauthorized error
Environment variable not loading
Environment variable not loading
Make sure you’ve exported the variable in your current shell:If empty, export it again or add it to your shell profile (
~/.bashrc, ~/.zshrc, etc.).Connection errors
Connection errors
If you’re getting connection errors:
- Verify your internet connection
- Check if you’re behind a proxy or firewall
- Ensure
DAYTONA_API_URLis set correctly if using a custom endpoint
Next steps
Quickstart
Create your first sandbox in under 5 minutes
SDK guides
Learn about SDK configuration options for all languages