Side Space API

API 參考 · v0.1.0

基礎網址
https://side.space/v1
區塊閘道網址
https://blocks.side.space

The REST API for spaces, files, versions, sidecars, forks, search and the journal, and the block gateway that carries file bytes. The whole description, every endpoint included, is at /v1/openapi.yaml.

  • Auth: Authorization: Bearer <token> on every /v1 call except /v1/openapi.yaml. The token is a personal access token ssp_… (see /v1/tokens) or a signed-in app's access token. A personal access token carries scopes and may be limited to some spaces; a call it does not cover answers 403 naming the scope it needs. Scopes for what this reference covers: files:read, files:write (includes read), sidecars:write (every namespace) or sidecars:write:<ns> (one; a trailing * covers a family, e.g. sidecars:write:x-acme.*), renditions:write, events:read, members:manage, webhooks:manage, admin (everything). Tokens never reach /v1/devices or /v1/tokens.
  • Workspaces and drives (ADR 0049): a workspace is the organization: its people and their roles (owner, admin, editor, commenter, viewer, for every drive), plan, tokens and storage backend (/v1/workspaces/…). A drive is a top-level folder of a workspace's storage with its own files, versions and journal: what is mounted, and what S3 calls a bucket. Drives answer at /v1/spaces/{id}/… (the older name) and /v1/drives/{id}/…; a fork is a further drive of the same workspace (workspace_id). GET /v1/spaces lists every drive you reach in every workspace. Ids are opaque: a workspace made before ADR 0049 may share its id with its first drive. Calls under /v1/spaces/{id} answer roles in drive terms (manager for an owner or admin; workspace_role has the role).
  • Free is locked: on a server that takes payments, a workspace on the free plan (also when its trial or subscription ended) answers 402 plan_required to everything but reading the workspace, its plan, Checkout and the billing portal. Files are kept.
  • A token reaches whole workspaces (space_ids: workspace ids; omitted means all of yours), drives made later included, or only some drives of them (drive_ids), which is how a token is kept to one fork. A drive's id in space_ids means that drive only.
  • A token's own space: a credential belongs to a space. A token made for one space (its space_ids has exactly one entry: an access token, an OAuth grant, or a token derived from either) reaches it without naming it: every /v1/spaces/{sid} and /v1/spaces/{sid}/… path also answers at /v1/space and /v1/space/…, with the same scopes and answers. That is the space's first drive, or for a token with drive_ids the first of those. Any other credential (a signed-in app, a token for several or every space) gets 400 space_required there and names the space: /v1/spaces/{sid}/….
  • Errors: {"error": {"code": "...", "message": "...", "details": {...}, "request_id": "req_…"}} with a matching HTTP status. A space the caller is not a member of answers 404, never 403. Every answer carries X-Request-Id and Sidespace-Version headers.
  • Safe writes: send If-Match: "ver_…" with the version you read (commit, delete, restore, rename) or If-None-Match: * to write only where nothing is yet; a write that would overwrite someone else's save answers 412 precondition_failed instead. The S3 gateway takes If-Match: "<etag>", If-None-Match: * and x-sidespace-if-version: ver_… on PutObject, CopyObject, CompleteMultipartUpload and DeleteObject.
  • History: as_of (a time, "-2h" or a journal seq) reads paths, nodes and folders as they were; POST …/nodes/{nid}/rewind puts a folder back. Over S3 every bucket is versioned: ListObjectVersions, GetObject/HeadObject versionId, copy ?versionId= to restore, trash shows as delete markers (del.<node id>; deleting one brings the file back), and x-sidespace-as-of lists or reads the bucket as it was. PUT bucket makes a space (with x-sidespace-fork-source: <bucket>[/<folder>], a fork); DELETE bucket deletes a space that never held anything.
  • Lists: ?cursor=&limit=; responses carry next_cursor (null on the last page).
  • Webhooks: a space manager subscribes a URL to the space's journal (/v1/spaces/{sid}/webhooks). Each event is one signed POST (WebhookEvent), in journal order; failures retry with backoff (10 s doubling to 1 h; 24 failures in a row turn the subscription off). Side-Signature: t=<unix>,v1=<hex HMAC-SHA256(secret, "<t>.<body>")>; dedupe on Side-Event-Id.
  • IDs: prefixed ULIDs (usr_, spc_, nod_, ver_, tok_, whk_).
  • Hashes: BLAKE3, 64 lowercase hex characters.