Installation
Install the Noketa SDK, create a client, and send your first request
This guide walks you through installing the Noketa SDK, creating a Noketa instance, and making your first API calls.
Installation
Install the package with Bun:
bun add noketaCreate a Noketa instance
Import the SDK and create a Noketa instance with your API key. The key is required; the constructor will throw if it is missing.
import { Noketa } from "noketa";
const noketa = new Noketa(process.env.NOKETA_API_KEY!);The client defaults to https://app.noketa.io as the API origin (paths under /api/v1). Override with new Noketa(key, { baseUrl: "http://localhost:3000" }) when calling a local or self-hosted deployment.
Keep your API key in environment variables and never commit it to version control.
Your first request
Create or update a contact
Sync a contact with the Contacts API (upsert by email):
await noketa.contacts.create({
email: "person@example.com",
attributes: {
first_name: "Jane",
last_name: "Doe",
},
});Send an email
Send a transactional or one-off email with the Emails API:
await noketa.emails.send({
from: "noreply@yourdomain.com",
to: "person@example.com",
subject: "Welcome",
html: "<p>Hello from Noketa</p>",
});Error handling
When the API returns an error, the SDK throws an Error with a message from the response. Always wrap calls in try/catch for production code.
try {
await noketa.emails.send({
from: "noreply@yourdomain.com",
to: "person@example.com",
subject: "Welcome",
html: "<p>Hello from Noketa</p>",
});
} catch (error) {
console.error((error as Error).message);
}Next steps
- Contacts — Full reference for creating and updating contacts
- Emails — Send options and response shape
- Type Reference — TypeScript types exported from the package