JSON:API routes

v0.0.1

Mishka Document serves its records over JSON:API. Readers use a small public set of routes, and site and master admins use full create, read, update and archive routes. This reference lists the routes of each surface, who can call them, and the type each one returns. The CMS mounts the API at /api/json, so every path below starts with /api/json.

Surfaces and access

SurfacePath prefixWho calls it
Master admin/v1/master/admin/mishka-document/<resource>A master account. It works across sites and needs admin:api:document:workspace or admin:api:document:section, whichever the resource asks for.
Tenant admin/v1/tenant/admin/mishka-document/<resource>A site account holding the same names for its own site.
Reader/v1/user/mishka-document/<resource>Any reader. Lists and single reads need no sign-in. Following and bookmarking need one.
  • The site comes from the host of the request. A request that names no site, such as one with the header x-no-tenant, is answered 400 with the code tenant_required on the reader routes.
  • Sign in at POST /api/json/v1/auth/user/sign-in with a user body holding email and password. The answer carries the token in meta.token. Send it as a bearer token. A master account adds the header x-no-tenant: true when it signs in.
  • Reader reads leave out locked records the caller cannot open. A locked record asked for by id answers 404 with the code not_found, the same as an id nothing is stored at. See Review, status and who can read a page.
  • Lists use offset pagination, 20 records by default and 100 at most. The comment lists of an issue and of a contributor, and the master list of issue comments, return 50 by default and 200 at most.
  • A write body is a JSON:API document: {"data": {"type": "<type>", "attributes": {}}}.

Resource types

Resource pathTypeArea
workspaceworkspaceWorkspace
workspace-versionworkspace_versionWorkspace
workspace-version-lineageworkspace_version_lineageWorkspace
sectionsectionSection
notenoteSection
section-draftsection_draftSection
note-draftnote_draftSection
tagtagSection
issueissueSection
issue-commentissue_commentSection
workspace-followworkspace_followerReader
section-bookmarksection_bookmarkReader

Admin routes with the same shape

The resources workspace, section, note, section-draft, note-draft, tag, issue and issue-comment share these routes on both admin surfaces. A delete archives the record. The permanent delete is a separate route.

Method and pathDoes
GET /Lists records.
GET /:idReads one record.
GET /archivedLists archived records.
GET /archived/:idReads one archived record.
POST /Creates a record.
PATCH /:idUpdates a record.
PATCH /:id/unarchiveRestores an archived record.
DELETE /:id/archiveArchives a record.
DELETE /:id/permanentDeletes a record for good.

Admin routes that differ

ResourceMethod and pathSurfaceDoes
workspaceGET /language-variantsBothLists the translations of a document, given a language group.
workspace-versionGET /, GET /:id, POST /, PATCH /:id, DELETE /:idBothThe usual routes. A delete removes the version for good.
workspace-versionGET /workspace/:workspace_idBothLists the versions of one document.
workspace-versionGET /latestTenantLists the versions marked latest.
workspace-versionGET /status/:statusTenantLists the versions with one status.
workspace-versionPATCH /:id/publishTenantSets the status to stable and publishes it now.
workspace-versionPATCH /:id/mark-latestTenantMarks the version as the document's latest.
workspace-version-lineageGET /, GET /:id, POST /, PATCH /:id, DELETE /:idBothThe clone records. A delete removes the record for good.
workspace-version-lineageGET /new-version/:new_version_id, GET /source-version/:source_version_id, GET /date-range, GET /recentBothFinds clone records by the new version, the source version, a date range, or the most recent.
issuePATCH /:id/mark-in-progress, /mark-resolved, /mark-closed, /reopenTenantMoves the issue to a status.
issue-commentGET /by-issue/:issue_id, GET /by-contributor/:contributor_idTenantLists the comments of an issue, or of a contributor.

Reader routes

Method and path under /v1/user/mishka-documentDoesSign-in
GET /workspace, GET /workspace/:idLists active documents, or reads one.No
GET /workspace-version, GET /workspace-version/:idLists versions that are Alpha, Beta, Rc or Stable, or reads one.No
GET /workspace-version-lineage/:id, /new-version/:new_version_id, /source-version/:source_version_id, /recentReads clone records.No
GET /section, GET /section/:idLists approved pages, or reads one.No
GET /section/workspace/:workspace_version_id/version/:version_numberLists the approved pages of one version.No
GET /tag, GET /tag/:idLists tags, or reads one.No
GET /workspace-follow/my-followingLists the documents the caller follows.Yes
POST /workspace-followFollows a document. Attribute workspace_id, optionally notification_enabled.Yes
PATCH /workspace-follow/:idChanges notification_enabled.Yes
DELETE /workspace-follow/:idUnfollows.Yes
GET /section-bookmark/my-bookmarksLists the caller's bookmarks of approved pages.Yes
POST /section-bookmarkBookmarks a page. Attribute section_id.Yes
DELETE /section-bookmark/:idRemoves a bookmark.Yes

Example: create a document as a master

json
{
  "data": {
    "type": "workspace",
    "attributes": {
      "name": "Tech Workspace",
      "slug": "tech-workspace",
      "description": "Technology documentation",
      "status": "active",
      "language": "en",
      "site_id": "<site id>"
    }
  }
}

Send it with POST /api/json/v1/master/admin/mishka-document/workspace. A site account sends the same body to the tenant path and leaves out site_id.