Requires the
entities bundle. A project without the entities bundle returns 403 database/tables-not-available for entity calls. See Bundles.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, with optional images and files. A signed-in user’s entity is always theirs. Without a signed-in user, the entity has no author, and the request is allowed only while the project’s Who can create entities without an author setting is Everyone (the default); otherwise it fails with403 entity/authorless-creation-not-allowed. See Create Entity.
Your application’s identifier for this entity. Used for idempotent lookups via
fetchEntityByForeignId.An optional secondary identifier for grouping or filtering entities. For no source, leave it out or pass
null. "none", "null" and "undefined" are reserved and refused with 400 entity/invalid-body.The entity’s own NSFW flag. Defaults to
false. Effective NSFW also inherits from the entity’s space. See Entity NSFW flagging.Images to attach, processed into sizes per
options (mode is required). With images or files the request is sent as multipart/form-data. A request takes at most 20 files in all. Requires the files-images bundle.Files to attach, stored as uploaded. Each file’s
type comes from its MIME type; an image sent here isn’t processed, so it has no image data. Requires the files-images bundle.Promise<Entity>
fetchEntity
Fetches a single entity by its Sublay ID. A removed entity is returned in full to its author and as a placeholder to everyone else.Associations to populate, as a single value or an array:
"user", "space", "topComments", "saved", "files", "grants". "topComments" adds the entity’s best top-level comments as full Comment objects — see Top comments. "saved" adds saved: { isSaved, collections }, the user’s saved state for the entity — see Saved state.With
include containing "topComments": how many top comments per entity. Server default 1, maximum 5. Rejected (400) without "topComments" in include.With
include containing "topComments": the reaction whose raw count ranks the top comments. Server default "upvote". Rejected (400) without "topComments" in include.Promise<Entity>
fetchEntityByForeignId
Fetches an entity by your application’s own identifier. It only reads: an entity that doesn’t exist throws a404. To create the entity when missing, use fetchOrCreateEntityByForeignId. A removed entity is returned in full to its author and as a placeholder to everyone else.
Associations to populate, as a single value or an array:
"user", "space", "topComments", "saved", "files", "grants". "topComments" adds the entity’s best top-level comments as full Comment objects — see Top comments. "saved" adds saved: { isSaved, collections }, the user’s saved state for the entity — see Saved state.With
include containing "topComments": how many top comments per entity. Server default 1, maximum 5. Rejected (400) without "topComments" in include.With
include containing "topComments": the reaction whose raw count ranks the top comments. Server default "upvote". Rejected (400) without "topComments" in include.Promise<Entity>
fetchOrCreateEntityByForeignId
Returns the entity with your application’s identifier, or creates it when there is none. The entity it creates carries only theforeignId: no title, content or author (an app-owned entity). Because it has no author, the project’s Who can create entities without an author setting decides who may create it: everyone by default. When it is set to Signed-in users only (a visitor with no session is refused) or No one from the client (only your backend may create it), a refused caller gets 403 entity/authorless-creation-not-allowed and nothing is created. A suspended user gets 403 user/suspended. Props type: FetchOrCreateEntityByForeignIdProps. A removed entity is returned in full to its author and as a placeholder to everyone else.
Associations to populate, as a single value or an array:
"user", "space", "topComments", "saved", "files", "grants". "topComments" adds the entity’s best top-level comments as full Comment objects — see Top comments. "saved" adds saved: { isSaved, collections }, the user’s saved state for the entity — see Saved state.With
include containing "topComments": how many top comments per entity. Server default 1, maximum 5. Rejected (400) without "topComments" in include.With
include containing "topComments": the reaction whose raw count ranks the top comments. Server default "upvote". Rejected (400) without "topComments" in include.Promise<FetchOrCreateEntityByForeignIdResult>: { entity: Entity; created: boolean }. created is true when this call created the entity (HTTP 201) and false when it already existed (HTTP 200, also when another call created it concurrently). A foreignId whose entity was deleted stays taken: the call throws 409 entity/foreign-id-taken and creates nothing. See Fetch Entity by Foreign ID.
fetchEntityByShortId
Fetches an entity by its short, human-readable ID (used in share URLs). A removed entity is returned in full to its author and as a placeholder to everyone else.Associations to populate, as a single value or an array:
"user", "space", "topComments", "saved", "files", "grants". "topComments" adds the entity’s best top-level comments as full Comment objects — see Top comments. "saved" adds saved: { isSaved, collections }, the user’s saved state for the entity — see Saved state.With
include containing "topComments": how many top comments per entity. Server default 1, maximum 5. Rejected (400) without "topComments" in include.With
include containing "topComments": the reaction whose raw count ranks the top comments. Server default "upvote". Rejected (400) without "topComments" in include.Promise<Entity>
fetchManyEntities
Fetches a filtered, paginated list of entities (feeds). Supports rich filtering by metadata, keywords, location, and more.Only entities from this source, or
"none" for entities with no source. Left out: any source.Only entities in this space, or
"none" for entities in no space. Left out: any space, or none.Sort order:
"createdAt" (chronological — honors sortDir), "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". Not accepted with "hot" or "controversial", which rank one way only.Which reaction
top ranks by: "upvote", "downvote", "like", "love", "wow", "sad", "angry", or "funny". Defaults to "upvote". Only valid with sortBy: "top" — the server rejects it with any other sort.Results per page: a whole number from
1 to 100. Defaults to 10. A larger value is rejected with 400 entity/invalid-query, never lowered to 100.Associations to populate, as a single value or an array:
"user", "space", "topComments", "saved", "files", "grants". "topComments" adds the entity’s best top-level comments as full Comment objects — see Top comments. "saved" adds saved: { isSaved, collections }, the user’s saved state for the entity — see Saved state.With
include containing "topComments": how many top comments per entity. Server default 1, maximum 5. Rejected (400) without "topComments" in include.With
include containing "topComments": the reaction whose raw count ranks the top comments. Server default "upvote". Rejected (400) without "topComments" in include.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 effective NSFW (
entity.nsfw OR its space's nsfwEffective). "include-all" (default) adds no predicate; "exclude" drops effective-NSFW entities; "only" returns only them. See Entity NSFW flagging.How to treat entities authored by users the viewer is block-edged with.
"exclude" (default) hides them; "include-outbound-blocked" re-includes only the viewer’s own outbound-blocked authors — never content from users who blocked the viewer. No effect without the moderation bundle.Promise<PaginatedResponse<Entity>>
updateEntity
Updates fields on an existing entity, and adds or removes its files.Updated NSFW own-flag. A space moderator flagging another user’s entity uses
spaces.setSpaceEntityNsfw instead. See Entity NSFW flagging.Images to append after the entity’s files, processed into sizes per
options (mode is required). With images or files the request is sent as multipart/form-data. Requires the files-images bundle.Files to append after the entity’s files, stored as uploaded. Requires the
files-images bundle.Ids of the entity’s files to remove (ids in its
files). Works alone or with uploads. Any other id throws a 400 (entity/invalid-remove-file-ids, with invalidIds).What the response adds:
"files", the entity’s files as they now are. Without it the response has no files, even after an upload or removal.Promise<Entity>. With include: "files", the entity carries its files as they now are.
deleteEntity
Permanently deletes an entity and its associated data. Deleting a published entity takes back the author’s reputation for creating it, once: not for a draft, and not again for one already soft-deleted.Promise<void>
fetchDrafts
Fetches the logged-in user’s unpublished draft entities. A draft marked removed (moderationStatus: "removed") is listed too, but it can’t be published or edited, only deleted.
Results per page: a whole number from
1 to 100. Defaults to 10. A larger value is rejected with 400 entity/invalid-query, never lowered to 100.Only drafts from this source, or
"none" for drafts with no source. Left out: any source.Only drafts in this space, or
"none" for drafts in no space. Left out: any space, or none.Associations to populate:
"user", "space", "files", "grants" (a single value or an array).Promise<PaginatedResponse<Entity>>
publishDraft
Publishes a draft entity, making it publicly visible.Promise<Entity>
addReaction
Adds the logged-in user’s reaction to an entity and returns the updated entity.Promise<Entity>
removeReaction
Removes the logged-in user’s reaction from an entity and returns the updated entity. A removed entity is returned in full to its author and as a placeholder to everyone else.Promise<Entity>
If the entity’s author has blocked the user, this fails with 404 entity/not-found and nothing changes.
fetchReactions
Fetches a paginated list of reactions on an entity, optionally filtered by reaction type.Results per page: a whole number from
1 to 100. Defaults to 20. A larger value is rejected with 400 entity/invalid-query, never lowered to 100.Promise<{ data: Reaction[]; pagination: { page: number; pageSize: number; totalPages: number; totalItems: number; hasMore: boolean } }>
Reactions from users block-edged with the signed-in user are left out. If the entity’s author has blocked the user, this fails with 404 entity/not-found.
getUserReaction
Gets the logged-in user’s reaction on an entity. Returnsnull if there is no reaction.
Promise<{ reactionType: ReactionType | null }>
If the entity’s author has blocked the user, this fails with 404 entity/not-found.
