Operating

Recipes

End-to-end CLI examples for CI pipelines, local operating, and agent runners

Concrete patterns for the three audiences the CLI is built for.

CI pipelines

GitHub Actions: draft a release campaign

Use nitrosend mcp tools call to create a reviewed campaign draft after a deploy. --machine gives stable JSON, exit codes, and an auto-issued idempotency key.

name: Draft release campaign
on:
  release:
    types: [published]

jobs:
  notify:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/setup-node@v4
        with:
          node-version: '20'
      - run: npm install -g @nitrosend/cli
      - name: Draft release email
        env:
          NITROSEND_API_KEY: ${{ secrets.NITROSEND_API_KEY }}
        run: |
          nitrosend mcp tools call nitro_compose_campaign --machine --args "$(cat <<EOF
          {
            "name": "Release ${{ github.event.release.tag_name }}",
            "channel": "email",
            "subject": "Release ${{ github.event.release.tag_name }}",
            "body": "Release notes are live: ${{ github.event.release.html_url }}",
            "idempotency_key": "release-${{ github.event.release.id }}"
          }
          EOF
          )"

The idempotency_key inside --args is what the platform dedupes against — set it from a stable, retry-survivable value like the release ID so a re-run of the job won't create duplicate drafts. Branch on exit codes for retry strategy: 75 retriable, 77 means rotate the API key, 78 means upgrade the CLI step.

Daily account health check

Run the dashboard read, fail the job on blockers:

#!/usr/bin/env bash
set -euo pipefail

result=$(nitrosend --machine)
blockers=$(echo "$result" | jq -r '.sidecars.blockers // [] | length')

if [ "$blockers" -gt 0 ]; then
  echo "$result" | jq '.sidecars.blockers'
  exit 1
fi

Local operating

Quick status snapshot

Three commands cover most "what's the state of my account" questions:

nitrosend                              # account state, blockers, next_action
nitrosend mcp resources read nitro://account
nitrosend mcp tools call nitro_get_insights --args '{"scope":"account"}'

Move from another email platform

Bring the old platform's opt-outs across before anything else. Export three files from it: people who unsubscribed, addresses that bounced, and people who marked your email as spam. If an export mixes them, as Klaviyo's suppressed profiles file does, split it by reason; anything suppressed for another reason goes in with the bounced file. Remove any phone columns, then import them in the app under Contacts, then Import, choosing Unsubscribe all from marketing for the unsubscribed file and Block all email delivery for the bounced and spam complaint files. nitrosend contacts import has neither option, so don't use it for these files. When those imports have finished, move the contacts:

  • Mailchimp, ActiveCampaign or Shopify: connect it and let it sync.
  • Klaviyo, Brevo, MailerLite, HubSpot or anything else: import a CSV file of only the people who subscribed to email marketing, one file per list plus one for subscribers on no list, with phone columns removed and any status or consent column kept. nitrosend contacts import <file> --list-id <id> works for these files. From HubSpot, export only the contacts who agreed to marketing email, and upload that file under Contacts, then Import, because HubSpot's import options offer only a sync.

nitrosend migrate <platform> opens the import options for the platform you're leaving, for the brand your CLI profile uses. For a platform migrate sources doesn't list, run nitrosend migrate on its own and choose Upload a file. You pick the route and finish it in the browser, so the old platform's login never passes through the terminal. migrate and connect need CLI 0.3.13 or later; nitrosend version shows yours and nitrosend update says how to upgrade.

See the provider catalog for CLI names and the import, sync, and connection options each provider supports.

nitrosend migrate sources                # the import and sync methods this brand has
nitrosend migrate mailchimp              # open the import options for Mailchimp
nitrosend migrate klaviyo --no-browser   # print the link instead of opening it
nitrosend connect activecampaign         # open the ActiveCampaign connection directly

Check subscription status in Contacts before your first send. While the old platform is still in use, export its unsubscribes, bounces and complaints again and import them before every send. The migration FAQ covers what carries over and how to move a big list.

Using an agent? Add the steps as a skill: npx skills add nitrosend/claude --skill klaviyo-migration. For Mailchimp use mailchimp-migration, and for any other platform email-platform-migration.

Pipe campaign results into a spreadsheet

nitrosend mcp tools call nitro_query \
  --args '{"resource":"campaigns","page":1,"per_page":100}' \
  --csv > campaigns.csv

CSV mode is table-only — no envelope, no sidecars. Use it when you want raw rows.

Purchase a plan or add prepaid funds

The Nitrosend CLI invokes nitro_manage_billing over MCP directly. No payment-specific CLI or external runtime sits between the command and Nitrosend.

# Inspect account route, plan, and prepaid balance
nitrosend mcp tools call nitro_manage_billing --machine \
  --args '{"operation":"status"}'

# List plans, then prepare owner-approved checkout
nitrosend mcp tools call nitro_manage_billing --machine \
  --args '{"operation":"plans"}'
nitrosend mcp tools call nitro_manage_billing --machine \
  --args '{"operation":"checkout","params":{"plan_id":2},"idempotency_key":"plan-pro-acme-2026-08-31"}'

# Or prepare a separate prepaid funding purchase
nitrosend mcp tools call nitro_manage_billing --machine \
  --args '{"operation":"add_funds","params":{"amount_cents":5000,"currency":"USD"},"idempotency_key":"fund-validation-acme-2026-08-31"}'

The command returns an approval URL and purchase ID when provider approval is needed. The account owner completes Checkout in a browser. Poll checkout_status until the plan is active, or funding_purchase_status until funds are credited.

See Payments for agents for complete commands, Link and Stripe CLI terminology, and recovery rules.

Replay a recent command

nitrosend recent              # show the last 10 commands
nitrosend redo 1 --explain    # show what `redo 1` would run, without running

recent and redo are local-only — they never call the API and they redact obvious secrets in their stored history.

Tab completion

# bash
nitrosend completion bash >> ~/.bashrc

# zsh
nitrosend completion zsh > ~/.config/zsh/completions/_nitrosend

# fish
nitrosend completion fish > ~/.config/fish/completions/nitrosend.fish

Agent runners

Plan, then act

Use --explain to get a deterministic plan before deciding to execute. The plan is the same envelope shape as a real run, with would_execute: false.

plan=$(nitrosend mcp tools call nitro_compose_campaign \
  --args "$(cat brief.json)" --explain --machine)

# Inspect the plan, decide, then run for real
echo "$plan" | jq '.data'

if [ "$(echo "$plan" | jq -r '.data.would_execute')" = "false" ]; then
  nitrosend mcp tools call nitro_compose_campaign \
    --args "$(cat brief.json)" --machine
fi

Discover the contract before calling

Cache the descriptor at startup. Don't guess flags.

nitrosend describe mcp tools call --json | jq '.input_schema'

The descriptor includes safety class, dry-run support, idempotency policy, and an agent.suitable flag. Skip any command marked suitable: false from an autonomous runner.

Approval handoff

When an agent needs human sign-off mid-run, hand off to approve / reject and pause. The CLI exposes these as stable stubs today and will gain an SSE waiter endpoint in a future release.

# Agent emits a token, then waits.
nitrosend approve $TOKEN   # human runs this
nitrosend reject  $TOKEN   # or this

Read sidecars for next-action loops

Don't write your own "what should I do next" logic. The platform already returns one. Read sidecars.next_action and sidecars.suggested_tool_calls and let it drive the loop.

result=$(nitrosend mcp tools call nitro_get_status --machine)
next=$(echo "$result" | jq -r '.sidecars.next_action // empty')
[ -n "$next" ] && echo "Next: $next"

See also