REST API

Response Format

The structure of list and single-item responses, date formats, and the meaning of null and empty values.

The Onttle REST API uses a consistent JSON format for all responses. Understanding the structural difference between list and single-item responses, date formats, and empty value handling allows you to parse responses in a predictable way.


List Response

The response format for GET requests that return a list (GET /tables/{table}).

{
  "list": [
    {
      "id": "0c8f6c1e-5d1b-4f0a-9a3e-2b7d4e6f8a10",
      "created_at": "2026-08-30T09:00:00.000Z",
      "updated_at": "2026-08-30T09:00:00.000Z",
      "published_at": "2026-08-30T09:00:00.000Z",
      "owner_member_id": null,
      "data": {
        "title": "Hello Onttle"
      },
      "slug": "hello-onttle"
    }
  ],
  "pagination": {
    "page": 1,
    "size": 50,
    "total": 42,
    "totalPages": 1
  }
}
Field Type Description
list array Array of retrieved items. Returns an empty array [] if no results
pagination.page number Current page number
pagination.size number Items per page that was applied (default 50)
pagination.total number Total number of items matching the filter
pagination.totalPages number Total number of pages

Single Item Response

The response format for GET requests that retrieve a specific resource by ID or slug (GET /tables/{table}/{id}). Creating (POST) or updating (PUT) Contents returns the same format.

{
  "id": "0c8f6c1e-5d1b-4f0a-9a3e-2b7d4e6f8a10",
  "created_at": "2026-08-30T09:00:00.000Z",
  "updated_at": "2026-08-30T09:00:00.000Z",
  "published_at": "2026-08-30T09:00:00.000Z",
  "owner_member_id": null,
  "data": {
    "title": "Hello Onttle",
    "is_featured": false,
    "thumbnail": null
  },
  "slug": "hello-onttle"
}

Single items are returned directly without a wrapping object.

Field Type Description
id string Content ID (UUID)
created_at string Creation time
updated_at string | null Last update time. null if never updated
published_at string | null Publication time
data object Column values keyed by Column name
slug string | null Content slug. Included only on Tables that use slugs
seo_title, seo_description object | null SEO title and description, one text per language: { "ko": "…", "en": "…" }. With language they are that language's string. Included only on Tables that use SEO
seo_image object | null SEO image file. Included only on Tables that use SEO
owner_member_id string | null ID of the member that owns the content. Always included, whatever the permission rule; null when there is no owner

Column values are always inside the data object. In create and update requests, on the other hand, Column values are sent at the top level of the body, not wrapped in data. See Request Examples.


Dates and Times

All date and time values use ISO 8601 UTC format.

2026-08-30T09:00:00.000Z

How to parse it in JavaScript.

const contents = await res.json()

// Convert to a Date object
const createdAt = new Date(contents.created_at)

// Format the date (Intl)
const formatted = new Intl.DateTimeFormat('en-US', {
  year: 'numeric',
  month: 'long',
  day: 'numeric',
}).format(createdAt)
// e.g. "August 30, 2026"

null, Empty Arrays, and Omitted Fields

Situation Response
Optional field has no value null
FILE or CATEGORY Column with no selection null or [] (when multiple is set)
List query returns no results { "list": [], "pagination": { ... , "total": 0 } }
A localization Column has no value for a specific locale The locale key may be omitted from the object. null when language is given
Only some fields were requested with fields Fields that were not requested are omitted from the response (id is always included)

Accessing a non-existent resource returns a 404 error, not null. The same applies to Contents that are not published or have been deleted.


Multilingual Field Structure

Columns with the localization option return per-locale values as an object. With the language parameter (also accepted as lang or locale) set to one of the Project's languages, only that language's value is returned, as a string.

// Without the language parameter
{
  "data": {
    "title": {
      "ko": "Onttle 소개",
      "en": "Hello Onttle"
    }
  }
}

// With ?language=en
{
  "data": {
    "title": "Hello Onttle"
  }
}

TypeScript Type Definitions

interface Pagination {
  page: number
  size: number
  total: number
  totalPages: number
}

interface ContentsData {
  title?: string | Record<string, string>
  is_featured?: boolean
  [key: string]: unknown
}

interface Contents {
  id: string
  created_at: string
  updated_at: string | null
  published_at: string | null
  data: ContentsData
  slug?: string | null // included only on Tables that use slugs
  owner_member_id: string | null // ID of the owning member; null when there is none
}

interface ContentsListResponse {
  list: Contents[]
  pagination: Pagination
}

interface ErrorResponse {
  type: string
  title: string
  message: string | string[]
}

Types that match a Table's Columns can be generated in the dashboard. See TypeScript.


Distinguishing Success and Error Responses

const res = await fetch(url, { headers })

if (res.ok) {
  // 2xx: Success response
  const data = await res.json()
  return data
} else {
  // 4xx, 5xx: Error response { type, title, message }
  const error: ErrorResponse = await res.json()
  const message = Array.isArray(error.message)
    ? error.message.join(', ')
    : error.message
  throw new Error(`${error.type}: ${message}`)
}

Next Steps

  • Error Codes — Understand the error response structure and resolutions per status code.
  • Pagination — Use the pagination object to iterate through multiple pages.