PageHub Media API

A site's media library and direct uploads.

GitHub OpenAPI

Operations 8

GET /api/v1/sites/{id}/media Read the media library #
POST /api/v1/sites/{id}/media Upload media: sign, confirm, import a URL, or register items #
PATCH /api/v1/sites/{id}/media Reorder or move library items #
GET /api/v1/sites/{id}/media/folders List media folders #
PUT /api/v1/sites/{id}/media/folders Replace the media folders #
GET /api/v1/sites/{id}/media/unattached List the user's unattached files #
PATCH /api/v1/sites/{id}/media/{mediaId} Update a library file #
DELETE /api/v1/sites/{id}/media/{mediaId} Remove a file from the library #

Work with this as data

Every API here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for apis

7 MCP tools reach this
  • find_apisBrowse and filter every API in the catalog.
  • get_api_artifactsOne API's artifacts, grouped by type.
  • get_openapiThe primary OpenAPI for this API.
  • find_similar_apisAPIs that look like this one.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This API
curl "https://apis.io/api/v1/apis/pagehub-dev:pagehub-dev-media-api"
All apis
curl "https://apis.io/api/v1/apis?limit=25"

Calls without X-API-Key need no key. Calls with it need a paid plan — get a key.

Get an API key

Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. By signing up you are subscribing to the APIs.io and API Evangelist newsletters — you can unsubscribe from any issue. See our Privacy Policy and Terms.

A second provider on the same verified email joins the account you already have.

OpenAPI Specification

pagehub-dev-media-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  title: PageHub Media API
  version: 1.0.0
  description: 'The public REST API of PageHub, called with a `ph_` API key (`Authorization: Bearer ph_...`), plus the one webhook the platform calls on a white-label tenant''s server (`fetchPage`).


    A site is HTML + Liquid files: its pages are files (`pages/*.liquid`), written through the files API; the page routes manage each page''s record (name, slug, SEO, access). Writes land in the site''s draft; `PUT /api/v1/sites/{id}` with `published: true` makes the draft live.


    The headless content API (`/api/v1/content/...`) is described by its own document (`GET /api/v1/content/openapi.json`); `GET /api/openapi.json` serves this document with it merged in.


    The routes also accept the dashboard''s session cookie from the dashboard itself; only the API key is the public contract.


    Every operation carries two extension fields. `x-auth` says who may call it: `api-key` (a `ph_` key), `session-or-key` (the dashboard''s own session, or a key), `optional-key` (public, a key widens what you see), `admin-key` (a platform admin''s key), `session` (the dashboard session only; an API key is refused) or `public`. `x-rate-limit` names the rate-limit rule (see the rate-limiting guide) when the route has one; most routes limit per user, public routes per IP.'
  contact:
    name: PageHub
    url: https://pagehub.dev/developers
servers:
- url: https://pagehub.dev
  description: PageHub
security:
- bearerAuth: []
tags:
- name: Media
  description: A site's media library and direct uploads.
