Types

TypeScript types exported from the noketa package

The noketa package exports the client and all request/response types from the root module. Use them for type-safe requests and responses.

Exports

import {
  Noketa,
  type ContactAttributes,
  type CreateContactRequest,
  type CreateContactResponse,
  type NoketaApiResponse,
  type SendEmailRequest,
  type SendEmailResponse,
  type TrackEventRequest,
  type TrackEventResponse,
} from "noketa";

Legacy names ProfileAttributes, CreateProfileRequest, and CreateProfileResponse are still exported for compatibility; prefer the Contact* types.

ContactAttributes

Used in Contacts for attributes. Supports known optional fields and arbitrary custom keys:

FieldTypeDescription
first_namestring?Given name
last_namestring?Family name
localestring?Locale code (e.g. en, en-US)
genderstring?Gender
agenumber?Age
birthdateDate?Birth date
external_idstring?Your system’s user ID
last_event_dateDate?Last activity date
propertiesRecord<string, unknown>?Custom key-value data
[key: string]unknownAdditional custom fields

API responses

CreateContactResponse is the typed shape returned by contacts.create:

type CreateContactResponse = {
  message: string;
  contactId: string;
  action?: "created" | "updated";
};

SendEmailRequest is used by Emails:

type SendEmailRequest = {
  from: string;
  to: string | string[];
  subject: string;
  html?: string;
  text?: string;
  replyTo?: string | string[];
  /** Defaults to `true`. Set `false` to skip open/click tracking. */
  tracking?: boolean;
  unsubscribeUrl?: string;
  unsubscribeOneClick?: boolean;
};

SendEmailResponse uses the broader NoketaApiResponse:

type NoketaApiResponse = {
  message?: string;
  [key: string]: unknown;
};

Use NoketaApiResponse when you need to access extra fields returned by the API.

TrackEventRequest is used by Events and Automations:

type TrackEventRequest = {
  event: string;
  email?: string;
  contactId?: string;
  attributes?: ContactAttributes;
  metadata?: Record<string, unknown>;
};

TrackEventResponse describes the automation dispatch result:

type TrackEventResponse = {
  message: string;
  eventId: string | null;
  contactId: string;
  contactAction: "matched" | "created" | "updated";
  triggered: number;
  completedWaitpoints: number;
  failed?: number;
};