Skip to main content

Overview

The Blog API provides comprehensive content management endpoints for articles, authors, categories, comments, and media. All Blog API endpoints require admin authentication.

Articles

List Articles

Query Parameters

integer
default:"1"
Page number (1-indexed)
integer
default:"20"
Items per page (max: 100)
string
Search by slug
string
Filter by status: draft, published, scheduled, archived
Filter featured articles (true or false)
boolean
Filter articles displayed on homepage
boolean
Filter articles displayed in blog listing
string
Filter by category ID
string
Filter by organization ID
string
Fetch single article by ID (returns full details with translations, authors, categories, media)

Create Article

From /src/pages/api/admin/blog/articles.ts:197-297:

Request Body

string
required
Must be "create"
string
required
URL-friendly slug (auto-generated if not provided)
string
default:"draft"
Article status: draft, published, scheduled, archived
string
default:"fr"
Primary language code (ISO 639-1)
string
Organization ID (nullable)
boolean
default:"false"
Show on homepage
boolean
default:"true"
Show in blog listing
Mark as featured
boolean
default:"true"
Enable comments
string
Estimated reading time (e.g., “5 min”)
string
Article word count
array
Array of translation objects (see structure above)
string[]
Array of author IDs
string[]
Array of category IDs
array
Array of media objects with mediaId, type, position

Update Article

From /src/pages/api/admin/blog/articles.ts:299-409:
Updating an article replaces translations, authors, categories, and media (full replacement strategy).

Other Article Actions

From /src/pages/api/admin/blog/articles.ts:411-534:

Publish Article

Sets status to "published" and sets publishedAt to current timestamp.

Unpublish Article

Delete Article

Deletes the article and all related data (translations, authors, categories, media).

Duplicate Article

Creates a copy with status "draft" and unique slug.

Authors

List Authors

From /src/pages/api/admin/blog/authors.ts:19-98:

Query Parameters

string
Fetch single author by ID (includes article count)
boolean
Return all authors (for selectors) with minimal fields
string
Search by slug
Filter featured authors
boolean
Filter authors displayed on homepage
boolean
Filter authors displayed in blog

Create Author

From /src/pages/api/admin/blog/authors.ts:122-166:

Response


Update/Delete Author

From /src/pages/api/admin/blog/authors.ts:168-238:

Categories

List Categories

From /src/pages/api/admin/blog/categories.ts:18-102:

Query Parameters

string
Fetch single category by ID
boolean
Return all categories (for selectors)
string
Filter by parent ID (use "root" for top-level)
boolean
Filter categories shown in menu

Create Category

From /src/pages/api/admin/blog/categories.ts:126-165:

Comments

List Comments

From /src/pages/api/admin/blog/comments.ts:13-66:

Query Parameters

string
Filter by status: pending, approved, rejected
string
Filter by post type
string
Search by author name or email

Response


Moderate Comments

From /src/pages/api/admin/blog/comments.ts:72-162:

Media

List Media

From /src/pages/api/admin/blog/media.ts:20-51:

Query Parameters

string
Filter by media type: image, video, audio
string
Search by URL

Upload Media

From /src/pages/api/admin/blog/media.ts:57-210:

Configuration

  • Upload directory: public/uploads/blog
  • Max file size: 10 MB
  • Allowed types: JPEG, PNG, WebP, AVIF, GIF, SVG

Form Fields

File
required
Image file to upload
string
Custom filename (auto-sanitized)
string
Alt text for accessibility
string
Image caption
string
Detailed description

Update/Delete Media

From /src/pages/api/admin/blog/media.ts:66-115:
Deleting media also removes the file from disk.

Common Response Codes


Audit Logging

All Blog API actions are logged to audit_log table:
  • blog.article.create
  • blog.article.update
  • blog.article.delete
  • blog.article.publish
  • blog.article.unpublish
  • blog.article.duplicate
  • blog.author.create
  • blog.author.update
  • blog.author.delete
  • blog.category.create
  • blog.category.update
  • blog.category.delete
  • blog.comment.approve
  • blog.comment.reject
  • blog.comment.delete
  • blog.media.upload
  • blog.media.delete

API Overview

Authentication and rate limiting

Services API

Manage service listings