Skip to main content
OnDB uses two key types to authenticate application operations and autonomous agent operations.

Key Types

App Key (X-App-Key)

  • Required for write operations
  • Identifies the application
  • Used for app-level permissions

Agent Key (X-Agent-Key)

  • App Key with Pay permission
  • Enables autonomous agents to pay other apps inline
  • Configurable spend limits and target app whitelisting

Configuration

TypeScript

App Key Permissions

App Keys support a four-tier permission system, allowing you to create keys with granular access control:

Read

  • Query data
  • Read documents
  • Access collections
  • View indexes

Write

  • Store data
  • Update documents
  • Delete documents
  • Create collections

Admin

  • Manage indexes
  • Configure encryption
  • App-level settings
  • Full access

Pay

  • Agent Key permission
  • Pay other apps inline via USDC
  • Configurable spend limits
  • Target app whitelisting
When generating an App Key from the Dashboard, you can select any combination of these permissions:
Create separate keys with minimal permissions for different parts of your application. A read-only key for your frontend proxy and a write key for your backend services.

Agent Keys

An Agent Key is an App Key with the Pay permission. It enables autonomous agents to pay other apps inline when storing or querying their data, using USDC.

Generating an Agent Key

Using an Agent Key

TypeScript

How Agent Auto-Pay Works

Writes: The broker handles payment automatically in a background task:
Reads: The agent key authenticates the request. If the collection has paid fields, the standard PaymentRequiredError flow applies separately.

Pay Limits

All limits are optional — omit any to leave it uncapped. Limits are enforced fail-fast in order:
1 USDC = 1,000,000 uUSDC (6 decimals). A max_payment_per_tx of 5_000_000 means 5 USDC.

App Key Usage

The App Key (X-App-Key header) is required for all write operations:
  • Creating documents
  • Updating documents
  • Deleting documents
  • Creating indexes
  • Creating collections
  • Managing views
TypeScript

Managing App Keys

Generating a New Key

  1. Go to app.ondb.ai
  2. Log in to your account
  3. Select your application
  4. Navigate to the Security tab
  5. Enter a name for your key (e.g., “production-backend”, “staging-api”)
  6. Select the permissions (Read, Write, Admin)
  7. Click Generate New API Key
  8. Approve the transaction (small fee ~$0.001 USDC)
  9. Copy your key immediately - it will only be shown once
App Keys are only displayed once at creation time. Store them securely in your environment variables or secrets manager immediately after generation.

Listing Existing Keys

From the Security tab, click Load Keys to view all your active App Keys. For each key you can see:
  • Key Hash: First 16 characters of the key hash for identification
  • Name: The name you assigned when creating the key
  • Permissions: Visual badges showing Read/Write/Admin access
  • Created: When the key was generated
  • Last Used: Most recent API request with this key

Revoking a Key

If a key is compromised or no longer needed:
  1. Go to the Security tab
  2. Click Load Keys to list all keys
  3. Find the key you want to revoke
  4. Click the Revoke button
  5. Confirm the revocation
  6. Approve the transaction
Revoked keys are immediately invalidated. Any applications using that key will receive authentication errors.

Security Best Practices

Never expose your App Key in client-side code. Use environment variables and server-side APIs for write operations.

Key Management Guidelines

Server-Side Configuration

TypeScript

HTTPS Only

Always use HTTPS when communicating with OnDB APIs. Never send App Keys over unencrypted connections.

Next Steps

Security Settings

Authentication and authz grants

Collections & Indexes

Learn about organizing your data

Payment Flows

Understand payment options