Create pastes from the command line
When the thing you want to share is already in a terminal — a failing test, a log excerpt, a curl response — the fastest path is to pipe it into a paste and get a URL back. The CLI does exactly that, with no dependencies beyond Node itself.
Install
- Get Plus (API keys are the paid feature), sign in, open your dashboard, and add a key with the
createpermission. Copy it once — it is never shown again. - Download the script and make it executable:
POSIX shell, macOS or Linux
mkdir -p ~/bin
curl -fsSL https://pastesite.com/cli/pts.mjs -o ~/bin/pts
chmod +x ~/bin/pts
# ~/bin is usually already on PATH; if not, add it:
echo 'export PATH="$HOME/bin:$PATH"' >> ~/.bashrc
On Windows, run it with node pts.mjs from Git Bash, PowerShell or WSL. There is no npm package to install.
Set the key
Once per shell, or put it in your shell profile
export PASTESITE_KEY="ps_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
The key is read from the environment, never from a command-line flag, so it does not end up in your shell history or in ps output.
Examples
Common invocations
# pipe a command's output
npm test 2>&1 | pts -t "failing test" -l bash
# a file, unlisted, deleted in a day
pts -t "app.log" -l plaintext -u -x 1440 ./app.log
# a one-time build token: burn it after the first read
printf 'build-token-%s' "$(date +%s)" | pts -t "build token" -u -b
# print only the URL, for scripts
URL=$(git diff | pts -l diff -r)
echo "$URL"
| Flag | Meaning |
|---|---|
-t, --title | Title, up to 200 characters |
-l, --language | Language id, e.g. bash, json, diff |
-u, --unlisted | Keep it out of Recent and Trending |
-x, --expires | Expiry in minutes (10 to 525600) |
-p, --password | Password-protect the paste |
-b, --burn | Delete on first read |
-s, --slug | Custom URL, 3–30 lowercase characters |
-r, --raw | Print only the raw URL |
--api | Override the API base (for testing or self-hosting) |
A password is access control, not encryption. The service can still read a password-protected paste, and the CLI does not encrypt. Never pipe a credential, private key or .env file through it. For a secret, create the paste in the browser with Encrypt in this browser on — that mode is the one the server cannot read.
Reading a paste back
Every paste has a raw URL that returns text/plain, which is what you want in a pipeline:
No CLI needed for reading
curl -s https://pastesite.com/raw/AbC123xYz9 | less
curl -s https://pastesite.com/raw/AbC123xYz9 > restored.log
Exit codes: 0 on success, 1 on a network or API error, 2 on bad arguments. Errors go to stderr so they can be logged without polluting the URL on stdout.
Curl, if you would rather not install anything
The one request the CLI makes
curl -sS https://pastesite.com/api/pastes \
-H "Authorization: Bearer $PASTESITE_KEY" \
-H "Content-Type: application/json" \
--data-binary @- <<JSON
{"content":"hello from curl","language":"plaintext","visibility":"unlisted","title":"curl test"}
JSON
The full request and response schema, including error codes, is in the API guide.
Frequently asked questions
Do I need an account for the CLI?
Yes, and a Plus subscription: API keys are the paid feature because they bypass the browser captcha for scripts. Creating pastes in the browser still needs no account, and reading a paste needs no key — /raw/<id> is plain text.
Which permissions does the key need?
Only create for this CLI. Add read or manage only if the same key also reads or edits your pastes.
Is there an npm package?
No. The script is a single file served from this site, so there is nothing to install and nothing to keep updated.
Can the CLI read or delete pastes?
It creates pastes. Reading is a plain curl against /raw/<id>, and deleting is a DELETE request to /api/pastes/<id> with a manage key.