Query and subscribe to documents

Fetch a single rich-text document, list a workspace's documents with filtering, sorting and pagination, and subscribe to real-time create/update/delete events.


Read rich-text documents from a workspace and watch them change in real time. Use the document query to fetch one document by id, the documents query to list a workspace’s documents with filtering, sorting, and pagination, and the subscribeToDocument subscription to receive create/update/delete events as they happen.

Documents are Document objects in the API, and a workspace is a Project. A document with wiki: true is a Wiki page; everything else about the type is identical. This page covers the rich-text document subsystem only — Portable Document PDF templates are a separate model, covered in Build Portable Document templates.

Request

Fetch a single document by id with the document query. The id is the document’s id (a cuid).

query GetDocument {
  document(id: "document_123") {
    id
    title
    content
    wiki
    updatedAt
  }
}

List a workspace’s documents with the documents query. Pass the workspace via filter.projectId, or omit it to default to the blue-workspace-id header.

query ListDocuments {
  documents(filter: { projectId: "project_123" }) {
    items {
      id
      title
      wiki
      createdBy {
        fullName
      }
      updatedAt
    }
    pageInfo {
      totalItems
      page
      perPage
      hasNextPage
    }
  }
}

Parameters

document arguments

ParameterTypeRequiredDescription
idString!YesThe document’s id.

documents arguments

ParameterTypeRequiredDescription
filterDocumentFilterInput!YesWhich workspace’s documents to list, and an optional wiki flag.
sort[DocumentSort!]NoSort order. Defaults to [updatedAt_DESC].
skipIntNoNumber of documents to skip (offset). Defaults to 0.
takeIntNoPage size. Schema default is 20; if you omit take entirely the resolver falls back to 200.

DocumentFilterInput

FieldTypeRequiredDescription
projectIdStringNoWorkspace to list documents from. Falls back to the blue-workspace-id header when omitted.
wikiBooleanNotrue returns only Wiki pages; false returns only regular documents. Omit to return both (subject to the role constraint above).

DocumentSort

ValueDescription
title_ASCTitle, A→Z.
title_DESCTitle, Z→A.
createdBy_ASCAuthor first name, A→Z.
createdBy_DESCAuthor first name, Z→A.
updatedAt_ASCOldest update first.
updatedAt_DESCMost recently updated first (default).

Response

document returns a single Document:

{
  "data": {
    "document": {
      "id": "clm4n8qwx000008l0g4oxdqn7",
      "title": "Onboarding runbook",
      "content": "<h1>Onboarding</h1><p>Welcome to the team.</p>",
      "wiki": false,
      "updatedAt": "2026-05-29T10:14:22.000Z"
    }
  }
}

documents returns a DocumentPagination with items and pageInfo:

{
  "data": {
    "documents": {
      "items": [
        {
          "id": "clm4n8qwx000008l0g4oxdqn7",
          "title": "Onboarding runbook",
          "wiki": false,
          "createdBy": { "fullName": "Ada Lovelace" },
          "updatedAt": "2026-05-29T10:14:22.000Z"
        }
      ],
      "pageInfo": {
        "totalItems": 1,
        "page": 1,
        "perPage": 20,
        "hasNextPage": false
      }
    }
  }
}

Document fields

FieldTypeDescription
idID!Stable document identifier.
uidString!Short unique id.
titleString!Document title.
contentStringRendered HTML body.
wikiBooleantrue if this document is a Wiki page.
projectProject!The workspace the document belongs to.
createdByUser!The user who created the document (select fullName, email, etc.).
createdAtDateTime!Creation timestamp.
updatedAtDateTime!Last-update timestamp.

DocumentPagination fields

FieldTypeDescription
items[Document!]The page of documents.
pageInfoPageInfoPagination metadata: totalItems, totalPages, page, perPage, hasNextPage, hasPreviousPage.

Full example

List only the Wiki pages in a workspace, sorted by title, taking the second page of 10:

query ListWikiPages {
  documents(
    filter: { projectId: "project_123", wiki: true }
    sort: [title_ASC]
    skip: 10
    take: 10
  ) {
    items {
      id
      title
      wiki
      createdBy {
        fullName
      }
    }
    pageInfo {
      totalItems
      totalPages
      page
      hasNextPage
      hasPreviousPage
    }
  }
}

Subscribe to documents

Use the subscribeToDocument subscription over a WebSocket (wss://api.blue.app/graphql) to receive an event whenever a document in a workspace is created, updated, or deleted. Pass the workspace in input.projectId; optionally pass input.wiki to scope the stream to only Wiki pages (true) or only regular documents (false).

subscription OnDocumentChange {
  subscribeToDocument(input: { projectId: "project_123" }) {
    mutation
    node {
      id
      title
      wiki
      updatedAt
    }
    updatedFields
    previousValues {
      title
    }
  }
}

SubscribeToDocumentInput

FieldTypeRequiredDescription
projectIdString!YesWorkspace to watch.
wikiBooleanNoScope the stream to Wiki pages (true) or regular documents (false). Omit to receive both.

DocumentSubscriptionPayload fields

FieldTypeDescription
mutationMutationType!The event type: CREATED, UPDATED, or DELETED.
nodeDocumentThe current state of the document (null on DELETED).
updatedFields[String!]Names of the fields that changed (on UPDATED).
previousValuesDocumentPreviousValuesThe document’s prior field values (title, wiki, timestamps, …).

Each payload only reaches you if you’re a member of the target workspace. Events fire for both document and Wiki changes within the workspace unless you narrow with wiki.

Errors

CodeWhen
DOCUMENT_NOT_FOUNDdocument was called with an id that doesn’t exist, or the document’s type (doc vs Wiki) is one your role can’t read.
UNAUTHENTICATEDMissing or invalid credentials.
FORBIDDENYou aren’t a member of the workspace you’re querying or subscribing to.

Permissions

  • The documents query auto-constrains results to the document types your role can read: a docs-enabled, Wiki-disabled role never sees Wiki pages, and vice versa — even if you set the wiki filter to the type you can’t access. A wiki filter can only narrow the result set further, never widen it. If neither feature is enabled, the query returns an empty page.
  • document applies the same per-type gate: requesting a Wiki page with a docs-only role (or vice versa) returns DOCUMENT_NOT_FOUND rather than the document. Internal service callers (API-key auth, e.g. the collaboration server) skip this per-role gate.