Constants

Constants provide secure storage for API keys, passwords, database URLs, and other configuration values used by your Buzzy applications and Functions. Secret constants are encrypted using AES encryption to ensure sensitive data remains protected.

What are Constants?

Constants are key-value pairs that store configuration data for your applications:

  • API Keys: Store authentication tokens for external services

  • Database URLs: Connection strings for external databases

  • Configuration Values: Base URLs, default settings, and other config

  • Passwords: Encrypted storage for sensitive credentials

  • Environment Settings: Different values for development, staging, production

Types of Constants

Regular Constants

  • Stored as plain text

  • Suitable for non-sensitive configuration

  • Examples: API base URLs, default settings, public configuration

Secret Constants

  • Encrypted using AES encryption with a secure key

  • Automatically encrypted when marked as "secret"

  • Examples: API keys, passwords, database credentials, private tokens

Creating Constants

Through the UI

  1. Navigate to your app's Constants panel

  2. Click "Add Constant"

  3. Configure the constant:

    • Name: Unique identifier (e.g., API_KEY, DATABASE_URL)

    • Value: The actual value to store

    • Description: What this constant is used for

    • Secret: Check if this should be encrypted

  4. Click "Create Constant"

Naming Conventions

Use descriptive, uppercase names with underscores:

  • OPENAI_API_KEY

  • STRIPE_SECRET_KEY

  • DATABASE_URL

  • EMAIL_SERVICE_PASSWORD

  • API_BASE_URL

Using Constants in Functions

Constants can be referenced in Function environment variables using the BUZZYCONSTANTS() syntax:

Direct Reference

Dot Notation

In Function Code

Security Features

AES Encryption

Secret constants are encrypted using AES encryption:

  • Encryption key is stored securely on the server

  • Values are encrypted before storage in the database

  • Automatic decryption when accessed by authorized functions

  • No plain text storage of sensitive values

Access Control

  • Constants are scoped to individual applications

  • Only users with edit permissions can view/modify constants

  • Secret values are masked in the UI by default

  • Audit trail for constant creation and modification

Best Practices

  • Always mark sensitive data as "secret"

  • Use descriptive names that indicate the purpose

  • Regularly rotate API keys and update constants

  • Don't include secrets in function code or comments

Managing Constants

Viewing Constants

  • Constants panel shows all constants for your app

  • Secret values are masked with asterisks by default

  • Click the eye icon to temporarily reveal secret values

  • Non-secret values are always visible

Editing Constants

  1. Click the edit icon next to a constant

  2. Modify the name, value, description, or secret status

  3. Click "Save" to update the constant

  4. Functions using this constant will automatically get updated values

Deleting Constants

  1. Click the delete icon next to a constant

  2. Confirm deletion in the dialog

  3. Warning: Deleting a constant may break functions that depend on it

Common Use Cases

API Integration

Database Connection

Multi-Environment Setup

Webhook Configuration

Advanced Features

Formula Support

Constants support JSONata expressions for dynamic values:

Constant References

Constants can reference other constants:

Troubleshooting

Common Issues

Constant not found error

  • Verify the constant name is spelled correctly

  • Check that the constant exists in the current app

  • Ensure proper syntax: BUZZYCONSTANTS('CONSTANT_NAME')

Secret value not decrypting

  • Verify the constant is marked as secret

  • Check server encryption key configuration

  • Ensure proper permissions to access the constant

Function environment variable empty

  • Check the BUZZYCONSTANTS() reference syntax

  • Verify the constant exists and has a value

  • Test with a simple, non-secret constant first

Best Practices for Debugging

  1. Test with non-secret constants first to verify syntax

  2. Use descriptive constant names to avoid confusion

  3. Check function logs for environment variable values (excluding secrets)

  4. Verify constant values in the Constants panel before deployment

Security Considerations

  • Never log secret values in function code

  • Rotate API keys regularly and update constants

  • Use least-privilege access for external API keys

  • Monitor constant access through audit logs

  • Backup important constants before making changes

Migration and Backup

Exporting Constants

While there's no direct export feature, you can:

  1. Document constant names and descriptions

  2. Keep a secure backup of non-secret values

  3. Maintain a list of secret constants for reference

Moving Between Apps

Constants are app-specific and must be recreated when:

  1. Moving functions between apps

  2. Creating new environments

  3. Setting up development/staging/production instances

Version Control

Consider maintaining a configuration file with:

  • Constant names and descriptions

  • Non-secret default values

  • Documentation of what each constant is used for

  • Environment-specific variations

Last updated