Build powerful integrations with MossDocs's GraphQL API. Manage documents, folders, and version control programmatically with a modern, type-safe API.
The MossDocs API is a GraphQL-based interface that allows you to interact with your documents, folders, and version control system. Unlike REST APIs, GraphQL lets you request exactly the data you need in a single query.
Create, read, update, and delete markdown documents with full CRUD operations
Organize documents with nested folder structures and hierarchies
Track document history with Git-backed version control
/api/graphql. Authentication is handled automatically when you're logged into the MossDocs web application.query GetDocuments {
documents(limit: 10) {
id
title
content
isPublic
createdAt
updatedAt
author {
id
name
email
}
}
}Use MossDocs's GraphQL API with AI assistants and automation tools.
Configure ChatGPT to access MossDocs via API. Use for automated document creation, content generation, and workflow automation.
Example Use Case:
"Create a meeting notes document from this transcript" - ChatGPT calls MossDocs API to create and populate a new document with structured content.
Use MossDocs's GraphQL API with Zapier or Make.com to create powerful automation workflows. Trigger document creation, send notifications, or sync data.
Example Workflow:
Google Form submission → Zapier → MossDocs API creates new document with form data → Send Slack notification when document is created.
Create custom GPTs in ChatGPT that can read and write to your MossDocs workspace. Perfect for specialized documentation assistants.
View AI Integration GuideReal-world GraphQL query examples for everyday tasks.
query GetPendingReviews {
documents(
filter: { status: PENDING_REVIEW }
limit: 20
) {
id
title
status
author {
name
email
}
createdAt
}
}mutation CreateFromTemplate {
createDocument(
title: "Weekly Status Report"
content: "# Weekly Status\n\n## Accomplishments\n\n## Challenges\n\n## Next Week"
folderId: "folder-id-here"
) {
id
title
createdAt
}
}# Use with a loop in your application code
mutation CreateDocument($title: String!, $content: String!) {
createDocument(
title: $title
content: $content
) {
id
title
}
}
# Variables (send separately for each document):
# { "title": "Document 1", "content": "Content here..." }
# { "title": "Document 2", "content": "Content here..." }query GetWorkspaceMembers($workspaceId: ID!) {
workspace(id: $workspaceId) {
id
name
members {
user {
id
name
email
}
role
joinedAt
}
}
}mutation UpdateDocument($id: ID!, $content: String!) {
updateDocument(
id: $id
content: $content
) {
id
title
content
updatedAt
}
}query SearchDocuments($query: String!) {
searchDocuments(
query: $query
limit: 10
) {
id
title
excerpt
lastModified
author {
name
}
}
}query GetDocumentApprovalStatus($id: ID!) {
document(id: $id) {
id
title
status
approvalWorkflow {
status
approvers {
user {
name
email
}
approved
approvedAt
}
}
}
}query GetRecentChanges {
documents(
filter: {
updatedAfter: "2026-01-01"
}
orderBy: UPDATED_AT_DESC
limit: 20
) {
id
title
updatedAt
author {
name
}
}
}mutation ArchiveDocument($id: ID!) {
updateDocument(
id: $id
archived: true
) {
id
title
archived
}
}query GetDocumentStats {
workspace {
documentCount
documents {
id
title
wordCount
lastModified
status
}
}
}query ListTemplates {
templates(
category: "Sales"
type: AI_GENERATED
) {
id
name
description
category
type
usageCount
variables
author {
name
}
}
}mutation CreateFromTemplate {
createDocumentFromTemplate(
templateId: "template-id-here"
variables: {
customer_name: "Acme Corp"
date: "2024-01-15"
project_name: "Q1 Initiative"
}
folderId: "folder-id-optional"
) {
id
title
content
createdAt
}
}mutation GenerateAIDocument {
generateFromTemplate(
templateId: "ai-template-id"
variables: {
customer_name: "Acme Corp"
customer_website: "acme.com"
call_date: "2024-02-15"
focus_areas: "pricing, integration"
}
) {
id
status
templateId
createdAt
}
}query GetGenerationStatus {
generationJob(id: "job-id-here") {
id
status
generatedTitle
generatedContent
tokensUsed
errorMessage
createdAt
completedAt
}
}mutation AcceptGeneration {
acceptGeneration(
jobId: "job-id-here"
folderId: "folder-id-optional"
) {
id
title
content
createdAt
}
}query GetTokenUsage {
workspace {
id
name
tier
tokenUsage {
monthlyTokensUsed
monthlyLimit
percentageUsed
resetDate
}
}
}mutation CreateTemplate {
createTemplate(
name: "Sales Call Prep"
description: "Research template for sales calls"
category: "Sales"
type: AI_GENERATED
content: "Research {{customer_name}} at {{customer_website}}..."
variables: {
customer_name: { type: "text", required: true }
customer_website: { type: "text", required: true }
call_date: { type: "date", required: false }
}
isPublic: false
) {
id
name
type
category
}
}X-RateLimit-Limit: 100 - Maximum requests per minuteX-RateLimit-Remaining: 95 - Remaining requests in current windowX-RateLimit-Reset: 1609459200 - Unix timestamp when limit resets// Example error handling in JavaScript
async function makeAPIRequest(query) {
const response = await fetch('/api/graphql', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ query }),
});
if (response.status === 429) {
const retryAfter = response.headers.get('Retry-After');
console.log(`Rate limited. Retry after ${retryAfter} seconds`);
// Wait and retry
await new Promise(resolve =>
setTimeout(resolve, retryAfter * 1000)
);
return makeAPIRequest(query); // Retry
}
return response.json();
}400 Bad Request
Invalid GraphQL query or mutation syntax. Check your query structure and variable types.
{ "errors": [{ "message": "Syntax error in GraphQL query" }] }401 Unauthorized
Missing or invalid authentication token. Ensure you're logged in or provide valid API key in Authorization header.
{ "errors": [{ "message": "Authentication required" }] }403 Forbidden
Insufficient permissions for the requested operation. Check your role in the workspace (VIEWER, EDITOR, or ADMIN).
{ "errors": [{ "message": "Permission denied: ADMIN role required" }] }404 Not Found
Requested resource (document, workspace, folder) does not exist or has been deleted.
{ "errors": [{ "message": "Document not found" }] }500 Internal Server Error
Server encountered an unexpected error. Try again later or contact support if the issue persists.
{ "errors": [{ "message": "Internal server error" }] }All GraphQL errors follow this structure:
{
"errors": [
{
"message": "Error description",
"locations": [{ "line": 2, "column": 3 }],
"path": ["fieldName"],
"extensions": {
"code": "ERROR_CODE",
"details": "Additional context"
}
}
],
"data": null
}Include your API key in the Authorization header of every request:
fetch('https://your-draft-url.com/api/graphql', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_API_KEY_HERE',
},
body: JSON.stringify({
query: `
query {
documents {
id
title
}
}
`,
}),
})Test your API key with a simple query:
query TestAuth {
me {
id
name
email
}
}If authentication is successful, you'll receive your user information. If not, check that your API key is correct and hasn't been revoked.
query ListDocuments {
documents(
limit: 20
offset: 0
folderId: null # Optional: filter by folder
) {
id
title
content
isPublic
isArchived
createdAt
updatedAt
folder {
id
name
}
}
}query GetDocument {
document(id: "cm4abc123def") {
id
title
content
isPublic
createdAt
updatedAt
author {
id
name
email
}
versions {
id
commitHash
message
createdAt
}
}
}mutation CreateDocument {
createDocument(
title: "Getting Started Guide"
content: "# Welcome\n\nThis is my new document!"
folderId: null # Optional: place in a folder
) {
id
title
content
createdAt
author {
name
}
}
}mutation UpdateDocument {
updateDocument(
id: "cm4abc123def"
title: "Updated Title"
content: "# Updated Content\n\nNew information here."
) {
id
title
content
updatedAt
}
}mutation DeleteDocument {
deleteDocument(id: "cm4abc123def") {
id
title
}
}query ListFolders {
folders {
id
name
parentId
documents {
id
title
}
subfolders {
id
name
}
}
}query GetVersionHistory {
document(id: "cm4abc123def") {
id
title
versions {
id
commitHash
message
createdAt
author {
name
}
}
}
}The MossDocs API is fully self-documenting. Use our interactive GraphiQL playground to explore all available types, queries, and mutations with inline documentation.
Open GraphiQL PlaygroundGraphQL allows you to specify exactly which fields you want. Avoid over-fetching by only requesting the data your application needs.
For large lists, use the limit and offset parameters to paginate results and improve performance.
GraphQL errors are returned in the errors array. Always check for errors before processing the data.
Instead of string interpolation, use GraphQL variables for dynamic values. This prevents injection attacks and improves caching.