API Reference

Models & Types

Request and response type definitions for the Node SDK.

All public types are exported from the package root:

import type {
  EventPayload,
  EventKind,
  IngestResponse,
  SearchResponse,
  SearchResult,
  SourceEvent,
  StatusResponse,
  HealthResponse,
  ClearResponse,
  UsageInfo,
  RateLimitInfo,
} from '@memsy-io/memsy';

The SDK is camelCase end-to-end. The HTTP wire format is snake_case (actor_id, session_id, event_ids); serialization happens automatically inside the client.

Request types

EventPayload

The shape you pass to client.ingest().

FieldTypeRequiredDescription
actorIdstringyesStable identifier for the entity producing the event.
sessionIdstringyesSession/conversation grouping ID.
kindEventKindyesOne of the literal values below.
contentstringyesThe event body — message text, tool output, etc.
roleIdstringnoOptional role attribution (e.g. 'admin').
teamIdstringnoOptional team scoping.
tsstringnoISO-8601 timestamp. Defaults to server-side now.
metadatastringnoFree-form JSON-encoded string for app-specific metadata.

EventKind

type EventKind =
  | 'user_message'
  | 'assistant_message'
  | 'tool_result'
  | 'app_event';

See Events & Memories for guidance on which to use.

Response types

Every successful response carries usage and rateLimit parsed from response headers — the call returned, but you also know how much of your plan you've burned.

IngestResponse

FieldTypeDescription
eventIdsstring[]One ID per event, in the order you submitted them.
usageUsageInfo | nullPlan usage snapshot from response headers.
rateLimitRateLimitInfo | nullRate-limit window state.

SearchResponse

FieldTypeDescription
resultsSearchResult[]Ranked memory matches.
usageUsageInfo | nullPlan usage snapshot.
rateLimitRateLimitInfo | nullRate-limit window state.

SearchResult

FieldTypeDescription
idstringMemory ID.
contentstringExtracted memory text.
scorenumberSimilarity score 0.0 (none) – 1.0 (exact).
metadataRecord<string, unknown> | nullServer-attached fields: type, kind, strength, confidence, entities, source_metadata, …
sourceEventsSourceEvent[] | nullOriginating events — populated when includeSourceEvents: true.
sourceMetadataSourceMetadata[] | nullUser-supplied metadata from source event(s); capped at 5 entries.

SourceMetadata

User-supplied event metadata propagated to memories derived from those events. Surfaced on SearchResult.sourceMetadata.

FieldTypeDescription
eventIdstringThe originating event's ID.
metadataRecord<string, unknown> (opt.)Parsed object when the event's metadata string was valid JSON object.
rawstring (opt.)Original string when the event's metadata was not a JSON object.

SourceEvent

A typed view of the events a memory was extracted from. Surfaced on SearchResult.sourceEvents whenever includeSourceEvents: true is passed to client.search(). The wire format embeds these as snake-cased dicts inside metadata.source_events; the SDK parses them and converts to camelCase for you.

FieldTypeDescription
eventIdstringThe ID of the originating event.
kindstringEventKind value of the originating event.
contentstringOriginal event body.
tsstring | nullISO-8601 timestamp.
const results = await client.search('preferences', {
  actorId: 'user_42',
  includeSourceEvents: true,
});

for (const r of results.results) {
  console.log(r.content);
  for (const src of r.sourceEvents ?? []) {
    console.log(`  ↳ from ${src.kind} at ${src.ts}: ${src.content}`);
  }
}

StatusResponse

FieldTypeDescription
completedIdsstring[]Events whose memories are indexed and searchable.
failedIdsstring[]Events whose extraction failed.
pendingIdsstring[]Events still being processed.
totalnumberSum of the three lists (matches your input length).
statusesRecord<string, string> | nullPer-event status string when available.
usageUsageInfo | null
rateLimitRateLimitInfo | null

HealthResponse

FieldTypeDescription
statusstring'ok' when healthy.
versionstringServer version string.
billingEnabledboolean | nullWhether billing is configured for this org.
componentsRecord<string, string> | nullPer-component health (db, redis, etc.).
usageUsageInfo | null
rateLimitRateLimitInfo | null

ClearResponse

FieldTypeDescription
deletednumberCount of records removed.
usageUsageInfo | null
rateLimitRateLimitInfo | null

Metadata types

UsageInfo

Snapshot of your plan consumption parsed from X-Usage-* and X-Plan headers.

FieldTypeDescription
apiCallsnumber | nullAPI calls used this period.
apiCallsLimitnumber | nullAPI calls allowed this period.
eventsIngestednumber | nullEvents ingested this period.
eventsIngestedLimitnumber | null
memoryStorednumber | nullMemories currently stored.
memoryStoredLimitnumber | null
llmTokensnumber | nullLLM tokens consumed for extraction.
llmTokensLimitnumber | null
searchQueriesnumber | nullSearch queries issued this period.
searchQueriesLimitnumber | null
planstring | nullPlan name (e.g. 'free', 'pro').

