Clay doesn't offer an API, but you can simulate an API via Val Town by listening to webhooks, enriching data in Clay, and having Clay send an HTTP request back when enrichment is complete.
This demo uses Clay like an API to automatically enrich new user signups and send notifications to Discord.
Here's an example:
Here's the underlying Clay Table (feel free to zoom in to see the exact setup
for debugging):
This project uses the Hono framework with a clean, flat architecture:
├── enrichedUserWebhook.ts # Receives enriched data from Clay
├── newUserWebhook.ts # Receives new signups from Clerk/Stripe
├── discordNotifications.ts # Discord message formatting and buttons
├── types.ts # TypeScript interfaces
├── test-signup.ts # Test utility
├── main.tsx # Hono app entry point with routing
├── deno.json # Deno configuration
└── README.md # This file
-
Create a new Clay workbook called "New User Enrichment"
-
Click Add → Pull in data from source at the bottom
-
Select Pull in data from a Webhook Table
-
Click Edit source on the Webhook column to copy the webhook URL
-
Add the webhook URL to your environment variables:
- Go to your val's Environment Variables
- Add environment variable:
CLAY_WEBHOOK_URL - Set value to:
https://api.clay.com/v3/sources/webhook/pull-in-data-from-a-webhook-YOUR_ID
Note: Setting up the webhook like this lets you transform / filter the data before sending it over to Clay. It also helps with error handling and give you logs in Val Town for observability. Otherwise, you could set up the webhook directly from the source ie. Clerk, Stripe etc.
Add whichever enrichment columns you want. This example uses:
- Enrich Person → Name, Title, Org
- LinkedIn Profile → LinkedIn URL
- Click Add Column → Add Enrichment → search for HTTP API
- Add HTTP API column to your Clay table
- Click Edit Column and fill in the following:
- Set endpoint to your HTTP URL:
https://your-val-url.com/enrichedUserWebhook(Note: you need the/enrichedUserWebhook!) - Set method: POST
- Configure request body:
{ "email": "{{email}}", "profile_image_url": "{{profile_image_url}}", "Name": "{{name}}", "Title": "{{title}}", "Org": "{{org}}", "LinkedIn": "{{LinkedIn Profile}}" }
- Enable Remove empty values
- Here's what my final column looked like:
- Click Environment Variables in your val's sidebar
- Add the following environment variables:
Required:
CLAY_WEBHOOK_URL- Your Clay webhook URL from step 1DISCORD_WEBHOOK- Your Discord webhook URL for notifications
Optional (for executive email feature):
GMAIL_USER- Gmail address to send emails fromGMAIL_PASS- Gmail app password (not your regular password!)
Note: If you don't set up Gmail credentials, the system will still work but won't send welcome emails to executives.
This project automatically detects executive signups and sends them a personalized welcome email with a $50 credit offer.
The system checks job titles for keywords like:
- C-Suite: CEO, CTO, CFO, CMO, etc.
- Leadership: VP, Director, Head of, etc.
- Founders: Founder, Co-founder, Owner
See the full list in send-email.ts.
Email templates are stored as editable text files in the templates/ directory:
templates/executive-welcome.txt- Plain text versiontemplates/executive-welcome.html- HTML version
Available variables:
{{firstName}}- Recipient's first name{{roleDescription}}- Generated from title/org{{teamQuestion}}- Customized based on whether they have an org{{subject}}- Email subject line
Simply edit these files to change the email copy - no code changes needed!
To test the email feature, send a webhook with a title like "CEO" or "Founder" and the system will automatically send an email.
This is what triggers a new row in the Clay table, hook up your source system
(Clerk, Stripe, etc.) to send webhooks to your val's HTTP URL:
https://your-val-url.com/newUserSignup (Note: you need the
/newUserSignup!)
For Clerk, you can find it here:
Enriched profiles (with ⭐):
⭐ New user! John Doe • Software Engineer @ Tech Corp • john@example.com • https://linkedin.com/in/johndoe
Basic signups:
New user! user@example.org
Executive signups (with email sent):
⭐ New user! Jane Smith • CEO @ Startup Inc • jane@startup.com • https://linkedin.com/in/janesmith • ✅ Executive welcome email sent
Executives automatically receive a welcome email with:
- Personalized greeting using their first name
- $50 credit offer for Val Town's Townie AI
- Customized message based on their role and company
User Signs Up (Clerk/Stripe)
↓
→ Val Town receives webhook at /newUserSignup
↓
→ Forwards to Clay for enrichment
↓
Clay enriches data (name, title, company, LinkedIn)
↓
→ Clay sends HTTP request to /enrichedUserWebhook
↓
Val Town processes enriched data:
├─→ Builds Discord notification message
├─→ Checks if executive title
│ └─→ If yes: Send welcome email
└─→ Sends Discord notification
- Automatic Enrichment: Uses Clay to enrich user emails with LinkedIn data
- Smart Detection: Identifies executives by job title keywords
- Personalized Emails: Sends customized welcome emails to executives
- Template-Based: Email copy stored in editable template files
- Discord Integration: Real-time notifications with user details
- Modular Architecture: Clean Hono-based structure for easy maintenance
- If email sending fails, Discord notification shows ❌ with error message
- All errors are logged to Val Town console for debugging
- Clay enrichment failures are handled gracefully (shows partial data)