Logokeyset
  • Product
  • Pricing
  • Docs
  • Contact
LoginGet Started
keyset
Navigation
  • Product
  • Pricing
  • Docs
  • Contact
Login to AccountGet Started Free
keyset

A powerful configuration and content management system for modern applications.

Product

  • Features
  • Pricing
  • Use Cases
  • Documentation

Company

  • About
  • Blog
  • Contact

Legal

  • Privacy Policy
  • Terms of Service

Follow Us

TwitterGitHub

© 2026 Keyset. All rights reserved.

Logokeyset
  • Product
  • Pricing
  • Docs
  • Contact
LoginGet Started
keyset
Navigation
  • Product
  • Pricing
  • Docs
  • Contact
Login to AccountGet Started Free
Docs/Reference/Configuration
Getting Started
Reference
  • Configuration
  • Content API
  • React Integration
  • TypeScript Types
Guides

Configuration

The Keyset constructor accepts a single KeysetConfig object.

TypeScript
import { Keyset } from "keysetapp";

const client = new Keyset(config: KeysetConfig);

KeysetConfig

PropertyTypeRequiredDefaultDescription
apiKeystringYes—Your Keyset API key. Prefix pkey_ = public (read-only), skey_ = secret (read + write).
cacheTTLnumberYes—Top-level TTL in milliseconds. Used as a required field on the config shape.
baseUrlstringNohttps://api.keyset.in/v1Override the API base URL (useful for self-hosted deployments or local development).
timeoutnumberNo5000Request timeout in milliseconds. The request is aborted if it exceeds this value.
retriesnumberNo0Number of retry attempts on failure. Uses exponential backoff: 2^attempt × 100 ms.
cacheCacheConfigNo—Enable and configure the in-memory response cache.

CacheConfig

PropertyTypeRequiredDefaultDescription
enabledbooleanNofalseEnable the in-memory cache.
ttlnumberNo60000Time-to-live in milliseconds for cached entries.

Examples

Minimal (public, no cache)

TypeScript
const client = new Keyset({
  apiKey: "pkey_abc123",
  cacheTTL: 0,
});

With caching and retry

TypeScript
const client = new Keyset({
  apiKey: "pkey_abc123",
  cacheTTL: 60000,
  cache: {
    enabled: true,
    ttl: 60000, // cache responses for 60 seconds
  },
  retries: 3,
  timeout: 8000,
});

With a custom base URL

TypeScript
const client = new Keyset({
  apiKey: "pkey_abc123",
  cacheTTL: 0,
  baseUrl: "https://keyset.mycompany.com/api/v1",
});

Secret key (server-side)

TypeScript
const admin = new Keyset({
  apiKey: "skey_xyz789",
  cacheTTL: 0,
  retries: 2,
});

API key validation

The SDK validates the key format at construction time. Invalid keys throw immediately:

TypeScript
new Keyset({ apiKey: "", cacheTTL: 0 });
// Error: API key is required

new Keyset({ apiKey: "invalid_key", cacheTTL: 0 });
// Error: Invalid API key format

Valid prefixes are pkey_ (public) and skey_ (secret).

Cache internals

When cache.enabled is true, the SDK creates an in-memory MemoryCache instance with:

  • TTL — entries expire after cache.ttl milliseconds (default 60 000 ms)
  • Max size — 1 000 entries maximum; when full, the oldest entry is evicted (LRU-ish)
  • Garbage collection — expired entries are purged every 60 seconds automatically
  • Cache invalidation — write operations (create, update, delete) automatically delete the cached content response
PreviousQuick Start
NextContent API

Use with AI

Copy the full Keyset SDK reference as a ready-to-use AI prompt. Paste it into any AI tool to get instant, accurate integration help.

Resources

  • FAQ
  • Privacy Policy
keyset

A powerful configuration and content management system for modern applications.

Product

  • Features
  • Pricing
  • Use Cases
  • Documentation

Company

  • About
  • Blog
  • Contact

Legal

  • Privacy Policy
  • Terms of Service

Follow Us

TwitterGitHub

© 2026 Keyset. All rights reserved.