Sawala CloudSawala Cloud — Docs
DatanaReference

Datana API Reference

Datana's public API — base URL, key tiers, every read endpoint, the query parameters, and the one secret-key write.

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

The public API serves published records of public collections. Most apps use the @sawala/datana-client SDK; this page documents the underlying HTTP surface.

Base URL

https://api.sawala.cloud/public/datana

Every path is scoped to a project and a collection:

/projects/{projectId}/collections/{slug}

Authentication

Send an API key in the X-API-Key header:

X-API-Key: pk_live_xxx
Key kindTokenCan do
Publishablepk_live_…Read public collections' published records — public fields only. Browser-safe.
Secretsk_live_…Read private fields too, filter/sort on them, and the only public write (PUT). Server-side only — a secret key sent from a browser origin is rejected.

Endpoints

MethodPathDescription
GET/projects/{projectId}/collections/{slug}Collection schema (fields & options; private fields stripped)
GET/projects/{projectId}/collections/{slug}/recordsList published records
GET/projects/{projectId}/collections/{slug}/records/{id}Fetch one published record
GET/projects/{projectId}/collections/{slug}/aggregateCounts over published records
PUT/projects/{projectId}/collections/{slug}/records/{id}Replace a published record's data — secret key only

List query parameters

GET …/records

ParameterDescription
limitPage size, 1–100 (default 25)
cursorOpaque pagination cursor from the previous response
sortfield (asc) or -field (desc). Supports createdAt, id, or any data field
filterRepeatable, ANDed. field:value · field:in:a,b · field:gte:N · field:lte:N. Array fields match by membership
populateComma-separated relation field names to inline, or * for all relations
qCase-insensitive search over the record title
statusFilter by lifecycle status

Aggregate parameters

GET …/aggregate

ParameterDescription
countInclude the total published record count → { total }
groupByField to group counts by (single, or array/relation field) → { groups }
distinctComma-separated fields to return distinct-value counts for

Response shape

List responses carry the records under items, with pagination metadata:

{
  "items": [
    { "id": "01J…", "data": { "title": "Bot Labs", "city": "Palembang" }, "status": "published" }
  ],
  "pagination": { "hasMore": true, "nextCursor": "…" }
}

A record's data holds the typed field values — relations, media, and multi-selects are objects or arrays, not strings.

Errors

StatusCodeMeaning
400PRIVATE_FIELD_NOT_QUERYABLEFiltered or sorted on a private field with a publishable key
401UNAUTHORIZEDMissing or invalid API key
403SECRET_KEY_REQUIREDAttempted the PUT write with a publishable key
404COLLECTION_NOT_FOUNDCollection doesn't exist, isn't public, or belongs to another organization

Cross-organization access is a 404, not a 403 — a collection that isn't yours is indistinguishable from one that doesn't exist.

For task-oriented examples, see How to query records.

Daftar Isi