Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Creates a Klaviyo profile, tracks an event, and queries the result with the klaviyo-api Node.js SDK as a smoke test.
61% 100%+39 ptsof test cases passed
Passed 23 of 23 test cases with the skill, and 14 of 23 without it.
What is the standard environment variable name to store the secret API key for authentication when initializing ApiKeySession in the Klaviyo Node.js SDK?
Names the API key environment variable KLAVIYO_PRIVATE_KEY.
3 of 3 safety checks passed
Minimal working example: create a profile, track an event, and query the result
using the klaviyo-api Node.js SDK against a.klaviyo.com/api/*. This is the
smoke test that proves your API key, SDK install, and network path all work
end-to-end before you build anything real.
klaviyo-install-auth setup so credentials are in place.KLAVIYO_PRIVATE_KEY exported in your environment (a private API key with
Profiles and Events scopes).klaviyo-api installed in the project (npm install klaviyo-api).tsx available to run the TypeScript file (npx tsx …).Write the code into a single hello-klaviyo.ts file, then run it with
npx tsx hello-klaviyo.ts. The full script performs four things in order:
Create a profile — profilesApi.createProfile(...) with a JSON:API
payload. The essential skeleton:
import { ApiKeySession, ProfilesApi, ProfileEnum } from 'klaviyo-api';
const session = new ApiKeySession(process.env.KLAVIYO_PRIVATE_KEY!);
const profilesApi = new ProfilesApi(session);
const profile = await profilesApi.createProfile({
data: {
type: ProfileEnum.Profile,
attributes: { email: '[email protected]', firstName: 'Hello', lastName: 'World' },
},
});
console.log('Profile created:', profile.body.data.id);
Next to this one in the catalogue, plus more from the same author.