CLI
The dependency-free command line, available to repository collaborators.
CLI
Available to repository collaborators for now. Git asks others to sign in; use the curl quick start if you do not have access.
The CLI has no dependencies and runs from a clone of the repository with Node.js 22.18 or later (23.6 or later on the 23 line), through Node's built-in TypeScript type stripping. There is nothing to install or build.
git clone 'https://github.com/theGlenn/instahost'
cd instahost
export INSTAHOST_API_URL='https://instahost.dev'
node packages/cli/bin/instahost.mjs share ./report.pdf
node packages/cli/bin/instahost.mjs share ./data.json --access private --ttl 1h --json
node packages/cli/bin/instahost.mjs publish ./dist --ttl 7d --json
node packages/cli/bin/instahost.mjs delete <id or URL> --token ihd_...The npm package named belongs to someone else and is unrelated to this project: do not install it or run it through npm or npx. This CLI is distributed only through the repository.
CLI reference
node packages/cli/bin/instahost.mjs share <file> [--ttl 24h] [--access unlisted|public|private] [--name <filename>] [--content-type <type>]
node packages/cli/bin/instahost.mjs publish <dir> [--ttl 24h] [--access unlisted|public] [--include-dotfiles] [--concurrency 6]
node packages/cli/bin/instahost.mjs delete <id|url> [--token <ihd_...>]Options
| Option | Commands | Meaning |
|---|---|---|
| all | Print exactly one JSON document on stdout, for every outcome. Nothing else is printed unless . |
| all | The API origin; else , else the CLI's built-in default. only, or for , and . |
| all | An API key (); else . Longer lifetimes, , higher limits. The CLI then also uses the key, not the delete token, for the uploads and of the artifacts it creates (so they count against the key's rate limits), and the key deletes the artifacts it owns. |
| all | Diagnostics on stderr, with tokens and URL signatures masked. |
, | all | Usage. With : . |
| all | The CLI version. With : . |
| share, publish | A number with , , or (, , ), plain seconds, or (persistent; needs an API key). Default: the service's 1 day. |
| share, publish | (default), , or (share only; is a usage error). |
| share | The name to share the file under (no ); the default is the file's own name. |
| share | Declares the media type instead of deriving it from the extension. |
| publish | Also publish dot-prefixed files and directories. Credentials, VCS data and OS metadata stay excluded. |
| publish | Parallel uploads, 1 to 16 (default 6). |
| delete | The artifact's delete token. |
An option given to a command it does not belong to is a usage error (exit 2). takes an artifact id or any of its URLs (a file URL, or a site URL in either mode). Its credential is the first of: , , , . Flags come before the environment; the environment keeps the token out of the process list.
What share and publish refuse or skip
refuses symbolic links, directories, names that look like credentials (the shared name and the real file's name), and any file whose real path goes through a credential or VCS directory (share ,.ssh ,.git , …)..aws refuses a directory inside such a directory, and one without a rootpublish . It walks the directory without following symbolic links and skips, listing each underindex.html with its reason:skipped (credential and VCS names, always),sensitive (os_metadata ,.DS_Store ,Thumbs.db ,desktop.ini ,._* ),__MACOSX/ (dot-prefixed paths exceptdotfile , unless.well-known ),--include-dotfiles andsymlink (sockets, FIFOs, devices). A skipped directory is listed once with a trailingspecial ./ - Both refuse a file that changes between hashing and upload (
).file_changed
Output
Without , the result goes to stdout (URL, access URL, expiry and the delete command) and skipped files, warnings and errors to stderr; progress is shown only when stderr is a terminal. Control and bidirectional-text characters from file names and server messages are shown as .
With , share and publish print:
{"ok": true, "id": "...", "type": "site", "access": "unlisted", "url": "https://<id>.instahost.cloud/",
"expires_at": "2026-11-29T10:00:00Z", "delete_token": "ihd_...", "access_token": null, "access_url": null,
"file_count": 12, "total_bytes": 482113,
"skipped": [{"path": ".git/", "reason": "sensitive"}],
"warnings": [{"code": "root_absolute_reference", "message": "...", "paths": ["index.html"]}]} and are set for private files. is a list of ; the CLI emits only when the site's URL has a path (path mode). prints ( is , with , for an artifact the operator took down).
Every failure prints one document:
{"ok": false, "error": {"code": "quota_exceeded", "message": "...", "details": {"scope": "client", "resets_at": "..."}, "exit_code": 6}} is the API's error code, or one of the CLI's own codes below. When a failure happens after the artifact was created (during the uploads or ), holds , unmasked, because the artifact may exist and its delete token is the only way to remove it.
Exit codes
| Exit | Meaning |
|---|---|
| 0 | Success. |
| 1 | Internal error in the CLI (, ). |
| 2 | Usage: unknown command or option, bad value, missing API URL or credential, unsupported Node.js version. |
| 3 | Local input refused before any request: , , , , , , , , , , , (over 10,000 files); also . |
| 4 | Authentication or authorization: HTTP 401 or 403. |
| 5 | Rejected by the server: 400, 413, 415, 422 and other 4xx not listed here. |
| 6 | Rate limited or over quota: HTTP 429. carries . |
| 7 | Network or server failure: 5xx, connection errors, storage refusing an upload after retries (), malformed answers (), or an unsafe URL from the server (). |
| 8 | Publication failed: during uploads or , a 409, 410 or 422 (, after the retries, , , …). |
| 9 | Not found: HTTP 404. |
Retries and safety
- Each file upload is retried up to 3 times (after 1, 2 and 4 s) on network errors, 429 and 5xx.
means already uploaded. A412 , usually an expired URL, gets a fresh URL once per file. URLs close to expiry are refreshed before use.403 re-uploads what is missing, with at most 3upload_incomplete calls.complete ,/uploads andcomplete are retried 3 times on network errors and 502, 503 and 504, and afterdelete (up to 60 s) onRetry-After . Create is never retried, so a quota is never charged twice.429 rate_limited - Credentials are sent only to the API origin. Upload URLs must be
(plainhttps only for a local development server), and thehttp anduploads_url the API returns must be on its own origin. Redirects are refused.complete_url