entities module gives you full server-side control over their lifecycle.
createEntity
Creates a new entity.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.
The Sublay user ID to set as the entity’s author.
When
true, the entity is created as an unpublished draft. Defaults to false.When
true, creates the entity with no author association even if userId is provided.When
true, the request fails unless a valid author user is resolved.A
Date used to backdate the entity’s creation time.A
Date used to backdate the entity’s last update time.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. Defaults to false.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. 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). Defaults to
1.Results per page. Defaults to
20.Comma-separated list of associations to populate (e.g.
"user").Time window to restrict results to:
"hour", "day", "week", "month", or "year".The viewing user, used 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?, includesAny?, doesNotInclude?, 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 coordinates
{ latitude: number; longitude: number }.Updated metadata. Merged with existing values.
Updated user mentions list.
Promise<Entity>
deleteEntity
Permanently deletes an entity and its associated data.The Sublay entity ID to delete.
Promise<void>
incrementEntityViews
Increments the view counter on an entity. Call this when a user views content to track engagement.The Sublay entity ID.
Number to add to the view counter. Defaults to
1.Promise<Entity>
fetchDrafts
Fetches a user’s unpublished draft entities.The Sublay user ID whose drafts to fetch.
Page number (1-indexed). Defaults to
1.Results per page. Defaults to
20.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 a reaction from a user to an entity.The Sublay entity ID.
The Sublay user ID of the reactor.
One of:
"upvote", "downvote", "like", "love", "wow", "sad", "angry", "funny".Promise<Reaction>
removeReaction
Removes a user’s existing reaction from an entity.The Sublay entity ID.
The Sublay user ID whose reaction to remove.
Promise<void>
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). Defaults to
1.Results per page. Defaults to
20.Sort direction:
"asc" or "desc".Promise<PaginatedResponse<Reaction>>
getUserReaction
Checks what reaction (if any) a specific user has left on an entity.The Sublay entity ID.
The Sublay user ID to check.
Promise<{ reactionType: ReactionType | null }>
isEntitySaved
Checks whether a user has saved an entity to any of their collections.The Sublay entity ID.
The Sublay user ID to check.
Promise<{ isSaved: boolean }>
