sendlayer-cli
v0.1.1
Published
Command-line interface for the SendLayer transactional email API
Downloads
572
Maintainers
Readme
sendlayer-cli
Command-line interface for the SendLayer transactional email API.
Send emails, manage webhooks, and tail delivery events from your terminal.
Install
npm (cross-platform)
npm install -g sendlayer-cliRequires Node.js 18 or newer. Verify it worked:
sendlayer --versionDirect download
Grab a standalone binary — no Node.js required — from the latest release:
| OS | Architecture | |---------|--------------| | Linux | x64, arm64 | | macOS | x64, arm64 | | Windows | x64 |
Authenticate
sendlayer login
# or set the env var, which every command reads:
export SENDLAYER_API_KEY=sl_xxx
# or non-interactive, reading the key from the environment:
sendlayer login --key "$SENDLAYER_API_KEY"Auth resolution: --api-key flag → SENDLAYER_API_KEY env → stored credentials.
Prefer the interactive prompt or the environment variable. A key passed on the
command line is visible in your shell history and to anyone who can run ps.
Check who you are:
sendlayer whoamiSend an email
sendlayer emails send \
--from "Paulie <[email protected]>" \
--to [email protected] \
--subject "Welcome" \
--text "Glad to have you."Use a JSON payload file for complex emails:
sendlayer emails send --file ./email.jsonWhere email.json is:
{
"from": { "email": "[email protected]", "name": "Paulie" },
"to": [{ "email": "[email protected]" }],
"subject": "Welcome",
"html": "<h1>Hi!</h1>",
"tags": ["onboarding"]
}Attachments, headers, and multiple recipients:
sendlayer emails send \
--from [email protected] \
--to [email protected],[email protected] \
--cc [email protected] \
--subject "Invoice" \
--html-file ./invoice.html \
--attachment ./invoice.pdf:application/pdf \
--header X-Campaign=Q2 \
--tag billingWebhooks
sendlayer webhooks list
sendlayer webhooks create --url https://example.com/hook --event bounce
sendlayer webhooks delete 42Local development with webhooks listen
Stream events to your terminal and forward them to a local HTTP server:
# in one terminal — expose your local port over a public URL
ngrok http 4000
# in another terminal
sendlayer webhooks listen \
--port 4000 \
--public-url https://abc.ngrok.io \
--forward-to http://localhost:3000/webhookNotes:
- The CLI registers one SendLayer webhook per event type (default: all six).
- On
Ctrl+Cit deletes every webhook it created. - If a previous run crashed, the next run will offer to clean up stale webhooks.
Events
sendlayer events list --event delivered --limit 50
sendlayer events list --start 2026-05-01 --end 2026-05-09
sendlayer events list --message-id <message-id>Output formats
Every command supports --json for machine-readable output, and auto-detects non-TTY (CI/pipes) to default to JSON.
sendlayer events list --json | jq '.Events[] | .Message.Headers.To'Configuration
Credentials are stored at:
- macOS / Linux:
$XDG_CONFIG_HOME/sendlayer/credentials.json(default~/.config/sendlayer/credentials.json) - Windows:
%APPDATA%\sendlayer\credentials.json
File mode is 0600. Multiple profiles supported via --profile <name>. The first
profile you save becomes the default, and any command run without --profile uses
it; sendlayer whoami shows which one is active.
Development
The CLI is written in TypeScript (src/**/*.ts). Two entrypoints:
bin/dev.js— runs the TypeScript sources directly via ts-node, no build step.bin/run.js— runs the compiled output indist/(what ships to users).
git clone https://github.com/SendLayer/sendlayer-cli
cd sendlayer-cli
npm install
# Run straight from TypeScript sources (fast inner loop):
./bin/dev.js whoami
npm run dev -- emails send --help
# Or build once and run the compiled CLI:
npm run build
./bin/run.js whoamiQuality checks (same as CI):
npm run lint # eslint over src/**/*.ts
npm run typecheck # tsc --noEmit
npm test # vitest
npm run build # tsc -> dist/ + oclif manifestBuild native binaries with Bun. npm install provides the pinned version:
npm run compile:binariesLicense
MIT
