Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Implement Customer.io rate limiting and backoff. Use when handling high-volume API calls, implementing retry logic, or hitting 429 errors. Trigger: "customer.io rate limit", "customer.io throttle", "customer.io 429", "customer.io backoff", "customer.io too many requests".
.claude/skills/jeremylongshore-customerio-rate-limits/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-04 | ✗→✓ | ▲ Improved | 6% | 0% |
| case-05 | ✗→✓ | ▲ Improved | 30% | 0% |
| case-08 | ✗→✓ | ▲ Improved | 51% | 0% |
| case-11 | ✗→✓ | ▲ Improved | 59% | 0% |
| case-13 | ✗→✓ | ▲ Improved | 82% | 0% |
Understand Customer.io's API rate limits and implement proper throttling: token bucket limiters, exponential backoff with jitter, queue-based processing, and 429 response handling.
| API | Endpoint | Limit | Scope | |-----|----------|-------|-------| | Track API | identify, track, trackAnonymous | ~100 req/sec | Per workspace | | Track API | Batch operations | ~100 req/sec | Per workspace | | App API | Transactional email/push | ~100 req/sec | Per workspace | | App API | Broadcasts, queries | ~10 req/sec | Per workspace |
These are approximate. Customer.io uses sliding window rate limiting. When exceeded, you get a 429 Too Many Requests response.
typescript// lib/rate-limiter.ts export class TokenBucket { private tokens: number; private lastRefill: number; constructor( private readonly maxTokens: number = 80, // Stay under 100/sec limit private readonly refillRate: number = 80 // Tokens per second ) { this.tokens = maxTokens; this.lastRefill = Date.now(); } private refill(): void { const now = Date.now(); const elapsed = (now - this.lastRefill) / 1000; this.tokens = Math.min(this.maxTokens, this.tokens + elapsed * this.refillRate); this.lastRefill = now; } async acquire(): Promise<void> { this.refill(); if (this.tokens >= 1) { this.tokens -= 1; return; } // Wait until a token is available const waitMs = ((1 - this.tokens) / this.refillRate) * 1000; await new Promise((r) => setTimeout(r, Math.ceil(waitMs))); this.tokens = 0; this.lastRefill = Date.now(); } }
typescript// lib/backoff.ts interface BackoffOptions { maxRetries: number; baseDelayMs: number; maxDelayMs: number; jitter: number; // 0 to 1 } const DEFAULTS: BackoffOptions = { maxRetries: 4, baseDelayMs: 1000, maxDelayMs: 60000, jitter: 0.25, }; export async function withBackoff<T>( fn: () => Promise<T>, opts: Partial<BackoffOptions> = {} ): Promise<T> { const { maxRetries, baseDelayMs, maxDelayMs, jitter } = { ...DEFAULTS, ...opts }; let lastErr: Error | undefined; for (let attempt = 0; attempt <= maxRetries; attempt++) { try { return await fn(); } catch (err: any) { lastErr = err; const status = err.statusCode ?? err.status; // Don't retry 4xx errors (except 429) if (status >= 400 && status < 500 && status !== 429) throw err; if (attempt === maxRetries) break; // Check Retry-After header (429 responses) const retryAfter = err.headers?.["retry-after"]; let delay: number; if (retryAfter) { delay = parseInt(retryAfter) * 1000; } else { delay = Math.min(baseDelayMs * Math.pow(2, attempt), maxDelayMs); } // Add jitter to prevent thundering herd delay += delay * jitter * Math.random(); console.warn(`CIO retry ${attempt + 1}/${maxRetries} in ${Math.round(delay)}ms`); await new Promise((r) => setTimeout(r, delay)); } } throw lastErr; }
typescript// lib/customerio-rate-limited.ts import { TrackClient, RegionUS } from "customerio-node"; import { TokenBucket } from "./rate-limiter"; import { withBackoff } from "./backoff"; export class RateLimitedCioClient { private client: TrackClient; private limiter: TokenBucket; constructor(siteId: string, apiKey: string, ratePerSec: number = 80) { this.client = new TrackClient(siteId, apiKey, { region: RegionUS }); this.limiter = new TokenBucket(ratePerSec, ratePerSec); } async identify(userId: string, attrs: Record<string, any>): Promise<void> { await this.limiter.acquire(); return withBackoff(() => this.client.identify(userId, attrs)); } async track(userId: string, event: { name: string; data?: any }): Promise<void> { await this.limiter.acquire(); return withBackoff(() => this.client.track(userId, event)); } async trackAnonymous(event: { anonymous_id: string; name: string; data?: any; }): Promise<void> { await this.limiter.acquire(); return withBackoff(() => this.client.trackAnonymous(event)); } async suppress(userId: string): Promise<void> { await this.limiter.acquire(); return withBackoff(() => this.client.suppress(userId)); } async destroy(userId: string): Promise<void> { await this.limiter.acquire(); return withBackoff(() => this.client.destroy(userId)); } }
For sustained high volume, use p-queue for cleaner concurrency control:
typescript// lib/customerio-queued.ts import PQueue from "p-queue"; import { TrackClient, RegionUS } from "customerio-node"; const cio = new TrackClient( process.env.CUSTOMERIO_SITE_ID!, process.env.CUSTOMERIO_TRACK_API_KEY!, { region: RegionUS } ); // Process at most 80 requests per second with max 10 concurrent const queue = new PQueue({ concurrency: 10, interval: 1000, intervalCap: 80, }); // Queue operations instead of calling directly export function queueIdentify(userId: string, attrs: Record<string, any>) { return queue.add(() => cio.identify(userId, attrs)); } export function queueTrack(userId: string, name: string, data?: any) { return queue.add(() => cio.track(userId, { name, data })); } // Monitor queue health setInterval(() => { console.log( `CIO queue: pending=${queue.pending} size=${queue.size}` ); }, 10000);
Install: npm install p-queue
For large data imports (>10K users), avoid hitting rate limits with controlled batching:
typescript// scripts/bulk-import.ts import { RateLimitedCioClient } from "../lib/customerio-rate-limited"; async function bulkImport(users: { id: string; attrs: Record<string, any> }[]) { const client = new RateLimitedCioClient( process.env.CUSTOMERIO_SITE_ID!, process.env.CUSTOMERIO_TRACK_API_KEY!, 50 // Conservative rate — 50/sec for imports ); let processed = 0; let errors = 0; for (const user of users) { try { await client.identify(user.id, user.attrs); processed++; } catch (err: any) { errors++; console.error(`Failed user ${user.id}: ${err.message}`); } if (processed % 1000 === 0) { console.log(`Progress: ${processed}/${users.length} (${errors} errors)`); } } console.log(`Done: ${processed} processed, ${errors} errors`); }
| Scenario | Strategy | |----------|----------| | 429 received | Respect Retry-After header, fall back to exponential backoff | | Burst traffic spike | Token bucket absorbs burst, queue holds overflow | | Sustained high volume | Use p-queue with interval limiting | | Bulk import | Use conservative rate (50/sec) with progress logging | | Downstream timeout | Don't count as rate limit — retry normally |
After implementing rate limits, proceed to customerio-security-basics for security best practices.
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→fail | 22,100 | 15,024 | -32% | 1 | 1 | 0% | 5,031 | 5,554 | +10% | 0 | 0 | — |
case-02 | fail→fail | 17,424 | 14,388 | -17% | 1 | 1 | 0% | 3,636 | 5,367 | +48% | 0 | 0 | — |
case-03 | pass→pass | 11,467 | 4,466 | -61% | 1 | 1 | 0% | 2,028 | 3,023 | +49% | 0 | 0 | — |
case-04 | fail→pass | 14,347 | 5,120 | -64% | 1 | 1 | 0% | 2,923 | 3,101 | +6% | 0 | 0 | — |
case-05 | fail→pass | 10,495 | 3,747 | -64% | 1 | 1 | 0% | 2,243 | 2,920 | +30% | 0 | 0 | — |
case-06 | pass→pass | 11,956 | 7,087 | -41% | 1 | 1 | 0% | 2,430 | 3,668 | +51% | 0 | 0 | — |
case-07 | pass→pass | 11,290 | 7,232 | -36% | 1 | 1 | 0% | 2,475 | 3,700 | +49% | 0 | 0 | — |
case-08 | fail→pass | 16,802 | 12,711 | -24% | 1 | 1 | 0% | 3,304 | 5,001 | +51% | 0 | 0 | — |
case-09 | fail→fail | 17,317 | 10,431 | -40% | 1 | 1 | 0% | 3,132 | 4,282 | +37% | 0 | 0 | — |
case-10 | pass→pass | 9,390 | 9,973 | +6% | 1 | 1 | 0% | 1,699 | 4,088 | +141% | 0 | 0 | — |
case-11 | fail→pass | 9,491 | 2,923 | -69% | 1 | 1 | 0% | 1,746 | 2,770 | +59% | 0 | 0 | — |
case-12 | pass→pass | 10,432 | 3,871 | -63% | 1 | 1 | 0% | 2,072 | 2,978 | +44% | 0 | 0 | — |
case-13 | fail→pass | 7,421 | 1,412 | -81% | 1 | 1 | 0% | 1,362 | 2,483 | +82% | 0 | 0 | — |
case-14 | fail→pass | 14,276 | 9,555 | -33% | 1 | 1 | 0% | 2,852 | 4,296 | +51% | 0 | 0 | — |
case-15 | fail→pass | 13,839 | 8,123 | -41% | 1 | 1 | 0% | 2,362 | 3,910 | +66% | 0 | 0 | — |
case-16 | pass→pass | 16,440 | 11,983 | -27% | 1 | 1 | 0% | 3,021 | 4,214 | +39% | 0 | 0 | — |
case-17 | fail→pass | 12,245 | 4,552 | -63% | 1 | 1 | 0% | 2,100 | 3,175 | +51% | 0 | 0 | — |
case-18 | fail→fail | 14,061 | 6,114 | -57% | 1 | 1 | 0% | 2,573 | 3,268 | +27% | 0 | 0 | — |
case-19 | pass→pass | 14,418 | 7,783 | -46% | 1 | 1 | 0% | 3,044 | 3,831 | +26% | 0 | 0 | — |
case-20 | pass→pass | 5,467 | 5,002 | -9% | 1 | 1 | 0% | 1,110 | 3,128 | +182% | 0 | 0 | — |
case-21 | pass→pass | 11,743 | 7,982 | -32% | 1 | 1 | 0% | 2,172 | 3,783 | +74% | 0 | 0 | — |
case-22 | pass→pass | 9,047 | 9,177 | +1% | 1 | 1 | 0% | 1,625 | 4,008 | +147% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +36 percentage points is the difference between those two pass rates over the 22 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.