01 Software

Response Format

API response format and type reference

Response Format

Reference for REST API and SDK response formats.

REST API Responses

List Query (Find)

GET /api/{collection}

{
  "docs": [
    {
      "id": "post_id",
      "title": "Post Title",
      "slug": "post-title",
      "createdAt": "2026-01-07T10:00:00Z",
      "updatedAt": "2026-01-07T10:00:00Z"
    }
  ],
  "totalDocs": 100,
  "limit": 10,
  "page": 1,
  "totalPages": 10,
  "pagingCounter": 1,
  "hasPrevPage": false,
  "hasNextPage": true,
  "prevPage": null,
  "nextPage": 2
}

Single Item Query (FindById)

GET /api/{collection}/{id}

{
  "id": "post_id",
  "title": "Post Title",
  "slug": "post-title",
  "createdAt": "2026-01-07T10:00:00Z",
  "updatedAt": "2026-01-07T10:00:00Z"
}

Create/Update

POST /api/{collection} or PATCH /api/{collection}/{id}

{
  "message": "Post created successfully",
  "doc": {
    "id": "post_id",
    "title": "Post Title",
    "slug": "post-title",
    "createdAt": "2026-01-07T10:00:00Z",
    "updatedAt": "2026-01-07T10:00:00Z"
  }
}

Delete

DELETE /api/{collection}/{id}

{
  "id": "post_id",
  "message": "Post deleted successfully"
}

SDK Response Types

PayloadFindResponse<T>

The type returned by the find() method.

interface PayloadFindResponse<T> {
  docs: T[]
  totalDocs: number
  limit: number
  totalPages: number
  page: number
  pagingCounter: number
  hasPrevPage: boolean
  hasNextPage: boolean
  prevPage: number | null
  nextPage: number | null
}
const response = await client.from('posts').find({ limit: 10 })
// response: PayloadFindResponse<Post>

console.log(response.docs)        // Post[]
console.log(response.totalDocs)   // 100
console.log(response.hasNextPage) // true

PayloadMutationResponse<T>

The type returned by the create() and update() methods.

interface PayloadMutationResponse<T> {
  message: string
  doc: T
  errors?: unknown[]
}
const response = await client.from('posts').create({ title: 'New Post', slug: 'new-post' })
// response: PayloadMutationResponse<Post>

console.log(response.doc)     // Post
console.log(response.message) // "Post created successfully"

findById / remove Return

findById() and remove() return the document object T directly.

const post = await client.from('posts').findById('id')
// post: Post

const deleted = await client.from('posts').remove('id')
// deleted: Post

count Return

count() returns the document count.

const result = await client.from('posts').count({
  where: { status: { equals: 'active' } }
})
// result: { totalDocs: number }

REST API Error Response

{
  "errors": [
    {
      "message": "Validation failed",
      "name": "ValidationError",
      "data": {
        "field": "email",
        "message": "Email is required"
      }
    }
  ]
}

HTTP Status Codes

CodeDescription
200Success
201Created
400Bad Request
401Authentication Required
403Forbidden
404Resource Not Found
429Too Many Requests
500Server Error

On this page