Skip to main content
customerio-rate-limits 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".
설치로 이동 Skills Marketplace 커뮤니티가 만든 AI 스킬을 발견하고 탐색하세요.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
직접 명령은 검토 Prompt를 거치지 않습니다. 실행하기 전에 소스를 확인하세요.
npx skills add https://github.com/jeremylongshore/claude-code-plugins-plus-skills --skill customerio-rate-limits명령은 한 줄로 유지됩니다. 복사하기 전에 가로로 스크롤해 전체 내용을 확인하세요.
로컬 사본을 원하시나요? SkillsMP에서 현재 제공할 수 있는 파일을 다운로드하세요.
Zip 다운로드 다운로드 중... 이 저장소의 다른 Skills Implement user sign-up and sign-in flows with Clerk.
Use when building authentication UI, customizing sign-in experience,
or implementing OAuth social login.
Trigger with phrases like "clerk sign-in", "clerk sign-up",
"clerk login flow", "clerk OAuth", "clerk social login".
Implement session management and middleware with Clerk.
Use when managing user sessions, configuring route protection,
or implementing token refresh and custom JWT templates.
Trigger with phrases like "clerk session", "clerk middleware",
"clerk route protection", "clerk token", "clerk JWT".
Configure enterprise SSO, role-based access control, and organization management.
Use when implementing SSO integration, configuring role-based permissions,
or setting up organization-level controls.
Trigger with phrases like "clerk SSO", "clerk RBAC",
"clerk enterprise", "clerk roles", "clerk permissions", "clerk organizations".
jeremylongshore
jeremylongshore/claude-code-plugins-plus-skills
GitHub 저장소 열기 name customerio-rate-limits description 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".
allowed-tools Read, Write, Edit, Bash(npm:*), Bash(npx:*), Glob, Grep version 1.14.0 license MIT author Jeremy Longshore <jeremy@intentsolutions.io> tags ["saas","customer-io","api","rate-limiting"] compatibility Designed for Claude Code, also compatible with Codex and OpenClaw
Customer.io Rate Limits
Overview
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.
Rate Limit Reference
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.
Instructions
Step 1: Token Bucket Rate Limiter
export class TokenBucket {
private tokens : number ;
private lastRefill : number ;
constructor (
private readonly maxTokens : number = 80 ,
private readonly refillRate : number = 80
) {
this .tokens = maxTokens;
this .lastRefill = . ();
}
(): {
now = . ();
elapsed = (now - . ) / ;
. = . ( . , . + elapsed * . );
. = now;
}
(): < > {
. ();
( . >= ) {
. -= ;
;
}
waitMs = (( - . ) / . ) * ;
( (r, . (waitMs)));
. = ;
. = . ();
}
}
Date
now
private
refill
void
const
Date
now
const
this
lastRefill
1000
this
tokens
Math
min
this
maxTokens
this
tokens
this
refillRate
this
lastRefill
async
acquire
Promise
void
this
refill
if
this
tokens
1
this
tokens
1
return
const
1
this
tokens
this
refillRate
1000
await
new
Promise
(r ) =>
setTimeout
Math
ceil
this
tokens
0
this
lastRefill
Date
now
Step 2: Exponential Backoff with Jitter
interface BackoffOptions {
maxRetries : number ;
baseDelayMs : number ;
maxDelayMs : number ;
jitter : number ;
}
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 ;
if (status >= 400 && status < 500 && status !== 429 ) throw err;
if (attempt === maxRetries) break ;
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);
}
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;
}
Step 3: Rate-Limited Client
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));
}
}
Step 4: Queue-Based Processing with p-queue For sustained high volume, use p-queue for cleaner concurrency control:
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 }
);
const queue = new PQueue ({
concurrency : 10 ,
interval : 1000 ,
intervalCap : 80 ,
});
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 }));
}
setInterval (() => {
console .log (
`CIO queue: pending=${queue.pending} size=${queue.size} `
);
}, 10000 );
Install: npm install p-queue
Step 5: Bulk Import Strategy For large data imports (>10K users), avoid hitting rate limits with controlled batching:
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
);
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` );
}
Error Handling Scenario Strategy 429 receivedRespect 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
Resources
Next Steps After implementing rate limits, proceed to customerio-security-basics for security best practices.