# Emails API Use `client.emails.send` to send an email through Noketa. Method Signature [#method-signature] ```ts client.emails.send(payload: SendEmailRequest): Promise ``` Request Shape [#request-shape] ```ts type SendEmailRequest = { from: string; to: string; subject: string; html: string; }; ``` Example [#example] ```ts import { Noketa } from "noketa"; const client = new Noketa(process.env.NOKETA_API_KEY!); const response = await client.emails.send({ from: "noreply@yourdomain.com", to: "person@example.com", subject: "Welcome to Noketa", html: "

Welcome

Thanks for signing up.

", }); ``` Notes [#notes] * `html` should be a complete or partial HTML email body string. * API errors are surfaced as thrown `Error` instances. # Getting Started Installation [#installation] ```bash bun add noketa ``` Create a Client [#create-a-client] ```ts import { Noketa } from "noketa"; const client = new Noketa(process.env.NOKETA_API_KEY!); ``` The constructor requires a Noketa API key and throws if the key is missing. First Request [#first-request] ```ts await client.profiles.create({ listId: "list_123", email: "person@example.com", attributes: { first_name: "Jane", last_name: "Doe", }, }); ``` Error Handling [#error-handling] All request helpers throw `Error` with a message coming from the API response when available. ```ts try { await client.emails.send({ from: "noreply@yourdomain.com", to: "person@example.com", subject: "Welcome", html: "

Hello from Noketa

", }); } catch (error) { console.error((error as Error).message); } ``` # Overview `noketa` is the official JavaScript and TypeScript SDK for interacting with the Noketa API. Use this SDK to: * Create and update audience profiles through `profiles.create` * Send transactional or campaign emails through `emails.send` * Build safely with first-class TypeScript request and response types Install [#install] ```bash bun add noketa ``` Quick Start [#quick-start] ```ts import { Noketa } from "noketa"; const client = new Noketa(process.env.NOKETA_API_KEY!); ``` Continue with: * [Getting Started](/getting-started) * [Profiles API](/profiles) * [Emails API](/emails) * [Type Reference](/types) # Profiles API Use `client.profiles.create` to create a profile in a target list. Method Signature [#method-signature] ```ts client.profiles.create(payload: CreateProfileRequest): Promise ``` Request Shape [#request-shape] ```ts type CreateProfileRequest = { listId: string; email: string; attributes: ProfileAttributes; }; ``` Example [#example] ```ts import { Noketa } from "noketa"; const client = new Noketa(process.env.NOKETA_API_KEY!); const response = await client.profiles.create({ listId: "list_123", email: "person@example.com", attributes: { first_name: "Jane", last_name: "Doe", locale: "en", external_id: "usr_123", properties: { plan: "pro", signup_source: "landing_page", }, }, }); ``` Notes [#notes] * `attributes` supports both standard fields and custom keys. * Dates such as `birthdate` and `last_event_date` should be passed as `Date` objects. # Type Reference The package exports the client plus request and response types from the root module. Exports [#exports] ```ts import { Noketa, type CreateProfileRequest, type CreateProfileResponse, type NoketaApiResponse, type ProfileAttributes, type SendEmailRequest, type SendEmailResponse, } from "noketa"; ``` ProfileAttributes [#profileattributes] `ProfileAttributes` supports known optional fields and any additional custom keys: * `first_name?: string` * `last_name?: string` * `locale?: string` * `gender?: string` * `age?: number` * `birthdate?: Date` * `external_id?: string` * `last_event_date?: Date` * `properties?: Record` * `[key: string]: unknown` Shared API Response [#shared-api-response] Both `CreateProfileResponse` and `SendEmailResponse` are currently aliases of `NoketaApiResponse`: ```ts type NoketaApiResponse = { message?: string; [key: string]: unknown; }; ```