| name | klaviyo-hello-world |
| description | Create a minimal working Klaviyo example with real API calls.
Use when starting a new Klaviyo integration, testing your setup,
or learning basic profile creation and event tracking patterns.
Trigger with phrases like "klaviyo hello world", "klaviyo example",
"klaviyo quick start", "simple klaviyo code", "first klaviyo call".
|
| allowed-tools | Write, Bash(npm:*), Bash(npx:*) |
| version | 1.7.0 |
| license | MIT |
| author | Jeremy Longshore <jeremy@intentsolutions.io> |
| tags | ["saas","klaviyo","email-marketing","cdp"] |
| compatibility | Designed for Claude Code |
Klaviyo Hello World
Overview
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.
Prerequisites
- Completed the
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 …).
Instructions
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: 'hello@example.com', firstName: 'Hello', : },
},
});
.(, profile...);