Skip to main content

Creating Secrets

Learn how to create and manage encrypted secrets for API keys, passwords, and tokens.

What You’ll Learn

  • How to create string secrets (API keys, passwords)
  • How to create OAuth2 secrets (auto-refreshing tokens)
  • Naming conventions and best practices
  • Secret versioning and rotation

Creating a String Secret

String secrets are the most common type - used for API keys, passwords, tokens, and any sensitive text value.

Step 1: Navigate to Secrets

  1. Click Secrets in the sidebar
  2. The Secrets page shows a two-level hierarchy: collections at the top level, secrets within each collection. Click a collection to see its secrets. Secrets not assigned to a collection appear under Uncollected.
  3. Click Add Secret (at the top level or within a collection)

Step 2: Choose Secret Type

Select String Secret For OAuth2 tokens, see OAuth2 Secrets below.

Step 3: Enter Secret Details

Secret Name (Required)

The name you’ll use to reference this secret in routes. Format: lowercase with underscores Good examples:
Bad examples:
Why naming matters: You’ll reference secrets in templates like this:
Clear names make your configurations self-documenting.

Secret Value (Required)

The actual sensitive value to encrypt and store. Examples:
Important:
  • Copy from source carefully (no extra spaces!)
  • Value is encrypted immediately after saving
  • You won’t be able to view plaintext again

Step 4: Save

Click Create Secret Done! Your secret is now:
  • Encrypted with AES-256-GCM
  • Stored securely
  • Ready to use in routes
⚠️ Important: The plaintext value is now gone from the UI. If you need to reference it later, you’ll need to get it from the original source.

Creating OAuth2 Secrets

OAuth2 secrets are special - they automatically refresh access tokens when they expire.

When to Use OAuth2 Secrets

Use OAuth2 for services that require token refresh:
  • ✅ Google APIs (Gmail, Drive, Sheets)
  • ✅ Microsoft Graph (Office 365, OneDrive)
  • ✅ Shopify
  • ✅ HubSpot
  • ✅ Salesforce
  • ✅ Slack

Step 1: Choose OAuth2 Secret Type

When creating secret, select OAuth2 Secret

Step 2: Fill in OAuth2 Details

Secret Name

OAuth2 Configuration

Client ID:
From your OAuth app settings Client Secret:
From your OAuth app settings Provider:
One of the supported OAuth2 providers (e.g. google, microsoft) Scopes (optional):
Defaults to the provider’s default scopes if omitted Auth URL / Token URL (optional):
Override the provider’s authorize/token endpoints; defaults are filled in for you
You do not paste in an access token, refresh token, or expiry at creation time. KnoxCall stores only your OAuth app’s client_id/client_secret (or an mtls_certificate_id) plus the endpoint config. The secret is created with connection_status: "not_connected", and the response includes a minted redirect_uri.

Step 3: Save and Connect

Click Create Secret. The response includes a redirect_uri on the fixed oauth.knoxcall.com/callback host. Complete the OAuth flow to obtain tokens. Visit the authorization URL, approve access at the provider, and the provider redirects back to the minted redirect_uri. KnoxCall then exchanges the code for tokens and flips connection_status to connected. Once connected, KnoxCall will:
  • Monitor token expiry
  • Refresh before expiration using the stored refresh token
  • Update the access token automatically
  • Log refresh events

Secret Naming Conventions

Pattern: {service}_{environment}_{type}

Examples:

By Service

By Environment

By Purpose

Multiple Secrets for Same Service

When you need different keys for different purposes:

Environment-Specific Secrets

Create separate secrets for each environment:

Production Secrets

Staging Secrets

Development Secrets

Then use in route overrides:

Best Practices

✅ Do

1. Use descriptive names
2. Document with descriptions
3. Separate by environment
4. Tag appropriately
5. Version for rotation
6. Use OAuth2 type when applicable

❌ Don’t

1. Don’t commit secrets to git
2. Don’t reuse across environments
3. Don’t use generic names
4. Don’t skip descriptions
5. Don’t expose test keys in production

Secret Security

How Secrets Are Stored

  1. Encryption: AES-256-GCM (military-grade)
  2. Envelope encryption: Each secret has unique encryption key
  3. Master key: Stored separately, never exposed
  4. Integrity: SHA-256 checksum verification

Who Can Access Secrets

View encrypted secrets:
  • All team members with access
View plaintext values:
  • Nobody - not even admins!
  • Plaintext only visible when:
    • Initially created (one-time viewing)
    • Decrypted server-side during requests
    • Never shown in logs or UI
Use secrets in routes:
  • Anyone with route edit permissions

Secret Transmission

When requests use secrets:
  1. Client makes request to KnoxCall
  2. KnoxCall loads route config
  3. Sees {{secret:stripe_key}} template
  4. Decrypts secret server-side
  5. Injects into request to backend
  6. Client never sees plaintext!

Common Use Cases

1. Payment APIs

Stripe:
Usage in route:

2. Email Services

SendGrid:
Usage:

3. SMS Services

Twilio:
Usage:

4. Database Credentials

PostgreSQL:
Usage in body:

5. Webhook Secrets

GitHub:
Usage:

6. Printing Services

PrintNode:
Usage:

Secret Versioning

KnoxCall tracks secret versions for safe rotation.

Creating a New Version

When rotating a secret:
  1. Go to Secrets
  2. Click on secret name
  3. Click Add New Version
  4. Enter new value
  5. Save
What happens:
  • New version becomes active immediately
  • Old version preserved (for rollback)
  • All routes using secret now use new value
  • Zero downtime!

Viewing Version History

  1. Click secret name
  2. Go to Version History tab
  3. See all versions with timestamps
  4. Can rollback if needed

Troubleshooting

Secret Not Found in Templates

Error: Secret 'stripe_key' not found Causes:
  • Typo in secret name
  • Secret was deleted
  • Wrong syntax in template
Solution:
  1. Check secret exists: ResourcesSecrets
  2. Verify spelling matches exactly
  3. Check template syntax: {{secret:name}}

Cannot View Secret Value

Symptom: Want to see what the value is. Cause: Plaintext never shown after creation (security feature). Solution:
  • Get value from original source
  • Or create new version with known value

Secret Not Injecting

Symptom: Backend receives literal {{secret:stripe_key}} text. Causes:
  • Template syntax error
  • Secret doesn’t exist
  • Injection disabled
Debug:
  1. Check logs - what was actually sent?
  2. Verify template syntax is correct
  3. Test secret exists and name matches
  4. Verify inject headers is enabled on route

Quick Reference


Next Steps

Using Secrets

How to inject secrets into routes

Secrets Overview

Complete secrets guide

OAuth2 Flow

Set up OAuth2 auto-refresh

Rotation Strategies

Best practices for rotating secrets

Security Reminder: Never commit secrets to git, share via email, or hardcode in applications. Always use KnoxCall’s encrypted secret storage.