> ## Documentation Index
> Fetch the complete documentation index at: https://docs.publishbuddy.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Get list of posts

> Sorting:
publish_at (asc) - default ordering
published_at (desc) - add this query to the URL "?filters[sort_by]=published_at" to order by the "published_at"



## OpenAPI

````yaml /openapi.json get /workspaces/{workspace}/posts
openapi: 3.1.0
info:
  title: PublishBuddy
  version: 0.0.1
servers:
  - url: https://api.publishbuddy.com/v1
security: []
paths:
  /workspaces/{workspace}/posts:
    get:
      tags:
        - Post
      summary: Get list of posts
      description: >-
        Sorting:

        publish_at (asc) - default ordering

        published_at (desc) - add this query to the URL
        "?filters[sort_by]=published_at" to order by the "published_at"
      operationId: workspaces.posts.index
      parameters:
        - name: workspace
          in: path
          required: true
          description: The workspace UUID
          schema:
            type: string
        - name: status
          in: query
          description: >-
            Post status: `waiting`, `publishing`, `published`, `failed`,
            `needs_approval`, `draft`
          schema:
            type: string
        - name: statuses[]
          in: query
          description: 'Post statuses: an array, or a comma-separated string without spaces'
          schema:
            type: array
            items:
              type: string
        - name: filters[profile_ids][]
          in: query
          description: 'Profile UUIDs to filter by: an array, or a comma-separated string'
          schema:
            type: array
            items:
              type: string
        - name: filters[group_id]
          in: query
          description: Group UUID shared by posts created in the same bulk request
          schema:
            type: string
            format: uuid
        - name: filters[search]
          in: query
          description: Search by input string
          schema:
            type: string
        - name: filters[publish_type]
          in: query
          description: >-
            Publish type: `queue_using_timeslots`,
            `schedule_using_fixed_datetime`, `now`, `recurring`
          schema:
            type: string
        - name: filters[publish_types][]
          in: query
          description: Publish types (same values as `publish_type`)
          schema:
            type: array
            items:
              type: string
        - name: filters[labels][]
          in: query
          description: Selected labels
          schema:
            type: array
            items:
              type: string
        - name: filters[post_type_id]
          in: query
          description: Selected Post Type ID
          schema:
            type: string
        - name: filters[date_range][]
          in: query
          description: Selected date range. Posts with published_at within interval
          schema:
            type: array
            items:
              type: string
        - name: filters[publish_range][]
          in: query
          description: Selected date range. Posts with publish_at within interval
          schema:
            type: array
            items:
              type: string
        - name: filters[sort_by]
          in: query
          description: Sort by selected parameter
          schema:
            type: string
        - name: per_page
          in: query
          description: Number of elements per page
          schema:
            type:
              - integer
              - 'null'
            minimum: 1
            maximum: 100
        - name: page
          in: query
          description: Requested page number
          schema:
            type:
              - integer
              - 'null'
            minimum: 1
        - name: Authorization
          in: header
          required: true
          description: Personal access token, sent as `Bearer <token>`.
          schema:
            type: string
          example: Bearer aBcDeF...
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    description: Main data
                    items:
                      $ref: '#/components/schemas/PostResource'
                  links:
                    type: object
                    description: Links
                    properties:
                      first:
                        type: string
                        description: First page link
                      last:
                        type: string
                        description: Last page link
                      prev:
                        type:
                          - string
                          - 'null'
                        description: Previous page link or null
                      next:
                        type:
                          - string
                          - 'null'
                        description: Next page link or null
                    required:
                      - first
                      - last
                      - prev
                      - next
                  meta:
                    type: object
                    description: >-
                      Pagination info, plus `status_counts`: post counts per
                      status (`waiting`, `publishing`, `published`, `failed`,
                      `needs_approval`, `draft`) for the current filters
                    properties:
                      current_page:
                        type: integer
                        description: Current page
                      from:
                        type:
                          - integer
                          - 'null'
                        description: First item number on the current page
                      last_page:
                        type: integer
                        description: Last page
                      links:
                        type: array
                        description: >-
                          Array of pagination links (previous, next, page
                          numbers)
                        items:
                          type: object
                          properties:
                            url:
                              type:
                                - string
                                - 'null'
                            label:
                              type: string
                            active:
                              type: boolean
                          required:
                            - url
                            - label
                            - active
                      path:
                        type: string
                        description: Base URL for pagination links
                      per_page:
                        type: integer
                        description: Items per page
                      to:
                        type:
                          - integer
                          - 'null'
                        description: Last item number on the current page
                      total:
                        type: integer
                        description: Total count of items
                      status_counts:
                        type: object
                        description: >-
                          Post counts per status for the current filters,
                          independent of the page
                        properties:
                          waiting:
                            type:
                              - integer
                              - 'null'
                          publishing:
                            type:
                              - integer
                              - 'null'
                          published:
                            type:
                              - integer
                              - 'null'
                          failed:
                            type:
                              - integer
                              - 'null'
                          needs_approval:
                            type:
                              - integer
                              - 'null'
                          draft:
                            type:
                              - integer
                              - 'null'
                        required:
                          - waiting
                          - publishing
                          - published
                          - failed
                          - needs_approval
                          - draft
                    required:
                      - current_page
                      - from
                      - last_page
                      - links
                      - path
                      - per_page
                      - to
                      - total
                      - status_counts
                required:
                  - data
                  - links
                  - meta
        '401':
          $ref: '#/components/responses/AuthenticationException'
        '404':
          $ref: '#/components/responses/ModelNotFoundException'
        '422':
          $ref: '#/components/responses/ValidationException'
