Use EK CMS as a headless CMS.
Edit content in the EK CMS dashboard and render it with your own front end. Your server reads published content over the API with your site ID and an API key.
Before you start
- 1. Headless access is part of the Pro plan.
- 2. In your dashboard, open API keys. Copy your site ID and create a key. The full key is shown once.
- 3. Store both as server environment variables. Never put the key in browser code.
Authenticate every request
Send your site ID in the x-site-id header and your key in the x-api-key header. The base URL is https://ekcms-api.ekrasunya.com/api/v1. Responses are JSON with the content under data.
curl
curl https://ekcms-api.ekrasunya.com/api/v1/site-config \
-H "x-site-id: YOUR_SITE_ID" \
-H "x-api-key: ekcms_pk_..."fetch
// Server-side only. Never ship the key to the browser.
const res = await fetch('https://ekcms-api.ekrasunya.com/api/v1/posts?type=blog&limit=10', {
headers: {
'x-site-id': process.env.EKCMS_SITE,
'x-api-key': process.env.EKCMS_API_KEY,
},
next: { revalidate: 300 },
});
const { data, meta } = await res.json();Public endpoints
All are GET requests and return published content only. Paginated lists take limit (default 20, at most 100) and offset, and return a meta object with total and hasMore.
| Path | Returns |
|---|---|
| /site-config | Site name, tagline, contact details, branding and theme. |
| /menu-items | The menu as a tree of items with labels, links and children. |
| /footer | Footer content. |
| /pages | Published pages. Paginated. |
| /pages/:slug | One published page by slug. |
| /pages/:pageId/sections | The ordered sections of a page, each with its type and data. |
| /posts?type=blog | Published articles. Paginated. |
| /posts/by-slug/:slug | One published article by slug. |
| /collections/:slug/entries | Entries of a content collection. |
| /collections/:slug/entries/by-slug/:entrySlug | One collection entry by slug. |
| /services | Services. |
| /team-members | Team profiles. |
| /media/:id | One media item. |
| /seo/sitemap | The URLs of your published content. |
Errors and rate limits
Errors return a JSON body with status: "error", a code and a message. Requests are rate limited per client IP over a one minute window, and the x-ratelimit-limit, x-ratelimit-remaining and x-ratelimit-reset headers report where you stand. Cache responses on your server to stay well inside the limit.
| Status | Code | Meaning |
|---|---|---|
| 401 | API_KEY_REQUIRED | No key was sent. |
| 401 | API_KEY_INVALID | The key is unknown, revoked or belongs to another site. |
| 403 | HEADLESS_NOT_ENTITLED | The site is not on the Pro plan. |
| 429 | RATE_LIMITED | Too many requests in the current minute. |
Start from the Next.js starter
A minimal Next.js site that reads one EK CMS site over the API: home page, pages, articles and the menu, with the key kept on the server and responses cached.
ek-cms-headless-starter on GitHubDeveloper questions
Which plan do I need for headless access?
Pro. API keys can only be created on a Pro site, and a key stops working if the site leaves Pro.
Where do I find my site ID and API key?
In your dashboard, open API keys. The page shows your site ID, and creating a key shows the full key once. Copy it then, because it is not shown again.
Can I call the API from the browser?
Keep the key on your server. Fetch from server code, such as a Next.js server component or route handler, and send only the rendered result to visitors.
Can I write content through the API?
No. API keys only read published content. Editing stays in the EK CMS dashboard.
What happens if a key leaks?
Revoke it on the API keys page. It stops working at once. Create a new key and update your server.
See every plan feature on the features page.