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
- Create an API key: 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 secret, password protected
cat .env | pts -t "env" -u -b -p "correct horse battery staple"
# 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) |
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. API keys are issued to signed-in accounts, because they bypass the browser captcha. Creating pastes in the browser still needs no account.
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.