Console →
SDK Reference

Initialization & Configuration

typescript
// lib/settle.ts
import { SettleSettle } from 'settlesettle'

if (!process.env.SETTLESETTLE_API_KEY) {
  throw new Error('SETTLESETTLE_API_KEY is not set in environment variables')
}

export const settle = new SettleSettle({
  apiKey: process.env.SETTLESETTLE_API_KEY,
})

Import this singleton wherever you need it:

typescript
import { settle } from '@/lib/settle'

Full configuration reference#

typescript
const settle = new SettleSettle({
  apiKey: 'ss_live_your_key', // Required if not in environment
  baseUrl: 'https://api.settlesettle.uno/v1', // Optional: Override API endpoint
  timeout: 10000,             // Optional: Request timeout in ms (default: 10000)
  eventBuffering: {
    enabled: true,            // Recommended: Process events in the background
    maxBatchSize: 50,         // Flush when queue reaches 50 events
    flushIntervalMs: 2000,    // Or flush every 2 seconds
  },
  retry: {
    maxRetries: 3,            // Retry on network/5xx/429 errors (default: 3)
    backoffFactor: 2,         // Exponential backoff multiplier (default: 2)
  },
})

All config options#

OptionTypeDefaultDescription
apiKeystringprocess.env.SETTLESETTLE_API_KEYYour app API key
baseUrlstringhttps://api.settlesettle.uno/v1The central SettleSettle API Base URL
timeoutnumber10000Request timeout in milliseconds
eventBuffering.enabledbooleantrueEnable background event batching
eventBuffering.maxBatchSizenumber50Force flush at this queue size
eventBuffering.flushIntervalMsnumber2000Background flush interval
retry.maxRetriesnumber3Max retry attempts per request
retry.backoffFactornumber2Exponential backoff multiplier