Skip to main content
Create Entity
Requires the entities bundle. A project without the entities bundle returns 403 database/tables-not-available. See Bundles.
Creates a new entity in your project. Supports optional file uploads via multipart/form-data. When no files are attached, use application/json. The entity’s author is the signed-in user, or the user a service key names in actingUserId; the create then runs under that user’s own checks, such as suspension. Without a user, the entity has no author: it is app-owned, and only a service key naming nobody can later edit, publish or delete it. Who may create an entity without an author:
  • A service key naming nobody — always.
  • A request with no credentials — only while the project’s Who can create entities without an author setting is Everyone (the default). Under Signed-in users only or No one from the client it returns 403 entity/authorless-creation-not-allowed, also for a draft (this is checked before the draft rule). A request whose user token is expired or invalid is treated as one with no credentials. A project admin changes the setting in the dashboard under Settings → General → SDK.
A signed-in user’s request always creates that user’s entity, whatever the setting.

Body Parameters

string
Your application’s identifier for this entity (URL, slug, database ID, etc.). Used to fetch or create entities without knowing the Sublay ID.
string | null
Groups entities by source. Use a topic ID or page ID to scope feeds to a specific context. For no source, leave it out or send null. none, null and undefined (as strings, exact and case-sensitive) are reserved: list filters use none to mean “no source”, so an entity can’t be stored with one of them. They are refused with 400 entity/invalid-body.
string
The ID of the space this entity belongs to. The space must exist in the same project, and the author must be allowed to post in it (see Who can post and take part): they can read the space’s content, aren’t banned in it or any space above it, and its postingPermission lets them in ("anyone"; "members": its active members; "team": its active admins and moderators). The same applies to a draft. A request with no credentials may post only in an "anyone" space whose content signed-out callers can read. A service key naming nobody may create an app-owned entity in any space, private ones included.
string
Service key only: the user this request acts as, who authors the entity. Leave it out to create an app-owned entity with no author. A user that doesn’t exist returns 404 entity/user-not-found. A user token always acts as its own user and must not send it, and neither may a request with no credentials (400 entity/acting-user-not-allowed).
string
A title or headline for the entity.
string
The main body text of the entity.
object[]
An array of generic attachment objects. Each item is a free-form JSON object — structure is defined by your application.
string[]
Tags or keywords associated with this entity. Used for keyword-based filtering in the list endpoint.
object[]
Users or spaces mentioned in this entity. Each object is a discriminated union:
  • { type: "user", id: string, username: string, foreignId?: string }
  • { type: "space", id: string, slug: string }
