---
name: mypages
description: Publish files to the web with NextPages (mypages.page) and get a shareable https link. Use when the user wants to publish, share, host or deploy something you made (an HTML page, a Markdown report, a PDF or Word document, images, a prototype, a static site folder or ZIP) or asks for a link to it. Needs an API token from a free NextPages account.
---

# NextPages: publish files, get a link

NextPages hosts static pages, sites and documents, each at its own address like
`https://u-k3x9qa.nextpages.io/hello`. One HTTP request publishes; the response has the link.
Nothing runs on the server: HTML, CSS, JavaScript, Markdown, PDF, Word, images,
fonts, media and data files only.

## Before you publish: an API token

Publishing needs an API token from the user's NextPages account (free). Use
`$MYPAGES_TOKEN` if it is set, else the token saved in `~/.mypages/token`
(Quick Start setup saves it there). The commands below read it like this:
`-H "Authorization: Bearer ${MYPAGES_TOKEN:-$(cat ~/.mypages/token)}"`.

If neither exists, set NextPages up first: follow https://mypages.page/start (the user
clicks Allow once, no token to copy). If you can't run that, ask the user to
create a token in Dashboard → Settings → API tokens and give it to you as the
environment variable `MYPAGES_TOKEN`.

Never print the token or put it on a page.

## Publish

Run the commands from the folder that holds the files you publish. Save each
response to its own file in `~/.mypages/` (a private folder outside anything
you publish), named after the page, e.g. `~/.mypages/report.json`: it holds the
page's `page_id`, which you need for updates. Create the folder once:

```bash
mkdir -p -m 700 ~/.mypages
```

Always add `?format=json`. `--fail-with-body` makes curl exit non-zero on
errors while still saving the error.

One HTML file:

```bash
curl -sS --fail-with-body "https://mypages.page/deploy?format=json" -H "Authorization: Bearer ${MYPAGES_TOKEN:-$(cat ~/.mypages/token)}" -F file=@index.html -o ~/.mypages/index.json
```

Then read `url`, `page_id` and `expires_at` from the file (`jq` or
`python3 -c 'import json; …'`). An `error` field instead means it failed
(see Errors).

Several files: repeat `-F`. curl sends only each file's base name, so a file in
a subfolder needs `;filename=` with its path in the site, or it lands at the
root (`-F file=@js/app.js` would become `/app.js`):

```bash
curl -sS --fail-with-body "https://mypages.page/deploy?format=json" -H "Authorization: Bearer ${MYPAGES_TOKEN:-$(cat ~/.mypages/token)}" -o ~/.mypages/site.json \
  -F "file=@index.html" \
  -F "file=@js/app.js;filename=js/app.js" \
  -F "file=@img/chart.png;filename=img/chart.png"
```

A folder (a built site, anything with an `index.html`): zip its contents and
send the ZIP. Run this from the folder that contains `site/`:

```bash
(cd site && zip -qr ../site.zip .) && curl -sS --fail-with-body "https://mypages.page/deploy?format=json" -H "Authorization: Bearer ${MYPAGES_TOKEN:-$(cat ~/.mypages/token)}" -F file=@site.zip -o ~/.mypages/site.json
```

Documents and images: send the file itself.

```bash
curl -sS --fail-with-body "https://mypages.page/deploy?format=json" -H "Authorization: Bearer ${MYPAGES_TOKEN:-$(cat ~/.mypages/token)}" -F file=@report.md -o ~/.mypages/report.json
```

Works for `.md`, `.pdf`, `.docx`, `.png`/`.jpg`/`.gif`/`.webp`/`.svg`,
`.mp4`/`.webm`, `.mp3`/`.wav`, `.txt`, `.json`, `.csv`/`.tsv`. A Markdown
file with images: send the images too, with `;filename=` matching the paths
in the Markdown (here it contains `![Chart](img/chart.png)`):

```bash
curl -sS --fail-with-body "https://mypages.page/deploy?format=json" -H "Authorization: Bearer ${MYPAGES_TOKEN:-$(cat ~/.mypages/token)}" -o ~/.mypages/report.json \
  -F "file=@report.md" \
  -F "file=@img/chart.png;filename=img/chart.png"
```

The first `# heading` becomes the title. In a browser the
link shows the file in a viewer (Markdown formatted with tables, code and
Mermaid diagrams; PDF and Word page by page; CSV as a table; images and media
full size); curl and agents get the file back as sent.

HTML you have as text only:

```bash
curl -sS --fail-with-body "https://mypages.page/deploy?format=json" -H "Authorization: Bearer ${MYPAGES_TOKEN:-$(cat ~/.mypages/token)}" -H "Content-Type: text/html" --data-binary @- -o ~/.mypages/hello.json <<'HTML'
<!doctype html><title>Hello</title><h1>Hello</h1>
HTML
```

Response (HTTP 201):

```json
{
  "success": true,
  "url": "https://u-k3x9qa.nextpages.io/hello",
  "page_id": "amber-otter-k3x9qa",
  "title": "Hello",
  "expires_at": "2026-10-18T09:30:00.000Z",
  "password_protected": false,
  "owner": "user",
  "warnings": []
}
```

