{% extends "base.html" %} {% block title %}API Reference{% endblock %} {% block content %}

API Reference

Complete guide to integrating with your FastCMS backend

Authentication

Login & Register

Users

User Management

Collections

Dynamic Data

Files

File Storage

Webhooks

Event Callbacks

Backups

Data Protection

OAuth

Social Login

Settings

Configuration

Base URL

All API endpoints are relative to this base URL. Include the access token in the Authorization header for authenticated requests.

Authentication

Secure JWT-based authentication with access and refresh tokens.

POST /auth/register

Create a new user account

View code examples �
POST /auth/login

Authenticate and receive tokens

View code examples �
POST /auth/refresh

Get a new access token using refresh token

View code examples �

Users

Manage user accounts and profiles.

GET /auth/me

Get current authenticated user

View code examples �
GET /admin/users Admin

List all users (admin only)

View code examples �
PUT /users/{id}

Update user profile

View code examples �

Collections

Dynamic collections allow you to create custom data structures.

Note: Each collection has its own set of CRUD endpoints. Create a collection first, then access its API reference.

GET /collections

List all collections

GET /collections/{collection_name}/records

List records in a collection

POST /collections/{collection_name}/records

Create a new record

GET /collections/{collection_name}/records?search={query}

Full-text search across text fields (can combine with filters)

curl -X GET "/collections/posts/records?search=fastcms" \
  -H "Authorization: Bearer YOUR_TOKEN"

Combine search with filters:

curl -X GET "/collections/posts/records?search=fastcms&filter=status=published" \
  -H "Authorization: Bearer YOUR_TOKEN"
POST /collections/{collection_name}/records/bulk-delete

Delete multiple records at once (max 100)

curl -X POST "/collections/posts/records/bulk-delete" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{
    "record_ids": ["id1", "id2", "id3"]
  }'
POST /collections/{collection_name}/records/bulk-update

Update multiple records with same data (max 100)

curl -X POST "/collections/posts/records/bulk-update" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{
    "record_ids": ["id1", "id2"],
    "data": {
      "status": "published",
      "featured": true
    }
  }'
GET /collections/{collection_name}/records/export/csv

Export records to CSV file

curl "/collections/posts/records/export/csv?filter=status=published" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -o posts_export.csv
POST /collections/{collection_name}/records/import/csv

Import records from CSV file

curl -X POST "/collections/posts/records/import/csv" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -F "file=@posts.csv"

Your Collections: Click on any collection to see its specific API endpoints

No collections yet. Create your first collection

Files

Upload and manage files with support for images, documents, and more.

POST /files

Upload a file (multipart/form-data)

GET /files

List uploaded files

GET /files/{file_id}/download

Download a file

DELETE /files/{file_id}

Delete a file

Webhooks

Subscribe to events and receive HTTP callbacks when records are created, updated, or deleted.

POST /webhooks

Create a new webhook subscription

curl -X POST "/webhooks" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://your-server.com/webhook",
    "collection_name": "posts",
    "events": ["create", "update", "delete"],
    "secret": "your-webhook-secret",
    "retry_count": 3
  }'
GET /webhooks

List all webhooks

curl -X GET "/webhooks" \
  -H "Authorization: Bearer YOUR_TOKEN"
DELETE /webhooks/{webhook_id}

Delete a webhook

curl -X DELETE "/webhooks/WEBHOOK_ID" \
  -H "Authorization: Bearer YOUR_TOKEN"

Pro Tip: Webhooks include HMAC signatures for security. See the Webhooks page for management or read full documentation for signature verification examples.

Backups

Create and restore database backups for disaster recovery.

POST /backups

Create a new database backup

curl -X POST "/backups" \
  -H "Authorization: Bearer YOUR_ADMIN_TOKEN"
GET /backups

List all backups

curl -X GET "/backups" \
  -H "Authorization: Bearer YOUR_ADMIN_TOKEN"
POST /backups/{backup_id}/restore

Restore a backup (overwrites current database)

curl -X POST "/backups/BACKUP_ID/restore" \
  -H "Authorization: Bearer YOUR_ADMIN_TOKEN"
DELETE /backups/{backup_id}

Delete a backup

curl -X DELETE "/backups/BACKUP_ID" \
  -H "Authorization: Bearer YOUR_ADMIN_TOKEN"

Warning: Backup operations require admin authentication. Visit the Backups page for a user-friendly interface or automate backups with cron jobs.

OAuth Social Login

Allow users to sign in with Google, GitHub, or Microsoft accounts.

Step 1: Redirect to OAuth Provider

GET /oauth/{provider}/login

Supported providers: google, github, microsoft

<!-- Simple HTML Button -->
<a href="/oauth/google/login">
  <button>Sign in with Google</button>
