---
name: htmlify-ai
description: >-
  Host a single-file, self-contained HTML document at a
  stable htmlify.ai URL, versioned by path and git commit
  and archived durably in cite.pub. One command: `curl -s
  https://htmlify.ai/SKILL.py | python3 - index.html --path
  tmp/slug/index.html` validates, logs in with the env
  credentials, uploads, and verifies. Backed by the
  TCAI_USERNAME/TCAI_PASSWORD trycopilot account.
---

# htmlify.ai

htmlify.ai stores demo-grade single-file HTML documents. Every upload is archived into cite.pub, the durable archive and short-code source: the returned short code resolves at both `https://htmlify.ai/<code>` and `https://cite.pub/<code>`.

## Quick start: upload one file

Run the served helper — `SKILL.py` validates the document,
logs in, uploads, and verifies in one command:

```sh
curl -s https://htmlify.ai/SKILL.py | python3 - index.html \
  --path tmp/2026-07-09-some-slug/index.gpt.html
```

It reads `TCAI_USERNAME` and `TCAI_PASSWORD` from the
environment (for example `set -a; . ~/my/.env; set +a`) and
resolves the commit from the current repository's HEAD; pass
`--commit <sha|HEAD>` and `--repo <dir>` to override, and
`--dry-run` to validate without uploading. Success prints JSON
with `canonical_url`, `short_code`, `cite_pub_url`, and
`bytes`.

Piping a remote script into `python3` runs remote code; to
inspect it first, `curl -sO https://htmlify.ai/SKILL.py` then
`python3 SKILL.py index.html --path <userpath>`. The raw API
the script uses is documented below.

## URLs

- Canonical: `https://htmlify.ai/<username>/<userpath>@<commit>` where `<commit>` is a 7-char git sha or `HEAD`. Omitting `@<commit>` serves HEAD (the newest upload for that path). `<username>` is `p13i` today.
- Short code: `https://htmlify.ai/<code>` (8 chars; the same code resolves at `https://cite.pub/<code>`).

## Auth (one-time setup)

Reading a public document needs no login; a private document answers only to its owner, admins, and accounts it has been shared with (see Visibility and sharing). Uploading requires a trycopilot.ai login. Provide `TCAI_USERNAME` and `TCAI_PASSWORD` via the environment or a gitignored `.env`.

The login is a first-party, CSRF-protected form, so a bare `POST /login/` carrying only the credentials is rejected with **403 before the password is checked**: the same-origin gate requires an `Origin` header equal to the auth origin plus the `login_intent` CSRF token bound to the session cookie from a prior `GET`. Do the two-step handshake (which `SKILL.py` performs for you):

```sh
# 1) GET the login page: keep the __Host-tc_login_session cookie and scrape
#    the hidden login_intent CSRF token (the two are paired).
page="$(curl -s -i https://auth.trycopilot.ai/login/)"
session="$(printf '%s' "$page" | grep -oiE 'set-cookie: *__Host-tc_login_session=[^;]*' | head -1 | sed -E 's/.*__Host-tc_login_session=//')"
intent="$(printf '%s' "$page" | grep -oE 'name="login_intent"[^>]*value="[^"]*"' | grep -oE 'value="[^"]*"' | sed -E 's/^value="//; s/"$//')"

# 2) POST the form with Origin + the session cookie + login_intent. The 302
#    sets auth_token. This POST can take 20-30s and is flaky under load; use a
#    >=90s timeout and retry.
auth_token="$(curl -s -i --max-time 90 \
  -H 'Origin: https://auth.trycopilot.ai' -H 'Sec-Fetch-Site: same-origin' \
  -H "Cookie: __Host-tc_login_session=$session" \
  --data-urlencode "login_intent=$intent" \
  --data-urlencode "email=$TCAI_USERNAME" \
  --data-urlencode "password=$TCAI_PASSWORD" \
  https://auth.trycopilot.ai/login/ \
  | grep -oiE 'set-cookie: *auth_token=[^;]*' | head -1 | sed -E 's/.*auth_token=//')"
```

