LoyumiDeveloper docsOpen Sandbox
COMMAND LINE · 1.5.1

Run loyalty work without memorizing the API.

Set up one project, prove a persisted official-origin Sandbox loop, manage value, search audit evidence, operate webhooks, pull an export, or produce a widget embed.

Public guide · no accountNode.js 20+ · Sandbox firstCLI 1.5.1 · current API 1.13.0

Pin the stable release before you automate it.

The package name is @loyumi/cli, version 1.5.1, and the executable is loyumi. Add it to each project and run it through npx so every teammate and CI job uses the reviewed version.

Install the stable download
npm install --save-dev https://docs.loyumi.com/downloads/loyumi-cli-1.5.1.tgz
npx loyumi --version
Verify the download66,971 bytesSHA-256 146a0a459b4210c275381bedb379242df175685f5439a11ad1c0d57ec5d09146
01

Node.js 20 or newer
Check with node --version.

02

Sandbox credentials to call the API
The guide is public; operating on an environment requires an environment ID and scoped API key.

Four commands. One safe project check.

  1. 1

    Put the key in your shell

    Use a Sandbox key. The CLI reads it from an environment variable and never writes it into project configuration.

  2. 2

    Run guided setup

    loyumi init asks only for missing project settings and writes .loyumi/config.json.

  3. 3

    Let doctor inspect the setup

    loyumi doctor validates the project config and API version, checks the referenced credential, and confirms API connectivity without sending a real customer record. Add --offline to skip the network check.

  4. 4

    Review the safe view

    loyumi config show displays effective project settings and recursively replaces secret-like values with [REDACTED].

Guided Sandbox setup
export LOYUMI_API_KEY="<sandbox-api-key>"
npx loyumi init
npx loyumi doctor
npx loyumi config show

Prove one real loop against your official Loyumi Sandbox.

quickstart proof is an opt-in, state-changing command. It accepts only https://app.loyumi.com/api/v1, rejects redirects, and does not use a local sample server, fixture response, or mock fallback. Run it only in a Sandbox where synthetic test data is allowed.

Create and verify synthetic Sandbox evidence
npx loyumi quickstart proof \
  --program "$PUBLISHED_SANDBOX_PROGRAM_ID" \
  --json \
  --non-interactive
01

Fail closed on context
The command pins the official API, reads authoritative export context, and continues only when the exact configured environment is active and reports sandbox. Production-identifying and non-official targets are refused before client construction.

02

Persist unmistakably synthetic data
It creates or safely reuses a deterministic member without email or phone, records explicit synthetic consent, and posts one labeled purchase twice with the same idempotency key.

03

Reconcile the readback
It requires one exact committed transaction, a balanced member-credit and treasury-debit ledger, and no second value change after the replay.

04

Keep the proof bounded
The result carries member, consent, request, transaction, ledger-entry, and payload-fingerprint IDs without printing or storing the API key.

Required credential scopes are exports:read, programs:read, members:read, members:write, events:write, and transactions:read. An existing published Sandbox program with an earn rule is also required. Reruns with the same program and optional --proof-id reuse the same synthetic identity and transaction; use a new proof ID before changing --amount-minor or --notice-version.

Easy defaults, with every important control available.

Interactive terminals receive a prompt for a missing environment ID. Scripts and non-interactive terminals do not. Supply required values with flags when a person cannot answer.

Non-interactive init
npx loyumi init \
  --environment "$LOYUMI_ENVIRONMENT_ID" \
  --api-key-env LOYUMI_API_KEY \
  --timeout-ms 10000 \
  --retries 2 \
  --non-interactive
Inspection commands
npx loyumi doctor [--config <path>] [--offline] [--json]
npx loyumi config show [--config <path>] [--json]
--environment <id>

Selects the exact Sandbox or production environment.

--base-url <url>

Overrides the API base URL. HTTPS is required except for localhost or 127.0.0.1 development.

--api-key-env <name>

Stores only the name of the environment variable. The default is LOYUMI_API_KEY.

--timeout-ms <ms>

Accepts an integer from 1 through 120,000 milliseconds.

--retries <0-5>

Controls retries only for operations the SDK marks safe to retry.

--config <path>

Uses an explicit config file instead of searching from the current folder through its parents.

--trust-origin <origin>

Approves one exact non-default API origin for this invocation only. The value is never persisted.

--trust-api-key-env <name>

Approves one exact non-default credential variable for this invocation only. --non-interactive does not grant trust.

--force

Allows init to replace an existing config after you deliberately request it.