The page belongs to the user's account and shows up in their dashboard.

## Check the page

- With `URL` set to the `url` from the response,
  `curl -sS -o /dev/null -w "%{http_code}\n" "$URL"` should print 200. Files
  the page refers to are at their paths under it (`"$URL"img/chart.png`).
- Documents are drawn in the visitor's browser. `curl -sS -H "Accept: text/html" "$URL"`
  returns the viewer page (its `<title>` is the document title); without that
  header you get the file itself. To see the rendered result (Mermaid
  diagrams, PDF pages), open the `url` with a browser tool if you have one.

## Tell the user

- Give them the `url`.
- Free accounts keep pages 14 days, renewable once; files kept 2 months; Pro keeps them while subscribed
  (`expires_at` is then `null`). `expires_at` is UTC: give the date in the
  user's time zone if you know it.

## Update the same link

`POST /deploy` always creates a new link. To change a page and keep its link,
use PUT with the `page_id` from the first response and the same token. Save
the PUT response to a second file so the first keeps the `page_id`.
Send the same `-F` list (or ZIP) as the first publish:

```bash
PAGE_ID=$(python3 -c 'import json,os; print(json.load(open(os.path.expanduser("~/.mypages/report.json")))["page_id"])')   # or: jq -r .page_id ~/.mypages/report.json
curl -sS --fail-with-body -X PUT "https://mypages.page/deploy/$PAGE_ID?format=json" -H "Authorization: Bearer ${MYPAGES_TOKEN:-$(cat ~/.mypages/token)}" \
  -o ~/.mypages/report-update.json \
  -F "file=@report.md" \
  -F "file=@img/chart.png;filename=img/chart.png"
```

- PUT replaces **all** files: a file you leave out is removed from the page.
- The title follows the new `<title>`, or `?title=`. PUT ignores `password`
  and `ttl`: both stay as they were.
- Visitors get the new version on their next load (every file is revalidated).
- Updates count toward the limits below, so collect several changes into one update.
- Check the page: `curl -sS "https://mypages.page/deploy/$PAGE_ID" -H "Authorization: Bearer ${MYPAGES_TOKEN:-$(cat ~/.mypages/token)}"`.
  Delete it: `curl -sS -X DELETE "https://mypages.page/deploy/$PAGE_ID" -H "Authorization: Bearer ${MYPAGES_TOKEN:-$(cat ~/.mypages/token)}"`.
- After the page expired (HTTP 410), or if it is gone (404), publish again
  with POST and tell the user the link changed.

## Options

Query parameters on `POST /deploy`:

- `title=…`: the page title (default: the HTML `<title>`).
- `password=…`: visitors must enter it. Tell the user the password separately.
- `ttl=2h` (or `3600`, `30min`, `7d`): expire sooner.
- `workspace=…`: publish into one of the user's teams instead of their
  personal space (see "Publish to a team").

## Publish to a team

If the user says the page is for their team (or names one), publish into the
team: it then shows up for the team's members in the dashboard and uses the
team's plan and storage. The same personal token works for every team the
user belongs to. List the teams and their addresses:

```bash
curl -sS --fail-with-body "https://mypages.page/api/orgs" -H "Authorization: Bearer ${MYPAGES_TOKEN:-$(cat ~/.mypages/token)}"
```

Then add `workspace=<slug>` (or the team's `id`) to the publish request:

```bash
curl -sS --fail-with-body "https://mypages.page/deploy?format=json&workspace=design" -H "Authorization: Bearer ${MYPAGES_TOKEN:-$(cat ~/.mypages/token)}" -F file=@index.html -o ~/.mypages/index.json
```

The response's `workspace` says where the page went. Without `workspace`
(or with `workspace=personal`) the page goes to the user's personal space.
Updates (PUT) keep the page where it is. A team the user isn't in answers 404.

## Limits

| | Free account | Pro |
|---|---|---|
| Size per upload | 20 MB | 100 MB |
| Publishes and updates | 10/hour | 30/hour (Max and Ultra: more) |
| Kept for | 14 days, renewable once; files kept 2 months | while subscribed |

The size limit applies to the request and to the unpacked files of a ZIP.

## Errors

Errors are JSON: `{"error": {"code": "…", "message": "…"}}`. Tell the user the
message. Fix the cause and retry at most once.

- `rate_limited` (HTTP 429): wait `retry_after` seconds.
- `sign_in_required` (401): no token was sent. Set NextPages up with
  https://mypages.page/start (the user signs up free and clicks Allow).
- `unauthorized` (401) on every request: the token was revoked. Set up again
  with https://mypages.page/start.
- `too_large` (413), `invalid_upload` (422): smaller upload, or remove the
  files named in the message. Executables and server scripts (.exe, .php, .py,
  .sh, …) are never accepted.
- `content_rejected` (422): the content review found phishing, fraud,
  malware or other content the terms don't allow. Don't retry or rework the
  page to get past it; tell the user.
- `expired` (410), `not_found` (404), `unauthorized` (401) on PUT: see
  "Update the same link".
