MossDocs API Documentation

Build powerful integrations with MossDocs's GraphQL API. Manage documents, folders, and version control programmatically with a modern, type-safe API.

Overview

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.

Documents

Create, read, update, and delete markdown documents with full CRUD operations

Folders

Organize documents with nested folder structures and hierarchies

Versions

Track document history with Git-backed version control

Getting Started

Authentication
The MossDocs API uses session-based authentication. You must be logged in to make API requests.
Making Your First Request
Here's a simple query to list your documents
query GetDocuments {
  documents(limit: 10) {
    id
    title
    content
    isPublic
    createdAt
    updatedAt
    author {
      id
      name
      email
    }
  }
}

AI Integration Examples

Use MossDocs's GraphQL API with AI assistants and automation tools.

ChatGPT Automation
Create custom GPT actions that interact with your MossDocs workspace

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.

Zapier / Make.com Integration
Connect MossDocs to thousands of apps using webhooks

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.

Custom GPT Actions
Build custom GPTs with MossDocs API access

Create custom GPTs in ChatGPT that can read and write to your MossDocs workspace. Perfect for specialized documentation assistants.

View AI Integration Guide

Common Use Cases

Real-world GraphQL query examples for everyday tasks.

1. List Documents Pending Review
Get all documents that need your approval
query GetPendingReviews {
  documents(
    filter: { status: PENDING_REVIEW }
    limit: 20
  ) {
    id
    title
    status
    author {
      name
      email
    }
    createdAt
  }
}
2. Create Document from Template
Create a new document with predefined content
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
  }
}
3. Bulk Document Creation
Create multiple documents programmatically
# 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..." }
4. Fetch Workspace Member List
Get all members of a workspace with their roles
query GetWorkspaceMembers($workspaceId: ID!) {
  workspace(id: $workspaceId) {
    id
    name
    members {
      user {
        id
        name
        email
      }
      role
      joinedAt
    }
  }
}
5. Update Document Content
Programmatically update document content
mutation UpdateDocument($id: ID!, $content: String!) {
  updateDocument(
    id: $id
    content: $content
  ) {
    id
    title
    content
    updatedAt
  }
}
6. Search Documents by Keyword
Full-text search across document titles and content
query SearchDocuments($query: String!) {
  searchDocuments(
    query: $query
    limit: 10
  ) {
    id
    title
    excerpt
    lastModified
    author {
      name
    }
  }
}
7. Get Approval Status
Check approval workflow status for a document
query GetDocumentApprovalStatus($id: ID!) {
  document(id: $id) {
    id
    title
    status
    approvalWorkflow {
      status
      approvers {
        user {
          name
          email
        }
        approved
        approvedAt
      }
    }
  }
}
8. Fetch Recent Document Changes
Get documents updated in the last 7 days
query GetRecentChanges {
  documents(
    filter: {
      updatedAfter: "2026-01-01"
    }
    orderBy: UPDATED_AT_DESC
    limit: 20
  ) {
    id
    title
    updatedAt
    author {
      name
    }
  }
}
9. Archive Completed Documents
Mark documents as archived
mutation ArchiveDocument($id: ID!) {
  updateDocument(
    id: $id
    archived: true
  ) {
    id
    title
    archived
  }
}
10. Generate Document Report
Aggregate document statistics for reporting
query GetDocumentStats {
  workspace {
    documentCount
    documents {
      id
      title
      wordCount
      lastModified
      status
    }
  }
}
11. List Available Templates
Browse document templates with category filtering
query ListTemplates {
  templates(
    category: "Sales"
    type: AI_GENERATED
  ) {
    id
    name
    description
    category
    type
    usageCount
    variables
    author {
      name
    }
  }
}
12. Create Document from Static Template
Instantly create document with variable substitution
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
  }
}
13. Generate AI-Powered Document
Start AI generation with web research capabilities
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
  }
}
14. Check AI Generation Status
Poll generation job status and retrieve results
query GetGenerationStatus {
  generationJob(id: "job-id-here") {
    id
    status
    generatedTitle
    generatedContent
    tokensUsed
    errorMessage
    createdAt
    completedAt
  }
}
15. Accept Generated Content
Create document from AI-generated content
mutation AcceptGeneration {
  acceptGeneration(
    jobId: "job-id-here"
    folderId: "folder-id-optional"
  ) {
    id
    title
    content
    createdAt
  }
}
16. Check Workspace Token Usage
Monitor AI token consumption and limits
query GetTokenUsage {
  workspace {
    id
    name
    tier
    tokenUsage {
      monthlyTokensUsed
      monthlyLimit
      percentageUsed
      resetDate
    }
  }
}
17. Create Custom Template
Build reusable templates for your team (admin only)
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
  }
}

