For AI agents: the documentation index is at /docs/aidbox/llms.txt. A Markdown version of this page is available at /docs/aidbox/configuration/secrets.md or by requesting it with the Accept: text/markdown header.
Aidbox Docs

Secrets

Aidbox keeps secrets in three places:

  • Settings: credentials and keys you pass as environment variables, such as the database password or the JWT signing key.
  • Resource fields: values stored in the database inside resources, such as a Client secret or an AwsAccount access key.
  • External secret files: files that Aidbox reads at runtime, so the value never reaches the database.

Secrets in settings

Aidbox marks the settings below as sensitive. For a sensitive setting, Aidbox:

  • masks the value in the Admin UI and in the settings API;
  • leaves the value out of error messages when it can't parse it;
  • accepts the value only from an environment variable and rejects attempts to store it in the database.

The settings export endpoint (/api/v1/settings/export) returns sensitive values in plaintext. It is off by default. Keep BOX_EXPORT_SETTINGS_ENDPOINT set to false in production.

The settings reference lists the deprecated environment variable names and the details for each setting.

Bootstrap credentials

Environment variablePurpose
BOX_ROOT_CLIENT_SECRETSecret of the root client, which has full access to the API.
BOX_ADMIN_PASSWORDPassword of the admin user for the Admin UI.

Set both in every environment. See Recommended environment variables.

Database

SettingEnvironment variablePurpose
db.passwordBOX_DB_PASSWORDPassword of the database user.
db.maintenance.passwordBOX_DB_MAINTENANCE_PASSWORDPassword of the user that creates the database and runs maintenance. Falls back to BOX_DB_PASSWORD.
db.ro-replica.passwordBOX_DB_RO_REPLICA_PASSWORDPassword for the read-only replica.
db.databricks-client-secretBOX_DB_DATABRICKS_CLIENT_SECRETOAuth client secret for Databricks Lakebase authentication.
db.ro-replica.databricks-client-secretBOX_DB_RO_REPLICA_DATABRICKS_CLIENT_SECRETThe same for the read-only replica.

Token signing and encryption keys

SettingEnvironment variablePurpose
security.auth.keys.privateBOX_SECURITY_AUTH_KEYS_PRIVATERSA private key that signs the JWTs Aidbox issues (RS256). Pair it with BOX_SECURITY_AUTH_KEYS_PUBLIC.
security.auth.keys.secretBOX_SECURITY_AUTH_KEYS_SECRETShared secret for HS256 JWTs.
security.encrypt-secretBOX_SECURITY_ENCRYPT_SECRETKey for the Encryption API and for resource fields that Aidbox encrypts.

Email providers

SettingEnvironment variablePurpose
provider.default.passwordBOX_MODULE_PROVIDER_DEFAULT_PASSWORDPassword of the default provider.
provider.smtp.passwordBOX_MODULE_PROVIDER_SMTP_PASSWORDSMTP password.
provider.mailgun.passwordBOX_MODULE_PROVIDER_MAILGUN_PASSWORDMailgun password.
provider.postmark.api-keyBOX_MODULE_PROVIDER_POSTMARK_API_KEYPostmark API key.
provider.sendgrid.api-keyBOX_MODULE_PROVIDER_SENDGRID_API_KEYSendGrid API key.

Aidbox doesn't mark the Postmark and SendGrid API keys as sensitive, so the Admin UI shows them in plaintext. Limit access to the Admin UI settings page if you use these providers.

Observability

SettingEnvironment variablePurpose
observability.datadog.api-keyBOX_OBSERVABILITY_DATADOG_API_KEYDatadog API key for log shipping.
observability.elasticsearch.authBOX_OBSERVABILITY_ELASTICSEARCH_AUTHElasticsearch credentials as <user>:<password>.

Modules and integrations

SettingEnvironment variablePurpose
module.subscriptions.pubsub.service-account.private-keyBOX_MODULE_SUBSCRIPTIONS_PUBSUB_SERVICE_ACCOUNT_PRIVATE_KEYGCP service account key for Pub/Sub subscriptions.
module.webpush.private-keyBOX_MODULE_WEBPUSH_PRIVATE_KEYPrivate key for web push notifications.
module.health-cards-links.issuer-private-keyBOX_MODULE_HEALTH_CARDS_LINKS_ISSUER_PRIVATE_KEYIssuer key that signs SMART Health Cards.
module.sdc.openai-api-keyBOX_MODULE_SDC_OPENAI_API_KEYOpenAI API key for Formbox AI features.
modules.sdc.gemini-api-keyBOX_SDC_GEMINI_API_KEYGemini API key for Formbox.
module.sdc.twilio-auth-tokenBOX_MODULE_SDC_TWILIO_AUTH_TOKENTwilio auth token for Formbox outbound voice calls.
module.sdc.dtr.client-secretBOX_MODULE_SDC_DTR_CLIENT_SECRETClient secret for the Da Vinci DTR service.

Formbox also takes API keys for ElevenLabs, Deepgram, and Cartesia (BOX_MODULE_SDC_ELEVENLABS_API_KEY, BOX_MODULE_SDC_DEEPGRAM_API_KEY, BOX_MODULE_SDC_CARTESIA_API_KEY).

