| name | clay-sdk-patterns |
| description | 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".
|
| allowed-tools | Read, Write, Edit, Bash(npm:*), Bash(node:*) |
| version | 1.14.0 |
| license | MIT |
| author | Jeremy Longshore <jeremy@intentsolutions.io> |
| tags | ["saas","clay","python","typescript"] |
| compatibility | Designed for Claude Code, also compatible with Codex and OpenClaw |
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)
interface ClayConfig {
webhookUrl: string;
enterpriseApiKey?: string;
baseUrl?: string;
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,
};
}
(: <, >): <> {
res = .(.., {
: ,
: { : },
: .(data),
});
(!res.) {
(, res.);
}
}
(: <, >[], delayMs = ): <> {
: = { : , : , : [] };
( row rows) {
{
.(row);
results.++;
} (err) {
results.++;
results..({ row, : (err ). });
}
(delayMs > ) ( (r, delayMs));
}
results;
}
(: ): <> {
(!..) {
();
}
res = .(, {
: ,
: {
: ,
: ,
},
: .({ email }),
});
res.();
}
(: ): <> {
(!..) {
();
}
res = .(, {
: ,
: {
: ,
: ,
},
: .({ domain }),
});
res.();
}
(: , : ): <> {
( attempt = ; attempt <= ..; attempt++) {
{
controller = ();
timeout = ( controller.(), ..);
res = (url, { ...init, : controller. });
(timeout);
(res. === ) {
retryAfter = (res..() || );
( (r, retryAfter * ));
;
}
res;
} (err) {
(attempt === ..) err;
( (r, * .(, attempt)));
}
}
();
}
}