How We Built an API for Clay
Clay doesn't have an API / SDK, so I built one!
I wrote this for the Val Town blog and wanted to reshare it here for you too. Enjoy! :)
I used to think doing enrichment was for big companies with massive outbound sales functions.
Before launching Val Town for Teams, we set a goal: find 10 pre‑sales customers. All of a sudden, I was spending all my time looking for teams who could be the right fit.
Our best channel was obviously new users signing up for Val Town. However, scrolling through emails and hoping we recognize someone quickly became unsustainable. (And really it only works for celebrities anyways.)
Clearbit vs Clay vs Val Town
Clearbit used to be the obvious answer, but post‑HubSpot acquisition, it's no longer an option for small new customers.
Clay is great, but we wanted to use it like an API so anyone on our team could use it programatically, without Clay knowledge or set-up.
We asked on X, the Clay CEO explained how we could do it.
Introducing: Clay API Proxy
We turned Clay into an API / SDK on Val Town via our Clay API Proxy.
The hard part was that Clay enrichments are triggered by one webhook, but you get the results from another webhook. We wanted the developer experience to be a single request that gets back the enriched data as the response.
Here's how we built it:
Your val imports and calls our
clay()"sdk" function with an email or GitHub usernameOur proxy authenticates you as a Val Town user
We generate a request id, and forward the payload to Clay with that id
Clay enriches, and POSTs the result back using the id. We save the result to SQLite.
While your original request is still open, we poll sqlite for it.
When it returns, we give you the JSON back in the normal request/response pattern.
Enriching emails with Clay is now as simple as:
import { clay } from "https://esm.town/v/charmaine/clay-proxy/sdk.ts";
const result = await clay({
email: "steve@val.town",
source: "user_signup",
});
console.log(result);
Which returns:
{
"email": "steve@val.town",
"person": "Steve Krouse",
"linkedin": "https://www.linkedin.com/in/stevekrouse",
"company": "Val Town",
"funding": "Seed round",
"totalFunding": "$7 million",
"employeeCount": "6"
}
How this helps
User enrichment is a big part of how we successfully found our first 10 pre-sales customers.
Our users are no longer a long list of anonymous emails. We are able to more efficiently spend our time interacting with our ICP (Ideal Customer Profile) as soon as they sign up, instead of combing through endless dashboards in search of a unicorn.
We see new users joining in real-time, with their enriched profiles
Anyone can start a thread, tag the right person, or notify everyone else that they've already reached out. For example:
Warm intros were easy to track
The team then starts building intuition about: how many new users joined, are we attracting ICP, who owns follow‑ups etc.
Then what?
Once you have this data on Val Town, there's lots you can do.
Here are some templates:
For fellow dev tool companies, we reach out with an auto‑generated Val that runs their SDK so the first touch includes a working demo. This got some great responses!
Get Townie AI to build custom outbound demos etc. based on their profile. (Patrick Spychalski has a great example post with a similar workflow.)
You can self-host this proxy, if you'd like to create an API for your own Clay account. Reach out if I could be of any help!




