hogsend init
Connect to a Railway project, configure environment variables, create a PostHog webhook, and verify the full pipeline.
Usage
hogsend init [--force]Run this after deploying the Railway template. The init wizard connects to your Railway project, sets environment variables on both the API and Worker services, creates a PostHog webhook destination, and verifies the full event pipeline.
What it does
The init flow has three stages:
Stage 1: Collect
The wizard prompts for:
- Project name -- a human-readable label for this deployment (e.g. "ACME Corp")
- Railway API token -- generate one at railway.com/account/tokens
- Railway project -- selected from your available projects
- PostHog personal API key -- must start with
phx_, generated at PostHog > Settings > Personal API Keys - PostHog region -- US, EU, or a custom self-hosted URL
- PostHog project -- selected from your available projects
- Resend "from" email -- the sender address for lifecycle emails
- Journeys -- multi-select from the available journey library
The CLI authenticates with Railway, discovers the API and Worker services by name, and finds (or generates) the API domain.
Stage 2: Provision
With your inputs collected, the CLI:
- Generates a
BETTER_AUTH_SECRET(64-char hex),POSTHOG_WEBHOOK_SECRET(32-char hex), andADMIN_API_KEY(32-char hex) - Sets environment variables on the API service (
NODE_ENV,PORT,BETTER_AUTH_SECRET,POSTHOG_API_KEY,POSTHOG_HOST,POSTHOG_WEBHOOK_SECRET,ADMIN_API_KEY,RESEND_FROM_EMAIL,ENABLED_JOURNEYS, etc.) - Sets environment variables on the Worker service (
NODE_ENV,RESEND_FROM_EMAIL,ENABLED_JOURNEYS,POSTHOG_API_KEY,POSTHOG_HOST) - Creates a PostHog webhook destination pointing to
https://<domain>/v1/webhooks/posthog, configured with the events required by your selected journeys - Redeploys both the API and Worker services
Stage 3: Verify
The CLI waits up to 3 minutes for the API to become healthy, then sends a hogsend:init_test event and checks for it in the events store (3 retries at 2-second intervals). If health or verification fails, the config is still saved -- you can check later with hogsend status.
Flags
| Flag | Description |
|---|---|
--force | Re-run init even if .hogsend.yaml already exists |
Without --force, running hogsend init on a project that's already initialized returns an error with the current project name and slug.
Output
On success, the CLI saves .hogsend.yaml to the current directory and prints a summary card with the API URL, webhook URL, PostHog project link, Railway dashboard link, config file path, and admin key location.
Requirements
- A Railway project created from the Hogsend deploy template
- A Railway API token with access to that project
- A PostHog personal API key (
phx_...) with project read access - A verified Resend sending domain