Sawala CloudSawala Cloud — Docs
Kontena

Build your first blog

Zero to a blog reading from Kontena in 15 minutes — schema, API key, fetch code.

TODO: translate to Indonesian. English source is authoritative; render it into Indonesian below.

This tutorial takes you from zero to a blog reading from Kontena in 15 minutes. You'll define a post schema in the dashboard, add and publish an entry, mint a public API key, and read the content back from code.

Prerequisite. An active Sawala Cloud account and one project. Sign up free at sawala.cloud.

Create a post schema

  1. Open your project in the dashboard and go to Kontena → Schemas.
  2. Click Create Schema. Name it Post, set the slug to post, and choose type Collection (a blog has many posts).
  3. Add fields:
    • titletext
    • slugtext
    • bodyrichtext (or markdown if you prefer)
    • coverImagemedia (managed by Berkasna)
    • publishedDatedate
  4. Save the schema.

Add and publish one entry

  1. Go to Kontena → Content and pick the Post collection.
  2. Click Create Entry, fill in title, slug, body, choose a cover image, and set the date.
  3. Pick the locale (e.g. en).
  4. Click Publish. Only published entries are returned by the public API — a draft stays invisible to your app.

Mint a public API key

  1. Open Organization Settings → API Keys.
  2. Click Create Key, choose Public type, scope it to this project, and product Kontena.
  3. Copy the pk_live_… token — it appears only once.

A public key is read-only and safe to ship to a browser. For the full model, see how to mint an API key.

Fetch from code

Send the key in the X-API-Key header and read the response.

Reading the response. The raw API returns your entries under a top-level data array, and each entry's own fields live inside that entry's data object — so a post's title is entry.data.title. The @sawala/kontena-client SDK unwraps this for you and exposes items, so SDK code can read fields more directly.

curl -H "X-API-Key: pk_live_xxx" \
  "https://api.sawala.cloud/public/kontena/projects/proj_xxx/content/collection/post?locale=en"
const res = await fetch(
  'https://api.sawala.cloud/public/kontena/projects/proj_xxx/content/collection/post?locale=en',
  { headers: { 'X-API-Key': 'pk_live_xxx' } }
);

const { data, meta } = await res.json();

// Each entry's fields live inside `entry.data`.
for (const entry of data) {
  console.log(entry.slug, entry.data.title);
}

// meta.pagination.nextCursor → pass back as ?cursor=… for the next page.
import { createKontenaClient } from '@sawala/kontena-client';

const kontena = createKontenaClient({
  baseUrl:      'https://api.sawala.cloud/public/kontena',
  projectId:    'proj_xxx',
  publicApiKey: 'pk_live_xxx',
});

interface Post { title: string; body: string }

// The SDK unwraps `data` into `items` for you.
const { items, pagination } = await kontena.listCollection<Post>('post', { locale: 'en' });

for (const post of items) {
  console.log(post.slug, post.data.title);
}

Next steps

  • Add an id locale to the same schema and publish the Indonesian variant — then read it with ?locale=id.
  • Read how to mint an API key for the full public-vs-secret model.
  • Browse all endpoints and parameters in the API reference.
  • Learn the SDK across products in CLI and SDK.

Daftar Isi