Resolution is predictable: --config <path> wins; otherwise the CLI searches from the current folder through its parents for the nearest .loyumi/config.json. Official defaults use https://app.loyumi.com and LOYUMI_API_KEY. Custom deployments must repeat the exact --trust-origin and/or --trust-api-key-env value on every credential-using command, including CI; trust is never saved. Change environment, URL, timeout, or retries by running init deliberately, rather than through a hidden runtime override.

Every command accepts --config, --json, --non-interactive, and --help; loyumi --version prints the installed CLI version. --non-interactive matters to init, the only command that can prompt.

Create identity, then govern each program membership explicitly.

Use your own stable customer ID. Values in angle brackets below are placeholders to replace, not sample merchant or customer records.

List safely

Filter by member status, external ID, or email and follow the opaque cursor. --limit accepts 1 through 200; copy --cursor from the prior response without decoding it.

List members
npx loyumi members list   --status active   --limit 50

1 · Create identity

--name and --external-id are required. This command does not enroll a program. Optional identity fields include --email, --phone, --consent, --notice-version, and --request-id.

Create member identity
npx loyumi members create \
  --external-id "$CUSTOMER_ID" \
  --name "$DISPLAY_NAME" \
  --consent opted_in \
  --notice-version "$IDENTITY_NOTICE_VERSION"

2 · Enroll, or leave at zero

members enroll fixes consent to opted_in and requires the actual notice version, a nonempty JSON evidence object, and a stable key. members unenroll requires a reason, evidence, zero available/pending/reserved balances, and no open reservation. It retains ledger and audit history and remains corrective while Production is locked.

Explicit program membership
npx loyumi members enroll \
  --external-id "$CUSTOMER_ID" \
  --program "$PROGRAM_ID" \
  --notice-version "$REWARDS_NOTICE_VERSION" \
  --evidence '{"source":"<consent-capture-channel>"}' \
  --idempotency-key "$ENROLLMENT_KEY"

npx loyumi members unenroll \
  --external-id "$CUSTOMER_ID" \
  --program "$PROGRAM_ID" \
  --reason "$APPROVED_WITHDRAWAL_REASON" \
  --evidence '{"source":"<withdrawal-channel>"}' \
  --idempotency-key "$UNENROLLMENT_KEY"

Read or update

Both commands use --external-id. Update only the fields you intend to change with --name, --email, --phone, --status, --consent, or --notice-version. Use --clear-email or --clear-phone instead of inventing an empty value. Supported status values are active, suspended, and closed; consent accepts unknown, opted_in, or opted_out.

Read and update
npx loyumi members get --external-id "$CUSTOMER_ID"

npx loyumi members update \
  --external-id "$CUSTOMER_ID" \
  --name "$UPDATED_DISPLAY_NAME" \
  --request-id "$TRACE_ID"

For a reviewed JSON request body, use exactly one of --file <path> or --stdin with members create or members update. This also keeps email addresses and phone numbers out of shell history. Add --dry-run to validate and display the redacted request without sending it.

Govern a privacy deletion

members delete requires the dedicated members:delete scope and an idempotency key derived from the verified privacy case. It tombstones the member profile, scrubs known structured identifier copies, and governance-scrubs stored idempotency receipt response snapshots that contain those identifiers while preserving the receipt's operation identity. Governed ledger, transaction, consent, and audit records remain explainable, while merchant-supplied references or evidence remain subject to the merchant's approved retention policy. Do not describe this as guaranteed global de-identification of arbitrary merchant-authored text.

Anonymize a verified member
npx loyumi members delete   --external-id <external-customer-id>   --deletion-reference <verified-privacy-case-id>   --reason "<approved-erasure-reason>"

Move exact business facts in; pull governed data out.

Award a completed purchase

Amounts use positive integer minor units. events earn uses --source as the default idempotency key; use --idempotency-key only when your stable business-event identity needs a different value. --channel defaults to web and also accepts store or app. Optional flags are --coupon, --request-id, and --dry-run.

Earn event
npx loyumi events earn \
  --program "$PROGRAM_ID" \
  --external-id "$CUSTOMER_ID" \
  --amount-minor "$ORDER_AMOUNT_MINOR" \
  --channel web \
  --source "$ORDER_ID"

Send a registered engagement event

The event type must already exist in the selected environment. --source is also the default idempotency key. Optional flags are --occurred-at <ISO>, --attributes <JSON object>, --idempotency-key, --request-id, and --dry-run. Use exactly one of --file or --stdin to supply the complete JSON body.

Custom event
npx loyumi events send \
  --type "$REGISTERED_EVENT_TYPE" \
  --external-id "$CUSTOMER_ID" \
  --source "$SOURCE_ID"

Send normalized commerce and item-selected returns

Use a reviewed JSON file when the purchase includes line references, currency, store, market, tax, discounts, shipping, tender, customer tags, or other normalized context. For an item-selected return, identify the original lineReference and returned quantity; Loyumi derives and verifies the attributable amount and points. The purchase source reference and return reference become their default idempotency keys.

