Developers

Your site stays yours. Citron is the back end it reads from.

Use any framework. Read published content over REST or GraphQL, send forms and bookings to the public endpoints, and rebuild only the pages an editor changed.

The SDK is not on npm yet. Until it is, we send it as a package tarball; ask us and we will share it with your team.

Quick start#

Three steps from an empty project to a page that updates itself when an editor publishes.

  1. Create an API key#

    In the console, open Settings → Developers → API keys and create a published key. It starts with ck_pub_ and is shown once: put it straight into your server’s environment.

    .env.local
    # .env.local (server only)
    CITRON_BASE_URL=https://api.console.citronos.com
    CITRON_API_KEY=ck_pub_…
    CITRON_WEBHOOK_SECRET=whsec_…
  2. Fetch content#

    Ask for a collection by its slug. locale flattens translated fields to one language. The REST reference covers filters, sorting, paging and relations.

    curl "https://api.console.citronos.com/v1/content/products?locale=en&pageSize=20" \
      -H "Authorization: Bearer $CITRON_API_KEY"
  3. Revalidate with webhooks#

    Add a route that checks the signature and revalidates the changed pages, then register its address under Settings → Developers → Webhooks and copy the secret into CITRON_WEBHOOK_SECRET. More on webhooks.

    app/api/citron-webhook/route.ts
    // app/api/citron-webhook/route.ts
    import { revalidateTag } from 'next/cache';
    import { citronTags, createRevalidateHandler } from '@citron/sdk/next';
    
    export const POST = createRevalidateHandler({
      secret: process.env.CITRON_WEBHOOK_SECRET,
      onEvent: (e) => citronTags(e.collection, e.entry.slug).forEach((tag) => revalidateTag(tag)),
    });

Reference#

Keys and environments#

ck_pub_…
Reads published content. Rate-limited per key. Keep it on a server or at the edge.
ck_prev_…
Reads drafts for previews. Keep it on the server; never ship it to a browser.
Where
Settings → Developers → API keys and Webhooks, in the console.
Base URL
https://api.console.citronos.com

Try it on a real workspace

Request access, then create a collection and a public key and read it from your site.