Skip to content
Docs

Search documentation

Search by topic or tool name
Browse documentation
Guides

Send backend events

Record optional app milestones using authenticated, app-scoped events.

On this page

New integrations: portable backend events

Use the Claude Code / Cursor setup guide and downloadable public Node package for new integrations. Generated helpers use crust.portable.v1, an immutable logical ID and original UTC occurrence, verified canonical shop identity and a bounded safe flat property allowlist. Prepare once, persist with the business write, then deliver the exact saved event after commit and on retries. Credentials stay on the app backend.

The reference below describes existing unmarked compatibility payloads. Its optional timestamp and legacy deduplication behavior must not be used to reconstruct a portable retry. The portable server contract validates required identity and rejects conflicting immutable event content.

What you need

A milestone defined and implemented in your app, the private workspace key and owned HeyCrust app UUID from list_apps. Shopify does not supply arbitrary in-app activation steps. These requirements address sender safety; they do not imply the HeyCrust API caused an app's lifecycle defects.

Names such as onboarding_completed are developer-defined milestones. The Urgency examples below illustrate more specific evidence boundaries; the API does not supply these events automatically.

Steps

  1. Define the occurrence and evidence required for each milestone. Emit only committed successful actions and accepted evidence.
  2. Implement the durable lifecycle and delivery protocol before sending. Keep request-start time, milestone occurrence time and theme-check time separate.
  3. Call validate_custom_events with the exact payload for a dry run. This stores nothing and cannot trigger a Flow/message.
  4. For authorized real events, POST JSON to https://heycrust.com/api/events with Content-Type: application/json and Authorization: Bearer followed by your private workspace key. Never use query-string credentials or browser-side requests with this key.
  5. Require HTTP 2xx and parsed JSON ok === true; inspect counts, app scope and result IDs. Persist the original serialized bytes and timestamp for retries.
  6. After an authorized release inspect a naturally occurring exact app/event receipt with get_custom_event_receipt. Verify any intended Flow/message separately. Do not send synthetic live events merely to complete verification.
json
{
  "appId": "11111111-1111-4111-8111-111111111111",
  "shopDomain": "example.myshopify.com",
  "name": "urgency_configuration_saved",
  "eventId": "opaque-lifecycle-save-id",
  "occurredAt": "2026-10-07T10:00:00Z",
  "properties": {}
}

Exact API schema

Single event object or an object containing an events array of 1–50 events. This table describes the implemented ingestion schema; get_setup_guide also returns the actual machine-readable JSON Schema. Unknown object fields are stripped, not stored.

FieldContract
appIdOptional UUID for compatibility; use an owned HeyCrust app UUID for every new integration. Ownership is checked against the authenticated workspace.
shopDomainRequired string, at least four characters and containing a dot. With appId it must normalize to a permanent myshopify.com domain: lowercase letters/digits/hyphens, 1–63-character shop label, no leading/trailing hyphen. Trimmed and lowercased. Legacy domains are only lowercased.
nameRequired, 1–64 letters, digits, underscore, dot or hyphen; stored lowercase.
propertiesOptional, defaults to an empty object. At most 20 keys, each up to 64 characters. Values: strings up to 500 characters, finite numbers, booleans or null. Arrays and nested objects are rejected. Empty property keys are schema-valid, but use an explicit meaningful allowlist.
occurredAtOptional UTC ISO datetime ending Z; offsets/local times are rejected. Fractional seconds accepted, normalized to JavaScript millisecond precision.
eventIdOptional, 1–128 characters, case-sensitive. Provide it for retry-safe app-scoped delivery. Without it, every accepted call can create a new row.

There is no general payload-byte cap or sensitive-property detector in this endpoint; enforce minimal properties and bounds in the sender. Do not assume schema validation enforces your milestone's semantics.

Timestamp behavior

