Skip to main content
Fetch Spaces
Fetches a paginated list of public spaces: the space directory. By default it lists top-level spaces (spaces with no parent); the parentSpaceId filter lists a space’s sub-spaces or every level instead. Supports text search. Authentication is optional; when there is a viewer (the signed-in user, or the user a service key names in actingUserId), each space carries their isMember flag.
Across levels (parentSpaceId left out, none or any) this is a discovery surface: a space is listed only if it and every space above it are public, for every caller. Under one parent (parentSpaceId=<id>) the list holds the direct sub-spaces the viewer can see that are public or that the viewer is an active member of — the same sub-spaces that space’s childSpaces preview shows and its childSpacesCount counts. So an unlisted sub-space appears only to its active members, and a private one only to its active members. To list the spaces the signed-in user is a member of, whatever their visibility, use Fetch My Spaces. See Space visibility.

Query Parameters

string
Service key only: the user to list as. The page is exactly what that user’s own access token would get (their membership on each space). Leave it out for the anonymous view. A user token always acts as its own user and must not send it, and neither may a request with no credentials (400 space/acting-user-not-allowed).
number
Page number (1-indexed): a whole number, 1 or more. Defaults to 1. Any other value returns 400 space/invalid-query with param: "page".
number
Results per page: a whole number from 1 to 100. Defaults to 20. A larger value returns 400 space/invalid-query with param: "limit" (it is never lowered to 100), as does 0, a negative number or a value that isn’t a whole number. See Pagination.
string
Sort order: "createdAt" (when the space was created), "alphabetical" (by name) or "members" (by active member count). Defaults to "members".
string
Direction, "asc" or "desc" (either case), for any sortBy. Left out: A–Z for "alphabetical", otherwise newest / most first.
string
Free-text search term, matched as a case-insensitive substring. Trimmed; a blank value returns 400 space/invalid-query. Leave it out for no text filtering.
string
The one field query is matched against: "slug", "name" or "description". Left out, query matches the slug, the name or the description. Values match exactly; any other value returns 400 space/invalid-query.
string
Which level of the space tree to list:
  • Left out, sent empty, or none: top-level spaces only (spaces with no parent). This is the default.
  • A space id: that space’s direct sub-spaces the viewer can see that are public or that the viewer is an active member of. This is how to page through a space’s sub-spaces (add sortBy=alphabetical to order them A–Z by name). An id that matches no space returns an empty page, not a 404.
  • any: spaces at every level.
null and undefined are refused with 400 space/unsupported-param (see Saying “no value”). none and any match exactly (ANY is refused). Any other value that isn’t a space id returns 400 space/invalid-query.
string
Filter by each space’s nsfwEffective (its own flag or any ancestor’s): "include-all" (default) lists every space, "exclude" leaves effective-NSFW spaces out, and "only" lists only them. See Space NSFW flagging.
string
Associations to include, as a comma-separated value or repeated params. The only value is:
  • files — the processed avatarFile and bannerFile objects on each space (requires the files-images bundle)
Matching ignores case. An unknown value returns 400 space/invalid-query.

Response

Space[]
Array of Space objects.
object

Error Responses

sortBy=newest is rejected with a pointer to its replacement, sortBy=createdAt.
parentSpaceId=null and parentSpaceId=undefined are rejected with the spelling to use instead.
memberOf, in any form, is rejected with a pointer to Fetch My Spaces, which lists the spaces the signed-in user is a member of.
GET /spaces/:spaceId/children is not a route. It answers with a pointer to this endpoint’s parentSpaceId filter.
searchSlug, searchName, searchDescription and searchAny are rejected with a pointer to query and searchFields. param names the parameter sent.
The error names the replacement for each:
  • searchSlug: query with searchFields=slug
  • searchName: query with searchFields=name
  • searchDescription: query with searchFields=description
  • searchAny: query without searchFields, which matches the slug, name and description
Returned with code space/invalid-query for invalid values — for example an unknown sortBy, sortDir, searchFields or include value, or a blank query. error names the first problem found.
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.
Returned when a service key names an actingUserId that isn’t a user in this project.
See also: useFetchManySpaces