🚧 FastCMS is under active development β€” not ready for production use. APIs and features may change without notice.
FastCMS
Core Concepts

Records

Records are the data entries stored within collections. Learn how to create, read, update, delete, filter, sort, and expand records.

Records

Records are the data entries stored within collections. This guide covers all CRUD operations and advanced querying capabilities.

localhost:8000/admin/collections/posts/records

posts

5 records Β· base collection

Search records…
IDtitlestatuscreated
rec_1a2bGetting Started with FastCMSpublished2026-03-01
rec_3c4dBuilding Your First Collectionpublished2026-03-01
rec_5e6fAuthentication Deep Divedraft2026-03-02
rec_7g8hReal-time with SSEdraft2026-03-02
rec_9i0jDeploying to Productionpublished2026-02-28

Quick Start

# Create a record
curl -X POST http://localhost:8000/api/v1/collections/posts/records \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"data": {"title": "Hello World", "content": "My first post"}}'

# List records
curl http://localhost:8000/api/v1/collections/posts/records \
  -H "Authorization: Bearer YOUR_TOKEN"

# Get single record
curl http://localhost:8000/api/v1/collections/posts/records/RECORD_ID \
  -H "Authorization: Bearer YOUR_TOKEN"

# Update record
curl -X PATCH http://localhost:8000/api/v1/collections/posts/records/RECORD_ID \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"data": {"title": "Updated Title"}}'

# Delete record
curl -X DELETE http://localhost:8000/api/v1/collections/posts/records/RECORD_ID \
  -H "Authorization: Bearer YOUR_TOKEN"

Create a Record

POST /api/v1/collections/{collection_name}/records
Authorization: Bearer <token>
Content-Type: application/json

{
  "data": {
    "title": "My Post",
    "content": "Post content here",
    "published": true,
    "tags": ["news", "tech"]
  }
}

Response:

{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "data": {
    "title": "My Post",
    "content": "Post content here",
    "published": true,
    "tags": ["news", "tech"]
  },
  "created": "2025-12-22T10:30:00Z",
  "updated": "2025-12-22T10:30:00Z"
}

List Records

Query Parameters

ParameterTypeDefaultDescription
pageint1Page number
per_pageint20Items per page (max: 100)
sortstringβ€”Sort fields
filterstringβ€”Filter expression
searchstringβ€”Full-text search
expandstringβ€”Relations to expand
fieldsstringβ€”Fields to return
skipTotalboolfalseSkip total count for faster queries

Filtering

OperatorDescriptionExample
=Equalstatus=active
!=Not equalstatus!=deleted
>Greater thanage>18
>=Greater or equalviews>=100
<Less thanprice<100
<=Less or equalstock<=10
~Contains (case-insensitive)title~hello
!~Does not containtitle!~spam
?=Any in arraytags?=[news,tech]
?!=Not in arraycategory?!=[spam,ads]

Combining Filters

# AND: Both conditions must be true
?filter=published=true&&views>100

# OR: Either condition can be true
?filter=featured=true||popular=true

# Complex
?filter=(status=active||status=pending)&&verified=true

DateTime Macros

MacroDescription
@nowCurrent datetime
@todayStart of today
@yesterdayStart of yesterday
@day+77 days from now
@hour-22 hours ago
# Records created today
?filter=created>=@today

# Records from the last 7 days
?filter=created>@day-7

Sorting

# Ascending
?sort=created

# Descending
?sort=-created

# Multi-field
?sort=-created,+title

# Random
?sort=@random

Expanding Relations

# Single relation
?expand=author

# Multiple relations
?expand=author,category,tags

# Nested relations
?expand=author.company
?search=hello world

Searches across all text, editor, email, and url fields.

Pagination

# Standard pagination
?page=2&per_page=50

# Skip total count for performance on large datasets
?skipTotal=true

JavaScript Examples

// Fetch records
const response = await fetch(
  'http://localhost:8000/api/v1/collections/posts/records?page=1&per_page=10&sort=-created',
  { headers: { 'Authorization': `Bearer ${token}` } }
);
const data = await response.json();

// Complex query
const params = new URLSearchParams({
  page: '1',
  per_page: '20',
  sort: '-created,+title',
  filter: 'published=true&&views>100',
  expand: 'author,category',
  fields: 'id,title,author,views,created'
});

const response = await fetch(
  `http://localhost:8000/api/v1/collections/posts/records?${params}`,
  { headers: { 'Authorization': `Bearer ${token}` } }
);

React Hook Example

import { useState, useEffect } from 'react';

function useRecords(collection, options = {}) {
  const [records, setRecords] = useState([]);
  const [loading, setLoading] = useState(true);
  const [pagination, setPagination] = useState({});

  useEffect(() => {
    const fetchRecords = async () => {
      setLoading(true);
      const params = new URLSearchParams({
        page: options.page || 1,
        per_page: options.perPage || 20,
        ...(options.sort && { sort: options.sort }),
        ...(options.filter && { filter: options.filter }),
        ...(options.expand && { expand: options.expand }),
      });

      const res = await fetch(
        `http://localhost:8000/api/v1/collections/${collection}/records?${params}`,
        { headers: { 'Authorization': `Bearer ${localStorage.getItem('token')}` } }
      );

      const data = await res.json();
      setRecords(data.items);
      setPagination({ total: data.total, page: data.page, totalPages: data.total_pages });
      setLoading(false);
    };

    fetchRecords();
  }, [collection, JSON.stringify(options)]);

  return { records, loading, pagination };
}

On this page