Normalized purchase and return files
npx loyumi events earn --file ./reviewed-purchase.json
npx loyumi events return --file ./reviewed-return.json

Pull a portable exit bundle

The default command writes the complete API response to the selected file. For pagination, use --collection <name>, then pass the returned cursor with --after <cursor>. --limit accepts 1 through 5,000. Existing files require --force.

Portable export
npx loyumi exports pull \
  --output ./loyumi-portability-export.json
Review the portability export JSON Schema →

The CLI covers the critical governed-value control paths.

The stable downloadable @loyumi/cli 1.5.1 package includes redemption, two-person adjustment, program-configuration, exact ledger-close, and read-only list operations. These commands call the public API; they do not weaken credential scopes, readiness gates, or approval rules.

Find governed value
npx loyumi redemptions list --program <program-id> --state reserved
npx loyumi adjustments list --state pending_approval

Quote, reserve, then decide

Create an immutable quote, reserve its exact point lots and reward inventory, then commit or release the reservation. Use the same stable idempotency key when retrying a mutation with an identical body.

Governed redemption
npx loyumi redemptions quote   --program <program-id>   --external-id <external-customer-id>   --source <stable-cart-reference>   --reward <reward-id>

npx loyumi redemptions reserve   --quote <quote-id>   --idempotency-key <stable-reservation-key>

npx loyumi redemptions commit   --redemption <redemption-id>   --provider <fulfillment-connector-name>

Keep adjustment approval separate

Request the adjustment with an evidence file, then approve it through a credential bound to a different immutable stable human or service principal. Another key bound to the requester's same principal is rejected. Legacy credentials without a stable principal fail closed until rotated; reversal scopes remain separate and should be off by default.

Two-person adjustment
npx loyumi adjustments request   --file <reviewed-adjustment.json>   --idempotency-key <stable-case-id>

npx loyumi adjustments approve   --adjustment <adjustment-id>   --approval-reference <approval-case-id>   --note "<recorded-decision>"

Deploy program configuration as code

Validate a complete manifest, create a revision under an exact ETag, and publish that immutable version only after the required evidence and approval are present. One program version supports up to 16 active tier definitions. A program may also have up to 16 choice-benefit sets effective at the same instant; schedules use [startsAt, endsAt), so adjacent or otherwise non-overlapping sets do not count together.

Versioned program manifest
npx loyumi programs validate --file <program-manifest.json>
npx loyumi programs revision-create   --program <program-id>   --file <program-manifest.json>   --if-match '<current-etag>'   --idempotency-key <stable-revision-id>
npx loyumi programs revision-publish   --program <program-id>   --version <revision-number>   --if-match '<current-etag>'   --idempotency-key <stable-publish-id>

Stage first. Inspect every exception. Apply in resumable chunks.

Use the import lifecycle for member opening balances. Staging validates up to 5,000 records without changing a balance. Status exposes accepted rows and row-level exceptions. Apply creates only missing members in bounded, idempotent chunks and never overwrites an existing member.

List import operations
npx loyumi imports list --program <program-id> --status exceptions_review
Stage, inspect, and apply
npx loyumi imports stage \
  --program "$PROGRAM_ID" \
  --file ./members-opening-balances.json \
  --idempotency-key "$IMPORT_BATCH_KEY"

npx loyumi imports status \
  --batch "$IMPORT_BATCH_ID" \
  --status exception

npx loyumi imports apply \
  --batch "$IMPORT_BATCH_ID" \
  --limit 100 \
  --idempotency-key "$IMPORT_APPLY_KEY"
  1. 1

    Prepare the governed file

    Use schemaVersion: "loyumi.members/v1" and a records array. Keep the file out of source control because it contains customer and balance data.

  2. 2

    Stage without mutation

    The service validates the complete batch and binds its checksum to the idempotency key. A redacted dry run is available before sending.

  3. 3

    Resolve exceptions

    Inspect exception rows before applying. Correct the source file and stage a new batch instead of hiding invalid data.

  4. 4

    Apply a bounded chunk

    Repeat apply with a new stable chunk key until the batch reports completion. The batch cursor makes interrupted work resumable.

Investigate real value without opening the console.

These 1.5.1 commands expose the common back-office reads. Every list accepts --limit <1-200> and the opaque --cursor returned by the previous response. Never decode or edit a cursor.

Transactions and long-running work
npx loyumi transactions list   --program <program-id>   --from <ISO-timestamp>   --to <ISO-timestamp>

