Repository navigation
Publish Website Feature in Nextcloud Collectives
is an open-source software you host yourself for files and collaboration, often described as a self-hosted alternative to Google Workspace or Microsoft 365. It handles file sync and sharing, calendar, contacts, mail, chat and video calls (Talk), and editing documents together.
is a Nextcloud app for shared team knowledge, like a wiki. The pages are stored as ordinary Markdown files in Nextcloud. Until now, the only way to show a collective to externals was a public share link, optionally with a password. That link opens the shared folder or page inside the Nextcloud Collectives interface.
Turns any selection of pages inside Collectives into a standalone static website.
Interface between the Nextcloud Collectives app and the external publish service, which builds and hosts websites from collectives.
Scope: requests from Collectives to the publish service, requests from the publish service to
Collectives, and the related internal handling. The frontend API is documented in openapi.json.
%%{init: {"sequence": {"useMaxWidth": false, "actorMargin": 30, "width": 100, "messageMargin": 20}, "themeVariables": {"fontSize": "12px"}}}%%
sequenceDiagram
participant C as Collectives
participant P as Publish service
C->>C: Store tar.gz of the build
C->>P: POST/PATCH /static-sites (Bearer token)
P-->>C: 202 Accepted
P->>C: GET archive (unguessable URL)
P->>C: PATCH status callback (unguessable URL)
C->>C: Store result, delete archive
Deletion works the same way: DELETE /static-sites/{id}, result via the callback URL.
| Identifier | Format | Created | Purpose |
|---|---|---|---|
static_site_id |
UUID v7 | Once per website | Website at the service, part of the secret URLs |
build_id |
UUID v7 | Per request (create, update, delete) | One attempt, part of the secret URLs |
slug |
^[a-z0-9]+(-[a-z0-9]+)*$, max. 64 chars |
On create, editable until first publication | Path of the public website, unique per instance |
static_site_id and build_id are never returned to the frontend.
App config collectives, set by admins:
| Key | Description |
|---|---|
static_site_generator_url |
Base URL of the publish service |
static_site_generator_token |
Bearer token, stored as sensitive, never sent to the browser |
static_site_max_size |
Max. total file size of a website (default 100 MiB) |
publish_enabled |
Enables creating and updating websites |
| Direction | Mechanism |
|---|---|
| Collectives → publish service | Authorization: Bearer <token> |
| Publish service → Collectives (download, callback) | None, authorized by the URL (static_site_id + build_id) |
A download or callback URL is only valid for the current build of a website.
Implementation: lib/Service/StaticSiteGeneratorClient.php. JSON bodies wrapped in {"data": {...}},
timeout 30 s, connect timeout 5 s, sent synchronously during the user request (or the cleanup job).
{
"data": {
"static_site_id": "…",
"slug": "my-collective",
"build_id": "…",
"content_download_url": "https://cloud.example.com/index.php/apps/collectives/api/v1.0/static-site-generator/static-sites/{static_site_id}/builds/{build_id}/archive",
"callback_status_url": "https://cloud.example.com/ocs/v2.php/apps/collectives/api/v1.0/static-site-generator/static-sites/{static_site_id}/builds/{build_id}",
"title": "My Collective",
"render_options": { "theme": "wiki" }
}
}Used for new websites. On 409 (unless "slug already taken") a PATCH is sent instead.
Same body without static_site_id and slug. Used for websites that were published before.
On 404 a POST is sent instead.
{ "data": { "callback_status_url": "…/static-sites/{static_site_id}/builds/{build_id}" } }Uses a new build_id. 404 deletes the website locally right away; 202 sets it to deleting
until the callback.
Expects 200 {"status": "ok"}.
| Response | Result in Collectives |
|---|---|
202 |
Accepted, status provided / deleting
|
Not reachable, timeout, 5xx
|
failed / generator_unavailable
|
409 "operation in progress"
|
failed / generator_busy
|
| Other |
failed / generator_rejected
|
Error messages of the service are only logged, never shown to users. For deletions, a rejected request restores the previous status.
GET /index.php/apps/collectives/api/v1.0/static-site-generator/static-sites/{staticSiteId}/builds/{buildId}/archive
lib/Controller/StaticSiteArchiveController.php – public, brute-force protected.
| Case | Response |
|---|---|
| Current build with archive |
200, application/gzip
|
Unknown staticSiteId
|
404, throttled |
| Other or outdated build, no archive | 404 |
Archive content (StaticSiteContentCollector, StaticSiteArchiver):
-
.tar.gz, stored in app data atstatic_sites/{staticSiteId}/{buildId}.tar.gz - Selected pages, their ancestor pages and their attachments; hidden files are excluded
- Files are read without user context; permissions (publish enabled, user can edit the collective, pages belong to the collective) are checked before
- Paths are validated against traversal (
.., absolute paths,\) and ustar length limits
PATCH /ocs/v2.php/apps/collectives/api/v1.0/static-site-generator/static-sites/{staticSiteId}/builds/{buildId}
OCS-APIRequest: true
Content-Type: application/json
{ "status": "published", "data": { "publish_url": "https://sites.example.com/my-collective/" } }
lib/Controller/StaticSiteGeneratorController.php – OCS endpoint, public, rate limit 60/min,
brute-force protected. The header OCS-APIRequest: true is required to pass Nextcloud's CSRF
check without a login; without it the request fails with 412.
| Parameter | Description |
|---|---|
status |
published, failed (build) or deleted, failed (deletion) |
data.publish_url |
Required for published: http(s) URL, max. 255 characters |
data.error_message |
Optional, only logged |
data.build_id |
Optional, must match the URL |
| Case | Response |
|---|---|
| Invalid status | 400 |
Unknown staticSiteId
|
404, throttled |
| Unknown build | 404 |
| Processed or ignored | 200 |
Rules:
- Only the current build changes the status; callbacks of older builds are only logged.
-
published→ statuspublished, storespublish_url; invalid URL →failed/generator_invalid_url. -
failed→failed/generator_failed(deletion:generator_delete_failed, website stays online). -
deleted→ website and archives are removed (only whiledeleting). - A published build isn't changed anymore. The archive of the build is deleted afterwards.
GET /ocs/v2.php/apps/collectives/api/v1.0/static-site-generator/health – admin only, used by
the admin settings. Returns 200 or 502 with a message.
| Status | Meaning |
|---|---|
pending |
Archive is built, request being sent |
provided |
Accepted by the service, waiting for callback |
published |
Website online |
failed |
See last_error
|
deleting |
Deletion accepted, waiting for callback |
- One request per collective at a time;
pending,providedanddeletingcount as aborted after 15 minutes. - Status changes are atomic (
WHERE build_id = …/status/updated_at), so late callbacks and concurrent requests don't overwrite each other.
Deleted when a newer build is stored, after the callback, on rejection and on deletion of the website. Kept on timeout, as the service may still download it.
Websites of purged collectives are deleted at the service. If it isn't reachable, the background
job DeleteOrphanedStaticSites retries every 6 hours.
staticSiteId, buildId and service error messages are written to the Nextcloud log.