pagehaus

The Pagehaus API

Scripts, apps and AI agents can manage your sites over HTTP: list, read, upload and delete files, unpack a zip, create sites, read form messages, add custom domains and check usage. Everything goes through the same limits, virus scanning and checks as the dashboard.

Get a token

Go to Account → API, give the token a name and choose what it can reach:

  • One site, read only: list and read files.
  • One site, read and write: also upload and delete files.
  • All my sites: read and write every site, and create new ones.

The token is shown once. Keep it like a password: in an environment variable, not in your site's files. You can see when each token was last used, and revoke it at any time.

export PAGEHAUS_TOKEN=ph_...

Examples

All requests go to https://pagehaus.app/api/v1 with the token in an Authorization header. Paths always start at the top of the site, like /index.html.

# Upload (or replace) a file. Folders are created as needed.
curl -X PUT -H "Authorization: Bearer $PAGEHAUS_TOKEN" --data-binary @index.html \
  "https://pagehaus.app/api/v1/sites/yoursite/files/content?path=/index.html"

# Read a file
curl -H "Authorization: Bearer $PAGEHAUS_TOKEN" "https://pagehaus.app/api/v1/sites/yoursite/files/content?path=/index.html"

# List a folder
curl -H "Authorization: Bearer $PAGEHAUS_TOKEN" "https://pagehaus.app/api/v1/sites/yoursite/files?path=/"

# Delete a file (or an empty folder)
curl -X DELETE -H "Authorization: Bearer $PAGEHAUS_TOKEN" "https://pagehaus.app/api/v1/sites/yoursite/files?path=/old.html"

# Upload a zip and unpack it into a folder
curl -X POST -H "Authorization: Bearer $PAGEHAUS_TOKEN" --data-binary @site.zip "https://pagehaus.app/api/v1/sites/yoursite/zip?path=/"

# See what a zip would unpack and replace, without changing anything
curl -X POST -H "Authorization: Bearer $PAGEHAUS_TOKEN" --data-binary @site.zip "https://pagehaus.app/api/v1/sites/yoursite/zip?path=/&dry=1"

Endpoints

RequestWhat it does
GET /meThe token's name, access, expiry and your plan
GET /sitesThe sites this token can use, with their addresses
POST /sitesCreate a site: {"name": "mysite"}. Whole-account tokens only.
GET /sites/{name}/files?path=List a folder
GET /sites/{name}/files/content?path=Read a file
PUT /sites/{name}/files/content?path=Create or replace a file; the body is the file
DELETE /sites/{name}/files?path=Delete a file, or a folder once it's empty
POST /sites/{name}/zip?path=&strip=&dry=Unpack a zip into a folder; the body is the zip. See Uploading a zip.
GET /sites/{name}/usageStorage, files and folders, and traffic against your plan
GET /sites/{name}/forms/messages?form=&limit=&before=Contact form messages, newest first, up to 50 at a time; pass the returned before to get older ones
GET /sites/{name}/domainsCustom domains, their status, and the DNS records still to add
POST /sites/{name}/domainsAdd a custom domain: {"domain": "www.example.com"} (Personal and Pro plans)
POST /sites/{name}/domains/{domain}/checkCheck a domain's DNS again now
GET /sites/{name}/blog/postsThe blog's posts, newest first, with their status and address
GET /sites/{name}/blog/posts/{slug}One post, with its Markdown body
PUT /sites/{name}/blog/posts/{slug}Create or change a post: {"title": "…", "body": "…", "tags": […], "publish": true}. See Blog posts.
DELETE /sites/{name}/blog/posts/{slug}Delete a post; if it was live, the blog is published again
POST /sites/{name}/blog/publishPublish the blog: its pages, feed and sitemap
GET /activityRecent changes made through the API and connected apps

Uploading a zip

Each file lands at path plus its path inside the zip, exactly as written: a zip holding audio/a.mp3 sent with path=/ creates /audio/a.mp3. Files that already exist are replaced.

  • strip=1 removes the zip's top folder when every file is inside the same one, as in GitHub's Download ZIP (mysite-main/index.html becomes /index.html).
  • dry=1 checks the zip against your plan and reports what it would unpack and replace, without writing anything.

The answer lists every file, the ones that replaced an existing file, and any removed by the virus scan:

{"extracted": ["/audio/a.mp3", "/audio/index.html"], "replaced": ["/audio/index.html"],
 "removed": [], "stripped": null, "dryRun": false}

Blog posts

Posts are Markdown. PUT takes JSON with title (needed for a new post), body, tags, description, image (a path such as /blog/images/oven.jpg), date and draft. When you change a post, anything you leave out keeps its current value. New posts are drafts; "publish": true makes the post public and publishes the blog in the same call. The site gets a blog at /blog/ the first time you write a post. Publishing is limited to 30 times an hour per account.

curl -X PUT -H "Authorization: Bearer $PAGEHAUS_TOKEN" -H "Content-Type: application/json" \
  -d '{"title": "Spring menu", "body": "New this week: **rhubarb tart**.", "tags": ["menu"], "publish": true}' \
  https://pagehaus.app/api/v1/sites/yoursite/blog/posts/spring-menu

Errors and limits

Errors come back as JSON with a message you can show to a person, such as {"error": "This token is read-only."}:

  • 400: something to fix, such as a bad path, a full plan or a file type your plan doesn't allow.
  • 401: the token is missing, wrong, revoked or expired, or your email address isn't confirmed yet.
  • 403: the token can't do that, or the site is suspended.
  • 404: no such site, file or folder for this token.
  • 409: a folder where a file was expected (or the reverse), or a folder that isn't empty.
  • 422: the file was removed because it contains malware.
  • 429: slow down. Each token can make 600 reads and 60 changes a minute, and 2,000 changes a day. An account can create 5 sites a day through the API.

Changes to one account are made one at a time, and every change is listed under Account → API.

Using it with an AI agent

Most assistants are easiest to connect with MCP: see Connect an AI assistant. Agents that can run commands can also use SFTP; see Let an AI agent manage your site.