npx loyumi transactions get --transaction <transaction-id>
npx loyumi operations list --type <operation-type> --status <operation-status>
npx loyumi operations get --operation <operation-id>
Audit evidence and ledger summary
npx loyumi audit list   --target-type <target-type>   --target-id <target-id>

npx loyumi analytics ledger-summary   --program <program-id>   --from <ISO-timestamp>   --to <ISO-timestamp>

npx loyumi reports ledger-close   --program <program-id>   --from <ISO-timestamp>   --to <ISO-timestamp>   --request-id <close-run-id>

Create disabled. Save the secret. Activate. Test. Inspect. Retry.

Endpoint and delivery commands preserve the same public webhook lifecycle. Create and rotate reveal the signing secret only in the original result and print a reminder to save it immediately.

Create and activate
npx loyumi webhooks endpoints create   --url <public-https-endpoint>   --event points.earned   --event redemption.committed   --event adjustment.posted   --idempotency-key <stable-create-key>

# Save the one-time signing secret in your secret manager.
npx loyumi webhooks endpoints update   --endpoint <endpoint-id>   --status active   --idempotency-key <stable-activate-key>
Rotate, test, inspect, and retry
npx loyumi webhooks endpoints rotate   --endpoint <endpoint-id>   --idempotency-key <stable-rotation-key>

npx loyumi webhooks endpoints test   --endpoint <endpoint-id>   --idempotency-key <stable-test-key>

npx loyumi webhooks deliveries list   --endpoint <endpoint-id>   --status failed

npx loyumi webhooks deliveries retry   --delivery <delivery-id>   --idempotency-key <stable-retry-key>
Read endpoint configuration
npx loyumi webhooks endpoints list --limit 50
npx loyumi webhooks endpoints get --endpoint <endpoint-id>

Add --dry-run to create, update, rotate, test, or retry to validate and show a redacted request without sending it.

Generate the embed instead of hand-writing it.

Choose rewards for a Studio-composed experience, or balance, tier-progress, catalog, or activity for one focused surface.

Guest widget snippet
npx loyumi widgets snippet \
  --deployment "$LOYUMI_DEPLOYMENT_ID" \
  --component rewards
Personalized widget snippet
npx loyumi widgets snippet \
  --deployment "$LOYUMI_DEPLOYMENT_ID" \
  --component rewards \
  --session-endpoint /api/loyumi/widget-session \
  --fallback-url /account/rewards

Stable process behavior for people and pipelines.

Non-interactive examples
npx loyumi init \
  --environment "$LOYUMI_ENVIRONMENT_ID" \
  --non-interactive \
  --json

npx loyumi doctor --json
npx loyumi members get --external-id "$CUSTOMER_ID" --json
--jsonWrites exactly one JSON document to standard output. Machine-readable errors go to standard error. It does not show progress or prompt.
--non-interactiveApplies to init and fails instead of asking for a missing environment ID.
Non-TTY executionNever prompts. Supply every required value with flags, configuration, or environment variables.
--request-id <id>Available on API commands so a pipeline can carry its own trace identity.

Know what failed before retrying.

0

Success. The requested command completed.

1

Operational or API failure. Read the error, preserve any returned request ID, and retry only when the operation is safe.

2

Invalid usage or cancelled input. Run the same command with --help, then fix flags or provide the missing value.

4

Authentication is missing or rejected. Check the environment variable named by apiKeyEnv, its environment, scopes, expiry, and revocation status.

  1. 1

    Run npx loyumi doctor

    It validates the loaded config, API version, referenced credential, and connectivity. Use --offline to inspect local setup without an API request.

  2. 2

    Show the effective config safely

    Use npx loyumi config show. Secret-like fields are recursively replaced with [REDACTED].

  3. 3

    Ask the exact command

    Every command accepts --help. Use --version at the root before comparing behavior with these notes.

Upgrade deliberately, then run doctor again.

After an approved release
npm install --save-dev https://docs.loyumi.com/downloads/loyumi-cli-$APPROVED_LOYUMI_CLI_VERSION.tgz
npx loyumi --version
npx loyumi doctor

Read release notes, replace the pinned version only after the registry and notes agree, review configuration or command changes, then validate in Sandbox. Do not use an unreviewed @latest range in production CI.

CLI 1.5.1 is current

It writes API 1.11.0 project configuration and reads 1.6.0 through 1.10.0 configs. Public API 1.13.0 is broader; use SDK 2.3.0 or OpenAPI for full 121-operation coverage.

Secrets stay external

There is no browser login. Supply the key through the configured environment variable.

No shell completion yet

Use command-level --help for the exact options.

No telemetry

The CLI does not claim background usage collection.

Sandbox first

A stable client release does not bypass production readiness or merchant approval controls.

No assurance claim

Release stability does not claim an SLA or independent certification.