Skip to main content
All Posts endpoints require a valid Bearer token in the Authorization header. Obtain a token via the authentication endpoints.

Endpoints

List all posts

GET /api/posts
Returns a paginated list of posts belonging to the authenticated user.

Get post by ID

GET /api/posts/:postId
Returns a single post along with its latest analytics snapshots.

Get post status

GET /api/posts/:postId/status
Returns the current overall status and per-platform statuses for a post.

Query parameters — List all posts

page
number
default:"1"
Page number for pagination.
limit
number
default:"20"
Number of posts to return per page. Must be a positive integer.
status
string
Filter by post status. One of DRAFT, PENDING, SCHEDULED, PROCESSING, COMPLETED, PARTIAL_SUCCESS, FAILED, or CANCELLED.
sortBy
string
default:"createdAt"
Field to sort results by. Accepts createdAt or scheduledAt.
sortOrder
string
default:"desc"
Sort direction. One of asc or desc.

Path parameters — Single post endpoints

postId
string
required
The MongoDB ObjectId of the post.

Response — List all posts

success
boolean
required
true when the request succeeded.
message
string
required
Human-readable status message.
data
object
required

Examples

curl --request GET \
  --url 'https://api.hayon.app/api/posts?page=1&limit=20&sortBy=createdAt&sortOrder=desc' \
  --header 'Authorization: Bearer <token>'

Example response — List all posts

{
  "success": true,
  "message": "Posts fetched successfully",
  "data": {
    "posts": [
      {
        "_id": "64f1a2b3c4d5e6f7a8b9c0d1",
        "userId": "64e0a1b2c3d4e5f6a7b8c9d0",
        "content": {
          "text": "Check out our latest update!",
          "mediaItems": []
        },
        "selectedPlatforms": ["bluesky", "threads"],
        "platformSpecificContent": {},
        "status": "COMPLETED",
        "platformStatuses": [
          {
            "platform": "bluesky",
            "status": "completed",
            "platformPostId": "3kj2gh8df",
            "platformPostUrl": "https://bsky.app/profile/user.bsky.social/post/3kj2gh8df",
            "attemptCount": 1,
            "completedAt": "2024-09-01T10:05:00.000Z"
          },
          {
            "platform": "threads",
            "status": "completed",
            "platformPostId": "17841400000000001",
            "platformPostUrl": "https://www.threads.net/@user/post/abc123",
            "attemptCount": 1,
            "completedAt": "2024-09-01T10:05:01.000Z"
          }
        ],
        "timezone": "UTC",
        "createdAt": "2024-09-01T10:00:00.000Z",
        "updatedAt": "2024-09-01T10:05:01.000Z"
      }
    ],
    "total": 42,
    "page": 1,
    "limit": 20,
    "totalPages": 3
  }
}

Build docs developers (and LLMs) love