</a>

<a href="/oauth/github/login">
  <button>Sign in with GitHub</button>
</a>

<a href="/oauth/microsoft/login">
  <button>Sign in with Microsoft</button>
</a>

Step 2: Handle OAuth Callback

GET /oauth/{provider}/callback

OAuth provider redirects here with authorization code

// JavaScript: Handle OAuth Redirect
function loginWithGoogle() {
  // Redirect to OAuth login
  window.location.href = '/oauth/google/login';
}

// On callback page (auto-handled by FastCMS)
// FastCMS automatically:
// 1. Exchanges code for access token
// 2. Fetches user profile
// 3. Creates/updates user account
// 4. Returns JWT tokens

// Response format:
// {
//   "access_token": "eyJhbGc...",
//   "refresh_token": "eyJhbGc...",
//   "token_type": "bearer",
//   "user": {
//     "id": "uuid",
//     "email": "user@gmail.com",
//     "name": "John Doe",
//     "verified": true,
//     "oauth_provider": "google"
//   }
// }

Complete Frontend Integration

Full example with token storage and redirect

// Complete OAuth Integration Example

// 1. Add OAuth buttons to your login page
<div class="oauth-buttons">
  <button onclick="loginWithGoogle()">
    <img src="google-icon.svg"> Sign in with Google
  </button>
  <button onclick="loginWithGitHub()">
    <img src="github-icon.svg"> Sign in with GitHub
  </button>
</div>

<script>
// 2. Redirect functions
function loginWithGoogle() {
  window.location.href = '/oauth/google/login';
}

function loginWithGitHub() {
  window.location.href = '/oauth/github/login';
}

// 3. Handle callback (optional manual handling)
// FastCMS automatically handles the callback and returns tokens
// If you need custom callback handling:
const urlParams = new URLSearchParams(window.location.search);
const code = urlParams.get('code');

if (code) {
  // Exchange code for tokens (handled automatically by FastCMS)
  fetch('/oauth/google/callback?code=' + code)
    .then(res => res.json())
    .then(data => {
      // Store tokens
      localStorage.setItem('access_token', data.access_token);
      localStorage.setItem('refresh_token', data.refresh_token);

      // Redirect to dashboard
      window.location.href = '/dashboard';
    })
    .catch(err => {
      console.error('OAuth failed:', err);
      alert('Login failed. Please try again.');
    });
}
</script>

Setup Required: Configure OAuth providers in your .env file before use:

# .env file
GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret
GOOGLE_REDIRECT_URI=http://localhost:8000/api/v1/oauth/google/callback

GITHUB_CLIENT_ID=your-github-client-id
GITHUB_CLIENT_SECRET=your-github-client-secret
GITHUB_REDIRECT_URI=http://localhost:8000/api/v1/oauth/github/callback

See full documentation for provider setup guides.

System Settings

Manage application configuration values stored in the database.

GET /settings

Get all settings across all categories

curl -X GET "/settings" \
  -H "Authorization: Bearer YOUR_ADMIN_TOKEN"
GET /settings/{category}

Get settings for a specific category (e.g., app, email, security)

curl -X GET "/settings/app" \
  -H "Authorization: Bearer YOUR_ADMIN_TOKEN"
POST /settings

Create or update a setting

curl -X POST "/settings" \
  -H "Authorization: Bearer YOUR_ADMIN_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "key": "maintenance_mode",
    "value": false,
    "category": "app",
    "description": "Enable maintenance mode"
  }'
DELETE /settings/{key}

Delete a setting by key

curl -X DELETE "/settings/old_setting" \
  -H "Authorization: Bearer YOUR_ADMIN_TOKEN"

Common Settings Examples

Feature flags, rate limits, and configuration

# Feature Flag Example
curl -X POST "/settings" \
  -H "Authorization: Bearer YOUR_ADMIN_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "key": "enable_ai_features",
    "value": true,
    "category": "app",
    "description": "Enable AI features"
  }'

# Rate Limiting Example
curl -X POST "/settings" \
  -H "Authorization: Bearer YOUR_ADMIN_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "key": "api_rate_limit",
    "value": 100,
    "category": "security",
    "description": "Max API requests per minute"
  }'

# File Upload Limit Example
curl -X POST "/settings" \
  -H "Authorization: Bearer YOUR_ADMIN_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "key": "max_file_size",
    "value": 10485760,
    "category": "storage",
    "description": "Maximum file size in bytes (10MB)"
  }'

Categories: Settings are organized into categories like app, email, security, storage, and custom for easy management.

Quick Start Integration

Get started with your frontend in minutes using these code examples.

JavaScript

Fetch API examples for web apps

Python

Requests library examples

cURL

Command-line examples

{% endblock %} {% block scripts %} {% endblock %}