Skip to main content

Overview

Spaces are community areas within Campus where users can share content and organize into groups. Each space has members with different roles (owner, moderator, member) and can be public or private.
Spaces are accessed via the PocketBase REST API spaces collection. There are no custom /api/spaces endpoints - all operations use standard PocketBase collection endpoints documented below.

Space Object

A space object contains the following fields:
id
string
Unique space identifier
name
string
Space name
slug
string
URL-friendly space identifier
description
string
Space description
avatar
string
Avatar image filename
isPublic
boolean
Whether the space is publicly accessible
owners
array
Array of user IDs who own the space
moderators
array
Array of user IDs who moderate the space
created
string
ISO 8601 timestamp of creation
updated
string
ISO 8601 timestamp of last update

List Spaces

Retrieve all accessible spaces.

Request

curl -X GET "https://your-domain.com/api/collections/spaces/records?page=1&perPage=30" \
  -H "Authorization: Bearer YOUR_AUTH_TOKEN"
page
number
default:"1"
Page number for pagination
perPage
number
default:"30"
Number of spaces per page
filter
string
Filter expression (e.g., isPublic = true)

Response

{
  "page": 1,
  "perPage": 30,
  "totalItems": 5,
  "totalPages": 1,
  "items": [
    {
      "id": "SPACE_ID",
      "collectionId": "spaces_collection_id",
      "collectionName": "spaces",
      "name": "Computer Science",
      "slug": "computer-science",
      "description": "Space for CS students and faculty",
      "avatar": "avatar.png",
      "isPublic": true,
      "owners": ["USER_ID"],
      "moderators": ["USER_ID_2"],
      "created": "2026-01-01 00:00:00.000Z",
      "updated": "2026-03-01 00:00:00.000Z"
    }
  ]
}

Get Space

Retrieve a single space by ID.

Request

curl -X GET "https://your-domain.com/api/collections/spaces/records/{id}" \
  -H "Authorization: Bearer YOUR_AUTH_TOKEN"

Response

{
  "id": "SPACE_ID",
  "collectionId": "spaces_collection_id",
  "collectionName": "spaces",
  "name": "Computer Science",
  "slug": "computer-science",
  "description": "Space for CS students and faculty",
  "avatar": "avatar.png",
  "isPublic": true,
  "owners": ["USER_ID"],
  "moderators": ["USER_ID_2"],
  "created": "2026-01-01 00:00:00.000Z",
  "updated": "2026-03-01 00:00:00.000Z"
}

Create Space

Create a new space.

Request

curl -X POST "https://your-domain.com/api/collections/spaces/records" \
  -H "Authorization: Bearer YOUR_AUTH_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "New Space",
    "slug": "new-space",
    "description": "A new space for collaboration",
    "isPublic": true,
    "owners": ["USER_ID"]
  }'
name
string
required
Space name
slug
string
required
URL-friendly identifier (must be unique)
description
string
Space description
isPublic
boolean
default:"true"
Whether the space is publicly accessible
owners
array
required
Array of user IDs who will own the space
moderators
array
Array of user IDs who will moderate the space
avatar
file
Avatar image file

Response

{
  "id": "SPACE_ID",
  "collectionId": "spaces_collection_id",
  "collectionName": "spaces",
  "name": "New Space",
  "slug": "new-space",
  "description": "A new space for collaboration",
  "avatar": "",
  "isPublic": true,
  "owners": ["USER_ID"],
  "moderators": [],
  "created": "2026-03-03 12:00:00.000Z",
  "updated": "2026-03-03 12:00:00.000Z"
}

Update Space

Update an existing space. Requires owner or moderator permissions.

Request

curl -X PATCH "https://your-domain.com/api/collections/spaces/records/{id}" \
  -H "Authorization: Bearer YOUR_AUTH_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "description": "Updated description"
  }'

Response

{
  "id": "SPACE_ID",
  "collectionId": "spaces_collection_id",
  "collectionName": "spaces",
  "name": "New Space",
  "slug": "new-space",
  "description": "Updated description",
  "avatar": "",
  "isPublic": true,
  "owners": ["USER_ID"],
  "moderators": [],
  "created": "2026-03-03 12:00:00.000Z",
  "updated": "2026-03-03 13:00:00.000Z"
}

Delete Space

Delete a space. Requires owner permissions.

Request

curl -X DELETE "https://your-domain.com/api/collections/spaces/records/{id}" \
  -H "Authorization: Bearer YOUR_AUTH_TOKEN"

Response

HTTP 204 No Content

Space Membership

Space membership is managed through the space_members collection.

List Space Members

curl -X GET "https://your-domain.com/api/collections/space_members/records?filter=space='SPACE_ID'&expand=user" \
  -H "Authorization: Bearer YOUR_AUTH_TOKEN"

Add Space Member

curl -X POST "https://your-domain.com/api/collections/space_members/records" \
  -H "Authorization: Bearer YOUR_AUTH_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "space": "SPACE_ID",
    "user": "USER_ID",
    "role": "member"
  }'
space
string
required
Space ID
user
string
required
User ID to add
role
string
required
Member role: member, moderator, or owner

Response

{
  "id": "MEMBER_ID",
  "collectionId": "space_members_collection_id",
  "collectionName": "space_members",
  "space": "SPACE_ID",
  "user": "USER_ID",
  "role": "member",
  "created": "2026-03-03 12:00:00.000Z",
  "updated": "2026-03-03 12:00:00.000Z"
}

Remove Space Member

curl -X DELETE "https://your-domain.com/api/collections/space_members/records/{id}" \
  -H "Authorization: Bearer YOUR_AUTH_TOKEN"

Permissions

  • Owner: Full control including deleting space and managing all members
  • Moderator: Can manage content, members (except owners)
  • Member: Can view and post content in the space

Build docs developers (and LLMs) love