LxBlog
/Docs

Api Reference

Sync

The Sync API provides an efficient way to keep your application's content in sync with LxBlog. Instead of fetching all articles and comparing them locally, you send a list of articles you already know about, and the API returns only the changes.

Sync Articles

POST/api/v1/sync

Compares your known articles against the current state of the blog and returns only the differences: new articles, updated articles, and deleted article IDs.

This endpoint requires the articles:read scope.

Request Body

NameTypeDescription
knownArticles*Array<{ id: string, contentHash: string }>List of articles your application currently has, each with its ID and content hash.

Example Request

Sync request
curl -X POST https://lxblog.app/api/v1/sync \
  -H "Authorization: Bearer lxb_at_your_access_token" \
  -H "Content-Type: application/json" \
  -d '{
    "knownArticles": [
      {
        "id": "cm5abc123def456ghi789",
        "contentHash": "a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2"
      },
      {
        "id": "cm5xyz789abc123def456",
        "contentHash": "f6e5d4c3b2a1f6e5d4c3b2a1f6e5d4c3b2a1f6e5d4c3b2a1f6e5d4c3b2a1f6e5"
      }
    ]
  }'

Response

200 OK
{
  "new": [
    {
      "id": "cm5new111aaa222bbb333",
      "slug": "introducing-server-actions",
      "title": "Introducing Server Actions",
      "description": "Learn how to use React Server Actions for form handling.",
      "content": "# Introducing Server Actions\n\nServer Actions are a new feature...",
      "coverImageUrl": "https://images.example.com/server-actions.jpg",
      "inlineImageUrls": [],
      "tags": ["react", "server-actions"],
      "seoKeywords": ["react server actions", "form handling"],
      "seoScore": 7,
      "schemaOrgJson": { "@context": "https://schema.org", "@type": "BlogPosting", "headline": "Introducing Server Actions" },
      "publishedAt": "2026-02-20T09:00:00.000Z",
      "updatedAt": "2026-02-20T09:00:00.000Z",
      "viewCount": 0,
      "contentHash": "d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5"
    }
  ],
  "updated": [
    {
      "id": "cm5abc123def456ghi789",
      "slug": "getting-started-with-nextjs",
      "title": "Getting Started with Next.js (Updated)",
      "description": "An updated guide to building modern web applications with Next.js.",
      "content": "# Getting Started with Next.js\n\nThis updated guide covers...",
      "coverImageUrl": "https://images.example.com/nextjs-cover-v2.jpg",
      "inlineImageUrls": [],
      "tags": ["nextjs", "react", "web-development"],
      "seoKeywords": ["next.js tutorial", "react framework"],
      "seoScore": 9,
      "schemaOrgJson": { "@context": "https://schema.org", "@type": "BlogPosting", "headline": "Getting Started with Next.js (Updated)" },
      "publishedAt": "2026-02-15T10:30:00.000Z",
      "updatedAt": "2026-02-22T16:45:00.000Z",
      "viewCount": 89,
      "contentHash": "b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3"
    }
  ],
  "deleted": [
    "cm5xyz789abc123def456"
  ],
  "syncedAt": "2026-02-23T12:00:00.000Z"
}

Response Fields

NameTypeDescription
newArticle[]Published articles that were not in your knownArticles list.
updatedArticle[]Articles whose contentHash has changed since your last sync.
deletedstring[]IDs of articles from your knownArticles that no longer exist (deleted or unpublished).
syncedAtstringISO 8601 timestamp of when this sync was processed.

How Sync Works

When you call the sync endpoint, the API compares your knownArticles against the current state of all published articles in the blog:

  1. Unchanged — Articles in your knownArticles that still exist and have the same contentHash are not returned. These articles are already up to date in your application.
  2. Updated — Articles in your knownArticles that still exist but have a different contentHash are returned in the updated array with their full, current data.
  3. Deleted — Articles in your knownArticles that no longer exist (either deleted or unpublished) are returned as IDs in the deleted array. You should remove these from your local store.
  4. New — Published articles that are not present in your knownArticles at all are returned in the new array. These are articles published since your last sync or articles you have never seen before.

For an initial sync, send an empty knownArticles array. The API will return all published articles in the new array, giving you a complete snapshot of the blog's content.

Initial sync (empty knownArticles)
curl -X POST https://lxblog.app/api/v1/sync \
  -H "Authorization: Bearer lxb_at_your_access_token" \
  -H "Content-Type: application/json" \
  -d '{ "knownArticles": [] }'

Content Hash

The contentHash field on each article is a SHA-256 hash computed from the concatenation of the article's title, description, content, and tags. This hash changes whenever any of these fields are modified, allowing the sync endpoint to efficiently detect which articles have been updated without comparing full content payloads.

Store the contentHash alongside each article in your local database. When calling the sync endpoint, include the stored hash so the API can determine which articles have changed.