Blogs¶
Manage blog posts, authors, and comments.
Permissions Summary¶
| Resource | Read | Create | Update | Delete |
|---|---|---|---|---|
| Authors | Anyone | Staff only | Staff only | Staff only |
| Posts | Anyone | Staff only | Staff only | Staff only |
| Comments | Anyone | Authenticated users | Staff only | Staff or comment owner |
Authors¶
Success (200 OK):
[
{
"id": 1,
"name": "Dr. Jane Doe",
"title": "Chief Medical Officer",
"email": "jane@example.com",
"bio": "Brief bio...",
"image_url": "https://cdn.example.com/authors/jane.png",
"image_ref": "authors/jane.png",
"image_alt": "Dr. Jane Doe",
"image_title": "Dr. Jane Doe",
"created_at": "2026-01-19T10:00:00Z",
"updated_at": "2026-01-19T10:00:00Z"
}
]
Success (200 OK) includes nested posts:
{
"id": 1,
"name": "Dr. Jane Doe",
"title": "Chief Medical Officer",
"email": "jane@example.com",
"bio": "Brief bio...",
"image_url": "https://cdn.example.com/authors/jane.png",
"image_ref": "authors/jane.png",
"image_alt": "Dr. Jane Doe",
"image_title": "Dr. Jane Doe",
"created_at": "2026-01-19T10:00:00Z",
"updated_at": "2026-01-19T10:00:00Z",
"posts": [
{
"id": 10,
"title": "Healthy Living Tips",
"slug": "healthy-living-tips",
"featured_image_url": "https://cdn.example.com/posts/healthy-living.png",
"is_published": true,
"views": 12,
"created_at": "2026-01-19T10:00:00Z",
"updated_at": "2026-01-19T10:00:00Z"
}
]
}
{
"name": "Dr. Jane Doe",
"title": "Chief Medical Officer",
"email": "jane@example.com",
"bio": "Brief bio...",
"image_url": "https://cdn.example.com/authors/jane.png",
"image_ref": "authors/jane.png",
"image_alt": "Dr. Jane Doe",
"image_title": "Dr. Jane Doe"
}
Error (403 Forbidden) if not staff:
{
"name": "Dr. Jane Doe",
"title": "Chief Medical Officer",
"email": "jane@example.com",
"bio": "Updated bio...",
"image_url": "https://cdn.example.com/authors/jane.png",
"image_ref": "authors/jane.png",
"image_alt": "Dr. Jane Doe",
"image_title": "Dr. Jane Doe"
}
PUTexpects the full object (all writable fields).PATCHcan send only the fields to change.
Posts¶
Success (200 OK):
[
{
"id": 10,
"title": "Healthy Living Tips",
"slug": "healthy-living-tips",
"author": 1,
"author_name": "Dr. Jane Doe",
"subcategories": [1, 2],
"subcategories_details": [
{"id": 1, "name": "Wellness", "category": 1, "category_name": "Health", "description": "", "created_at": "2026-01-19T10:00:00Z", "updated_at": "2026-01-19T10:00:00Z"},
{"id": 2, "name": "Nutrition", "category": 1, "category_name": "Health", "description": "", "created_at": "2026-01-19T10:00:00Z", "updated_at": "2026-01-19T10:00:00Z"}
],
"related_products": [1, 5],
"related_products_details": [
{"id": 1, "name": "Vitamin D Supplement", "slug": "vitamin-d-supplement", "price": "19.99", "image_urls": []},
{"id": 5, "name": "Omega-3 Capsules", "slug": "omega-3-capsules", "price": "24.99", "image_urls": []}
],
"content": "Post body...",
"excerpt": "SEO description up to 160 chars",
"featured_image_url": "https://cdn.example.com/posts/healthy-living.png",
"featured_image_ref": "",
"featured_image_alt": "",
"featured_image_title": "",
"meta_keywords": "health,wellness",
"is_published": true,
"views": 12,
"created_at": "2026-01-19T10:00:00Z",
"updated_at": "2026-01-19T10:00:00Z"
}
]
Success (200 OK) returns the full post object with the same structure as list items:
{
"id": 10,
"title": "Healthy Living Tips",
"slug": "healthy-living-tips",
"author": 1,
"author_name": "Dr. Jane Doe",
"subcategories": [1, 2],
"subcategories_details": [
{"id": 1, "name": "Wellness", "category": 1, "category_name": "Health", "description": "", "created_at": "2026-01-19T10:00:00Z", "updated_at": "2026-01-19T10:00:00Z"}
],
"related_products": [1, 5],
"related_products_details": [
{"id": 1, "name": "Vitamin D Supplement", "slug": "vitamin-d-supplement", "price": "19.99", "image_urls": []},
{"id": 5, "name": "Omega-3 Capsules", "slug": "omega-3-capsules", "price": "24.99", "image_urls": []}
],
"content": "Post body...",
"excerpt": "SEO description up to 160 chars",
"featured_image_url": "https://cdn.example.com/posts/healthy-living.png",
"featured_image_ref": "",
"featured_image_alt": "",
"featured_image_title": "",
"meta_keywords": "health,wellness",
"is_published": true,
"views": 12,
"created_at": "2026-01-19T10:00:00Z",
"updated_at": "2026-01-19T10:00:00Z"
}
{
"title": "Healthy Living Tips",
"author": 1,
"subcategories": [1, 2],
"related_products": [1, 5, 8],
"content": "Post body...",
"excerpt": "SEO description up to 160 chars",
"featured_image_url": "https://cdn.example.com/posts/healthy-living.png",
"featured_image_ref": "s3://bucket/key",
"featured_image_alt": "alt text",
"featured_image_title": "image title",
"meta_keywords": "health,wellness",
"is_published": true
}
Error (401 Unauthorized) if not authenticated:
Error (403 Forbidden) if authenticated but not staff:
{
"title": "Healthy Living Tips (Updated)",
"author": 1,
"subcategories": [1, 2],
"related_products": [1, 5, 8],
"content": "Revised post body...",
"excerpt": "Updated SEO description",
"featured_image_url": "https://cdn.example.com/posts/healthy-living-updated.png",
"featured_image_ref": "s3://bucket/new-key",
"featured_image_alt": "new alt text",
"featured_image_title": "new image title",
"meta_keywords": "health,wellness,updated",
"is_published": true
}
PUTexpects the full object (all writable fields).PATCHcan send only the fields to change.
Comments¶
Success (200 OK):
Error (401 Unauthorized) if not authenticated:
Notes¶
- Unauthenticated users can only read posts and comments.
- Non-staff authenticated users can create comments; they may delete only their own comments.
- Only staff can create/update/delete authors and posts, and only staff can edit comments.
Categories & Subcategories¶
Blogs support categories and subcategories. Categories list and retrieve responses include nested subcategories.
Success (200 OK):
[
{
"id": 1,
"name": "Health",
"description": "Health and wellness topics",
"created_at": "2026-01-19T10:00:00Z",
"updated_at": "2026-01-19T10:00:00Z",
"subcategories": [
{
"id": 1,
"name": "Wellness",
"category": 1,
"category_name": "Health",
"description": "",
"created_at": "2026-01-19T10:00:00Z",
"updated_at": "2026-01-19T10:00:00Z"
},
{
"id": 2,
"name": "Nutrition",
"category": 1,
"category_name": "Health",
"description": "",
"created_at": "2026-01-19T10:00:00Z",
"updated_at": "2026-01-19T10:00:00Z"
}
]
}
]
Returns the same structure as list items: category fields plus a subcategories array.
- Categories: Staff CRUD at
/api/blogs/categories/{id}/for create, update, delete. - Subcategories: Staff CRUD at
/api/blogs/subcategories/{id}/for create, update, delete. - A post can belong to multiple subcategories using the
subcategoriesfield on the post endpoints.
Related Products¶
Posts support a many-to-many relationship with products:
related_products(writable): Array of product IDs. Use when creating or updating a post.related_products_details(read-only): Array of lightweight product objects{id, name, slug, price, image_urls}for display.