PageHub Files API

A site's draft files (pages, partials, `theme.css`, `site.json`, ...).

GitHub OpenAPI

Operations 5

GET /api/v1/sites/{id}/files List draft files, read several, or search them #
POST /api/v1/sites/{id}/files Save a batch of files atomically #
GET /api/v1/sites/{id}/files/{path} Read one draft file #
PUT /api/v1/sites/{id}/files/{path} Write one draft file #
GET /api/v1/sites/{id}/outline Outline a page #

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-files-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-files-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  title: PageHub Files 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: Files
  description: A site's draft files (pages, partials, `theme.css`, `site.json`, ...).
paths:
  /api/v1/sites/{id}/files:
    parameters:
    - $ref: '#/components/parameters/SiteId'
    - $ref: '#/components/parameters/Stage'
    get:
      tags:
      - Files
      summary: List draft files, read several, or search them
      description: 'Without `q` or `read`: every file path of the draft with its version (a content hash); `glob` keeps only the matching paths. With `read`: the text and version of up to 40 files in one call (400,000 characters at most; the rest comes back as `skipped`). With `q`: the hits of the text (plain, case-insensitive) or, with `regex`, of a JavaScript regular expression run under a time limit; each hit has its line and column and the text around the match. Up to 100 hits.'
      operationId: listSiteFiles
      parameters:
      - name: q
        in: query
        required: false
        schema:
          type: string
          minLength: 1
          maxLength: 200
        description: Text to search for.
      - name: path
        in: query
        required: false
        schema:
          type: string
        description: 'With `q`: only files whose path starts with this, e.g. `pages/`.'
      - name: read
        in: query
        required: false
        schema:
          type: string
        description: Comma-separated paths to read in one call (1-40), e.g. `pages/index.liquid,partials/header.liquid`.
      - name: regex
        in: query
        required: false
        schema:
          type: string
          enum:
          - '1'
          - 'true'
        description: 'With `q`: the text is a JavaScript regular expression (case-insensitive). An invalid or too slow pattern answers 400 `bad_query`.'
      - name: glob
        in: query
        required: false
        schema:
          type: string
          maxLength: 200
        description: 'Only paths matching, for the listing and for `q`: `*` within a folder, `**` across folders, `?`, `{a,b}`. A glob with no `/` matches the file name at any depth (`*.liquid`).'
      - name: context
        in: query
        required: false
        schema:
          type: integer
          minimum: 0
          maximum: 5
        description: 'With `q`: lines of context before and after each hit.'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                oneOf:
                - $ref: '#/components/schemas/FileList'
                - $ref: '#/components/schemas/FileSearch'
                - $ref: '#/components/schemas/FileRead'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/SiteFormatChanged'
      x-auth: session-or-key
    post:
      tags:
      - Files
      summary: Save a batch of files atomically
      description: Writes and deletes up to 500 files in one atomic save. `baseVersions` says which version of each file you edited; a file someone else changed since answers 409 `version_conflict` and nothing is written. Files are linted and sanitized; invalid HTML nesting is repaired and reported in `repaired`, so compare the stored text before the next edit. `pages` also creates a page record for each new page file in the same write, so a new page and the link to it land together; a page that can't be created (taken URL, plan cap) answers 400 or 403 and writes nothing. Not available in review mode.
      operationId: saveSiteFiles
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                changes:
                  type: array
                  minItems: 1
                  maxItems: 500
                  items:
                    oneOf:
                    - type: object
                      properties:
                        path:
                          type: string
                        text:
                          type: string
                      required:
                      - path
                      - text
                    - type: object
                      properties:
                        path:
                          type: string
                        delete:
                          const: true
                      required:
                      - path
                      - delete
                baseVersions:
                  type: object
                  additionalProperties:
                    type:
                    - string
                    - 'null'
                  description: '`{ [path]: version }`; `null` (or a missing path) means the file must not exist yet.'
                pages:
                  type: array
                  items:
                    $ref: '#/components/schemas/PageFromFile'
                  description: Pages to create for new `pages/….liquid` files in `changes` (each with no base version).
              required:
              - changes
      responses:
        '200':
          description: Saved
          content:
            application/json:
              schema:
                type: object
                properties:
                  versions:
                    type: object
                    additionalProperties:
                      type: string
                    description: The new version of each written path.
                  version:
                    type: integer
                    description: The draft's shared version.
                  staged:
                    const: true
                    description: Present when the write went into the staged AI layer.
                  repaired:
                    $ref: '#/components/schemas/NestingRepairs'
                  pages:
                    type: array
                    items:
                      $ref: '#/components/schemas/SitePage'
                    description: The page records created for `pages`.
                required:
                - versions
                - version
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          description: '`version_conflict` (nothing written) or `site_format_changed`.'
          content:
            application/json:
              schema:
                oneOf:
                - type: object
                  properties:
                    error:
                      const: version_conflict
                    conflicts:
                      type: array
                      items:
                        type: object
                        properties:
                          path:
                            type: string
                          theirs:
                            type:
                            - string
                            - 'null'
                          version:
                            type: integer
                  required:
                  - error
                  - conflicts
                - $ref: '#/components/schemas/ApiError'
        '413':
          $ref: '#/components/responses/WriteRejected'
        '422':
          $ref: '#/components/responses/WriteRejected'
        '429':
          $ref: '#/components/responses/RateLimited'
        '503':
          $ref: '#/components/responses/Maintenance'
      x-auth: session-or-key
      x-rate-limit: site_save
  /api/v1/sites/{id}/files/{path}:
    parameters:
    - $ref: '#/components/parameters/SiteId'
    - $ref: '#/components/parameters/Stage'
    - name: path
      in: path
      required: true
      schema:
        type: string
      allowReserved: true
      description: The file's path in the site, one URL segment per folder, e.g. `pages/shop/[handle].liquid`.
    get:
      tags:
      - Files
      summary: Read one draft file
      operationId: getSiteFile
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  text:
                    type: string
                  version:
                    type: string
                    description: The file's content hash.
                required:
                - text
                - version
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          description: The site, or the file in its draft (`file_not_found`), does not exist.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
        '409':
          $ref: '#/components/responses/SiteFormatChanged'
      x-auth: session-or-key
    put:
      tags:
      - Files
      summary: Write one draft file
      description: Same rules as the batch save, for a single file. `page` on a new `pages/.liquid` file also creates its page record.
      operationId: putSiteFile
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                text:
                  type: string
                baseVersion:
                  type:
                  - string
                  - 'null'
                  description: The version you edited; `null` means the file must not exist yet.
                page:
                  type: object
                  description: 'Create the page record for this new page file: `{ name?, seo?, pathPattern? }` (an empty object takes the defaults).'
                  properties:
                    name:
                      type: string
                    seo:
                      type: object
                    pathPattern:
                      type:
                      - string
                      - 'null'
              required:
              - text
      responses:
        '200':
          description: Saved
          content:
            application/json:
              schema:
                type: object
                properties:
                  version:
                    type: string
                  staged:
                    const: true
                  repaired:
                    $ref: '#/components/schemas/NestingRepairs'
                  pages:
                    type: array
                    items:
                      $ref: '#/components/schemas/SitePage'
                required:
                - version
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          description: '`version_conflict` (nothing written) or `site_format_changed`.'
          content:
            application/json:
              schema:
                oneOf:
                - type: object
                  properties:
                    error:
                      const: version_conflict
                    theirs:
                      type:
                      - string
                      - 'null'
                    version:
                      type: integer
                  required:
                  - error
                - $ref: '#/components/schemas/ApiError'
        '413':
          $ref: '#/components/responses/WriteRejected'
        '422':
          $ref: '#/components/responses/WriteRejected'
        '429':
          $ref: '#/components/responses/RateLimited'
        '503':
          $ref: '#/components/responses/Maintenance'
      x-auth: session-or-key
      x-rate-limit: site_save
  /api/v1/sites/{id}/outline:
    parameters:
    - $ref: '#/components/parameters/SiteId'
    - $ref: '#/components/parameters/Stage'
    get:
      tags:
      - Files
      summary: Outline a page
      description: 'The structure of one page of the draft: sections and landmarks with their line ranges, headings, and every `{% render %}` / `{% section %}` of a partial, expanded in place with its own sections and headings (anchored to the partial''s file and lines) unless `expand=0`. Rendered partials that are components carry their use counts.'
      operationId: outlineSitePage
      parameters:
      - name: page
        in: query
        required: true
        schema:
          type: string
        description: A page id, its URL (`/about`) or a file path (`pages/about.liquid`, `partials/header.liquid`).
      - name: expand
        in: query
        required: false
        schema:
          type: string
          enum:
          - '0'
          - '1'
        description: '`0` names each render without expanding it.'
      - name: classes
        in: query
        required: false
        schema:
          type: string
          enum:
          - '1'
          - 'true'
        description: Full class strings; by default the first three and a count.
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PageOutline'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          description: The site, or the page or file, does not exist (`page_not_found`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
        '409':
          $ref: '#/components/responses/SiteFormatChanged'
      x-auth: session-or-key
