clay-sdk-patterns
Apply production-ready patterns for integrating with Clay via webhooks and HTTP API. Use when building Clay integrations, implementing webhook handlers, or establishing team coding standards for Clay data pipelines. Trigger with phrases like "clay SDK patterns", "clay best practices", "clay code patterns", "clay integration patterns", "clay webhook patterns".
Best use case
clay-sdk-patterns is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Apply production-ready patterns for integrating with Clay via webhooks and HTTP API. Use when building Clay integrations, implementing webhook handlers, or establishing team coding standards for Clay data pipelines. Trigger with phrases like "clay SDK patterns", "clay best practices", "clay code patterns", "clay integration patterns", "clay webhook patterns".
Teams using clay-sdk-patterns should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/clay-sdk-patterns/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How clay-sdk-patterns Compares
| Feature / Agent | clay-sdk-patterns | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Apply production-ready patterns for integrating with Clay via webhooks and HTTP API. Use when building Clay integrations, implementing webhook handlers, or establishing team coding standards for Clay data pipelines. Trigger with phrases like "clay SDK patterns", "clay best practices", "clay code patterns", "clay integration patterns", "clay webhook patterns".
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
Related Guides
AI Agents for Coding
Browse AI agent skills for coding, debugging, testing, refactoring, code review, and developer workflows across Claude, Cursor, and Codex.
Best AI Skills for Claude
Explore the best AI skills for Claude and Claude Code across coding, research, workflow automation, documentation, and agent operations.
ChatGPT vs Claude for Agent Skills
Compare ChatGPT and Claude for AI agent skills across coding, writing, research, and reusable workflow execution.
SKILL.md Source
# Clay Integration Patterns
## Overview
Production-ready patterns for Clay integrations. Clay does not have an official SDK -- you interact via webhooks (inbound), HTTP API enrichment columns (outbound from Clay), and the Enterprise API (programmatic lookups). These patterns wrap those interfaces into reliable, reusable code.
## Prerequisites
- Completed `clay-install-auth` setup
- Familiarity with async/await patterns
- Understanding of Clay's webhook and HTTP API model
## Instructions
### Step 1: Create a Clay Webhook Client (TypeScript)
```typescript
// src/clay/client.ts — typed wrapper for Clay webhook and Enterprise API
interface ClayConfig {
webhookUrl: string; // Table's webhook URL for inbound data
enterpriseApiKey?: string; // Enterprise API key (optional)
baseUrl?: string; // Default: https://api.clay.com
maxRetries?: number;
timeoutMs?: number;
}
class ClayClient {
private config: Required<ClayConfig>;
constructor(config: ClayConfig) {
this.config = {
baseUrl: 'https://api.clay.com',
maxRetries: 3,
timeoutMs: 30_000,
enterpriseApiKey: '',
...config,
};
}
/** Send a record to a Clay table via webhook */
async sendToTable(data: Record<string, unknown>): Promise<void> {
const res = await this.fetchWithRetry(this.config.webhookUrl, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(data),
});
if (!res.ok) {
throw new ClayWebhookError(`Webhook failed: ${res.status}`, res.status);
}
}
/** Send multiple records in sequence with rate limiting */
async sendBatch(rows: Record<string, unknown>[], delayMs = 200): Promise<BatchResult> {
const results: BatchResult = { sent: 0, failed: 0, errors: [] };
for (const row of rows) {
try {
await this.sendToTable(row);
results.sent++;
} catch (err) {
results.failed++;
results.errors.push({ row, error: (err as Error).message });
}
if (delayMs > 0) await new Promise(r => setTimeout(r, delayMs));
}
return results;
}
/** Enterprise API: Enrich a person by email (Enterprise plan only) */
async enrichPerson(email: string): Promise<PersonEnrichment> {
if (!this.config.enterpriseApiKey) {
throw new Error('Enterprise API key required for person enrichment');
}
const res = await this.fetchWithRetry(`${this.config.baseUrl}/v1/people/enrich`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${this.config.enterpriseApiKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ email }),
});
return res.json();
}
/** Enterprise API: Enrich a company by domain (Enterprise plan only) */
async enrichCompany(domain: string): Promise<CompanyEnrichment> {
if (!this.config.enterpriseApiKey) {
throw new Error('Enterprise API key required for company enrichment');
}
const res = await this.fetchWithRetry(`${this.config.baseUrl}/v1/companies/enrich`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${this.config.enterpriseApiKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ domain }),
});
return res.json();
}
private async fetchWithRetry(url: string, init: RequestInit): Promise<Response> {
for (let attempt = 0; attempt <= this.config.maxRetries; attempt++) {
try {
const controller = new AbortController();
const timeout = setTimeout(() => controller.abort(), this.config.timeoutMs);
const res = await fetch(url, { ...init, signal: controller.signal });
clearTimeout(timeout);
if (res.status === 429) {
const retryAfter = parseInt(res.headers.get('Retry-After') || '5');
await new Promise(r => setTimeout(r, retryAfter * 1000));
continue;
}
return res;
} catch (err) {
if (attempt === this.config.maxRetries) throw err;
await new Promise(r => setTimeout(r, 1000 * Math.pow(2, attempt)));
}
}
throw new Error('Max retries exceeded');
}
}
```
### Step 2: Type Definitions for Clay Data
```typescript
// src/clay/types.ts
interface PersonEnrichment {
name?: string;
email?: string;
title?: string;
company?: string;
linkedin_url?: string;
location?: string;
}
interface CompanyEnrichment {
name?: string;
domain?: string;
industry?: string;
employee_count?: number;
linkedin_url?: string;
location?: string;
description?: string;
}
interface BatchResult {
sent: number;
failed: number;
errors: Array<{ row: Record<string, unknown>; error: string }>;
}
class ClayWebhookError extends Error {
constructor(message: string, public statusCode: number) {
super(message);
this.name = 'ClayWebhookError';
}
}
```
### Step 3: Python Client
```python
# clay_client.py — Python wrapper for Clay webhook and Enterprise API
import httpx
import asyncio
from dataclasses import dataclass, field
from typing import Any
@dataclass
class ClayClient:
webhook_url: str
enterprise_api_key: str = ""
base_url: str = "https://api.clay.com"
max_retries: int = 3
timeout: float = 30.0
async def send_to_table(self, data: dict[str, Any]) -> None:
"""Send a single record to a Clay table via webhook."""
async with httpx.AsyncClient(timeout=self.timeout) as client:
for attempt in range(self.max_retries + 1):
response = await client.post(
self.webhook_url,
json=data,
headers={"Content-Type": "application/json"},
)
if response.status_code == 429:
retry_after = int(response.headers.get("Retry-After", "5"))
await asyncio.sleep(retry_after)
continue
response.raise_for_status()
return
raise Exception("Max retries exceeded")
async def send_batch(self, rows: list[dict], delay: float = 0.2) -> dict:
"""Send multiple records with rate limiting."""
results = {"sent": 0, "failed": 0, "errors": []}
for row in rows:
try:
await self.send_to_table(row)
results["sent"] += 1
except Exception as e:
results["failed"] += 1
results["errors"].append({"row": row, "error": str(e)})
await asyncio.sleep(delay)
return results
async def enrich_person(self, email: str) -> dict:
"""Enterprise API: Look up person data by email."""
async with httpx.AsyncClient(timeout=self.timeout) as client:
response = await client.post(
f"{self.base_url}/v1/people/enrich",
json={"email": email},
headers={"Authorization": f"Bearer {self.enterprise_api_key}"},
)
response.raise_for_status()
return response.json()
```
### Step 4: Singleton Pattern for Multi-Use
```typescript
// src/clay/instance.ts — reuse a single client across your app
let instance: ClayClient | null = null;
export function getClayClient(): ClayClient {
if (!instance) {
instance = new ClayClient({
webhookUrl: process.env.CLAY_WEBHOOK_URL!,
enterpriseApiKey: process.env.CLAY_API_KEY,
});
}
return instance;
}
```
## Error Handling
| Pattern | Use Case | Benefit |
|---------|----------|---------|
| Retry with backoff | 429 rate limits, network errors | Automatic recovery |
| Batch with delay | Sending many rows | Respects Clay rate limits |
| Enterprise API guard | Missing API key | Clear error before API call |
| Timeout control | Slow webhook delivery | Prevents hung connections |
## Examples
### Webhook Handler for Clay Callbacks
```typescript
// Express handler for Clay HTTP API column callbacks
app.post('/api/clay/callback', (req, res) => {
// Respond 200 immediately (Clay expects fast response)
res.json({ ok: true });
// Process async
processEnrichedData(req.body).catch(console.error);
});
```
## Resources
- [Clay University -- HTTP API Integration](https://university.clay.com/docs/http-api-integration-overview)
- [Clay University -- Webhook Guide](https://university.clay.com/docs/webhook-integration-guide)
- [Clay University -- Using Clay as an API](https://www.clay.com/university/guide/using-clay-as-an-api)
## Next Steps
Apply patterns in `clay-core-workflow-a` for real-world lead enrichment.Related Skills
workhuman-sdk-patterns
Workhuman sdk patterns for employee recognition and rewards API. Use when integrating Workhuman Social Recognition, or building recognition workflows with HRIS systems. Trigger: "workhuman sdk patterns".
wispr-sdk-patterns
Wispr Flow sdk patterns for voice-to-text API integration. Use when integrating Wispr Flow dictation, WebSocket streaming, or building voice-powered applications. Trigger: "wispr sdk patterns".
windsurf-sdk-patterns
Apply production-ready Windsurf workspace configuration and Cascade interaction patterns. Use when configuring .windsurfrules, workspace rules, MCP servers, or establishing team coding standards for Windsurf AI. Trigger with phrases like "windsurf patterns", "windsurf best practices", "windsurf config patterns", "windsurfrules", "windsurf workspace".
windsurf-reliability-patterns
Implement reliable Cascade workflows with checkpoints, rollback, and incremental editing. Use when building fault-tolerant AI coding workflows, preventing Cascade from breaking builds, or establishing safe practices for multi-file AI edits. Trigger with phrases like "windsurf reliability", "cascade safety", "windsurf rollback", "cascade checkpoint", "safe cascade workflow".
webflow-sdk-patterns
Apply production-ready Webflow SDK patterns — singleton client, typed error handling, pagination helpers, and raw response access for the webflow-api package. Use when implementing Webflow integrations, refactoring SDK usage, or establishing team coding standards. Trigger with phrases like "webflow SDK patterns", "webflow best practices", "webflow code patterns", "idiomatic webflow", "webflow typescript".
vercel-sdk-patterns
Production-ready Vercel REST API patterns with typed fetch wrappers and error handling. Use when integrating with the Vercel API programmatically, building deployment tools, or establishing team coding standards for Vercel API calls. Trigger with phrases like "vercel SDK patterns", "vercel API wrapper", "vercel REST API client", "vercel best practices", "idiomatic vercel API".
vercel-reliability-patterns
Implement reliability patterns for Vercel deployments including circuit breakers, retry logic, and graceful degradation. Use when building fault-tolerant serverless functions, implementing retry strategies, or adding resilience to production Vercel services. Trigger with phrases like "vercel reliability", "vercel circuit breaker", "vercel resilience", "vercel fallback", "vercel graceful degradation".
veeva-sdk-patterns
Veeva Vault sdk patterns for REST API and clinical operations. Use when working with Veeva Vault document management and CRM. Trigger: "veeva sdk patterns".
vastai-sdk-patterns
Apply production-ready Vast.ai SDK patterns for Python and REST API. Use when implementing Vast.ai integrations, refactoring SDK usage, or establishing coding standards for GPU cloud operations. Trigger with phrases like "vastai SDK patterns", "vastai best practices", "vastai code patterns", "idiomatic vastai".
twinmind-sdk-patterns
Apply production-ready TwinMind SDK patterns for TypeScript and Python. Use when implementing TwinMind integrations, refactoring API usage, or establishing team coding standards for meeting AI integration. Trigger with phrases like "twinmind SDK patterns", "twinmind best practices", "twinmind code patterns", "idiomatic twinmind".
together-sdk-patterns
Together AI sdk patterns for inference, fine-tuning, and model deployment. Use when working with Together AI's OpenAI-compatible API. Trigger: "together sdk patterns".
techsmith-sdk-patterns
TechSmith sdk patterns for Snagit COM API and Camtasia automation. Use when working with TechSmith screen capture and video editing automation. Trigger: "techsmith sdk patterns".