occurredAt is optional: ISO datetime ending Z (UTC; offsets and local times rejected); fractional seconds allowed, normalized to JavaScript milliseconds. Omitted time uses ingestion time. No API past-age limit. Future times are accepted but the stored occurrence time is clamped to ingestion time. Dedupe hashes the normalized SUBMITTED time before clamping, or null if omitted. Keep timestamp and serialized bytes immutable across retries; adding/changing occurredAt under an existing ID conflicts.

Use the actual committed save time or accepted observation/check time as the milestone occurrence time. It is independent of the early requestStartedAt needed for redaction fencing. A delayed theme result cannot be made current by changing its timestamp.

Expected result

Require an HTTP 2xx response AND parsed JSON ok === true. HTTP success alone is insufficient. 200 receipt: {ok:true,stored:<new count>,deduped:<replay count>,scope:"app"|"legacy_unscoped"|"mixed",results:[{appId:<UUID|null>,scope:"app"|"legacy_unscoped",id:<stored decimal string>}]} in input order. Check counts and each app scope/result. This acknowledges persistence, not milestone truth, Flow execution or message delivery.

For one new app-scoped event:

json
{
  "ok": true,
  "stored": 1,
  "deduped": 0,
  "scope": "app",
  "results": [
    {
      "appId": "11111111-1111-4111-8111-111111111111",
      "scope": "app",
      "id": "123"
    }
  ]
}

For the identical retry, stored is zero, deduped is one and the same stored ID is returned. results has one entry per submitted event in input order; the counts sum to the submitted count. A mixed batch contains app-scoped and legacy records and reports scope mixed. New integrations should report app scope for every entry.

Duplicate and conflict rules

Scoped namespace: (workspace, appId, eventId), NOT per shop/name. Identical normalized app/shop/name/properties/source=api/submitted-time returns 200, stored:0, deduped:1 and the original stored ID/time. Property order and normalized name/domain case do not conflict. Different or unverifiable content under an existing ID returns 409 CONFLICT. Omitting eventId disables dedupe. Legacy unscoped IDs are workspace-wide and do NOT check payload equality; avoid this compatibility path.

IDs are unique across all shops and names within that app, so include shop and milestone plus lifecycle context in a hashed identity. Configuration/theme changes and disable/re-enable transitions are separate occurrences; a retry is the original occurrence. A changed timestamp or properties under the same ID is a conflict, not a retry. Future-time clamping does not alter the submitted timestamp used in the dedupe hash. A successful replay does not refresh the app's lastServerEventAt or original receipt time.

All events validate and commit atomically. An invalid schema (400), foreign app (403), or ID conflict (409) rejects the whole batch; no partial receipt. Identical batch retries use the original events and IDs.

A conflict returns HTTP 409 with this shape:

json
{
  "error": {
    "code": "CONFLICT",
    "message": "Event ID already has different or unverifiable content"
  }
}

HTTP and retry semantics

401 missing/invalid workspace credential; 400 schema; 403 app ownership; 409 conflict; 500 storage/internal error. Retry ambiguous transport/timeout/body failures, 408, 429 or 5xx with identical bytes and exponential backoff plus jitter. Honor Retry-After seconds or HTTP date within your age budget; do not shorten a longer server delay. Stop on 400/401/403/409 and redirects; investigate configuration/content, never invent a new ID to bypass conflict. The endpoint defines no automatic retry, request timeout, six-attempt cap or rate-limit quota; proxy/platform limits may apply.

The handler normally returns 200 on acknowledgement. Authentication errors return an error string; schema errors return a flattened validation error; domain/storage errors return an error object with code/message. Error response shapes differ, so classify status first and never log raw responses. A timeout may occur after the event was stored: keep the same ID and bytes. A six-attempt/24-hour sender budget is a recommended local policy, not a HeyCrust quota.

Milestone evidence