components:
  schemas:
    PostResource:
      type: object
      properties:
        post_id:
          type: string
          description: Post UUID (same as `id`)
        id:
          type: string
          description: Post UUID (alias of `post_id`)
        group_id:
          type: string
          description: Shared group ID for posts created in the same bulk request
        content:
          type: string
          description: Post text
        profile_id:
          type: string
          description: Profile UUID this post targets
        account_id:
          type: string
          description: Deprecated alias of `profile_id`
        scheduled_for:
          type: string
          description: Scheduled publish time in ISO 8601 UTC
        timezone:
          type: string
          description: Timezone of the datetime fields in this resource (always `UTC`)
          enum:
            - UTC
        media_ids:
          type: array
          description: Attached media UUIDs
          items:
            type: string
        media:
          type: object
          description: Attached media metadata
          properties:
            media_id:
              type: string
            type:
              type: string
            width:
              type:
                - integer
                - 'null'
            height:
              type:
                - integer
                - 'null'
            duration:
              type:
                - integer
                - 'null'
          required:
            - media_id
            - type
            - width
            - height
            - duration
        platform_content:
          type:
            - array
            - 'null'
          description: >-
            Per-platform settings keyed by platform slug (e.g. `instagram`,
            `tiktok`)
          items: {}
        publish_type:
          type:
            - string
            - 'null'
          description: >-
            Publish mode: `queue_using_timeslots`,
            `schedule_using_fixed_datetime`, `now`, `recurring`
        status:
          type:
            - string
            - 'null'
          description: >-
            Post status: `waiting`, `publishing`, `published`, `failed`,
            `needs_approval`, `draft`
        created_at:
          type: string
          description: Creation timestamp in ISO 8601 UTC
        updated_at:
          type: string
          description: Last update timestamp in ISO 8601 UTC
        link:
          type: string
          description: Optional link attached to the post
        labels:
          type:
            - string
            - 'null'
          description: Labels when the `labels` relation is eager-loaded; otherwise `null`
        comments:
          type: array
          description: First-comment thread items
          items:
            $ref: '#/components/schemas/CommentResource'
        published_at:
          type: string
          description: Actual publish time in ISO 8601 UTC
        error_message:
          type: string
          description: Last publish error for the active profile
      required:
        - post_id
        - id
        - group_id
        - content
        - profile_id
        - account_id
        - scheduled_for
        - timezone
        - media_ids
        - media
        - platform_content
        - publish_type
        - status
        - created_at
        - updated_at
        - link
        - labels
        - comments
        - published_at
        - error_message
      title: PostResource
    CommentResource:
      type: object
      properties:
        id:
          type: string
          description: ID
        text:
          type: string
          description: Text of comment
        delay_n:
          type:
            - integer
            - 'null'
          description: Amount of time to delay the post, represented as a number
        delay_type:
          type: string
          description: 'Unit of time used for delay. Example: minutes, hours, days'
        media_ids:
          type: array
          description: Attached media UUIDs
          items:
            type: string
        media:
          type: object
          description: Media content Info which included in comment
          properties:
            media_id:
              type: string
            type:
              type: string
            width:
              type:
                - integer
                - 'null'
            height:
              type:
                - integer
                - 'null'
            duration:
              type:
                - integer
                - 'null'
          required:
            - media_id
            - type
            - width
            - height
            - duration
      required:
        - id
        - text
        - delay_n
        - delay_type
        - media_ids
        - media
      title: CommentResource
  responses:
    AuthenticationException:
      description: Unauthenticated
      content:
        application/json:
          schema:
            type: object
            properties:
              message:
                type: string
                description: Error overview.
            required:
              - message
    ModelNotFoundException:
      description: Not found
      content:
        application/json:
          schema:
            type: object
            properties:
              message:
                type: string
                description: Error overview.
            required:
              - message
    ValidationException:
      description: Validation error
      content:
        application/json:
          schema:
            type: object
            properties:
              message:
                type: string
                description: Errors overview.
              errors:
                type: object
                description: A detailed description of each field that failed validation.
                additionalProperties:
                  type: array
                  items:
                    type: string
            required:
              - message
              - errors

````