Save / Unsave Post
Bookmark a post for the current user, remove a bookmark, or list saved posts. The backend uses api/Post.
Save a post
POST /api/Post/{postId}/save
Authentication: Required (User, Moderator, or Admin)
Path parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| postId | GUID | Yes | Post to save |
Response (200 OK)
{
"success": true,
"message": "Post saved",
"data": {
"isSaved": true
}
}
Idempotent if the post is already saved. Returns an error if the post does not exist.
Example
const response = await fetch(`http://localhost:5000/api/Post/${postId}/save`, {
method: 'POST',
headers: { 'Authorization': `Bearer ${token}` }
});
Unsave a post
DELETE /api/Post/{postId}/save
Authentication: Required
Path parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| postId | GUID | Yes | Post to remove from saved |
Response (200 OK)
{
"success": true,
"message": "Post unsaved",
"data": {
"isSaved": false
}
}
List saved posts
GET /api/Post/saved?page=1&pageSize=10
Authentication: Required
Query parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| page | int | 1 | Page number (1-based) |
| pageSize | int | 10 | Page size |
Response (200 OK)
{
"success": true,
"data": {
"posts": [],
"totalCount": 12,
"page": 1,
"pageSize": 10,
"totalPages": 2,
"hasMore": true
}
}
Posts are ordered by save time (newest first). Only posts still visible to the caller are included (own posts, or public and not hidden). Each item includes isSaved: true.
Example
const response = await fetch(
'http://localhost:5000/api/Post/saved?page=1&pageSize=10',
{ headers: { 'Authorization': `Bearer ${token}` } }
);