CLI Commands
hapnd login
Section titled “hapnd login”Authenticate with the Hapnd API.
npx @hapnd/cli login <api-key>Validates the key against /auth/whoami, then stores it in ~/.hapnd/config.json. Exits with an error if the key is invalid or the API is unreachable.
hapnd logout
Section titled “hapnd logout”Clear stored credentials.
npx @hapnd/cli logouthapnd whoami
Section titled “hapnd whoami”Show current authentication status.
npx @hapnd/cli whoamiDisplays tenant name, masked API key, and whether the key came from the config file or HAPND_API_KEY environment variable. Exits with a warning if not authenticated.
hapnd init
Section titled “hapnd init”Create a hapnd.json configuration file in the current directory.
npx @hapnd/cli initnpx @hapnd/cli init --reducernpx @hapnd/cli init --projectionThe config file tells the CLI what kind of project this is. If you don’t use hapnd.json, the CLI auto-detects from your source code (looks for IReducer<T> or IProjection<T> implementations).
hapnd deploy
Section titled “hapnd deploy”Upload and compile a reducer or projection.
npx @hapnd/cli deploy [path] [--dry-run] [--wait]| Option | Description |
|---|---|
path | Directory to deploy from. Defaults to current directory. |
--dry-run | Validate the project without uploading. Shows what would be deployed. |
--wait | Wait for compilation to complete before returning. |
The CLI:
- Scans the directory for
.csfiles - Detects the project type from the
.csprojorhapnd.json - Determines whether it’s a reducer or projection (from interface implementations)
- Zips the source files
- Uploads to Hapnd
- Returns the deployment ID
Example output:
Scanning /Users/you/src/MyReducers...
Detected: Language: C# Kind: reducer Files: 3
Files to deploy: OrderReducer.cs OrderState.cs EventData.cs
✓ Deployed successfully ID: red_abc123def456 Status: compilingFor multi-reducer DLLs, all IReducer<T> implementations are discovered and auto-bound to their aggregate types on successful compilation.
hapnd bind
Section titled “hapnd bind”Bind a reducer to an aggregate type. This tells Hapnd to run the reducer on every event appended to aggregates of that type.
npx @hapnd/cli bind <aggregate-type> <reducer-id>Example:
npx @hapnd/cli bind order red_abc123def456Output:
✓ Reducer bound successfully Aggregate Type: order Reducer: red_abc123def456 Bound At: 2026-03-15T18:30:00.000ZBinding is typically automatic when deploying multi-reducer DLLs. Use this command to manually bind or rebind a reducer to a different aggregate type.
hapnd status
Section titled “hapnd status”Check the compilation status of a deployment.
npx @hapnd/cli status <id>Example:
npx @hapnd/cli status red_abc123def456Output for a successful compilation:
Deployment Status
ID: red_abc123def456 Status: compiled Kind: reducer Created: 2026-03-15T18:30:00.000Z Class: MyReducers.OrderReducer State: MyReducers.OrderState Compiled: 2026-03-15T18:30:05.000ZOutput for a failed compilation:
Deployment Status
ID: red_abc123def456 Status: failed Kind: reducer Created: 2026-03-15T18:30:00.000Z
Compilation Error: error CS0246: The type or namespace name 'HttpClient' could not be foundPossible statuses:
| Status | Meaning |
|---|---|
pending_compilation | Uploaded, waiting in the compilation queue |
compiling | Currently being compiled |
compiled | Successfully compiled and ready to use |
failed | Compilation failed — check the error output |