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

# List media

> The files in your media library, newest first.

Needs an API key with the `read` scope.



## OpenAPI

````yaml /openapi.json get /media
openapi: 3.1.0
info:
  title: PostMesh API
  version: 1.0.0
  description: >-
    The PostMesh API posts, schedules and reads your posts on every network you
    connected, with JSON in and out.


    **Authentication.** Send an API key from Settings, API & MCP as
    `Authorization: Bearer pm_live_...`. Each key has scopes (read, drafts,
    publish, media); every endpoint says which it needs.


    **Retries.** Send an `Idempotency-Key` header (up to 255 printable
    characters, a UUID is ideal) with every POST. Sending the same key again
    within 24 hours answers with the first request's status and body instead of
    posting twice, and says so with `Idempotent-Replayed: true`. A request still
    running under the key answers 409; one that failed with a 5xx or 429 frees
    the key, so the retry runs. The same key with a different body is refused
    with 422.


    **Rate limits.** Each key may make 120 requests a minute. Every answer
    carries `X-RateLimit-Limit`, `X-RateLimit-Remaining` and `X-RateLimit-Reset`
    (Unix seconds); a 429 also carries `Retry-After`. Posting and uploads have
    their own, smaller limits.


    **Errors.** A refusal is JSON with `error` (plain words) and `code` (stable,
    to act on).
servers:
  - url: https://postmesh.app/api/v1
security:
  - apiKey: []
tags:
  - name: Posts
    description: Send, schedule, change and read posts.
  - name: Drafts
    description: Posts saved for later.
  - name: Media
    description: Images and videos for posts.
  - name: Accounts
    description: Your connected accounts and your plan.
  - name: Analytics
    description: How your posts did.
paths:
  /media:
    get:
      tags:
        - Media
      summary: List media
      description: |-
        The files in your media library, newest first.

        Needs an API key with the `read` scope.
      operationId: listMedia
      parameters:
        - name: kind
          in: query
          required: false
          schema:
            type: string
            enum:
              - image
              - video
        - name: source
          in: query
          required: false
          schema:
            type: string
            enum:
              - upload
              - api
              - clip_factory
              - ai_image
        - name: q
          in: query
          required: false
          schema:
            type: string
            maxLength: 200
          description: Words in the file's name or alt text.
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 100
        - name: cursor
          in: query
          required: false
          schema:
            type: string
            maxLength: 512
      responses:
        '200':
          description: A page of files.
          headers:
            X-RateLimit-Limit:
              $ref: '#/components/headers/X-RateLimit-Limit'
            X-RateLimit-Remaining:
              $ref: '#/components/headers/X-RateLimit-Remaining'
            X-RateLimit-Reset:
              $ref: '#/components/headers/X-RateLimit-Reset'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MediaList'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
        '503':
          $ref: '#/components/responses/Unavailable'
components:
  headers:
    X-RateLimit-Limit:
      description: Requests this key may make in a minute.
      schema:
        type: integer
    X-RateLimit-Remaining:
      description: Requests left this minute.
      schema:
        type: integer
    X-RateLimit-Reset:
      description: When the minute resets, in Unix seconds.
      schema:
        type: integer
  schemas:
    MediaList:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/Media'
        next_cursor:
          anyOf:
            - type: string
            - type: 'null'
      required:
        - data
        - next_cursor
      additionalProperties: false
    Media:
      type: object
      properties:
        id:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
          description: >-
            The media library id, for media_ids. Null when the file isn't in the
            library.
        media_ref:
          type: object
          properties:
            path:
              type: string
            name:
              type: string
            mime_type:
              type: string
          required:
            - path
            - name
            - mime_type
          additionalProperties: false
          description: Put this in a post's media.
        kind:
          type: string
          enum:
            - image
            - video
        size_bytes:
          anyOf:
            - type: integer
              minimum: -9007199254740991
              maximum: 9007199254740991
            - type: 'null'
        width:
          anyOf:
            - type: integer
              minimum: -9007199254740991
              maximum: 9007199254740991
            - type: 'null'
        height:
          anyOf:
            - type: integer
              minimum: -9007199254740991
              maximum: 9007199254740991
            - type: 'null'
        duration_ms:
          anyOf:
            - type: integer
              minimum: -9007199254740991
              maximum: 9007199254740991
            - type: 'null'
        alt_text:
          type: string
        source:
          type: string
          enum:
            - upload
            - api
            - clip_factory
            - ai_image
        url:
          description: A short-lived link to view the file.
          anyOf:
            - type: string
            - type: 'null'
        duplicate:
          description: 'The library had this file already: media_ref is that copy.'
          type: boolean
          const: true
        created_at:
          type: string
          format: date-time
      required:
        - id
        - media_ref
      additionalProperties: false
      description: A file in your media library.
    Error:
      type: object
      properties:
        error:
          type: string
          description: What went wrong, in plain words.
        code:
          type: string
          description: >-
            A stable code to act on, such as invalid_request, rate_limited or
            idempotency_key_reused.
        field:
          description: The request field that was refused.
          type: string
        retry_after:
          type: integer
          minimum: -9007199254740991
          maximum: 9007199254740991
      required:
        - error
        - code
      additionalProperties: false
      description: Every refusal looks like this.
  responses:
    BadRequest:
      description: >-
        The request was refused: a field is missing or invalid. `field` names
        it.
      headers:
        X-RateLimit-Limit:
          $ref: '#/components/headers/X-RateLimit-Limit'
        X-RateLimit-Remaining:
          $ref: '#/components/headers/X-RateLimit-Remaining'
        X-RateLimit-Reset:
          $ref: '#/components/headers/X-RateLimit-Reset'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unauthorized:
      description: No API key, or one that isn't valid any more.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Forbidden:
      description: >-
        The key can't do this: it needs another scope (`code` is
        `api_key_scope`), or it is in approval mode.
      headers:
        X-RateLimit-Limit:
          $ref: '#/components/headers/X-RateLimit-Limit'
        X-RateLimit-Remaining:
          $ref: '#/components/headers/X-RateLimit-Remaining'
        X-RateLimit-Reset:
          $ref: '#/components/headers/X-RateLimit-Reset'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    TooManyRequests:
      description: Too many requests. Wait for `Retry-After` seconds.
      headers:
        X-RateLimit-Limit:
          $ref: '#/components/headers/X-RateLimit-Limit'
        X-RateLimit-Remaining:
          $ref: '#/components/headers/X-RateLimit-Remaining'
        X-RateLimit-Reset:
          $ref: '#/components/headers/X-RateLimit-Reset'
        Retry-After:
          description: Seconds to wait.
          schema:
            type: integer
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unavailable:
      description: PostMesh can't answer right now. Try again shortly.
      headers:
        X-RateLimit-Limit:
          $ref: '#/components/headers/X-RateLimit-Limit'
        X-RateLimit-Remaining:
          $ref: '#/components/headers/X-RateLimit-Remaining'
        X-RateLimit-Reset:
          $ref: '#/components/headers/X-RateLimit-Reset'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer
      description: 'An API key from Settings, API & MCP: pm_live_...'

````

## Related topics

- [MCP tool reference](https://postmesh.app/docs/mcp-tools.md)
- [List drafts](https://postmesh.app/docs/api-reference/drafts/list-drafts.md)
- [List posts](https://postmesh.app/docs/api-reference/posts/list-posts.md)
- [API keys](https://postmesh.app/docs/api-keys.md)
- [List connected accounts](https://postmesh.app/docs/api-reference/accounts/list-connected-accounts.md)


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