MilestoneRequired evidenceMinimal properties for the Urgency example
urgency_configuration_savedIntended changed settings save committed successfully. Define occurrence identity using an immutable save UUID or revision. Failed, rolled-back and no-op saves do not create a new success event.Empty object.
urgency_app_embed_enabledBackend verifies the currently published main theme contains the target embed with disabled=false. A present block, editor URL, draft theme or saved app setting alone is insufficient.theme_id.
urgency_storefront_display_observedApp accepts a browser observation for the current shop, lifecycle epoch, revision and published theme under its authenticated/replay validation rules.theme_id, configuration_revision and evidence_origin=storefront_browser.

Accept an authenticated browser observation for the current shop/epoch/configuration/published theme under your validation and replay rules. Preserve evidence_origin=storefront_browser; API transport/source=api does not turn browser evidence into independent backend verification. An absent, blocked, delayed or stale browser observation is unknown, never setup failure.

The general API does not enforce these event names or property allowlists. Specify acceptance, replay and freshness rules in your app and test them. Never equate missing/blocked/stale browser observations with failed setup, disabled embeds or merchant inactivity.

Privacy, retention and rollback

Allowlist properties for each milestone; never include access/session tokens, Authorization headers, client secrets, emails, owner names, full URLs/query strings, settings bodies or raw exceptions. Keep CRUST_API_KEY server-side in hosting secrets; never expose it to browser bundles. Log only safe event/attempt/status codes and redacted identifiers; disable payload/header logging in clients, proxies and error reporting. General API property limits do not enforce the milestone allowlists.

IDs dedupe while the row exists; no automatic custom-event TTL or permanent ID tombstone is implemented. Authorized DELETE /api/identify with myshopifyDomain and appId erases that app’s matching private records. Other app sources and explicit workspace contact imports survive. Use scope:"workspace" instead of appId only for an explicitly authorized whole-workspace merchant erasure. Ambiguous domain-only requests fail with APP_SCOPE_REQUIRED. Unattributed legacy contacts/users may need fresh identification after a relevant erase.

Receiver app/global privacy fences reject stale transactions and old occurrences; fresh installation evidence can admit fresh data. Imported old source payloads stay blocked. There is no event-specific correction or undo of an already delivered message. Deletion removes event dedupe evidence. Fence local work first and validate the exact scoped erasure receipt; see Identify and redaction. Financial audit history remains separate.

Set and implement an explicit local retention period for pending/delivered/failed payloads and receipts. Disable tracking on rollback; stop workers and cancel queued work, preserve epochs/boundaries/attempt counts through schema/code rollback. Do not replay old outboxes on restart. Rollback cannot undo remote events/messages. On redaction erase payloads and bounded logs; retain only the lawful minimal fence needed to reject stale work.

What this proves

An authenticated backend event records what your app reported for a merchant and app. It does not independently verify the milestone, create a Shopify collection or affiliate commission, or prove that a Flow ran or a message was delivered. API transport source and evidence provenance are different. Shopify reporting coverage is separate from optional tracking observations.

Local lifecycle/SQL regressions, production build and dry-run validation are separate from a live receipt. Inspect exact natural app/event receipts after an authorized release. Flow/message verification requires separate actual execution/delivery evidence and authorization. Missing observation is unknown. Never declare E2E complete from a guide, successful build, matching browser bundle, HTTP 2xx alone or a dry run.

Troubleshooting

Use the dry-run validator before delivery, and exact receipt lookup after release. list_events is Shopify lifecycle history, not custom-event receipt inspection. Investigate terminal status errors without changing IDs to bypass conflicts. If receipt lookup returns no row, preserve unknown state; erasure may have removed it. If lifecycle fencing or attempt accounting is missing, do not describe the sender as verified. Read Browser tracking and Data sources for their independent evidence boundaries.

Discover events and build activation reports

Inspect stored app-scoped observations in Activation → Event explorer or the owner MCP discovery tools. Received events are directly selectable in Activation → Funnels without separate approval or definition setup. Safe property metadata remains optional; declare release coverage deliberately before interpreting missing observations. See event discovery and tracking coverage and Activation.