← Back to TopicNorth

API & Publishing Docs

Programmatic access, incremental feeds, and one-click publishing to any site.

Manage API keys

1. Authentication

Create a key in User → API Keys. Keys start with kt_, are shown once, and are stored as a SHA-256 hash. Send one of:

Authorization: Bearer kt_...
# or
X-API-Key: kt_...
ScopeAllows
readAll GET endpoints: projects, topics, content, feed, publications, jobs
content:writePOST/PATCH/DELETE content
topics:writeCreate topic clusters and article ideas
publishTrigger publish, update and unpublish deliveries

A key can be bound to one project. Rate limit: 120 requests/minute per key (API_RATE_LIMIT_PER_MINUTE).

2. Endpoints

MethodPathPurpose
GET/api/v1/meKey/user identity and accessible projects
GET/api/v1/projectsProjects visible to the key
GET/api/v1/projects/:projectIdProject details and counts
GET/api/v1/projects/:projectId/destinationsConnected destinations and capabilities (no secrets)
GET/api/v1/projects/:projectId/topicsTopic clusters with nested article ideas
POST/api/v1/projects/:projectId/topicsCreate a topic cluster (topics:write)
GET/api/v1/projects/:projectId/articlesArticle ideas
GET/api/v1/projects/:projectId/contentContent list (status, type, q, since, include)
POST/api/v1/projects/:projectId/contentIngest content (content:write)
GET/api/v1/projects/:projectId/content/:contentIdFull content item
PATCH/api/v1/projects/:projectId/content/:contentIdUpdate content (content:write)
GET/api/v1/projects/:projectId/feedIncremental feed for AntyBrowser / external sites
GET/api/v1/projects/:projectId/publicationsRemote publication mappings
POST/api/v1/projects/:projectId/publishPublish / update / unpublish (publish)
GET/api/v1/projects/:projectId/jobsRecent delivery jobs

Machine-readable spec: /api/v1/openapi.json

3. AntyBrowser: fetch new topics and content

The incremental feed is designed for a scheduled sync. Send the lastmeta.generatedAt value assince on the next run. Use the ETag to skip unchanged responses.

curl -H "Authorization: Bearer kt_..." \
  "${BASE_URL}/api/v1/projects/1/feed?since=2026-10-01T00:00:00Z&include=body"
{
  "data": {
    "project": { "id": 1, "name": "AntyBrowser", "domain": "antybrowser.com" },
    "topics": [
      {
        "id": "topic_123",
        "name": "Browser fingerprinting",
        "keywords": ["fingerprint browser", "anti-detect"],
        "articles": [
          { "id": "article_456", "title": "How fingerprinting works", "primaryKeyword": "..." }
        ]
      }
    ],
    "articles": [ ... ],
    "content": [
      {
        "id": 123,
        "title": "How fingerprinting works",
        "slug": "how-fingerprinting-works",
        "status": "published",
        "markdown": "...",
        "html": "<h2>...</h2>",
        "seo": { "description": "...", "canonicalUrl": "..." },
        "revision": "sha256..."
      }
    ]
  },
  "meta": { "since": "...", "generatedAt": "2026-10-29T12:00:00.000Z", "counts": { "topics": 1, "articles": 1, "content": 1 } }
}

For a single item use GET /content/:id; for the list use?include=body,seo.

4. TopicNorth publish protocol (outbound)

This is the contract a destination site implements to receive first-class, idempotent updates and unpublishes. TopicNorth calls it from a TopicNorth Protocol destination.

GET  {SITE}/api/kontentos/v1/health
  -> { "ok": true, "protocol": "kontentos.publish/v1", "capabilities": ["create","update","unpublish"] }

POST {SITE}/api/kontentos/v1/posts
  Authorization: Bearer kt_site_...
  Idempotency-Key: <document.idempotencyKey>
  X-KontentOS-Signature: t=<unix>,v1=<hmac-sha256(secret, "<t>.<raw body>")>

POST {SITE}/api/kontentos/v1/posts/{slug}/unpublish
  Authorization: Bearer kt_site_...
{
  "protocol": "kontentos.publish/v1",
  "action": "publish",             // publish | update | unpublish
  "idempotencyKey": "4:123:publish:sha256...",
  "source": { "projectId": 1, "contentId": 123, "revision": "sha256..." },
  "remote": { "id": null, "slug": null, "url": null },
  "post": {
    "title": "How fingerprinting works",
    "slug": "how-fingerprinting-works",
    "excerpt": "...",
    "markdown": "## Heading\n\nBody...",
    "html": "<h2>Heading</h2><p>Body...</p>",
    "plainText": "Heading Body...",
    "status": "published",
    "publishedAt": "2026-10-29T12:00:00.000Z",
    "updatedAt": "2026-10-29T12:00:00.000Z",
    "locale": "en",
    "tags": ["fingerprinting"],
    "category": "Guides",
    "author": { "name": "", "role": "", "url": "" },
    "featuredImage": { "url": "https://...", "alt": "" },
    "canonicalUrl": "https://primary.example/blog/...",
    "seo": { "description": "...", "ogImage": "..." }
  }
}

