Getting your API key
1
Sign up or log in
Go to app.daytona.io and create an account or log in
2
Navigate to API keys
Click on your profile and go to Dashboard > API Keys
3
Generate a new key
Click “Generate New API Key” and give it a descriptive name
4
Copy and store securely
Copy the API key immediately - you won’t be able to see it again
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
Using .env files
For local development, you can use a.env file to store your API key:
1
Create a .env file
Create a file named
.env in your project root:2
Add to .gitignore
Make sure
.env is in your .gitignore:3
Load environment variables
Use a library to load the
.env file:- Python
- TypeScript
- Go
- Ruby
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
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