entities module gives you full control over their lifecycle, reactions, and drafts. All actions are performed on behalf of the logged-in user.
createEntity
Creates a new entity, optionally as a draft or without attributing it to the logged-in user.Your application’s identifier for this entity. Used for idempotent lookups via
fetchEntityByForeignId.An optional secondary identifier for grouping or filtering entities.
The space this entity belongs to.
Title text for the entity.
Body/content text for the entity.
File or media attachments.
Tags or keywords used for filtering and discovery.
User mentions embedded in the entity.
Geographic coordinates
{ latitude: number; longitude: number }.Arbitrary public metadata.
When
true, the entity is created as an unpublished draft.When
true, creates the entity without attributing it to the logged-in user (authorless).Promise<Entity>
fetchEntity
Fetches a single entity by its Sublay ID.The Sublay entity ID.
Comma-separated list of associations to populate.
Promise<Entity>
fetchEntityByForeignId
Fetches an entity by your application’s own identifier. Optionally creates it if not found.Your application’s entity identifier.
When
true, creates a stub entity if no match is found.Comma-separated list of associations to populate.
Promise<Entity>
fetchEntityByShortId
Fetches an entity by its short, human-readable ID (used in share URLs).The entity’s short ID.
Comma-separated list of associations to populate.
Promise<Entity>
fetchManyEntities
Fetches a filtered, paginated list of entities (feeds). Supports rich filtering by metadata, keywords, location, and more.Filter by source ID.
Filter to entities within a specific space.
Sort order:
"new", "hot" (trending), "top" (highest scored), or "controversial". A "metadata.<prop>" value is also accepted to sort by a metadata field.Sort direction:
"asc" or "desc".How to interpret a metadata sort value:
"auto", "numeric", "text", "boolean", or "timestamp".Sort by the count of a specific reaction:
"upvote", "downvote", "like", "love", "wow", "sad", "angry", or "funny".Page number (1-indexed).
Results per page.
Comma-separated list of associations to populate (e.g.
"user").Time window to restrict results to:
"hour", "day", "week", "month", or "year".The author to filter by, also used as the viewing user to resolve
followedOnly.When
"true", returns only entities from users the given userId follows.Filter by keyword tags:
{ includes?: string[]; doesNotInclude?: string[] }.Filter by metadata fields:
{ includes?: object; includesAny?: object[]; doesNotInclude?: object; exists?: string[]; doesNotExist?: string[] }.Filter by title:
{ hasTitle?: "true" | "false"; includes?: string | string[]; doesNotInclude?: string | string[] }.Filter by content:
{ hasContent?: "true" | "false"; includes?: string | string[]; doesNotInclude?: string | string[] }.Filter by attachments:
{ hasAttachments?: "true" | "false" }.Filter within a geographic radius:
{ latitude: string; longitude: string; radius: string }.Promise<PaginatedResponse<Entity>>
updateEntity
Updates fields on an existing entity.The Sublay entity ID to update.
New title.
New content body.
Updated attachments list.
Updated keywords list.
Updated user mentions list.
Updated coordinates
{ latitude: number; longitude: number }.Updated metadata. Merged with existing values.
Promise<Entity>
deleteEntity
Permanently deletes an entity and its associated data.The Sublay entity ID to delete.
Promise<void>
fetchDrafts
Fetches the logged-in user’s unpublished draft entities.Page number (1-indexed).
Results per page.
Filter drafts by source ID.
Filter drafts to a specific space.
Comma-separated list of associations to populate.
Promise<PaginatedResponse<Entity>>
publishDraft
Publishes a draft entity, making it publicly visible.The Sublay entity ID of the draft to publish.
Promise<Entity>
fetchTopComment
Fetches the highest-scored (top) comment on an entity. Returnsnull if the entity has no comments.
The Sublay entity ID.
Promise<TopComment | null>
addReaction
Adds the logged-in user’s reaction to an entity and returns the updated entity.The Sublay entity ID.
One of:
"upvote", "downvote", "like", "love", "wow", "sad", "angry", "funny".Promise<Entity>
removeReaction
Removes the logged-in user’s reaction from an entity and returns the updated entity.The Sublay entity ID.
Promise<Entity>
fetchReactions
Fetches a paginated list of reactions on an entity, optionally filtered by reaction type.The Sublay entity ID.
Filter to a specific reaction type.
Page number (1-indexed).
Results per page.
Sort direction:
"asc" or "desc".Promise<{ data: Reaction[]; pagination: { page: number; limit: number; total: number; totalPages: number; hasMore: boolean } }>
getUserReaction
Gets the logged-in user’s reaction on an entity. Returnsnull if there is no reaction.
The Sublay entity ID.
Promise<{ reactionType: ReactionType | null }>
isEntitySaved
Checks whether the logged-in user has saved an entity, and in which collections.The Sublay entity ID.
Promise<{ saved: boolean; collections: { id: string; name: string }[] }>