paths:
  /api/v1/sites/{id}/media:
    parameters:
    - $ref: '#/components/parameters/SiteId'
    get:
      tags:
      - Media
      summary: Read the media library
      description: The site's media items and folders. `?summary=1` returns the library's tab counts and `?usage=1` where each file is used, instead.
      operationId: getSiteMedia
      parameters:
      - name: kind
        in: query
        schema:
          const: image
        description: Only images.
      - name: summary
        in: query
        schema:
          const: '1'
      - name: usage
        in: query
        schema:
          const: '1'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  media:
                    type: array
                    items:
                      type: object
                      additionalProperties: true
                  folders:
                    type: array
                    items:
                      type: object
                      additionalProperties: true
                description: With `summary` or `usage`, the summary object or `{ usage }` instead.
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
      x-auth: session-or-key
    post:
      tags:
      - Media
      summary: 'Upload media: sign, confirm, import a URL, or register items'
      description: 'Large files go straight to the CDN in two steps, so the bytes never pass through the API:


        1. `{ step: "sign", size, contentType, filename? }` returns an `uploadURL`. Send the file there: images as a multipart `POST` with field `formField` (`file`); everything else as a raw `PUT` whose `Content-Type` matches `contentType` exactly.

        2. `{ step: "confirm", ticket, filename?, width?, height? }` finalizes the upload and registers it in the library. Confirm is not optional.


        `private: true` (digital downloads) works only through sign then confirm. Without `step`: `{ fileUrl }` (or `imageUrl`) imports a public URL, `{ dataBase64, mimeType, filename }` uploads small bytes inline (a few MB at most), and `{ items }` registers already-uploaded files in the library.'
      operationId: uploadSiteMedia
      requestBody:
        required: true
        content:
          application/json:
            schema:
              oneOf:
              - title: Sign
                type: object
                properties:
                  step:
                    const: sign
                  size:
                    type: number
                    exclusiveMinimum: 0
                    description: Bytes.
                  contentType:
                    type: string
                  filename:
                    type: string
                  private:
                    type: boolean
                required:
                - step
                - size
              - title: Confirm
                type: object
                properties:
                  step:
                    const: confirm
                  ticket:
                    type: string
                    description: The `ticket` from the sign response.
                  filename:
                    type: string
                  width:
                    type: integer
                  height:
                    type: integer
                  private:
                    type: boolean
                required:
                - step
                - ticket
              - title: Import
                type: object
                properties:
                  fileUrl:
                    type: string
                    format: uri
                  imageUrl:
                    type: string
                    format: uri
                    description: Older alias of `fileUrl`.
                  dataBase64:
                    type: string
                  mimeType:
                    type: string
                  filename:
                    type: string
              - title: Register
                type: object
                properties:
                  items:
                    type: array
                    items:
                      type: object
                      additionalProperties: true
                required:
                - items
      responses:
        '200':
          description: The sign response, the confirmed or imported file, or the registered items.
          content:
            application/json:
              schema:
                oneOf:
                - $ref: '#/components/schemas/MediaSigned'
                - $ref: '#/components/schemas/MediaFile'
                - type: object
                  properties:
                    media:
                      type: array
                      items:
                        type: object
                        additionalProperties: true
                    added:
                      type: integer
                  required:
                  - media
                  - added
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          description: No access to the site, or the plan or storage quota refuses the file.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
        '404':
          $ref: '#/components/responses/NotFound'
        '413':
          description: The file is too large for the plan or the import limit.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
        '429':
          $ref: '#/components/responses/RateLimited'
        '503':
          description: Image CDN, R2 or private storage is not configured, or writes are paused for maintenance.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
      x-auth: session-or-key
    patch:
      tags:
      - Media
      summary: Reorder or move library items
      operationId: updateSiteMedia
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                order:
                  type: array
                  items:
                    type: string
                  description: Media ids in the new order.
                move:
                  type: object
                  properties:
                    ids:
                      type: array
                      items:
                        type: string
                    folderId:
                      type:
                      - string
                      - 'null'
                  required:
                  - ids
      responses:
        '200':
          description: The updated library state.
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
      x-auth: session-or-key
      x-rate-limit: media_delete
  /api/v1/sites/{id}/media/folders:
    get:
      tags:
      - Media
      summary: List media folders
      operationId: listMediaFolders
      parameters:
      - $ref: '#/components/parameters/SiteId'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  folders:
                    type: array
                    items:
                      $ref: '#/components/schemas/MediaFolder'
                required:
                - folders
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
      x-auth: session-or-key
    put:
      tags:
      - Media
      summary: Replace the media folders
      description: Replaces all folders. Items in a removed folder move to the top level.
      operationId: replaceMediaFolders
      parameters:
      - $ref: '#/components/parameters/SiteId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                folders:
                  type: array
                  items:
                    $ref: '#/components/schemas/MediaFolder'
              required:
              - folders
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  folders:
                    type: array
                    items:
                      $ref: '#/components/schemas/MediaFolder'
                required:
                - folders
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
      x-auth: session-or-key
      x-rate-limit: media_delete
  /api/v1/sites/{id}/media/unattached:
    get:
      tags:
      - Media
      summary: List the user's unattached files
      description: The signed-in user's stored files that no library lists. An API key gets an empty list. `canManage` is true for the site's owner, who may add them to the library or delete them.
      operationId: listUnattachedMedia
      parameters:
      - $ref: '#/components/parameters/SiteId'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  files:
                    type: array
                    items:
                      $ref: '#/components/schemas/UnattachedFile'
                  canManage:
                    type: boolean
                required:
                - files
                - canManage
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
      x-auth: session-or-key
  /api/v1/sites/{id}/media/{mediaId}:
    patch:
      tags:
      - Media
      summary: Update a library file
      description: '`metadata` merges key by key; a null value removes a key.'
      operationId: updateMediaItem
      parameters:
      - $ref: '#/components/parameters/SiteId'
      - name: mediaId
        in: path
        required: true
        schema:
          type: string
        description: The file's media id.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                order:
                  type: number
                type:
                  type: string
                cdnId:
                  type: string
                metadata:
                  type: object
                  additionalProperties: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  media:
                    type: object
                    additionalProperties: true
                required:
                - media
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
      x-auth: session-or-key
      x-rate-limit: media_delete
    delete:
      tags:
      - Media
      summary: Remove a file from the library
      description: 'Drops the entry and, for a signed-in caller, deletes the stored file when that is safe. An API key only drops the entry (`deleted: false`). A file in no library is deleted only by the site''s owner, and only when nothing uses it (409 `in-use`).'
      operationId: deleteMediaItem
      parameters:
      - $ref: '#/components/parameters/SiteId'
      - name: mediaId
        in: path
        required: true
        schema:
          type: string
        description: The file's media id.
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
                properties:
                  id:
                    type: string
                  deleted:
                    type: boolean
                  reason:
                    type: string
                  removed:
                    type: boolean
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          description: A conflict (`error` says which).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
        '429':
          $ref: '#/components/responses/RateLimited'
      x-auth: session-or-key
      x-rate-limit: media_delete