Any field is null when the platform hasn't reported it on this response.

RateLimitInfo

Parsed from X-RateLimit-* headers.

FieldTypeDescription
limitnumber | nullMax requests allowed in the current window.
remainingnumber | nullCalls remaining in the current period (clamped at 0).
resetnumber | nullUnix timestamp (seconds) of the next billing-period boundary.

Populated on every authenticated response — the rate-limit dimension is api_calls.

const { rateLimit } = await client.search('preferences');

if (rateLimit.remaining !== null && rateLimit.remaining < 5) {
  console.warn(`Only ${rateLimit.remaining} requests left.`);
}

Onboarding types

Org, Role, Team

All three share a common shape and differ only in the ID fields.

FieldTypeNotes
orgIdstringAll three.
roleIdstringRole only.
teamIdstringTeam only.
namestringDisplay name.
focusstringDescription used to generate the promotion prompt.
promotionPromptstringAuto-generated extraction prompt.
createdAtstringISO-8601 timestamp.
updatedAtstringISO-8601 timestamp.
promptMetaRecord<string, unknown> | nullMetadata about prompt generation.

Console memory types

MemoryItem

FieldTypeDescription
memoryIdstringUnique memory ID.
orgIdstringOwning org.
scopeMemoryScopeScope info (level + actor/team/role IDs).
typestringE.g. "preference", "fact".
kindstringE.g. "semantic", "episodic".
memoryKindstringLow-level kind classification.
statusstring"active" / "archived" / "decayed".
textstringThe extracted memory text.
confidencenumberExtraction confidence (0–1).
strengthnumberReinforcement strength (0–5.0, default 1.0). Not a probability.
recallCountnumberTimes recalled in search.
decayHalfLifeDaysnumberDays until strength halves.
pinnedbooleanPinned memories never decay.
tagsstring[]Tags from extraction.
entityRefsRecord<string, string>[]Named entity references.
sourceEventIdsstring[]Contributing event IDs.
sourceUrlsstring[]Source URLs if applicable.
summarystring | nullAuto-generated summary.
payloadRecord<string, unknown> | nullRaw extraction payload.
lastRecalledAtstring | nullISO-8601 timestamp.
effectiveFromstring | nullISO-8601 timestamp.
effectiveTostring | nullISO-8601 timestamp.
observedAtstring | nullISO-8601 timestamp.
createdAtstring | nullISO-8601 timestamp.
updatedAtstring | nullISO-8601 timestamp.

MemoryScope

FieldTypeDescription
levelstring"org" / "role" / "team" / "actor".
actorIdstring | null
teamIdstring | null
roleIdstring | null

MemoryListResponse / MemoryStatsResponse

MemoryListResponse is { items: MemoryItem[]; total: number; limit: number; offset: number }.

MemoryStatsResponse carries aggregate counts: total, totalMemories, activeMemories, byType, byKind, byStatus, avgConfidence, avgStrength, topEntities, confidenceBuckets, dateRange.

Control-plane types

MeResponse

FieldTypeDescription
customerIdstring
emailstring
tierstringE.g. "free", "pro".
isSuperadminboolean
orgIdstring
isBillingAdminboolean
userIdstring | null
orgRolestring | null

BillingSummary

{ tier, purchasedSeats, assignedSeats, availableSeats, stripeCustomerId, paymentMethod, upcomingInvoice, subscriptionStatus, billingContact, stripeSubscriptionId }.

PaymentMethod is { brand, last4, expMonth, expYear }. UpcomingInvoice is { amountDue, currency, periodEnd }.

Invoice

{ id, amountDue, amountPaid, currency, status, created, hostedInvoiceUrl }.

ApiKeyInfo / ApiKeyListResponse / CreateKeyResponse

ApiKeyInfo:           { keyId, prefix, name, scopes, isActive, createdAt, lastUsedAt, expiresAt }
ApiKeyListResponse:   { keys: ApiKeyInfo[], maxKeys, activeCount }
CreateKeyResponse:    { keyId, rawKey, prefix, name, scopes }

rawKey is returned only once on create — store it securely.

UsageSummaryResponse / UsageTimeseriesResponse

DimensionUsage:           { dimension, used, limit, overageRate }
UsageSummaryResponse:     { orgId, tier, periodStart, periodEnd, dimensions: DimensionUsage[] }
TimeseriesPoint:          { date, dimension, quantity }
UsageTimeseriesResponse:  { orgId, granularity, data: TimeseriesPoint[] }

EventItem / EventListResponse

EventItem:           { eventId, orgId, actorId, kind, content, ts, sessionId, metadata, ingestedAt }
EventListResponse:   { items: EventItem[], total, limit, offset }

ProInterestResponse

{ message: string }.

See also