Guides
in.mt from the command line
Shorten URLs and send one-time secrets from your terminal with curl and one small script. Secrets are encrypted on your machine, and the URL comes back ready to paste.
Set up once
- In your workspace, open API keys and create a key with write access. Copy it: it is shown once.
- Export it with the API address, then look up the key’s workspace id once (an API key belongs to one workspace).
- The examples use curl and jq; the secret script needs Node 20+, Bun or Python 3.10+.
export INMT_API="https://api.in.mt"
export INMT_API_KEY="<your-api-key>"
export INMT_WORKSPACE_ID="$(curl -s "$INMT_API/workspace/list" -H "x-api-key: $INMT_API_KEY" |
jq -r '.workspaces[0]._id')"
echo "$INMT_WORKSPACE_ID"Short URLs with curl
POST /url/create answers the new URL and publicUrl, the address to share. jq builds the body so quotes in a URL stay safe, and prints only the address.
jq -n --arg ws "$INMT_WORKSPACE_ID" \
'{workspaceId: $ws, type: "short", destinationUrl: "https://example.com/spring-sale"}' |
curl -s -X POST "$INMT_API/url/create" -d @- \
-H "x-api-key: $INMT_API_KEY" -H "content-type: application/json" |
jq -r .publicUrlurl=$(jq -n --arg ws "$INMT_WORKSPACE_ID" \
'{workspaceId: $ws, type: "short", destinationUrl: "https://example.com/spring-sale", slug: "spring"}' |
curl -s -X POST "$INMT_API/url/create" -d @- \
-H "x-api-key: $INMT_API_KEY" -H "content-type: application/json" |
jq -r .publicUrl)
echo "$url"
open "$url" # xdg-open on Linuxcurl -s "$INMT_API/url/list?workspaceId=$INMT_WORKSPACE_ID&type=short&limit=5" \
-H "x-api-key: $INMT_API_KEY" |
jq -r '.urls[] | "https://\(.domain)/\(.slug) \(.destinationUrl)"'Send a one-time secret from the terminal
The script below encrypts what you pipe in, exactly as the in.mt web app does in the browser, so in.mt never sees the text or the key. It prints the secret URL with the key after #; anyone with the whole URL can open it in a browser or with the same script. Save it as ~/.local/bin/secret-url and make it executable.
- Format: AES-256-GCM with a fresh random 32-byte key; the ciphertext is the 12-byte IV followed by the encrypted text and its tag, base64url without padding. The key, base64url, goes only after # in the URL.
- Options: --views 1 to 100 (default 1), --expires in seconds or 30m, 1h, 7d (1 minute to 30 days, default 7 days), --passphrase for a second secret the reader must type, --domain to use another of your domains.
- Up to 100,000 characters, as in the web app: a whole .env file, a private key or a long config.
#!/usr/bin/env node
// secret-url: send and read in.mt one-time secret URLs from the terminal. Node 20+ or Bun, no dependencies.
// The text is encrypted here with AES-256-GCM: only the ciphertext reaches the API, and the key lives only after # in the URL.
// cat .env | secret-url send --views 1 --expires 1h --passphrase "blue fox"
// secret-url read "https://in.mt/s/AbC123xYz789#<key>" --passphrase "blue fox" > .env
const api = (process.env.INMT_API ?? "https://api.in.mt").replace(/\/+$/, "");
const [command, ...args] = process.argv.slice(2);
const option = (name) => (args.includes("--" + name) ? args[args.indexOf("--" + name) + 1] : undefined);
const seconds = (value) => Number(value.replace(/^(\d+)([smhd])$/, (_, n, unit) => n * { s: 1, m: 60, h: 3600, d: 86400 }[unit]));
async function call(path, body, headers = {}) {
const response = await fetch(api + path, { method: body ? "POST" : "GET", headers: { "content-type": "application/json", ...headers }, body: body && JSON.stringify(body) });
const data = await response.json();
if (!response.ok) throw new Error((data.error ?? response.status) + ": " + (data.message ?? "request failed"));
return data;
}
async function send() {
const chunks = [];
for await (const chunk of process.stdin) chunks.push(chunk);
const plaintext = Buffer.concat(chunks).toString("utf8");
if (!plaintext) throw new Error("Nothing to send: pipe the secret in, e.g. cat .env | secret-url send");
const key = crypto.getRandomValues(new Uint8Array(32));
const iv = crypto.getRandomValues(new Uint8Array(12));
const aes = await crypto.subtle.importKey("raw", key, "AES-GCM", false, ["encrypt"]);
const sealed = await crypto.subtle.encrypt({ name: "AES-GCM", iv }, aes, new TextEncoder().encode(plaintext));
const { publicUrl } = await call(
"/url/create",
{
workspaceId: process.env.INMT_WORKSPACE_ID,
type: "secret",
ciphertext: Buffer.concat([iv, new Uint8Array(sealed)]).toString("base64url"),
maxViews: option("views") && Number(option("views")),
expiresInSeconds: option("expires") && seconds(option("expires")),
passphrase: option("passphrase"),
domain: option("domain"),
},
{ "x-api-key": process.env.INMT_API_KEY ?? "" },
);
console.log(publicUrl + "#" + Buffer.from(key).toString("base64url"));
}
async function read() {
const url = new URL(args.find((arg) => arg.includes("/s/")) ?? "");
const [domain, slug, key] = [url.hostname, url.pathname.split("/").pop(), url.hash.slice(1)];
if (key.length !== 43) throw new Error("This URL is missing its key: copy all of it, including the part after #.");
const details = await call("/visit/secret/details?" + new URLSearchParams({ domain, slug }));
if (!details.exists) throw new Error("This secret is gone: it was already viewed, it expired, or the URL is wrong.");
if (details.requiresPassphrase && !option("passphrase")) throw new Error("This secret needs its passphrase: add --passphrase.");
// A wrong passphrase answers like a missing secret, and uses no view.
const { ciphertext, viewsLeft } = await call("/visit/secret/reveal", { domain, slug, passphrase: option("passphrase") }).catch((error) => {
throw details.requiresPassphrase ? new Error("That passphrase is not right. Check with the sender and try again.") : error;
});
const payload = Buffer.from(ciphertext, "base64url");
const aes = await crypto.subtle.importKey("raw", Buffer.from(key, "base64url"), "AES-GCM", false, ["decrypt"]);
const plaintext = new TextDecoder().decode(await crypto.subtle.decrypt({ name: "AES-GCM", iv: payload.subarray(0, 12) }, aes, payload.subarray(12)));
// Exactly the text when piped to a file; a closing newline only on a terminal, so the prompt starts on its own line.
process.stdout.write(process.stdout.isTTY && !plaintext.endsWith("\n") ? plaintext + "\n" : plaintext);
console.error(viewsLeft === 0 ? "That was the last view: the secret is now deleted." : viewsLeft + (viewsLeft === 1 ? " view" : " views") + " left.");
}
const commands = { send, read };
if (!commands[command]) {
console.error("Usage: secret-url send [--views N] [--expires 1h] [--passphrase TEXT] [--domain HOST] < file\n secret-url read <secret URL> [--passphrase TEXT]");
process.exit(2);
}
commands[command]().catch((error) => {
console.error("secret-url: " + error.message);
process.exit(1);
});mkdir -p ~/.local/bin && $EDITOR ~/.local/bin/secret-url # paste the script, save
chmod +x ~/.local/bin/secret-url # ~/.local/bin must be on your PATH
cat .env | secret-url send --views 1 --expires 1h
secret-url send --passphrase "blue fox" --expires 30m < ~/.ssh/deploy_keyThe same in Python
Same commands and options, with the cryptography package. With uv, the script declares its own dependency; otherwise pip install cryptography first.
#!/usr/bin/env python3
# /// script
# dependencies = ["cryptography"]
# ///
"""secret_url.py: send and read in.mt one-time secret URLs from the terminal (Python 3.10+, cryptography).
The text is encrypted here with AES-256-GCM: only the ciphertext reaches the API, and the key lives only after # in the URL.
cat .env | uv run secret_url.py send --views 1 --expires 1h --passphrase "blue fox"
uv run secret_url.py read "https://in.mt/s/AbC123xYz789#<key>" --passphrase "blue fox" > .env
"""
import argparse, base64, json, os, re, secrets, sys, urllib.error, urllib.parse, urllib.request
from cryptography.hazmat.primitives.ciphers.aead import AESGCM
API = os.environ.get("INMT_API", "https://api.in.mt").rstrip("/")
def b64(data: bytes) -> str:
return base64.urlsafe_b64encode(data).rstrip(b"=").decode()
def unb64(text: str) -> bytes:
return base64.urlsafe_b64decode(text + "=" * (-len(text) % 4))
def seconds(value: str) -> int:
number, unit = re.fullmatch(r"(\d+)([smhd]?)", value).groups()
return int(number) * {"": 1, "s": 1, "m": 60, "h": 3600, "d": 86400}[unit]
def call(path: str, body: dict | None = None, headers: dict | None = None, not_found: str | None = None) -> dict:
data = json.dumps({k: v for k, v in body.items() if v is not None}).encode() if body is not None else None
request = urllib.request.Request(API + path, data=data, headers={"content-type": "application/json", **(headers or {})})
try:
with urllib.request.urlopen(request) as response:
return json.load(response)
except urllib.error.HTTPError as error:
if error.code == 404 and not_found:
sys.exit("secret_url.py: " + not_found)
answer = json.load(error)
sys.exit(f"secret_url.py: {answer.get('error', error.code)}: {answer.get('message', 'request failed')}")
def send(args: argparse.Namespace) -> None:
plaintext = sys.stdin.buffer.read()
if not plaintext:
sys.exit("secret_url.py: nothing to send: pipe the secret in, e.g. cat .env | secret_url.py send")
key, iv = secrets.token_bytes(32), secrets.token_bytes(12)
body = {
"workspaceId": os.environ.get("INMT_WORKSPACE_ID"),
"type": "secret",
"ciphertext": b64(iv + AESGCM(key).encrypt(iv, plaintext, None)),
"maxViews": args.views,
"expiresInSeconds": seconds(args.expires) if args.expires else None,
"passphrase": args.passphrase,
"domain": args.domain,
}
created = call("/url/create", body, {"x-api-key": os.environ.get("INMT_API_KEY", "")})
print(created["publicUrl"] + "#" + b64(key))
def read(args: argparse.Namespace) -> None:
url = urllib.parse.urlsplit(args.url)
domain, slug, key = url.hostname, url.path.rsplit("/", 1)[-1], url.fragment
if len(key) != 43:
sys.exit("secret_url.py: this URL is missing its key: copy all of it, including the part after #.")
details = call("/visit/secret/details?" + urllib.parse.urlencode({"domain": domain, "slug": slug}))
if not details["exists"]:
sys.exit("secret_url.py: this secret is gone: it was already viewed, it expired, or the URL is wrong.")
if details["requiresPassphrase"] and not args.passphrase:
sys.exit("secret_url.py: this secret needs its passphrase: add --passphrase.")
# A wrong passphrase answers like a missing secret, and uses no view.
wrong = "that passphrase is not right. Check with the sender and try again." if details["requiresPassphrase"] else None
revealed = call("/visit/secret/reveal", {"domain": domain, "slug": slug, "passphrase": args.passphrase}, not_found=wrong)
payload = unb64(revealed["ciphertext"])
sys.stdout.buffer.write(AESGCM(unb64(key)).decrypt(payload[:12], payload[12:], None))
left = revealed["viewsLeft"]
print("That was the last view: the secret is now deleted." if left == 0 else f"{left} {'view' if left == 1 else 'views'} left.", file=sys.stderr)
parser = argparse.ArgumentParser(prog="secret_url.py")
commands = parser.add_subparsers(dest="command", required=True)
send_parser = commands.add_parser("send", help="encrypt stdin and print the secret URL")
send_parser.add_argument("--views", type=int)
send_parser.add_argument("--expires", help="seconds, or 30m, 1h, 7d")
send_parser.add_argument("--passphrase")
send_parser.add_argument("--domain")
read_parser = commands.add_parser("read", help="reveal a secret URL and print its text (uses one view)")
read_parser.add_argument("url")
read_parser.add_argument("--passphrase")
parsed = parser.parse_args()
{"send": send, "read": read}[parsed.command](parsed)cat .env | uv run secret_url.py send --views 2 --expires 1d
uv run secret_url.py read "https://in.mt/s/AbC123xYz789#<key>" > .env
# without uv
pip install cryptography && cat .env | python3 secret_url.py sendRead a secret URL in the terminal
read takes the whole URL, checks that the secret is still there and whether it needs a passphrase, then reveals it and decrypts it on your machine. The text goes to stdout, so you can pipe it or write it to a file; how many views are left goes to stderr.
- Reading uses one view, as in the browser. On the last view the content is deleted for good.
- A wrong passphrase uses no view. A secret that is gone, expired or never existed answers the same way.
secret-url read "https://in.mt/s/AbC123xYz789#<key>"
secret-url read "$url" --passphrase "blue fox" > .env
open "$url" # or reveal it in the browser insteadShell functions
Paste these into ~/.zshrc or ~/.bashrc with your key and workspace id. urlshort needs only curl and jq; secret-send and secret-read call the secret-url script above.
# in.mt from the terminal: paste into ~/.zshrc or ~/.bashrc, then open a new terminal.
export INMT_API="https://api.in.mt"
export INMT_API_KEY="<your-api-key>"
export INMT_WORKSPACE_ID="<your-workspace-id>"
# urlshort <url> [slug]: creates a short URL and prints it.
urlshort() {
jq -n --arg ws "$INMT_WORKSPACE_ID" --arg url "$1" --arg slug "${2-}" \
'{workspaceId: $ws, type: "short", destinationUrl: $url} + (if $slug == "" then {} else {slug: $slug} end)' |
curl -sS -X POST "$INMT_API/url/create" -d @- \
-H "x-api-key: $INMT_API_KEY" -H "content-type: application/json" |
jq -r 'if .publicUrl then .publicUrl else ("urlshort: \(.error): \(.message)\n" | halt_error(1)) end'
}
# cat .env | secret-send [--views N] [--expires 1h] [--passphrase TEXT]: prints the secret URL with its #key.
secret-send() { secret-url send "$@"; }
# secret-read <secret URL> [--passphrase TEXT]: prints the text. Uses one view.
secret-read() { secret-url read "$@"; }urlshort https://example.com/spring-sale
urlshort https://example.com/spring-sale spring
open "$(urlshort https://example.com/docs)"
url=$(cat .env | secret-send --expires 1h)
echo "$url" | pbcopy # wl-copy or xclip on Linux
secret-read "$url" > .envLimits and errors
- Plan limits apply as in the app: short URLs and secrets per month count the same from the terminal.
- Over the rate limit the API answers 429 with Retry-After in seconds.
- Errors are { "error": "CODE", "message": "…" }; the script and urlshort print them and exit with status 1, for example SLUG_TAKEN or AUTHENTICATION_FAILED.
- A read key lists and reads; creating needs a write key.
AI agents
To let Claude, Cursor or another agent create and read URLs, connect it to the in.mt MCP server with the same API key. Its create_secret_url tool encrypts on the server; for text in.mt must never see, have the agent run secret-url instead.