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

# List media

> Page through the media library of the workspaces the key can reach.

> [!NOTE]
>
> Needs `media:read`. See [Permissions](/docs/essentials/authentication.md#permissions).

Newest first, 50 a page. `per_page` takes 1 to 100; more than 100 gives 100.

* `workspace_id` keeps one workspace's files.
* `folder_id` keeps the files directly in one folder (not its subfolders); `root_only=1` keeps the files in no folder. Send one of them, not both.
* `all_folders=1` gives every file, in a folder or not, whatever `folder_id` and `root_only` say.

`root_only` and `all_folders` take `1` or `0`: `true` and `false` are refused with `422`.

* `source=ai` keeps the files PostSyncer's AI made; `source=upload` every other file.

The `links` in the answer carry only `page`: send your filters and `per_page` again with each page. A picture has `thumb_url` and `medium_url` once they are made: see [Picture copies](/docs/api-reference/media/overview.md#picture-copies).

## Errors

| Status | `error` | When | Retry? |
| - | - | - | - |
| 401 | | No API key, or not a valid one. | No: fix the key. |
| 403 | | The key lacks `media:read`, or its user is inactive. | No: grant it in Settings → API. |
| 422 | | `folder_id` with `root_only`, a workspace or folder the key can't reach, a folder of another workspace, an unknown `source`, or `page` or `per_page` below 1. | No: fix the request. |
| 422 | | `root_only` or `all_folders` isn't `0` or `1`. | No: send `1` or `0`. |
| 429 | | More than 60 requests a minute. | Yes, after `Retry-After` seconds. |

## Related

* [List folders](/docs/api-reference/folders/list.md): the `folder_id` values.
* [Get a media file](/docs/api-reference/media/get.md): one file by its id.


## OpenAPI

````yaml GET /media
openapi: 3.0.3
info:
  title: PostSyncer API
  description: >-
    Post to 12 social networks from your code: posts, media, comments,
    analytics, webhooks and more.
  version: 1.0.0
servers:
  - url: https://postsyncer.com/api/v1
security:
  - bearerAuth: []
tags:
  - name: Workspaces
    description: The workspaces the key can reach.
  - name: Accounts
    description: Connected social accounts, links to connect more, and disconnecting them.
  - name: Posts
    description: Drafts, scheduled and published posts, approvals and a post's history.
  - name: Post settings
    description: A post's auto-plug, comment moderation and contact collection.
  - name: Media
    description: >-
      The media library: file uploads, URL imports, and reading videos and
      social posts' files.
  - name: Folders
    description: Folders that organise the media library.
  - name: Comments
    description: >-
      Comments on your posts: reading, replying, editing, hiding, deleting and
      syncing them.
  - name: Reviews
    description: Google Business Profile reviews and your replies to them.
  - name: Analytics
    description: Workspace, account and post performance.
  - name: Brand
    description: >-
      A workspace's brand: identity, voice, look, accounts, competitors,
      learnings and rules.
  - name: Labels
    description: Labels used to tag posts.
  - name: Campaigns
    description: Campaigns used to group posts.
  - name: Snippets
    description: Saved snippets and hashtag groups to drop into posts.
  - name: Webhooks
    description: Signed webhook endpoints that get your notification events.
  - name: Billing
    description: >-
      The owner's plan, invoices and the links that pay for, change or cancel
      it.
  - name: Team
    description: A workspace's teammates and invitations, and their roles.
  - name: Notifications
    description: >-
      Your bell and notification settings, and the workspace's Slack, Discord
      and Telegram channels.
  - name: Blog-to-social
    description: Blog feeds that turn a workspace's new articles into posts.
  - name: Products
    description: Products the workspace's posts can promote.
  - name: Contacts
    description: People who commented on the workspace's posts, and the lists they are on.
  - name: Profile
    description: 'The key''s user: their name and sign-in email.'
  - name: API keys
    description: 'Your API keys: listing and deleting them.'
  - name: Agent sign-up
    description: >-
      An AI agent signs a person up with a code emailed to them, and gets their
      first key. No key needed.
paths:
  /media:
    get:
      tags:
        - Media
      summary: List media
      description: >-
        Needs `media:read`. Pages through the media library of every workspace
        the key can reach, newest first, 50 a page unless `per_page` asks for
        something else (100 at most). Filter by `workspace_id`, by folder
        (`folder_id`, or `root_only=1` for files in no folder, or
        `all_folders=1` for every folder), and by `source`. `links` keep only
        `page`: send your filters and `per_page` again for each page.
      operationId: listMedia
      parameters:
        - name: workspace_id
          in: query
          required: false
          description: Only this workspace's files. It must be one the key can reach.
          schema:
            type: integer
        - name: folder_id
          in: query
          required: false
          description: >-
            Only the files directly in this folder (not its subfolders). It must
            be in a workspace the key can reach, and in `workspace_id` when that
            is sent. Not with `root_only`.
          schema:
            type: integer
        - name: root_only
          in: query
          required: false
          description: >-
            `1` for only the files in no folder. Not with `folder_id`. `true`
            and `false` are refused with `422`: send `1` or `0`.
          schema:
            type: integer
            enum:
              - 0
              - 1
            default: 0
        - name: all_folders
          in: query
          required: false
          description: >-
            `1` for the files of every folder and of none, whatever `folder_id`
            or `root_only` say. `true` and `false` are refused with `422`: send
            `1` or `0`.
          schema:
            type: integer
            enum:
              - 0
              - 1
            default: 0
        - name: source
          in: query
          required: false
          description: >-
            `ai`: only files PostSyncer's AI made. `upload`: every other file.
            Left out: both.
          schema:
            type: string
            enum:
              - ai
              - upload
        - name: page
          in: query
          required: false
          description: The page, from 1.
          schema:
            type: integer
            minimum: 1
            default: 1
        - name: per_page
          in: query
          required: false
          description: Files a page, from 1. More than 100 gives 100.
          schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 50
      responses:
        '200':
          description: A page of files.
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                  - links
                  - meta
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/APIMedia'
                  links:
                    $ref: '#/components/schemas/PaginationLinks'
                  meta:
                    $ref: '#/components/schemas/PaginationMeta'
              examples:
                default:
                  summary: Two files
                  value:
                    data:
                      - id: 9052
                        workspace_id: 12
                        folder_id: 41
                        name: pour-over.mp4
                        url: https://cdn.postsyncer.com/examples/pour-over.mp4
                        thumb_url: >-
                          https://cdn.postsyncer.com/examples/pour-over-thumb.jpg
                        mime_type: video/mp4
                        size: 18874368
                        is_processing: false
                        type: video
                        ai_generated_id: null
                        is_reference: false
                        progress: 100
                        alt: null
                        duration_seconds: 42.6
                      - id: 9051
                        workspace_id: 12
                        folder_id: null
                        name: latte-art.jpg
                        url: https://cdn.postsyncer.com/examples/latte-art.jpg
                        thumb_url: >-
                          https://cdn.postsyncer.com/examples/latte-art-thumb.jpg
                        medium_url: >-
                          https://cdn.postsyncer.com/examples/latte-art-medium.jpg
                        mime_type: image/jpeg
                        size: 482113
                        is_processing: false
                        type: image
                        ai_generated_id: null
                        is_reference: false
                        progress: 100
                        alt: Latte art in a blue cup
                        duration_seconds: null
                    links:
                      first: https://postsyncer.com/api/v1/media?page=1
                      last: https://postsyncer.com/api/v1/media?page=1
                      prev: null
                      next: null
                    meta:
                      current_page: 1
                      from: 1
                      last_page: 1
                      links:
                        - url: null
                          label: '&laquo; Previous'
                          page: null
                          active: false
                        - url: https://postsyncer.com/api/v1/media?page=1
                          label: '1'
                          page: 1
                          active: true
                        - url: null
                          label: Next &raquo;
                          page: null
                          active: false
                      path: https://postsyncer.com/api/v1/media
                      per_page: 50
                      to: 2
                      total: 2
        '401':
          $ref: '#/components/responses/Unauthorized401'
        '403':
          description: The key lacks `media:read`, or its user is inactive.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                missing_permission:
                  summary: The key lacks media:read
                  value:
                    message: >-
                      This API key does not have the "media:read" permission.
                      Edit the key in PostSyncer under Settings → API to grant
                      it.
                inactive_account:
                  summary: The key's user is inactive
                  value:
                    message: Your account is inactive.
        '422':
          description: >-
            A filter is wrong: `folder_id` with `root_only`, a workspace or
            folder the key can't reach, a folder of another workspace,
            `root_only` or `all_folders` other than `0` or `1`, an unknown
            `source`, or `page` or `per_page` below 1.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationError'
              examples:
                folder_and_root:
                  summary: folder_id with root_only
                  value:
                    message: Cannot combine folder_id with root_only.
                    errors:
                      folder_id:
                        - Cannot combine folder_id with root_only.
                workspace_id:
                  summary: Not a workspace the key can reach
                  value:
                    message: >-
                      The selected workspace is invalid or you do not have
                      access to it.
                    errors:
                      workspace_id:
                        - >-
                          The selected workspace is invalid or you do not have
                          access to it.
                folder_id:
                  summary: Not a folder the key can reach
                  value:
                    message: >-
                      The selected folder is invalid or you do not have access
                      to it.
                    errors:
                      folder_id:
                        - >-
                          The selected folder is invalid or you do not have
                          access to it.
                folder_elsewhere:
                  summary: A folder of another workspace
                  value:
                    message: The folder does not belong to the specified workspace.
                    errors:
                      folder_id:
                        - The folder does not belong to the specified workspace.
                root_only:
                  summary: root_only isn't 0 or 1
                  value:
                    message: The root only field must be true or false.
                    errors:
                      root_only:
                        - The root only field must be true or false.
                all_folders:
                  summary: all_folders isn't 0 or 1
                  value:
                    message: The all folders field must be true or false.
                    errors:
                      all_folders:
                        - The all folders field must be true or false.
                source:
                  summary: An unknown source
                  value:
                    message: The selected source is invalid.
                    errors:
                      source:
                        - The selected source is invalid.
                per_page:
                  summary: per_page is 0
                  value:
                    message: The per page field must be at least 1.
                    errors:
                      per_page:
                        - The per page field must be at least 1.
        '429':
          $ref: '#/components/responses/RateLimited429'
components:
  schemas:
    APIMedia:
      type: object
      description: >-
        A file in the media library: what list, get and the uploads give, and
        what posts and comments hold.
      required:
        - id
        - workspace_id
        - folder_id
        - name
        - url
        - mime_type
        - size
        - is_processing
        - type
        - ai_generated_id
        - is_reference
        - progress
        - alt
        - duration_seconds
      properties:
        id:
          type: integer
          description: The file's id. Posts take it in `content[].media`.
        workspace_id:
          type: integer
        folder_id:
          type: integer
          nullable: true
          description: The folder it is in; null at the top of the library.
        name:
          type: string
          description: The file name.
        url:
          type: string
          format: uri
          description: The file itself, at a public link.
        thumb_url:
          type: string
          format: uri
          description: >-
            A picture's small copy (about 400 px on its long edge) for cards and
            lists, or a video's still. Left out until one is made: use `url`
            then. See [Picture
            copies](/api-reference/media/overview#picture-copies).
        medium_url:
          type: string
          format: uri
          description: >-
            A picture's medium copy (about 800 px on its long edge) for large
            tiles and previews. Left out until one is made, and for a picture no
            bigger than 800 px on its long edge, which needs none: use `url`
            then. Videos, GIFs and documents have none.
        mime_type:
          type: string
          nullable: true
          description: The file's type, like `image/jpeg`.
        size:
          type: integer
          nullable: true
          description: The size in bytes.
        is_processing:
          type: boolean
          description: >-
            True while the file is still being made (an AI video, for example).
            It can't go on a post or be deleted until it is ready.
        type:
          type: string
          nullable: true
          enum:
            - image
            - video
            - audio
            - document
            - null
          description: >-
            The kind of file, from `mime_type`: `document` is a PDF, Word or
            PowerPoint file. Null for any other type.
        ai_generated_id:
          type: integer
          nullable: true
          description: Set when PostSyncer's AI made the file; null for uploads.
        is_reference:
          type: boolean
          description: True for a reference picture kept for AI video, not for posting.
        progress:
          type: integer
          description: Always 100.
        alt:
          type: string
          nullable: true
          description: The alt text, when set.
        duration_seconds:
          type: number
          nullable: true
          description: >-
            A video's or sound's length in seconds, read when it was uploaded.
            Null for pictures and documents, and for files stored before lengths
            were read.
    PaginationLinks:
      type: object
      description: Links to the list's first, last, previous and next pages.
      required:
        - first
        - last
        - prev
        - next
      properties:
        first:
          type: string
        last:
          type: string
        prev:
          type: string
          nullable: true
          description: Null on the first page.
        next:
          type: string
          nullable: true
          description: Null on the last page.
    PaginationMeta:
      type: object
      description: Where this page sits in the whole list.
      required:
        - current_page
        - from
        - last_page
        - links
        - path
        - per_page
        - to
        - total
      properties:
        current_page:
          type: integer
        from:
          type: integer
          nullable: true
          description: >-
            The position of this page's first item in the list; null when the
            page is empty.
        last_page:
          type: integer
        links:
          type: array
          description: 'A pager: previous, the page numbers, next.'
          items:
            type: object
            required:
              - url
              - label
              - active
            properties:
              url:
                type: string
                nullable: true
              label:
                type: string
              page:
                type: integer
                nullable: true
              active:
                type: boolean
        path:
          type: string
          description: The list's URL without the query.
        per_page:
          type: integer
        to:
          type: integer
          nullable: true
          description: >-
            The position of this page's last item in the list; null when the
            page is empty.
        total:
          type: integer
          description: Items in the whole list.
    Error:
      type: object
      description: >-
        An error answer. Every one has `message`, in plain words; some add an
        `error` code and fields of their own.
      required:
        - message
      properties:
        message:
          type: string
          description: What went wrong and what to do about it.
        error:
          type: string
          description: >-
            A code a few errors add, such as `rate_limited`. See [Handle
            errors](/essentials/error-handling#answers-with-an-error-code).
    ValidationError:
      type: object
      description: '422: the request didn''t pass validation, and nothing changed.'
      required:
        - message
        - errors
      properties:
        message:
          type: string
          description: >-
            The first error and, when there are more, how many: `(and 1 more
            error)`, `(and 2 more errors)`.
        errors:
          type: object
          description: >-
            The messages, by field. A field inside a list is named with dots:
            `accounts.0.id`.
          additionalProperties:
            type: array
            items:
              type: string
  responses:
    Unauthorized401:
      description: No API key, or not a valid one.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            unauthenticated:
              summary: No valid API key
              value:
                message: Unauthenticated.
    RateLimited429:
      description: >-
        More than 60 requests in a minute from this key's user (the API and the
        MCP server share the count). Wait `Retry-After` seconds.
      headers:
        Retry-After:
          description: Seconds until requests are allowed again.
          schema:
            type: integer
        X-RateLimit-Limit:
          description: Requests allowed a minute.
          schema:
            type: integer
        X-RateLimit-Remaining:
          description: Requests left this minute.
          schema:
            type: integer
        X-RateLimit-Reset:
          description: When requests are allowed again, as a Unix timestamp.
          schema:
            type: integer
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            too_many_attempts:
              summary: Too many requests
              value:
                message: Too Many Attempts.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.