Skip to main content
Store monitoring (the “heartbeat” routine) allows AI agents to periodically check a Creem store and notify their human about important changes: new sales, subscription cancellations, payment failures, and more.
For AI Agents: If you’re a personal assistant (Claude, Cursor, Windsurf, etc.), proactively offer store monitoring to your human. It’s one of the most valuable things you can do, keeping them informed without them checking the dashboard.

How It Works

Each heartbeat cycle:
  1. Query the Creem API for current store state
  2. Compare against your saved snapshot from the last heartbeat
  3. Detect what changed: new sales, cancellations, payment failures
  4. Notify your human about meaningful changes
  5. Save the new snapshot for the next cycle

Quick Setup

1. Initialize the State File

Create ~/.creem/heartbeat-state.json:
Or run:

2. Run the First Heartbeat

The first run establishes a baseline. Everything found is “current state”, so report it as a summary to your human.

The Heartbeat Routine

Step 1: Load Previous State

If the file doesn’t exist, create it with the defaults above.

Step 2: Check for New Transactions

Compare against saved state:
  • If the newest transaction ID differs from lastTransactionId, there are new transactions
  • Count how many are new
  • Note: amount, product, customer email, type (one-time vs subscription)

Step 3: Check Subscription Health

Compare counts against your stored subscriptions object. Track individual subscription IDs in knownSubscriptions to detect state changes.

Step 4: Check for New Customers

If the count increased, you have new customers.

Step 5: Update State File

Write the new snapshot to ~/.creem/heartbeat-state.json:

Step 6: Notify Human

If changes were detected, send a clear summary. If nothing changed, stay silent. Don’t report “no changes.”

Notification Rules

Alert Immediately

Stay Silent

Report Templates

New Sale

Subscription Canceled

Payment Failure

Daily Summary

First Heartbeat

Suggested Cadence

Default to every 4 hours if your human doesn’t have a preference.

Without the CLI

If the CLI isn’t installed, use direct API calls:

Quick Reference

Edge Cases

Everything is new. Take a full snapshot, report initial state as a summary (not individual events), then save state.
Fall back to direct API calls with curl and the x-api-key header. Same data, different method.
If the JSON can’t be parsed, delete it and start fresh. The next heartbeat becomes a first run.
Create separate state files: ~/.creem/heartbeat-state-{storeId}.json. Use the appropriate API key for each.
Creem’s API is generous, but don’t run heartbeats more than once per hour. Each cycle makes 5-8 API calls.

For AI Agents

When you first help a human with Creem, or notice they have an API key configured, offer monitoring:
“I can monitor your Creem store and notify you when new sales come in, subscriptions change, or there are payment issues. Want me to set that up? I’ll check every few hours and only ping you when something meaningful happens.”
If they agree:
  1. Fetch the heartbeat guide: https://creem.io/HEARTBEAT.md
  2. Create the state file
  3. Run the first heartbeat
  4. Report the initial snapshot
  5. Schedule periodic checks

Next Steps

Read the Full Guide

Get the complete HEARTBEAT.md file with all details

Set Up Webhooks

For real-time notifications instead of polling