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 server-side control over their lifecycle.
createEntity
Creates a new entity, with optional images and files.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 user the service key acts as, who authors the entity; the create runs under that user’s own checks. Omit it to create an app-owned entity with no author, which only your service key naming nobody can later edit, publish or delete. A user that doesn’t exist returns
404 entity/user-not-found.The entity’s own NSFW flag. Defaults to
false. Effective NSFW also inherits from the entity’s space. See Entity NSFW flagging.When
true, the entity is created as an unpublished draft. Defaults to false. A draft needs an owner, so it requires actingUserId (400 entity/draft-requires-user otherwise).Backdates the entity’s creation time: a
Date, or a full UTC timestamp string such as "2024-03-01T12:00:00.000Z" (date.toISOString()). A string in another format (a date alone, or a time with an offset) is refused with 400 entity/invalid-body and param naming the field. A service key ability, also with actingUserId (for imports with original authors and dates). More than five minutes in the future returns 400 entity/invalid-body (createdAt can't be in the future.).Same format as
createdAt, used to backdate the entity’s last update time. More than five minutes in the future returns 400 entity/invalid-body (updatedAt can't be in the future.).{ files: { file: Uint8Array | Blob; filename?: string; mimeType?: string }[]; options: ImageOptions }
Images to attach, up to 50 MB each, processed per
options (mode is required). Raw bytes carry no type, so pass mimeType with a Uint8Array (image/jpeg, image/png or image/webp; without it the file goes as application/octet-stream and is refused with 400 entity/unsupported-file-type); a Blob keeps its own type. A PDF goes in files: in images it isn’t a valid image (422 entity/invalid-image). A part without a filename is named image. 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: { file: Uint8Array | Blob; filename?: string; mimeType?: string }[]; options?: { pathParts?: string[] } }
Files to attach, stored as uploaded (JPEG, PNG, WebP or PDF: pass
mimeType with a Uint8Array), up to 50 MB each. Each file’s type comes from its MIME type; an image sent here isn’t processed, so it has no image data. A part without a filename is named file. 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.The user to read as: you get exactly what their own access token would get (their drafts, blocks,
saved, their own reaction, top comments), and the read counts as their view. Omit it for the anonymous view (drafts return 404; no view is counted).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.
The user to read as: you get exactly what their own access token would get (their drafts, blocks,
saved, their own reaction, top comments), and the read counts as their view. Omit it for the anonymous view (drafts return 404; no view is counted).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). A service key may always create it, whatever the project’s Who can create entities without an author setting, except when it names a suspended user in actingUserId: that returns 403 user/suspended and nothing is created. Props type: FetchOrCreateEntityByForeignIdProps. A removed entity is returned in full to its author and as a placeholder to everyone else.
The user to read as, as on
fetchEntityByForeignId. It shapes the read only: an entity this call creates is always app-owned. An existing entity this user can’t read comes back as 404, and nothing is created.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.The user to read as: you get exactly what their own access token would get (their drafts, blocks,
saved, their own reaction, top comments), and the read counts as their view. Omit it for the anonymous view (drafts return 404; no view is counted).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. 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.Author filter: returns only entities authored by this user. Not the viewer: that is
actingUserId.The user to list as: you get exactly what their own access token would get (
followedOnly and blockedFilter for them, their own removed entities when userId names them, saved, their own reactions, top comments), and the reads count as their views. Omit it for the anonymous view.When
"true", returns only entities from users the viewer (actingUserId) follows. Without actingUserId it has no effect.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 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, as its author, and adds or removes its files.The user this edit acts as. Required when the entity has an author: pass the author, and the request runs exactly as their own (
400 entity/missing-user-id without it; anyone else gets 403). Omit it only for an app-owned entity.Updated NSFW own-flag (the owner’s). A space moderator flagging another user’s entity uses
spaces.setSpaceEntityNsfw instead. See Entity NSFW flagging.{ files: { file: Uint8Array | Blob; filename?: string; mimeType?: string }[]; options: ImageOptions }
Images to append after the entity’s files, processed per
options (mode is required). Raw bytes carry no type, so pass mimeType with a Uint8Array (image/jpeg, image/png or image/webp; without it the file goes as application/octet-stream and is refused with 400 entity/unsupported-file-type); a Blob keeps its own type. A PDF goes in files: in images it isn’t a valid image (422 entity/invalid-image). With images or files, the request is sent as multipart/form-data. Requires the files-images bundle.{ files: { file: Uint8Array | Blob; filename?: string; mimeType?: string }[]; options?: { pathParts?: string[] } }
Files to append after the entity’s files, stored as uploaded (JPEG, PNG, WebP or PDF: pass
mimeType with a Uint8Array). 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
Deletes an entity and its associated data, as its author. 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.The user this delete acts as. Required when the entity has an author: pass the author, and the request runs exactly as their own (
400 entity/missing-user-id without it; anyone else gets 403). Omit it only for an app-owned entity.Promise<void>
incrementEntityViews
Increments the view counter on an entity. Call this when a user views content to track engagement. It always acts as your app and takes noactingUserId.
Number to add to the view counter: an integer of at least
1. Defaults to 1. Sent as a JSON number in the request body.Promise<EntityRecord>: the stored entity record only, without the computed fields (commentsCount, userReaction, nsfwEffective) or any included associations (user, space, files, topComments, saved, grants). Moderation details (moderationReason, moderatedById, moderatedByType) read as null.
fetchDrafts
Fetches a 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 as its author, making it publicly visible.The user this publish acts as: the draft’s author, and the request runs exactly as their own (
400 entity/missing-user-id without it; anyone else gets 403). A draft with no author, which this API never creates, is answered as not found (404 entity/not-found).Promise<Entity>
addReaction
Adds a reaction from a user to an entity.Promise<Entity> — the updated entity, as the reacting user sees it: userReaction and reactionCounts reflect the new reaction.
removeReaction
Removes a user’s existing reaction from an entity. It sendsDELETE /entities/:entityId/reactions with actingUserId in the query and no body. A removed entity is returned in full to its author and as a placeholder to everyone else.
Promise<Entity> — the updated entity, as that user sees it. When the user has no reaction on the entity, the entity comes back unchanged.
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.The user to list as, exactly as their own access token: reactions from users they are block-edged with are left out, and an entity whose author blocked them fails with
404 entity/not-found. Omit it for the anonymous view.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<PaginatedResponse<Reaction>>
getUserReaction
Checks what reaction (if any) a specific user has left on an entity.Promise<{ reactionType: ReactionType | null }>
If the entity’s author has blocked the user, this fails with 404 entity/not-found.
