Event Ticket Example
Create a ticket holder, issue an event pass, and record entry scans.
typescript
import { WalletHero } from "@wallethero/sdk";
const walletHero = new WalletHero({
apiToken: process.env.WALLETHERO_API_TOKEN!,
});
const workspaceId = "workspace-uuid";
const projectId = "event-project-uuid";
const { data: template } = await walletHero.passTemplates.create({
uuid: crypto.randomUUID(),
name: "Summer Concert",
pass_type: "EVENT_TICKET",
apple_pass_type_identifier: "pass.com.example.concert",
workspace_id: workspaceId,
project_id: projectId,
background_color: "#111827",
label_color: "#9CA3AF",
value_color: "#FFFFFF",
barcode_type: "qr",
barcode_id: "${client.id}",
top_field_label: "GUEST",
top_field_value: "${client.first_name} ${client.last_name}",
front_fields: [
{ label: "SECTION", value: "${custom_fields.section}" },
{ label: "SEAT", value: "${custom_fields.seat}" },
],
});
const { data: guest } = await walletHero.clients.create(workspaceId, {
workspace_id: workspaceId,
first_name: "Alex",
last_name: "Guest",
email: "[email protected]",
custom_fields: {
order_id: "ORDER-1042",
section: "A",
seat: "12",
},
});
const { data: ticket } = await walletHero.passes.create({
workspace_id: workspaceId,
project_id: projectId,
pass_template_id: template.id,
client_id: guest.id,
});
console.log(ticket.apple_pass_url, ticket.google_pass_url);Check in the guest
typescript
await walletHero.events.recordCheckIn(ticket.id, {
external_id: "gate-a:ORDER-1042",
source: "gate-a",
metadata: { scanner_id: "scanner-7" },
});
const history = await walletHero.events.getByPass(ticket.id, {
event_category: "engagement",
limit: 25,
});
const alreadyCheckedIn = history.data.some(
(event) => event.event_type === "check_in",
);Use an idempotent external_id from the ticketing or scanning system so repeated deliveries can be recognized by the backend integration.
Find tickets
typescript
const result = await walletHero.passes.search(
"ORDER-1042",
{
filter: { workspace_id: { _eq: workspaceId } },
limit: 20,
},
);
console.log(result.data);Use client.clients.updateCustomFields() when seat or attendee data changes, because these fields belong to the client record and the update path emits field-change events.