Convex Api Keys

Add production-ready API key management to Convex with rotation, expiration, typed permissions, and audit logging for secure API access control.

Installation

npm install convex-api-keys

About Convex Api Keys

Convex API Keys adds production-ready API key management to Convex.

## Features
- Create, validate, rotate, touch, and revoke keys
- Support expiration and idle timeouts
- Add typed namespaces, permissions, and metadata
- Keep audit logs for key lifecycle events
- Retain keys and audit events on separate cleanup schedules

## Use cases
A good fit for public APIs, partner integrations, internal tools, and service-to-service authentication.

Benefits

Use cases

how to add API key authentication to Convex functions

Convex API Keys provides functions to create, validate, and manage API keys directly in your Convex backend. You can validate incoming API keys in your functions and enforce permissions based on namespaces and metadata attached to each key.

Convex API key rotation and expiration

The component automatically handles key rotation with configurable expiration dates and idle timeouts. Keys can be programmatically rotated while maintaining audit logs of all lifecycle events for security compliance.

secure service to service authentication Convex

Use typed permissions and namespaces to create service-specific API keys with granular access control. The component supports metadata attachment and separate cleanup schedules for keys and audit events.

Convex public API security best practices

Convex API Keys implements production security patterns including automatic key expiration, usage tracking, and comprehensive audit logging. This enables secure public API exposure without custom authentication infrastructure.

Frequently asked questions

How does Convex API Keys handle key validation performance?

Convex API Keys leverages Convex's built-in database indexes for fast key lookups and validation. The component includes a touch function to update last-used timestamps for idle timeout tracking without impacting validation performance.

Can I customize permissions and metadata for different API keys?

Yes, Convex API Keys supports typed namespaces, custom permissions, and arbitrary metadata attachment to keys. This allows you to implement role-based access control and store application-specific data with each key.

What audit information does Convex API Keys track?

The component maintains comprehensive audit logs for all key lifecycle events including creation, validation, rotation, and revocation. Audit events and keys have separate configurable cleanup schedules for compliance requirements.

How do I handle API key rotation without service interruption?

Convex API Keys supports overlapping key validity periods during rotation. You can create new keys before revoking old ones, and the audit logs track the complete rotation history for each key.

Links