Each mentioned user receives one in-app notification, however many times they are mentioned. A space mention sends no notification, and an author mentioning themselves is not notified. When a service key creates the entity on a user’s behalf, that user is the notification’s initiator. An entity without an author sends no mention notifications.
object
Geographic coordinates for this entity. Enables proximity-based filtering.
object
A free-form JSON object for any custom data your application needs alongside the entity. Supports rich filtering via metadataFilters in the list endpoint.
boolean
When true, the entity is saved as a draft and excluded from public feeds. Publish it later via the Publish Entity endpoint. A draft needs an owner: send it with a user token, or with a service key and actingUserId. Otherwise it returns 400 entity/draft-requires-user.
string
ISO 8601 datetime to backfill a creation timestamp. Service key only, also with actingUserId (importing content with its original authors and dates). Ignored from a user token. More than five minutes in the future returns 400 entity/invalid-body (createdAt can't be in the future.).
string
ISO 8601 datetime for updatedAt. Requires createdAt to also be set. Must be ≥ createdAt. When only createdAt is sent, updatedAt is set to the same time. Service key only, also with actingUserId. Ignored from a user token. More than five minutes in the future returns 400 entity/invalid-body (updatedAt can't be in the future.).

File Uploads (multipart/form-data)

When uploading files, send the request as multipart/form-data. All JSON fields above are sent as form fields. Form fields can only carry strings, so the object and array fields — attachments, keywords, mentions, location and metadata — must be JSON-stringified. Booleans are sent as "true" / "false". Plain strings such as title and content are sent as-is.
The SDKs handle this for you — useCreateEntity switches to multipart/form-data and stringifies these fields automatically as soon as you pass images or files.
file[]
Images to attach, up to 50 MB each, processed into sizes per images.options. Must be valid images. Requires images.options. A request takes at most 20 files over images and files together (see Upload errors).
string
Stringified JSON describing how to process uploaded images. Must include a mode field:
  • "exact-dimensions" — resize to specific pixel dimensions per variant
  • "aspect-ratio-width-based" — resize by width maintaining aspect ratio
  • "aspect-ratio-height-based" — resize by height maintaining aspect ratio
  • "original-aspect" — preserve original ratio, resize by max dimension
  • "multi-aspect-ratio" — picks the ratio in aspectRatios closest to the image; one variant per sizes entry
Every requested size is 1–10000 px, and dimensions, widths, heights and sizes take at most 30 entries (one variant each). A variant name uses only letters, digits, _, - and ., is at most 64 characters, can’t contain .., and can’t be original. Optional fields: fit, quality (1–100), format (webp, jpeg, png, original; original keeps the upload’s format when it is JPEG, PNG or WebP, and stores an image whose content is HEIC or AVIF (sent under a JPEG, PNG or WebP type) as WebP), stripExif (boolean), originalMaxSize (50–10000, default 3840: the longest side the stored original is shrunk to), pathParts (string[]; a folder that is, or contains, . or .. (also written %2e%2e), or that contains ?, # or an encoded slash, is refused with a 400). See Upload Image for every field of each mode. A key the options don’t take, a key of another mode included (for example sizes with exact-dimensions), is refused with 400 entity/invalid-body, param naming it.
file[]
Files to attach, stored as uploaded, up to 50 MB each. Each file’s type comes from its MIME type (image, video, document or other); an image sent here isn’t processed, so it has no image data. Counts toward the 20 files a request takes.
string
Stringified JSON for file options. Optional pathParts (string[]) customizes the storage path, with the same folder rule as image options. A key other than pathParts is refused with 400 entity/invalid-body, param naming it.
Images come first in the entity’s files, then the files, each in upload order. An images.options or files.options sent without its files isn’t used, but is still validated: invalid options get a 400. The old field names images.files and files.files are refused with 400 entity/unexpected-file-field.

Response

Returns HTTP 201 with the created Entity object. When the files-images bundle is installed, the entity includes files ([] for none), with a URL for each file, in order, images with their variants.
Draft entities are invisible to everyone but their author until published. Use Fetch Drafts to list an author’s unpublished drafts.

Error Responses

A request with no credentials, on a project whose Who can create entities without an author setting is Signed-in users only or No one from the client. A project admin can change the setting in the dashboard under Settings → General → SDK.
The entity’s author is suspended: the signed-in user, or the user a service key names in actingUserId. Nothing is created.
reason is null when none was given; endDate is null for a suspension with no end date.
A user token, or a request with no credentials, sent actingUserId, even naming its own user. Only a service key names the user it acts as; a user token always acts as its own user.
The request sent userId. On this route the user a service key acts as is actingUserId.With a service key:
With a user token, or with no credentials:
sourceId is "none", "null" or "undefined". Other spellings, such as "None", are ordinary values.
Returned when your entity.created validation webhook rejects the request. error carries the message your webhook returned. Nothing is stored.
The request sent a foreignId that is taken. Another entity already has this foreignId, or had it: a foreignId is unique across the project’s entities, deleted ones included, and a deleted entity’s foreignId can’t be reused. Nothing is created.
When the entity holding it was deleted:
The space doesn’t exist, or the author can’t see it (for example a private space they aren’t an active member of, banned there included). Both answer the same way. Nothing is created.
The author can see the space but may not post in it: they can’t read its content, they’re banned in it or in a space above it, or its postingPermission doesn’t include them. One answer for every cause. Nothing is created. Checked before the suspension check.
Also returned when updatedAt is earlier than createdAt:
Returned to a service key when createdAt or updatedAt is more than five minutes ahead of the current time. param names the field.
A file is over 50 MB. param names its field (images or files).
A file can’t be read as an image. error names the file as it was uploaded. An image over 10000 px on a side gets the same code. error gives its size:
images was sent without images.options. Checked before the validation webhook and before anything is uploaded, so nothing is stored.
images.options without mode, or with a mode that isn’t one of the five (other options fields the same way, named in error and param):
In an aspect-ratio mode, a variant’s computed side would be outside 1–10000 px. Checked once the image is read, before anything is stored. param names the option:
In aspect-ratio-height-based it names a heights option and gives a width. In multi-aspect-ratio it names a sizes option, and the ratio is the one in aspectRatios closest to the image, so the text reads ”… at the 3:1 aspect ratio, the one in aspectRatios closest to this image. Each side of a variant must be 1–10000 px.” More than 30 entries in dimensions, widths, heights or sizes (one variant each). param names the option:
A variant name that uses a character other than letters, digits, _, - and ., that is longer than 64 characters, that contains .., or that is original. param names the option:
A key the options don’t take (also a key of another mode). error names the object holding it, param the key itself:
files.options takes only pathParts; any other key gets the same code:
A value refers to a record that doesn’t exist. constraint names the database constraint that refused it.
The request sent excludeUserId. To create an entity with no author, use a service key without actingUserId.
The request sent requireUser. A user’s token always creates that user’s entity, and who else may create an entity without an author is the project’s Who can create entities without an author setting.
isDraft was true with no author: a request with no credentials, or a service key naming nobody. A draft needs an owner.
Returned when a service key names an actingUserId that isn’t a user in this project.
The uploaded files would take the project past its plan’s file-storage limit. Nothing is created or stored.
Returned when a file or image is uploaded on a project without the files-images bundle. missingTables lists the tables that aren’t installed and bundleId the bundle to install. While the bundle is still being installed, the response is 503 database/tables-provisioning instead. See Bundles.
A file was refused as the body was read: entity/unsupported-file-type or entity/unexpected-file-field (also for the old field names images.files and files.files), with param naming the field when there is one, or 413 entity/too-many-files for more than 20 files in the request. A body over 250 MB gets 413 request/body-too-large; one that can’t be read at all gets request/invalid-multipart or request/field-too-large. See Upload errors.