Skip to main content
The GraphQL API supports real-time subscriptions for content updates via WebSocket connections.

Subscription Schema

type Subscription {
  # Subscribe to updates for a specific content item
  contentUpdated(id: ID!): ContentUpdate!

  # Preview link updates (token-based auth)
  previewUpdated(token: String!, version: Int): PreviewUpdate!
}

Available Subscriptions

WebSocket Client Setup

Using graphql-ws

import { createClient } from 'graphql-ws';

const client = createClient({
  url: 'wss://api.metabind.ai/graphql',
  connectionParams: {
    headers: {
      'x-api-key': 'YOUR_API_KEY'
    }
  }
});

For Preview Subscriptions

Use previewToken instead of x-api-key:
const client = createClient({
  url: 'wss://api.metabind.ai/graphql',
  connectionParams: {
    previewToken: 'YOUR_PREVIEW_TOKEN'
  }
});

Handling Large Payloads

AWS WebSocket has a 128KB payload limit. When data exceeds this limit:
  1. The content or component field will be null
  2. The resolvedRef field is always included
  3. Fetch the full data separately using the ID
  4. Use the resolvedRef to fetch package data
if (!update.content) {
  // Content exceeded 128KB - fetch separately
  const content = await fetchContent(update.contentId);
  refreshContent(content, update.resolvedRef);
} else {
  // Content included in payload
  refreshContent(update.content, update.resolvedRef);
}