Skip to content

Events — Create

Record a single event for a pass. The request body is a discriminated union on event_category, so the required fields depend on the category.

Auth: Bearer token. The event is tied to pass_id; the service derives the pass's workspace and checks the caller's membership.


Create Event

POST /wallethero-api/events

Creates one event.

Auth: Bearer token — workspace member (derived from the pass).

Request Body (common fields)

FieldTypeRequiredDefaultDescription
event_categorystringYesOne of field_change, transaction, engagement, loyalty, pass_lifecycle
pass_idstring (UUID)YesPass the event belongs to
event_typestringYes*Category-specific type (see below). Optional for field_change (defaults to field_updated)
event_timestampstring (ISO 8601)NonowWhen the event occurred
external_idstring (≤255)NoYour dedupe key
sourcestring (≤100)NoEvent source (e.g. pos-terminal-1)
metadataobjectNoArbitrary JSON

Category-Specific Fields

field_changeevent_typefield_updated (default), field_increment, field_decrement

FieldTypeRequiredDescription
field_namestring (1–100)YesName of the changed field
old_valuestring | nullNoPrevious value (as string)
new_valuestring | nullNoNew value (as string)

transactionevent_typepurchase, refund

FieldTypeRequiredDescription
amountnumberYesTransaction amount
currencystring (3)YesISO 4217 currency code (e.g. USD)

engagementevent_typecheck_in, check_out, visit, scan (no extra fields)

loyaltyevent_typetier_promoted, tier_demoted, reward_redeemed, reward_cancelled, reward_used, points_earned, points_spent, points_expired, points_adjusted

FieldTypeRequiredDescription
amountnumberNoPoints/value delta, where applicable

pass_lifecycleevent_typepass_installed, pass_uninstalled, pass_registered, template_changed

FieldTypeRequiredDescription
field_namestring (1–100)NoRelevant field (e.g. for template_changed)
old_valuestring | nullNoPrevious value
new_valuestring | nullNoNew value

Example: Transaction Event

bash
curl -X POST "https://api.wallethero.app/wallethero-api/events" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "event_category": "transaction",
    "pass_id": "PASS_ID",
    "event_type": "purchase",
    "amount": 49.99,
    "currency": "USD",
    "source": "online-store",
    "metadata": { "order_id": "ORD-12345" }
  }'

Example: Engagement Event

bash
curl -X POST "https://api.wallethero.app/wallethero-api/events" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "event_category": "engagement",
    "pass_id": "PASS_ID",
    "event_type": "check_in",
    "source": "store-001"
  }'

Example: Field Change Event

bash
curl -X POST "https://api.wallethero.app/wallethero-api/events" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "event_category": "field_change",
    "pass_id": "PASS_ID",
    "event_type": "field_increment",
    "field_name": "points",
    "old_value": "1000",
    "new_value": "1050"
  }'

Response (200)

json
{
  "data": {
    "id": "event-uuid",
    "workspace_id": "WORKSPACE_ID",
    "pass_id": "PASS_ID",
    "event_category": "transaction",
    "event_type": "purchase",
    "amount": 49.99,
    "currency": "USD",
    "event_timestamp": "2026-01-15T14:30:00Z",
    "source": "online-store",
    "metadata": { "order_id": "ORD-12345" }
  }
}

SDK

typescript
// Generic
await wh.events.create({
  event_category: "transaction",
  pass_id: "PASS_ID",
  event_type: "purchase",
  amount: 49.99,
  currency: "USD",
});

// Convenience helpers
await wh.events.recordPurchase("PASS_ID", 49.99, "USD", { source: "online-store" });
await wh.events.recordCheckIn("PASS_ID", { source: "store-001" });
await wh.events.recordFieldChange("PASS_ID", "points", "1000", "1050", {
  event_type: "field_increment",
});

Errors

StatusCodeDescription
400INVALID_PAYLOADMissing or invalid fields for the category
403FORBIDDENNot authenticated, or not a member of the pass's workspace
404RECORD_NOT_FOUNDPass not found

WalletHero Documentation