FOUR SDK / V1.0.0
API Reference
Every method returns a Promise.
R— optional finalRequestOptionsP—{ limit?, cursor? }IDs accept strings as input and are branded on validated output.
The SDK exposes exact TypeScript contracts through:
Input<'module.method'>;
ParsedInput<'module.method'>;
Output<'module.method'>;operations exports the corresponding Zod input/output schemas and mutation flags.
TypeScript declarations ship in both .d.ts and .d.cts formats.
Modules and methods
characters
create(input, R) → Characterget(id, R) → Characterupdate(id, patch, R) → Characterlist({ limit?, cursor?, status?, owner?, world? }, R) → Page<Character>archive(id, R) → Characterhydrate(id, { limit? }, R) → Hydration
events
capture(input, R) → EventcaptureBatch(inputs, R) → BatchResult<Event>[]get(id, R) → Eventlist(characterId, P, R) → Page<Event>
memory
commit(input, R) → Memoryrecall(query, R) → Page<RecallResult>list(characterId, P, R) → Page<Memory>forget(id, reason?, R) → Memoryhydrate(query, R) → Page<RecallResult>evolve({ memoryId, content?, salience?, tags?, provenance? }, R) → Memory
relationships
get(characterId, subjectId, R) → Relationshipupdate(input, R) → Relationshiplist(characterId, P, R) → Page<Relationship>
inventory
grant(input, R) → InventoryItemtransfer({ characterId, toCharacterId, itemId, quantity }, R) → { from: InventoryItem | null, to: InventoryItem }remove({ characterId, itemId, quantity }, R) → InventoryItem | nullverify({ characterId, itemId, quantity? }, R) → Verificationlist(characterId, P, R) → Page<InventoryItem>
achievements
unlock({ characterId, key, name, description?, metadata? }, R) → Achievementget(id, R) → Achievementlist(characterId, P, R) → Page<Achievement>
identity
resolve({ characterId }, R) → Identitycreate({ characterId, wallet, publicKey?, portability? }, R) → Identitycheckpoint({ characterId }, R) → Checkpointpublish({ checkpointId }, R) → Checkpointverify({ checkpointId }, R) → VerificationgetHistory(characterId, P, R) → Page<Checkpoint>
sessions
start({ characterId, worldId?, playerId?, hydrate?, metadata? }, R) → Sessionend(id, { summarize?, checkpoint? }, R) → Sessionget(id, R) → Session
client
sync({ id }, { checkpoint?, ...R }) → Hydrationhealth(R) → { status: "ok", network, timestamp }withContext(overrides) → FourBTDClient
Characters
Character creation requires name and owner.
Optional fields include:
description
traits
goals
world
metadatametadata must contain valid JSON values.
Character updates accept a partial creation input.
Archived characters remain readable but reject new character-state mutations. archive is idempotent.
Character versions track profile updates and archival. Memory, relationship, inventory, session, and identity versions track changes to their respective entities.
Use state roots to detect aggregate character-state changes.
Public Exports
The SDK exports branded IDs for:
Character
Event
Memory
Session
Player
World
Item
Achievement
CheckpointIt also exports entity, pagination, error, and configuration types, along with all runtime schemas.
Core interfaces include:
Transport;
Storage;
StoreState;
IdentityAdapter;
CheckpointSigner;
Clock;
IdGenerator;
Logger;Concrete adapters and transports are also exported.
Utilities include:
canonical;
stateRoot;
redact;
systemClock;
randomId;
noopLogger;
checkpointMemo;
isSolanaPublicKey;
validateUrl;Errors
Typed SDK errors include:
FourBTDError;
AuthenticationError;
AuthorizationError;
ValidationError;
NotFoundError;
ConflictError;
RateLimitError;
TimeoutError;
NetworkError;
ServerError;
AbortError;All SDK errors expose:
code
message
status?
requestId?
details?
retryAfterMs?
retryabletoJSON() returns safe error data.
Error utilities are also exported:
isFourBTDError;
isRetryableError;
errorForStatus;