What are Secrets
Secrets are secure environment variables for storing sensitive information like API keys, database passwords, and authentication tokens. They’re essential for:- Payment processing - Stripe, PayPal API keys
- Email services - SendGrid, Resend API keys
- External APIs - HubSpot, Zendesk, custom service credentials
- Database connections - Connection strings and passwords
Managing Secrets in the Dashboard
Adding Secrets
- Go to the Secrets tab in OptiDev Cloud
- Click Add Secret
- Enter a name (like
STRIPE_SECRET_KEY) - Enter the value (your actual API key)
- Click Add another to add more secrets, or click Save to finish
Use UPPERCASE_WITH_UNDERSCORES for secret names. This is the standard convention and makes them easy to identify in your code.
Viewing Secrets
The Secrets tab shows all your secrets with:- Secret name - The identifier you use in code
- SHA256 digest - For verification (not the actual value)
- Last updated - When the secret was last modified
Deleting a Secret
- Click the trash icon next to the secret you want to remove
- Confirm the deletion
Using Secrets with OptiDev Agent
Ask OptiDev Agent to use your secrets when creating functions:“Create a Stripe payment function using my STRIPE_SECRET_KEY secret”OptiDev Agent will:
- Write code that securely accesses your secret
- Never expose the secret value in your frontend code
- Use the proper
Deno.env.get()method to retrieve it
Example: Email Service
“Set up email sending with my SENDGRID_API_KEY secret”
Example: Database Connection
“Connect to my external database using the DATABASE_URL secret”
Security
Write-Only Storage
Secrets are write-only for security. Once saved:- You can see the secret name
- You can see a SHA256 digest for verification
- You cannot view the actual value
Auto-Injected Secrets
These secrets are automatically available in all Edge Functions without adding them manually:SUPABASE_URL- Your project URLSUPABASE_ANON_KEY- Public (publishable) keySUPABASE_SERVICE_ROLE_KEY- Admin key with full accessSUPABASE_DB_URL- Direct database connection string
Auto-injected secrets are not visible in the Secrets tab. They’re automatically available to your Edge Functions.
For Developers
Technical Reference
Technical Reference
Accessing Secrets in Edge Functions
UseDeno.env.get() to access secrets in your function code:Secret Naming Conventions
- Use
UPPERCASE_WITH_UNDERSCORES - Be descriptive:
STRIPE_SECRET_KEYnotSK - Include the service name:
HUBSPOT_API_KEY,ZENDESK_TOKEN