Rate Limiting

Rate Limit Headers

Response Headers:

  • X-RateLimit-Limit: 100 - Maximum requests per minute
  • X-RateLimit-Remaining: 95 - Remaining requests in current window
  • X-RateLimit-Reset: 1609459200 - Unix timestamp when limit resets

Handling 429 Errors:

// 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();
}

Error Handling

Error Response Format

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
}

Authentication for External Tools

Step 1: Generate API Key
  1. 1.Log into MossDocs and navigate to Settings
  2. 2.Go to "API Keys" section
  3. 3.Click "Generate New API Key"
  4. 4.Copy the key immediately (it won't be shown again)
Step 2: Add Bearer Token to Requests

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
        }
      }
    `,
  }),
})
Step 3: Verify Authentication

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.

Common Operations

List Documents
Retrieve a list of your documents with pagination and filtering options
query ListDocuments {
  documents(
    limit: 20
    offset: 0
    folderId: null  # Optional: filter by folder
  ) {
    id
    title
    content
    isPublic
    isArchived
    createdAt
    updatedAt
    folder {
      id
      name
    }
  }
}
Get Single Document
Fetch a specific document by its ID
query GetDocument {
  document(id: "cm4abc123def") {
    id
    title
    content
    isPublic
    createdAt
    updatedAt
    author {
      id
      name
      email
    }
    versions {
      id
      commitHash
      message
      createdAt
    }
  }
}
Create Document
Create a new document with markdown content
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
    }
  }
}
Update Document
Update an existing document's title or content
mutation UpdateDocument {
  updateDocument(
    id: "cm4abc123def"
    title: "Updated Title"
    content: "# Updated Content\n\nNew information here."
  ) {
    id
    title
    content
    updatedAt
  }
}
Delete Document
Permanently delete a document
mutation DeleteDocument {
  deleteDocument(id: "cm4abc123def") {
    id
    title
  }
}
Work with Folders
Organize documents using folder structures
query ListFolders {
  folders {
    id
    name
    parentId
    documents {
      id
      title
    }
    subfolders {
      id
      name
    }
  }
}
Version History
Track changes with Git-backed version control
query GetVersionHistory {
  document(id: "cm4abc123def") {
    id
    title
    versions {
      id
      commitHash
      message
      createdAt
      author {
        name
      }
    }
  }
}

Schema Reference

Interactive Schema Explorer
Explore the complete API schema with auto-generated documentation

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 Playground

In the playground, you can:

  • Click "Docs" to browse the complete schema
  • Use Ctrl+Space for auto-complete suggestions
  • Click any field name to see its documentation
  • Run queries and see real-time results
  • View field types and required parameters

Best Practices

Request Only What You Need

GraphQL allows you to specify exactly which fields you want. Avoid over-fetching by only requesting the data your application needs.

Use Pagination

For large lists, use the limit and offset parameters to paginate results and improve performance.

Handle Errors Gracefully

GraphQL errors are returned in the errors array. Always check for errors before processing the data.

Use Variables

Instead of string interpolation, use GraphQL variables for dynamic values. This prevents injection attacks and improves caching.

Need Help?
Get support and learn more about the MossDocs API