Content
Content methods read and write entries under /{collectionSlug} and bulk routes. They use your API key (CMS routes), not end-user tokens.
const noma = createClient({ projectId, apiKey })Entry bodies use a data object keyed by each field’s name from the schema (usually kebab-case, e.g. meta-title). System fields such as state, locale, and published_at sit next to data on create and update.
content.list
Query entries in a collection.
const result = await noma.content.list("blog-posts", {
state: "published",
locale: "en",
sort: "created_at:DESC",
paginate: 20,
page: 1,
})| Param | Type | Description |
|---|---|---|
state | 'draft' | 'published' | Filter by draft or published entries. |
locale | string | Locale code. |
exclude | string | string[] | Field names to omit from each entry. |
where | Record<string, unknown> | Structured filters; serialized to where[field][...] query params. |
sort | string | Comma-separated sort keys. Each key is column:ASC or column:DESC (for example created_at:DESC, title:ASC). Core columns include id, created_at, updated_at, published_at; custom field names sort when paginate is set. |
limit | number | Max rows (non-paginated list). |
offset | number | Skip rows (only applied when limit is set). |
paginate | number | Page size when using page. |
page | number | Page number. |
timestamps | boolean | Include created_at / updated_at on each entry when supported. |
count | flag | If the count query parameter is present, the response is { count: number } for the current filters instead of a list of entries. |
first | flag | If the first query parameter is present on a list collection, the response is a single entry object (first row). Singleton collections use a different code path and ignore this. |
Singleton collections
If the collection has is_singleton: true, list returns one entry resource directly (not an array), before pagination. That is separate from the first query parameter, which applies to non-singleton collections when you want only the first matching row.
where filters
Pass a nested object; the SDK flattens it for query strings. Detailed operators (equals, in, relations, and so on) are documented in the Content API filtering reference.
content.get
Fetch a single entry by UUID.
const entry = await noma.content.get("blog-posts", entryUuid, {
locale: "en",
translation_locale: "tr",
state: "published",
})| Param | Type | Description |
|---|---|---|
locale | string | Preferred locale for the entry. |
translation_locale | string | Load a linked translation in this locale when available. |
state | 'draft' | 'published' | Which revision to read. |
exclude | string | string[] | Fields to strip from the response. |
timestamps | boolean | Include timestamps when supported. |
content.create
Create an entry.
await noma.content.create("blog-posts", {
locale: "en",
state: "draft",
data: {
title: "Hello",
slug: "hello",
content: "<p>...</p>",
},
})| Field | Description |
|---|---|
locale | Optional locale for the new entry. |
state | draft or published. Use the built-in state instead of a custom "published" boolean field. |
published_at | Optional ISO timestamp when publishing. |
data | Required. Field values keyed by field name. |
content.update
Full replacement of an entry (PUT semantics on the API).
await noma.content.update("blog-posts", entryUuid, {
state: "published",
data: {
title: "Hello (updated)",
slug: "hello",
content: "<p>Updated</p>",
},
})content.patch
Partial update (PATCH). Send only the fields you want to change inside data, plus optional state / locale / published_at.
await noma.content.patch("blog-posts", entryUuid, {
data: {
title: "New title only",
},
})content.delete
Delete an entry.
await noma.content.delete("blog-posts", entryUuid)
await noma.content.delete("blog-posts", entryUuid, true) // force when API allowsThe third argument sets force on the query string when you need hard deletes per API rules.
Bulk operations
content.bulkCreate
await noma.content.bulkCreate("blog-posts", {
items: [
{ locale: "en", state: "draft", data: { title: "A", slug: "a" } },
{ locale: "en", state: "draft", data: { title: "B", slug: "b" } },
],
})content.bulkUpdate
await noma.content.bulkUpdate("blog-posts", {
items: [
{ uuid: uuid1, data: { title: "A2" } },
{ uuid: uuid2, state: "published", data: { title: "B2" } },
],
})content.bulkDelete
await noma.content.bulkDelete("blog-posts", {
uuids: [uuid1, uuid2],
force: false,
})content.linkTranslation
Link two entries in the same collection as translations (different locales).
import type { LinkTranslationPayload } from "@nomacms/js-sdk"
const payload: LinkTranslationPayload = {
translation_entry_uuid: otherEntryUuid,
}
await noma.content.linkTranslation("blog-posts", entryUuid, payload)Related
- Assets - Upload files referenced from media fields.
- Error Handling - Validation and not-found errors from these calls.