Response: { "ok": true, "remoteId": "42", "slug": "...", "url": "https://..." }. The receiver should upsert by slug or source id, so a retried delivery never creates a duplicate.

Reference receiver (Next.js App Router)

The AntyBrowser site can implement this in one route and keep using its existing blog_posts table.

// src/app/api/kontentos/v1/posts/route.ts
import { NextRequest, NextResponse } from "next/server";
import { db } from "@/lib/db";
import { blogPosts } from "@shared/schema";
import { eq } from "drizzle-orm";
import { sanitizeRichText } from "@/lib/rich-text";
import { slugify } from "@/lib/blog";

export async function POST(req: NextRequest) {
  const token = req.headers.get("authorization")?.replace(/^Bearer\s+/i, "");
  if (!token || token !== process.env.KONTENTOS_PUBLISH_TOKEN) {
    return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
  }

  const body = await req.json();
  const post = body?.post;
  if (!post?.title) return NextResponse.json({ error: "title required" }, { status: 400 });

  const slug = post.slug || slugify(post.title);
  const values = {
    title: post.title,
    slug,
    excerpt: post.excerpt ?? "",
    content: sanitizeRichText(post.html ?? ""),
    publishedAt: new Date(post.publishedAt ?? Date.now()),
    category: post.category ?? "",
    authorName: post.author?.name ?? "",
    authorRole: post.author?.role ?? "",
    image: post.featuredImage?.url ?? "from-indigo-500 to-violet-500",
    published: body.action !== "unpublish" && post.status !== "draft",
  };

  const [existing] = await db.select({ id: blogPosts.id })
    .from(blogPosts).where(eq(blogPosts.slug, slug));

  if (existing) {
    await db.update(blogPosts).set(values).where(eq(blogPosts.id, existing.id));
    return NextResponse.json({ ok: true, remoteId: String(existing.id), slug, url: `/blog/${slug}` });
  }

  const [created] = await db.insert(blogPosts).values(values);
  return NextResponse.json({ ok: true, remoteId: String(created.insertId), slug, url: `/blog/${slug}` }, { status: 201 });
}

5. Generic webhook destination

Use Custom HTTP / Webhook when the destination already has an API but does not implement the TopicNorth protocol. Configure URL, method, auth header, extra headers and a JSON body template.

Available placeholders inside the body template:

{{title}}{{slug}}{{excerpt}}{{markdown}}{{html}}{{plainText}}{{status}}{{publishedAt}}{{updatedAt}}{{tags}}{{category}}{{authorName}}{{authorRole}}{{authorUrl}}{{canonicalUrl}}{{featuredImageUrl}}{{featuredImageAlt}}{{action}}{{revision}}{{idempotencyKey}}{{projectId}}{{contentId}}{{document}}{{seo}}

Use {{document}} as a whole string value to send the entire protocol document. Use {{tags}} as a whole value to send an array.

{
  "title": "{{title}}",
  "slug": "{{slug}}",
  "excerpt": "{{excerpt}}",
  "content": "{{html}}",
  "publishedAt": "{{publishedAt}}",
  "status": "{{status}}",
  "image": "{{featuredImageUrl}}",
  "action": "{{action}}"
}

Response mapping: remoteIdPath andremoteUrlPath are dot paths, e.g.data.post.id. For AntyBrowser's existing/api/admin/blog, set the auth header tox-admin-key and map the fields toblog_posts.

6. Safety and operations

  • Destination configs (passwords, tokens, app passwords) are encrypted at rest with AES-256-GCM.
  • User-supplied destination URLs pass an SSRF guard (loopback, RFC1918, metadata ranges, DNS resolution). Use PUBLISH_ALLOW_PRIVATE_HOSTS=true only for intentional local testing.
  • Every delivery is recorded in publish_jobs; retryable failures are retried three times.
  • Successful deliveries are stored in content_publications, enabling update and unpublish later.
  • API keys are hashed, scoped, optionally project-bound, expiring and revocable. Usage is logged without request bodies.