Skip to content

PassesService

Issue and manage individual passes.

Methods

MethodDescription
list(options?)List all passes
get(id)Get a single pass
create(data)Create a new pass
update(id, data)Update a pass
delete(id)Delete a pass
updateCustomFields(id, fields)Update custom fields only

list()

List passes with optional filtering.

typescript
// List all passes in a workspace
const passes = await client.passes.list({
  filter: { workspace_id: { _eq: 'workspace-uuid' } },
  limit: 100
});

// Filter by custom field
const goldMembers = await client.passes.list({
  filter: {
    workspace_id: { _eq: 'workspace-uuid' },
    custom_fields: { tier: { _eq: 'Gold' } }
  }
});

// Search by name or email
const results = await client.passes.list({
  filter: { workspace_id: { _eq: 'workspace-uuid' } },
  search: '[email protected]'
});

get()

Get a single pass by ID.

typescript
const pass = await client.passes.get('pass-uuid');

console.log('Name:', pass.full_name);
console.log('Points:', pass.custom_fields?.points);
console.log('Apple URL:', pass.apple_pass_url);

create()

Create a new pass.

typescript
const pass = await client.passes.create({
  pass_template_id: 'template-uuid',
  project_id: 'project-uuid',
  workspace_id: 'workspace-uuid',
  full_name: 'Jane Doe',
  email: '[email protected]',
  custom_fields: {
    points: 0,
    tier: 'Bronze',
    member_since: '2024-01-15'
  }
});

// Send pass to user
console.log('Download link:', pass.apple_pass_url);
console.log('Google Wallet:', pass.google_pass_url);

update()

Update a pass. Triggers push update to user's wallet.

typescript
// Update points and send notification
await client.passes.update('pass-uuid', {
  notification: 'You earned 100 points!',
  custom_fields: {
    points: 100,
    last_activity: new Date().toISOString()
  }
});

// Switch to different template (tier upgrade)
await client.passes.update('pass-uuid', {
  pass_template_id: 'gold-template-uuid',
  notification: 'Congratulations! You\'re now a Gold member!',
  custom_fields: {
    tier: 'Gold',
    upgraded_at: new Date().toISOString()
  }
});

delete()

Delete a pass.

typescript
await client.passes.delete('pass-uuid');

WARNING

Deleted passes remain in the user's wallet but will no longer update.

updateCustomFields()

Convenience method to update only custom fields.

typescript
// Increment points
const current = await client.passes.get('pass-uuid');
const newPoints = (current.custom_fields?.points || 0) + 50;

await client.passes.updateCustomFields('pass-uuid', {
  points: newPoints,
  last_purchase: new Date().toISOString()
});

Types

typescript
interface Pass {
  id: string;
  pass_template_id: string;
  project_id: string;
  workspace_id: string;
  full_name?: string;
  email?: string;
  notification?: string;
  marketing_consent?: boolean;
  custom_fields?: Record<string, any>;
  apple_pass_url?: string;
  apple_qrcode_url?: string;
  google_pass_url?: string;
  google_qrcode_url?: string;
  date_created?: string;
  date_updated?: string;
}

interface CreatePassRequest {
  pass_template_id: string;
  project_id: string;
  workspace_id: string;
  full_name?: string;
  email?: string;
  notification?: string;
  custom_fields?: Record<string, any>;
}

interface UpdatePassRequest {
  pass_template_id?: string;
  full_name?: string;
  email?: string;
  notification?: string;
  custom_fields?: Record<string, any>;
}

WalletHero Documentation