OptimoCMSDocs

Quickstart

Van nul naar je eerste werkende OptimoCMS API call in 5 minuten. SDK installeren, client configureren, sites ophalen en pagina's publiceren.

Quickstart

In 5 stappen heb je een werkende integratie met OptimoCMS.

Stap 1 — API key aanmaken

  1. Log in op optimocms.com
  2. Ga naar Instellingen → API Keys
  3. Klik op API Key Aanmaken
  4. Geef de key een naam (bijv. "Mijn App") en selecteer de benodigde scopes
  5. Kopieer de key — deze wordt slechts één keer getoond

Tip: Begin met sites:read en pages:read scopes. Je kunt later meer scopes toevoegen.

Stap 2 — SDK installeren

npm install @optimocms/sdk

De SDK werkt met Node.js 18+ en moderne browsers (ESM).

Geen SDK nodig? Je kunt ook direct de REST API aanroepen:

curl https://api.optimocms.com/v1/health \
  -H "X-Api-Key: jouw_api_key"
{
  "status": "ok",
  "version": "1.0.0",
  "timestamp": "2026-05-26T12:00:00Z"
}

Stap 3 — Client initialiseren

Maak een bestand cms.ts aan:

import { OptimoCMS } from '@optimocms/sdk';

const cms = new OptimoCMS({
  apiKey: process.env.OPTIMOCMS_API_KEY!,
});

export default cms;

Security: Sla je API key altijd op in een environment variable, nooit hardcoded in je code.

Stap 4 — Sites ophalen

import cms from './cms';

const response = await cms.sites.list();

for (const site of response.data) {
  console.log(`${site.name} — ${site.domain} (${site.status})`);
}

Response:

{
  "data": [
    {
      "id": "site_abc123",
      "name": "Bakkerij Van Dijk",
      "domain": "bakkerijvandijk.nl",
      "status": "published",
      "createdAt": "2026-01-15T10:30:00Z",
      "updatedAt": "2026-05-20T14:22:00Z"
    },
    {
      "id": "site_def456",
      "name": "Café De Hoek",
      "domain": "cafedehoek.nl",
      "status": "draft",
      "createdAt": "2026-03-01T09:00:00Z",
      "updatedAt": "2026-05-25T16:45:00Z"
    }
  ],
  "pagination": { "total": 2, "limit": 20, "nextCursor": null },
  "meta": { "requestId": "req_abc123", "timestamp": "2026-05-26T12:00:00Z" }
}

Try it — curl:

curl https://api.optimocms.com/v1/sites \
  -H "X-Api-Key: jouw_api_key"

Try it — MCP (Cursor/Claude):

Gebruik de list_sites tool om al mijn sites op te halen.

Stap 5 — Pagina bijwerken en publiceren

import cms from './cms';

const siteId = 'site_abc123';
const pageId = 'page_xyz789';

// Pagina titel en SEO bijwerken
const updated = await cms.pages.update(siteId, pageId, {
  title: 'Ons Broodassortiment',
  seo: {
    title: 'Brood | Bakkerij Van Dijk',
    description: 'Ontdek ons dagverse broodassortiment.',
  },
});

console.log(`Pagina bijgewerkt: ${updated.data.title}`);

// Site publiceren
const deploy = await cms.sites.publish(siteId);
console.log(`Deploy gestart: ${deploy.data.deployId}`);

Response (update):

{
  "data": {
    "id": "page_xyz789",
    "title": "Ons Broodassortiment",
    "slug": "brood",
    "status": "draft",
    "seo": {
      "title": "Brood | Bakkerij Van Dijk",
      "description": "Ontdek ons dagverse broodassortiment."
    },
    "updatedAt": "2026-05-26T12:05:00Z"
  },
  "meta": { "requestId": "req_def456", "timestamp": "2026-05-26T12:05:00Z" }
}

Response (publish):

{
  "data": {
    "deployId": "deploy_ghi789",
    "status": "queued",
    "cached": false
  },
  "meta": { "requestId": "req_ghi789", "timestamp": "2026-05-26T12:05:01Z" }
}

Try it — curl:

curl -X PUT https://api.optimocms.com/v1/sites/site_abc123/pages/page_xyz789 \
  -H "X-Api-Key: jouw_api_key" \
  -H "Content-Type: application/json" \
  -d '{"title": "Ons Broodassortiment", "seo": {"title": "Brood | Bakkerij Van Dijk"}}'

Try it — MCP:

Update de pagina "brood" op site site_abc123 met titel "Ons Broodassortiment"
en publiceer daarna de site.

Volgende stappen

On this page