components:
  schemas:
    FileSearch:
      type: object
      properties:
        matches:
          type: array
          items:
            type: object
            properties:
              path:
                type: string
              line:
                type: integer
                description: 1-based.
              text:
                type: string
                description: 'The line around the match: up to 80 characters each side, `…` where cut.'
              column:
                type: integer
                description: 1-based column of the match in the line.
              before:
                type: array
                items:
                  type: string
                description: 'With `context`: the lines before.'
              after:
                type: array
                items:
                  type: string
                description: 'With `context`: the lines after.'
            required:
            - path
            - line
            - column
            - text
        truncated:
          type: boolean
      required:
      - matches
      - truncated
    SitePage:
      type: object
      properties:
        pageId:
          type: string
        name:
          type: string
        slug:
          type: string
          description: The page's own URL segment; empty for the home page.
        file:
          type:
          - string
          - 'null'
          description: The page's file in the draft.
        url:
          type: string
        isHomePage:
          type: boolean
        is404Page:
          type: boolean
        isHidden:
          type: boolean
        pathPattern:
          type:
          - string
          - 'null'
        seo:
          type:
          - object
          - 'null'
          additionalProperties: true
      required:
      - pageId
      - name
      - slug
      - file
      - url
      - isHomePage
      - is404Page
      - isHidden
      - pathPattern
      - seo
    NestingRepairs:
      type: array
      description: The nesting fixes the server made to the text it stored (a stray `</p>`, an unclosed `<li>`), per file. Absent when it stored exactly what was sent.
      items:
        type: object
        properties:
          path:
            type: string
          fixes:
            type: array
            items:
              type: object
              properties:
                message:
                  type: string
                line:
                  type: integer
        required:
        - path
        - fixes
    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
    FileList:
      type: object
      properties:
        paths:
          type: array
          items:
            type: string
        versions:
          type: object
          additionalProperties:
            type: string
        version:
          type: integer
      required:
      - paths
      - versions
      - version
    PageFromFile:
      type: object
      properties:
        path:
          type: string
          description: A new `pages/<slug>.liquid` file in `changes` (`pages/shop/[handle].liquid` makes `/shop/:handle`). Its route is read from the path.
        name:
          type: string
          description: Display name; default from the file name.
        seo:
          type: object
          description: The page's SEO, as the pages route takes it.
        pathPattern:
          type:
          - string
          - 'null'
      required:
      - path
    FileRead:
      type: object
      properties:
        files:
          type: array
          items:
            type: object
            properties:
              path:
                type: string
              text:
                type: string
              version:
                type: string
            required:
            - path
            - text
            - version
        missing:
          type: array
          items:
            type: string
          description: Asked for, not in the draft.
        skipped:
          type: array
          items:
            type: object
            properties:
              path:
                type: string
              chars:
                type: integer
            required:
            - path
            - chars
          description: In the draft, left out because the answer reached its size cap; read them alone.
      required:
      - files
      - missing
      - skipped
    OutlineNode:
      type: object
      properties:
        kind:
          type: string
          enum:
          - section
          - heading
          - render
          - block
        file:
          type: string
          description: The page file, or the partial the node was expanded from.
        line:
          type: integer
        endLine:
          type: integer
        tag:
          type: string
        label:
          type: string
        id:
          type: string
        classes:
          type: string
        component:
          type: object
          properties:
            id:
              type: string
            uses:
              type: integer
            pages:
              type: integer
        missing:
          type: boolean
          description: A render of a partial that has no file.
        children:
          type: array
          items:
            $ref: '#/components/schemas/OutlineNode'
      required:
      - kind
      - file
      - line
      - endLine
      - tag
      - label
      - children
    PageOutline:
      type: object
      properties:
        page:
          type: object
          properties:
            pageId:
              type: string
            name:
              type: string
            url:
              type: string
            file:
              type: string
          required:
          - file
        outline:
          type: object
          properties:
            path:
              type: string
            lines:
              type: integer
            nodes:
              type: array
              items:
                $ref: '#/components/schemas/OutlineNode'
            truncated:
              type: boolean
          required:
          - path
          - lines
          - nodes
          - truncated
      required:
      - page
      - outline
  responses:
    WriteRejected:
      description: 'A file write was refused: `lint` (422, with `issues` and `path`), too large (413), or another `rejected` reason.'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiError'
    SiteFormatChanged:
      description: 'The site is not an HTML-first site (`error: site_format_changed`).'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiError'
    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'
    Maintenance:
      description: 'Writes are paused for maintenance (`error: maintenance`, `Retry-After` header).'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiError'
  parameters:
    Stage:
      name: X-PageHub-Stage
      in: header
      required: false
      schema:
        const: review
      description: 'With an API key: read the draft under the staged AI layer and write into that layer instead of the draft.'
    SiteId:
      name: id
      in: path
      required: true
      schema:
        type: string
      description: The site's id.
  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.