API

The three ways to reach your content.

Tenon has one set of operations, with three ways to call them. They share the names, the options and the access rules.

WayWhere it runsUse it for
Local APIYour server codePages, hooks, tasks, scripts. No HTTP in between
ClientThe browser, or another serviceIslands, client components, admin pages, a frontend on another origin
HTTP routesAnything that sends HTTPOther languages, tools like n8n, curl
// Server code: the local API
import cms from "../tenon.config";
const posts = await cms.find("posts", { limit: 3 });

// Browser code: the client
import { createClient } from "tenoncms/client";
const client = createClient();
const same = await client.find("posts", { limit: 3 });
# Anything else: the HTTP route
curl "https://example.com/_tenon/collections/posts?limit=3"

How they differ

  • The imported cms skips the access rules. The client and the routes always apply them, for the user of the session or the API key.
  • The local API reads published content. The client and the routes read drafts only in preview.
  • Some methods exist on one side only. See Methods only on the client.