components:
  parameters:
    SiteId:
      name: id
      in: path
      required: true
      schema:
        type: string
      description: The site's id.
  responses:
    Unauthorized:
      description: Missing, malformed or invalid `ph_` API key.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiError'
    BadRequest:
      description: The request is malformed or refused (`error`, often `message`).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiError'
    Forbidden:
      description: The key's user lacks the role this needs, or a plan limit applies.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiError'
    NotFound:
      description: No such site, or the key has no access to it, or no such resource under it.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiError'
    RateLimited:
      description: Too many requests.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiError'
  schemas:
    MediaFolder:
      type: object
      additionalProperties: true
    MediaSigned:
      type: object
      description: The sign step's answer.
      properties:
        mediaId:
          type: string
        uploadURL:
          type: string
          format: uri
        destination:
          type: string
          enum:
          - cf-images
          - r2
          - r2-private
        type:
          type: string
          enum:
          - cdn
          - r2
          - r2-private
        method:
          type: string
          enum:
          - POST
          - PUT
        formField:
          type: string
          description: 'Images: the multipart field to send the file in.'
        contentType:
          type: string
          description: 'R2: the `Content-Type` the `PUT` must send.'
        url:
          type: string
          description: Where the file is served once uploaded (not for private files).
        ticket:
          type: string
          description: Send this to the confirm step.
      required:
      - mediaId
      - uploadURL
      - destination
      - method
      - ticket
    MediaFile:
      type: object
      description: A confirmed or imported file.
      properties:
        siteId:
          type: string
        mediaId:
          type: string
        type:
          type: string
          enum:
          - cdn
          - r2
          - r2-private
        url:
          type: string
        contentType:
          type: string
        size:
          type: number
          description: Private files only.
        registered:
          type: boolean
          description: Whether the file was added to the site's library.
      required:
      - mediaId
      - type
      - registered
    UnattachedFile:
      type: object
      additionalProperties: true
      properties:
        mediaId:
          type: string
        destination:
          type: string
        url:
          type:
          - string
          - 'null'
    ApiError:
      type: object
      description: The error body of the management routes. The content API uses `Error` instead.
      properties:
        error:
          type: string
          description: A message, or a code such as `version_conflict`, `lint`, `maintenance`, `site_format_changed`.
        message:
          type: string
        code:
          type: string
        upgrade:
          type: boolean
          description: True when the plan is the reason.
      required:
      - error
      additionalProperties: true
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: A `ph_` API key (a user's key, or a tenant's).
    tenantAuthToken:
      type: apiKey
      in: header
      name: x-pagehub-auth
      description: The tenant's token, sent by PageHub on every webhook call so the tenant can check the request came from PageHub.