Send the token on API calls as `Authorization: Bearer <auth_token>`.

## Upload

```sh
curl -s "https://htmlify.ai/upload/?path=tmp/2026-07-09-some-slug/index.gpt.html&commit=$(git rev-parse --short=7 HEAD)" \
  -H "Authorization: Bearer $TCAI_AUTH_TOKEN" \
  -H "Content-Type: text/html" \
  --data-binary @index.html
```

A successful upload returns HTTP 201 JSON with `canonical_url`, `short_code`, `cite_pub_url`, `bytes`, and `visibility`. Constraints: self-contained HTML only (inline CSS and JS, no external assets) — this also rejects any `src`/`href` pointing at `http(s)://` or `//`, including plain `<a>` hyperlinks, so write external URLs as plain text, not links; at most 4 MiB; and the body must open with an HTML doctype or `<html>` tag. Re-uploading the same path and commit appends a new version; the newest wins.

**Set `visibility` explicitly — the accepted values are `public` and `private`.** An upload query with no `visibility` currently defaults to **public**, so always pass `&visibility=private` (query) or a `private` `visibility` form field if the document must not be world-readable. `visibility=authenticated` is **not accepted by the current build**: it is rejected with a 400 (`registered collection payload is incompatible with this schema`) even though earlier revisions of this doc described it. A private document is still archived, but every URL for it, on htmlify.ai and on cite.pub, answers only to the owner, admins, shared accounts, and anyone holding a live share link: a browser is sent to the trycopilot.ai login and an API call without a session gets 403, while an account without access gets 404. The 201 response echoes the `visibility` that was stored, which is how a client confirms what it got.

## Visibility and sharing

Owners and admins manage access per short code. A grant names the other account by its trycopilot.ai login email; an unknown email is a 404 and creates nothing. Visibility can change in either direction at any time and the URLs stay the same.

```sh
curl -s -X POST "https://htmlify.ai/api/docs/share/<short_code>/visibility/" \
  -H "Authorization: Bearer $TCAI_AUTH_TOKEN" \
  --data-urlencode "visibility=private"
curl -s -X POST "https://htmlify.ai/api/docs/share/<short_code>/viewers/" \
  -H "Authorization: Bearer $TCAI_AUTH_TOKEN" \
  --data-urlencode "email=colleague@example.com"
curl -s -X DELETE "https://htmlify.ai/api/docs/share/<short_code>/viewers/?email=colleague@example.com" \
  -H "Authorization: Bearer $TCAI_AUTH_TOKEN"
```

The same controls are on `https://htmlify.ai/docs/share/<short_code>/` and from My Docs. `SKILL.py` takes `--visibility public` and a repeatable `--share EMAIL`.

A share link opens one document without an account. Mint one with `POST https://htmlify.ai/api/docs/share/<short_code>/links/`, optionally with `ttl_seconds` and `max_uses`; the response carries `link_token` and a ready `url`. Revoke it with `DELETE .../links/?link_token=<token>`. The token is the only secret involved: a short code already travels in this response, in the canonical URL, and in the archive filename.

Errors: 400 invalid path, commit, or bytes; 403 missing or invalid token (JSON); 413 oversized body.

## Fetch

```sh
curl -s https://htmlify.ai/p13i/tmp/2026-07-09-some-slug/index.gpt.html
curl -s "https://htmlify.ai/p13i/tmp/2026-07-09-some-slug/index.gpt.html@abc1234"
curl -s https://htmlify.ai/<short_code>
```

## Permanently delete

Delete one upload version by its UUID:

```sh
curl -s -X DELETE https://htmlify.ai/api/docs/version/<uuid>/ \
  -H "Authorization: Bearer $TCAI_AUTH_TOKEN"
```

Delete every owned upload version at one path:

```sh
curl -s -X DELETE \
  "https://htmlify.ai/api/docs/path/?path=tmp%2Fdemo%2Findex.html" \
  -H "Authorization: Bearer $TCAI_AUTH_TOKEN"
```

Both operations permanently remove the htmlify.ai rows,
their cite.pub archives, and live blob bytes. They cannot be
undone.