Secrets in resources

Values Aidbox hashes or encrypts

Aidbox transforms these fields before it saves the resource:

FieldWhat Aidbox stores
User.passwordAn scrypt hash.
Client.secretA SHA-256 hash.
Session.access_token, Session.refresh_token, Session.authorization_codeA SHA-256 hash.
SDCConfig auth.client-secret (form store, data store, terminology server, DTR service)A value encrypted with security.encrypt-secret.

Aidbox can't recover a hashed value, only compare a submitted one against it. To change a client secret or a password, write a new value.

To keep the Client and SDCConfig secrets out of the database entirely, use External Secrets.

Values Aidbox stores as you send them

These fields hold credentials for external systems, and Aidbox saves them in the database unchanged:

ResourceFields
AwsAccountsecret-access-key
GcpServiceAccountprivate-key
AzureAccountkey, clientSecret
IdentityProviderclient.secret, client.private-key, client.certificate
TokenIntrospectorjwt.secret, jwt.keys.k, introspection_endpoint.authorization
AidboxTopicDestinationKafka saslJaasConfig and sslKeystoreKey, webhook header, and the credentials of module destinations: password (NATS, ClickHouse, RabbitMQ, AMQP 1.0), serviceAccountKey (BigQuery), AWS keys (Data Lakehouse, EventBridge, SNS)

Restrict read access to these resource types with access policies. To keep these values out of the database:

  • For IdentityProvider, TokenIntrospector, and AidboxTopicDestination, use External Secrets. For module destinations, check the minimum module version in Supported resources. AWS EventBridge and SNS destinations don't support secret references, so omit their AWS keys and use the AWS default credentials chain.
  • For cloud storage accounts, External Secrets don't apply. Use the keyless mode instead: the default credentials chain for AWS (omit access-key-id), Workload Identity for GCP, or workload identity for Azure. Aidbox then gets credentials from the cloud platform and stores no key.

Keep secrets out of the database

External Secrets let a resource field point to a file instead of holding the value:

  1. You mount the secret as a file, for example from a Kubernetes Secret or a vault CSI driver.
  2. A vault config file, set with BOX_VAULT_CONFIG, maps a secret name to the file path and to the resources that may use it.
  3. The resource stores only the secret name in a secret-reference extension. Aidbox reads the file when it needs the value and never returns the value through the API.

External Secrets also hold the keys for field-level encryption, with "kind": "encryption" in the vault config.

See the Azure Key Vault and HashiCorp Vault tutorials for end-to-end setups.

Rotate secrets

SecretHow to rotate
SettingsChange the environment variable and restart Aidbox. Aidbox reads sensitive settings only from environment variables, so a new value takes effect after the restart.
JWT signing keysTokens signed with the old key stop validating after the restart, so clients have to get new tokens.
security.encrypt-secretRe-encrypt every value stored with the old key. See Rotating security.encrypt-secret.
Client.secret, User.passwordWrite a new value to the resource.
External secret filesReplace the file. Aidbox notices the new modification time and uses the new value without a restart.
Field-level encryption keysAdd the new key next to the old one, as described in Key rotation.

Rotating security.encrypt-secret

security.encrypt-secret is a single symmetric key, so Aidbox can't keep the old and the new key side by side the way field-level encryption can. The moment you change the key, every value encrypted with the old one becomes unreadable: Aidbox can no longer decrypt it, and the Encryption API returns an error for ciphertext produced with a different key.

Plan the rotation so you can re-encrypt those values:

  1. Find what the key protects. This includes the encrypted SDCConfig fields (auth.client-secret of the form store, data store, terminology server, and DTR service), any ciphertext you created through the Encryption API, and any other field Aidbox encrypts with this key.
  2. Collect the plaintext. Aidbox stores only the ciphertext, so you need the original secret from your own records — you can't recover it from Aidbox once the key changes.
  3. Change the key and restart. Set the new BOX_SECURITY_ENCRYPT_SECRET and restart Aidbox. Sensitive settings come only from environment variables, so the new key takes effect on restart.
  4. Write the plaintext back. Re-save each affected resource with the plaintext secret so Aidbox encrypts it with the new key. For SDCConfig, write the auth.client-secret fields again; if the config points at external FHIR servers, update their credentials too.

To avoid re-encrypting on every rotation, keep these secrets in External Secrets instead. Aidbox reads them from the vault at runtime and never encrypts them with security.encrypt-secret, so rotating the key leaves them untouched.

Recommendations

  • Pass secrets as environment variables from your orchestrator's secret store, such as Kubernetes Secrets. Don't commit them to docker-compose.yaml or Helm values files.
  • Use External Secrets for credentials in resources where Aidbox supports it, and keyless cloud credentials for storage accounts.
  • Generate long random values for BOX_ROOT_CLIENT_SECRET, BOX_ADMIN_PASSWORD, and BOX_SECURITY_AUTH_KEYS_SECRET.
  • Give the database user only the privileges Aidbox needs, and use a separate maintenance user if your platform allows it.
  • Keep the settings export endpoint off.
  • See Security hardening for related recommendations.

Last updated: