Push updates
Let a scheduled task ask a script which passes to update and what to change on each, with runtime.scriptable.pushUpdates.
A push updates script builds, each time a scheduled task fires, the list of passes to update and what to change on them: new additional data, another theme, a benefit to grant, a notification. The Wallet Crew then queues one update per pass, paced at the throughput the script asks for. It is the tool for updates whose audience comes from a query on a system the brand owns, such as "every member whose tier changed since yesterday" from a data warehouse or a CRM. This page is the reference for runtime.scriptable.pushUpdates.{scriptId}.
When the list of updates arrives as a file instead, the bulk import is simpler, and its rows can be adapted by the bulk pass update row transformation. When the audience can be expressed with the pass filters of the scheduler, a standard push update task needs no script at all.
Registration
The script registers runtime.scriptable.pushUpdates.{scriptId}, and a task of type wallet.scriptablePushUpdates in server/scheduler.yml names the same {scriptId} in settings.scriptName:
tasks:
- id: nightly-points-refresh
type: wallet.scriptablePushUpdates
isEnabled: true
trigger:
type: recurrence
scheduleExpression: "0 0 3 * * *"
settings:
scriptName: pointsRefreshThe recurrence trigger takes a cron expression with a seconds field (six fields: seconds, minutes, hours, day of month, month, day of week), here every day at 03:00:00. A one-off run uses a fixedDate trigger with runAt, an ISO 8601 date and time.
The minimal skeleton is:
When it runs
The script runs in the background job of its task, each time the trigger fires, never inside a holder's request. The updates themselves run later, at their planned time, exactly like the updates of any other push update task. The number of passes queued is recorded as the result of the task's execution.
The lifecycle of one run:
Handlers
GetPasses
none
{ Throughput?, PassInformations }, or a promise of it
Required
Return value
The returned object uses PascalCase keys:
PassInformations
array
Required. One entry per update, described below. An empty array updates nothing.
Throughput
number
Pass updates per second. 3 when omitted. Must be greater than zero; values above 1000 are capped at 1000.
Each entry of PassInformations is an update description. This page owns the table below; the Bulk pass update row transformation uses the same description. Every key left out or null leaves that part of the pass unchanged.
Identifiers
Required. The passes to update. An id key selects one pass by its pass id; otherwise id.<name> keys select every pass carrying all the given identifiers ({ 'id.crm.customerId': '1042' }). Every key other than id must start with id..
PassType
The pass type to convert the passes to.
ThemeId
The theme to apply. An empty string "" removes the current theme.
BenefitTemplateId
A benefit template granted to each pass before the update.
AdditionalData
Keys merged into the pass's additional data, as strings. A null or empty value removes the key.
UpdateMetadata
true recomputes the pass metadata with the update, which runs the pass data providers and the benefit provider. Slower. false by default.
NewIdentifiers
Identifiers to set on the passes, keyed by identifier name (an id. prefix is accepted and ignored). Every value is required.
Notification
The notification text for devices whose language has no entry in NotificationLocalizations.
NotificationLocalizations
Notification text per language code, such as { fr: 'Vos points ont changé' }. When this and Notification are both empty, no notification is sent.
Values of AdditionalData are strings: the script converts numbers and booleans with String(value), and serializes a value that must keep its structure with JSON.stringify.
Errors and edge cases
GetPasses throws or its promise rejects: the task execution fails and nothing is updated.
GetPassesis missing from the registered object: the handler is required, so the task fails and nothing is updated.No script registers the key named by
scriptName: the task logs an error stating that the script does not exist, and no pass is updated.An entry names a pass type, theme or benefit template the tenant does not have, or a
NewIdentifiersvalue is empty: that entry is skipped with an error logged with its position, the others continue.An entry matches no pass: a warning is logged and nothing is queued for it.
An entry matches several passes: each matching pass is updated; one pass named by two entries is updated twice.
Throughputis zero or negative: the task fails when it plans the updates.Several files register the key: the last registered wins, and the load order of files is not defined.
Example
The script reads the changed balances from a reporting API page by page. A hard cap on the number of pages protects the task from an API that never stops paging, and reaching the cap is logged rather than silent. A failed page throws, so the task fails visibly instead of updating half of the audience.
Checking the result
The executions of the task show whether it ran and how many passes it queued. A smaller number than expected usually means entries that matched no pass (identifier keys without the id. prefix, or values in another format than the one the passes carry) or entries refused for an unknown pass type, theme or benefit template; both are logged per entry. After the planned time, the pass in the admin console, or GET /api/{tenantId}/passes/{passId}, shows the new additional data or theme.
Common pitfalls
An identifier key written as
customerIdinstead ofid.customerId.A throughput so low that the updates of one run are still being delivered when the next run starts.
A one-off task with a
fixedDatetrigger that is forgotten in the configuration after it ran.
FAQ
Last updated

