Skip to main content
Create Space
Creates a new space. Its creator — the signed-in user, or the user a service key names in actingUserId — is automatically added as an admin. A space always has a creator, so a service key must name one. A top-level space’s owner (its userId) is its creator. A sub-space’s owner is the root space’s creator, so one user owns the whole tree: whoever creates a sub-space becomes its admin, not its owner, and can’t delete it unless they also own the root space. The parent space’s active admins and moderators are added to a new sub-space with the same roles. See the Space data model. Send multipart/form-data to upload an avatar or banner with it (other fields as form fields, objects as JSON strings); without files, use application/json. To change or remove the images later, use Update Space. Authentication required. A request with no credentials returns 401.

Body Parameters

string
required
Display name for the space: 3–100 characters after leading and trailing whitespace is trimmed. Every space has a name; leaving it out, or sending null, returns 400 space/invalid-body with param: "name".
string
Optional URL slug. Must be unique per project. Supports Unicode letters, numbers, hyphens, and underscores.
string
Optional description. Up to 1,000 characters.
string
Who can read content: "anyone" or "members". Defaults to "anyone".
string
Who can post entities: "anyone", "members" (active members), or "team" (the space’s active admins and moderators). Defaults to "members". Any other value, "admins" included, is refused with 400 space/invalid-body.
string
Who can find and see the space: "public", "unlisted", or "private". Defaults to "public". Independent of readingPermission, which governs content. "unlisted" keeps the space out of the directory and search, and out of sub-space lists for non-members, but reachable by id, short id or slug; "private" makes it seen only by its active members (everyone else gets 404), and it can’t be joined: members are added by its moderators and admins. See Space visibility.
boolean
Whether new joins require approval. Defaults to true.
object
Optional arbitrary key-value data. Up to 1 MB.
string | null
Optional UUID of a parent space. The caller must be an admin of the parent space; when a service key creates the space for a user (actingUserId), that user must be. For a top-level space, send null or leave it out; the string "none" is refused with 400 space/unsupported-param (see Saying “no value”).
file
Optional avatar image, up to 50 MB. Multipart form field. Requires avatarFile.options.
string
Stringified JSON describing how to process the avatar. Must include a mode field; see Upload Image for the modes and optional fields. Not used when no avatarFile is sent, but still validated: invalid JSON or options get a 400. A key the options don’t take, a key of another mode included (for example sizes with exact-dimensions), is refused with 400 space/invalid-body, param naming it.
file
Optional banner image, up to 50 MB. Multipart form field. Requires bannerFile.options.
string
Stringified JSON describing how to process the banner, as avatarFile.options. Not used when no bannerFile is sent, but still validated: invalid JSON or options get a 400.
string
Service key only, and required with one: the user this request acts as, who creates the space and becomes its admin, held to their own permissions. Leaving it out returns 400 space/missing-user-id. A user token always acts as its own user and must not send it (400 space/acting-user-not-allowed).

Response

Returns the created Space object with membersCount, childSpacesCount, optional file associations, and memberPermissions: what the creator may do in the new space, as a SpaceMemberPermissions object.

Error Responses

Returned with no JSON body: 401 when no Authorization header is sent, 403 when the access token is invalid or expired. Checked before any uploaded file is read, so a request with no credentials gets 401 rather than a body or acting-user error.
Every space has a name. name was left out, sent as null, or isn’t 3–100 characters after trimming (an empty or whitespace-only name included). Over multipart, a missing name form field is the same as leaving it out.
A service key sent no actingUserId. A space needs a creator.
A user token 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.
actingUserId was sent in the query string. On this endpoint every field, actingUserId included, goes in the request body.
Returned when a service key names an actingUserId that isn’t a user in this project.
The request sent userId. On this route the user a service key acts as is actingUserId.With a service key:
With a user token:
The parent space doesn’t exist, or the caller can’t see it (see Space visibility). Checked before the parent-admin check.
The creator was banned in the parent space (or above) while the child space was being created.
Returned when an avatar or banner 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.
The image is over 50 MB. param names its field: avatarFile or bannerFile.
The file can’t be read as an image. Also returned for the banner, with param: "bannerFile". An image over 10000 px on a side gets the same code. error gives its size:
For bannerFile:
avatarFile or bannerFile was uploaded without its .options field. param is avatarFile.options or bannerFile.options.
The .options field isn’t valid JSON. param names the field: avatarFile.options or bannerFile.options. avatarFile.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:
A file was refused as the body was read: space/unsupported-file-type or space/unexpected-file-field (a file in another field, or a second file in avatarFile or bannerFile), with param naming the field when there is one. 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.
See also: useCreateSpace