instantly-sdk-patterns
Apply production-ready Instantly.ai API client patterns for TypeScript and Python. Use when building reusable API wrappers, implementing retry logic, or establishing coding standards for Instantly integrations. Trigger with phrases like "instantly SDK patterns", "instantly best practices", "instantly client wrapper", "instantly code patterns", "idiomatic instantly".
What this skill does
# Instantly SDK Patterns
## Overview
Production-ready patterns for Instantly API v2 integrations. Instantly has no official SDK — all integrations use direct REST calls to `https://api.instantly.ai/api/v2/`. These patterns provide type safety, retry logic, pagination, and multi-tenant support.
## Prerequisites
- Completed `instantly-install-auth` setup
- Familiarity with async/await and TypeScript generics
- Understanding of REST API pagination patterns
## Instructions
### Step 1: Type-Safe Client with Error Classification
```typescript
// src/instantly/client.ts
import "dotenv/config";
export class InstantlyClient {
private baseUrl: string;
private apiKey: string;
constructor(options?: { apiKey?: string; baseUrl?: string }) {
this.apiKey = options?.apiKey || process.env.INSTANTLY_API_KEY || "";
this.baseUrl = options?.baseUrl || "https://api.instantly.ai/api/v2";
if (!this.apiKey) throw new Error("INSTANTLY_API_KEY is required");
}
async request<T>(path: string, options: RequestInit = {}): Promise<T> {
const url = `${this.baseUrl}${path}`;
const res = await fetch(url, {
...options,
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${this.apiKey}`,
...options.headers,
},
});
if (!res.ok) {
const body = await res.text();
throw new InstantlyApiError(res.status, path, body);
}
return res.json() as Promise<T>;
}
// Typed convenience methods
async getCampaigns(params?: { limit?: number; status?: number; search?: string }) {
const qs = new URLSearchParams();
if (params?.limit) qs.set("limit", String(params.limit));
if (params?.status !== undefined) qs.set("status", String(params.status));
if (params?.search) qs.set("search", params.search);
return this.request<Campaign[]>(`/campaigns?${qs}`);
}
async getCampaign(id: string) {
return this.request<Campaign>(`/campaigns/${id}`);
}
async createCampaign(data: CreateCampaignInput) {
return this.request<Campaign>("/campaigns", {
method: "POST",
body: JSON.stringify(data),
});
}
async activateCampaign(id: string) {
return this.request<void>(`/campaigns/${id}/activate`, { method: "POST" });
}
async pauseCampaign(id: string) {
return this.request<void>(`/campaigns/${id}/pause`, { method: "POST" });
}
async getAccounts(params?: { limit?: number; status?: number }) {
const qs = new URLSearchParams();
if (params?.limit) qs.set("limit", String(params.limit));
if (params?.status !== undefined) qs.set("status", String(params.status));
return this.request<Account[]>(`/accounts?${qs}`);
}
async addLead(data: CreateLeadInput) {
return this.request<Lead>("/leads", {
method: "POST",
body: JSON.stringify(data),
});
}
async listLeads(filter: ListLeadsInput) {
return this.request<Lead[]>("/leads/list", {
method: "POST",
body: JSON.stringify(filter),
});
}
async getCampaignAnalytics(ids: string[]) {
const qs = ids.map((id) => `ids=${id}`).join("&");
return this.request<CampaignAnalytics[]>(`/campaigns/analytics?${qs}`);
}
}
// Error classification
export class InstantlyApiError extends Error {
public retryable: boolean;
constructor(public status: number, public path: string, public body: string) {
super(`Instantly ${status} on ${path}: ${body}`);
this.name = "InstantlyApiError";
this.retryable = status === 429 || status >= 500;
}
}
```
### Step 2: TypeScript Interfaces
```typescript
// src/instantly/types.ts
export interface Campaign {
id: string;
name: string;
status: number; // 0=Draft,1=Active,2=Paused,3=Completed,4=Running Subsequences
campaign_schedule: CampaignSchedule;
sequences: Sequence[];
daily_limit: number | null;
stop_on_reply: boolean;
email_gap: number;
timestamp_created: string;
}
export interface CampaignSchedule {
start_date: string | null;
end_date: string | null;
schedules: Array<{
name: string;
timing: { from: string; to: string };
days: Record<string, boolean>;
timezone: string;
}>;
}
export interface Sequence {
steps: SequenceStep[];
}
export interface SequenceStep {
type: "email";
delay: number;
delay_unit?: "minutes" | "hours" | "days";
variants: Array<{ subject: string; body: string; v_disabled?: boolean }>;
}
export interface Account {
email: string;
first_name: string;
last_name: string;
status: number;
warmup_status: string;
daily_limit: number | null;
provider_code: number;
warmup: { limit: number; increment: string; advanced: Record<string, unknown> };
}
export interface Lead {
id: string;
email: string | null;
first_name: string | null;
last_name: string | null;
company_name: string | null;
status: number; // 1=Active,2=Paused,3=Completed,-1=Bounced,-2=Unsubscribed,-3=Skipped
campaign: string | null;
email_open_count: number;
email_reply_count: number;
}
export interface CreateCampaignInput {
name: string;
campaign_schedule: CampaignSchedule;
sequences: Sequence[];
daily_limit?: number;
stop_on_reply?: boolean;
email_gap?: number;
open_tracking?: boolean;
link_tracking?: boolean;
}
export interface CreateLeadInput {
campaign?: string;
list_id?: string;
email: string;
first_name?: string;
last_name?: string;
company_name?: string;
custom_variables?: Record<string, string>;
skip_if_in_workspace?: boolean;
verify_leads_on_import?: boolean;
}
export interface ListLeadsInput {
campaign?: string;
list_id?: string;
limit?: number;
starting_after?: string;
}
export interface CampaignAnalytics {
campaign_id: string;
total_leads: number;
emails_sent: number;
emails_opened: number;
emails_replied: number;
emails_bounced: number;
}
```
### Step 3: Retry with Exponential Backoff
```typescript
// src/instantly/retry.ts
export async function withRetry<T>(
operation: () => Promise<T>,
maxRetries = 3,
baseDelayMs = 1000
): Promise<T> {
for (let attempt = 0; attempt <= maxRetries; attempt++) {
try {
return await operation();
} catch (err) {
if (attempt === maxRetries) throw err;
if (err instanceof InstantlyApiError && !err.retryable) throw err;
const delay = baseDelayMs * Math.pow(2, attempt);
const jitter = Math.random() * delay * 0.1;
console.warn(`Retry ${attempt + 1}/${maxRetries} in ${delay}ms...`);
await new Promise((r) => setTimeout(r, delay + jitter));
}
}
throw new Error("Unreachable");
}
// Usage
const campaigns = await withRetry(() => client.getCampaigns({ limit: 50 }));
```
### Step 4: Cursor-Based Pagination
```typescript
// src/instantly/paginate.ts
export async function* paginate<T extends { id: string }>(
client: InstantlyClient,
path: string,
pageSize = 100
): AsyncGenerator<T[], void, void> {
let startingAfter: string | undefined;
while (true) {
const qs = new URLSearchParams({ limit: String(pageSize) });
if (startingAfter) qs.set("starting_after", startingAfter);
const page = await client.request<T[]>(`${path}?${qs}`);
if (page.length === 0) break;
yield page;
startingAfter = page[page.length - 1].id;
if (page.length < pageSize) break;
}
}
// Usage — iterate all campaigns
for await (const batch of paginate<Campaign>(client, "/campaigns")) {
for (const campaign of batch) {
console.log(campaign.name, campaign.status);
}
}
```
### Step 5: Multi-Tenant Factory (Agency Pattern)
```typescript
// src/instantly/factory.ts
const clients = new Map<string, InstantlyClient>();
export function getClientForWorkspace(workspaceId: string, apiKey: string): InstantlyClient {
if (!clients.has(workspaceId)) {
clients.set(workspaceId, new InstantlyClient({ apiKey }));
}
return clients.get(workspaceId)!;
}
// Usage — agency managing multiple client workspaces
const clientA = getClientForWorkspace("acme", process.env.ACME_ARelated in Backend & APIs
jfrog
IncludedInteract with the JFrog Platform via the JFrog CLI and REST/GraphQL APIs. Use this skill when the user wants to manage Artifactory repositories, upload or download artifacts, manage builds, configure permissions, manage users and groups, work with access tokens, configure JFrog CLI servers, search artifacts, manage properties, set up replication, manage JFrog Projects, run security audits or scans, look up CVE details, query exposures scan results from JFrog Advanced Security, manage release bundles and lifecycle operations, aggregate or export platform data, or perform any JFrog Platform administration task. Also use when the user mentions jf, jfrog, artifactory, xray, distribution, evidence, apptrust, onemodel, graphql, workers, mission control, curation, advanced security, exposures, or any JFrog product name.
cupynumeric-migration-readiness
IncludedPre-migration readiness assessor for porting NumPy to cuPyNumeric. Use BEFORE substantial porting work begins when the user asks whether code will scale on GPU, whether they should migrate to cuPyNumeric, which NumPy patterns transfer cleanly, what must be refactored before porting, or mentions pre-port assessment, scaling analysis, or refactor planning. Inspect the user's source code, look up NumPy usage, cross-reference the cuPyNumeric API support manifest, and distinguish distributed-scaling-friendly patterns from blockers such as unsupported APIs, scalar synchronization, host round-trips, Python/object-heavy control flow, shape/data-dependent branching, and in-place mutation hazards. Produce a verdict of READY, LIGHT REFACTOR, SIGNIFICANT REFACTOR, or NOT RECOMMENDED, with concrete refactor pointers.
alibabacloud-data-agent-skill
IncludedInvoke Alibaba Cloud Apsara Data Agent for Analytics via CLI to perform natural language-driven data analysis on enterprise databases. Data Agent for Analytics is an intelligent data analysis agent developed by Alibaba Cloud Database team for enterprise users. It automatically completes requirement analysis, data understanding, analysis insights, and report generation based on natural language descriptions. This tool supports: discovering data resources (instances/databases/tables) managed in DMS, initiating query or deep analysis sessions, real-time progress tracking, and retrieving analysis conclusions and generated reports. Use this Skill when users need to query databases, analyze data trends, generate data reports, ask questions in natural language, or mention "Data Agent", "data analysis", "database query", "SQL analysis", "data insights".
token-optimizer
IncludedReduce OpenClaw token usage and API costs through smart model routing, heartbeat optimization, budget tracking, and native 2026.2.15 features (session pruning, bootstrap size limits, cache TTL alignment). Use when token costs are high, API rate limits are being hit, or hosting multiple agents at scale. The 4 executable scripts (context_optimizer, model_router, heartbeat_optimizer, token_tracker) are local-only — no network requests, no subprocess calls, no system modifications. Reference files (PROVIDERS.md, config-patches.json) document optional multi-provider strategies that require external API keys and network access if you choose to use them. See SECURITY.md for full breakdown.
resend-cli
IncludedUse this skill when the task is specifically about operating Resend from an AI agent, terminal session, or CI job via the official resend CLI: installing/authenticating the CLI, sending/listing/updating/cancelling emails, batch sends, domains and DNS, webhooks and local listeners, inbound receiving, contacts, topics, segments, broadcasts, templates, API keys, profiles, or debugging Resend CLI/API failures. Trigger on mentions of Resend CLI, `resend`, `resend doctor`, `resend emails send`, `resend domains`, `resend webhooks listen`, `resend emails receiving`, or agent-friendly terminal automation.
alibabacloud-odps-maxframe-coding
IncludedUse this skill for MaxFrame SDK development and documentation navigation on Alibaba Cloud MaxCompute (ODPS). Helps answer MaxFrame API, concept, official example, and supported pandas API questions; create data processing programs; read/write MaxCompute tables; debug jobs (remote or local); and build custom DPE runtime images. Trigger when users mention MaxFrame, MaxCompute with MaxFrame, ODPS table processing, DPE runtime, MaxFrame docs/examples, DataFrame/Tensor operations, or GPU runtime setup. Works for both English and Chinese queries about Alibaba Cloud data processing with MaxFrame.