Skip to content

Create Pass Template

Create a new pass template.

POST /wallethero-api/workspace/:workspaceId/pass-templates

Dedicated wallethero-api endpoint

This is a workspace-scoped wallethero-api endpoint, not Directus /items/pass_templates. The workspace_id is taken from the path and set on the row server-side. The SDK strips audit fields (id, user_created, date_created, user_updated, date_updated, statistics, passes) before sending.

Authentication

Bearer token — caller must be a member of the workspace in the path.

Path Parameters

ParameterTypeDescription
workspaceIdstring (UUID)Workspace identifier

Request Body

FieldTypeRequiredDescription
namestringYesTemplate name
workspace_idstring (UUID)YesWorkspace identifier (must match the path)
project_idstring (UUID)YesProject identifier
pass_typestringYesOne of: LOYALTY, GIFT_CARD, EVENT_TICKET, OFFER, GENERIC
apple_pass_type_identifierstringYesApple Pass Type ID (e.g. pass.com.example.loyalty)
uuidstring (UUID)YesPublic template identifier
descriptionstringNoTemplate description
background_colorstring (hex)NoBackground color (e.g. #FF5733)
label_colorstring (hex)NoLabel text color
value_colorstring (hex)NoValue text color
logo_textstringNoText displayed with the logo
barcode_typestringNoOne of: none, qr, aztec, code128, pdf417
barcode_idstringNoField name used as the barcode value
barcode_labelstringNoLabel displayed under the barcode
top_field_labelstringNoHeader field label
top_field_valuestringNoHeader field value (supports interpolation)
front_fieldsarray<PassField>NoPrimary fields on the pass front
secondary_fieldsarray<PassField>NoSecondary fields below the primary row
back_fieldsarray<PassField>NoFields on the back of the pass
show_benefits_on_backbooleanNoRender tier benefits on the back
show_available_rewards_on_backbooleanNoRender available rewards on the back
show_active_rewards_on_backbooleanNoRender active rewards on the back
show_loyalty_portal_link_on_backbooleanNoRender the loyalty portal link on the back
show_referral_code_on_backbooleanNoRender the referral code on the back
back_sections_orderarray<string>NoOrder of back sections (e.g. benefits, available_rewards, custom:<id>)
locationsarray<Location>NoLocation-based notification triggers
location_messagestringNoMessage shown when near a location
ios_deeplink_idnumberNoiOS deeplink identifier
ios_deeplink_urlstringNoiOS deeplink URL
tier_idstring (UUID)NoTier identifier (loyalty)
tier_labelstringNoDisplay label for the tier
icon / logo / cover_imagestring (UUID)NoDirectus file IDs — see Template Images

PassField Object

FieldTypeRequiredDescription
labelstringYesField label
valuestringYesField value (supports interpolation)

Location Object

FieldTypeRequiredDescription
latitudenumberYesLatitude coordinate (-90 to 90)
longitudenumberYesLongitude coordinate (-180 to 180)
altitudenumberNoAltitude in meters
namestringNoLocation name for reference

Example Request

bash
curl -X POST "https://api.wallethero.app/wallethero-api/workspace/WORKSPACE_ID/pass-templates" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Gold Member Card",
    "workspace_id": "WORKSPACE_ID",
    "project_id": "PROJECT_ID",
    "uuid": "11111111-2222-3333-4444-555555555555",
    "pass_type": "LOYALTY",
    "apple_pass_type_identifier": "pass.com.example.loyalty",
    "background_color": "#1a1a2e",
    "label_color": "#ffffff",
    "value_color": "#ffd700",
    "logo_text": "ACME Rewards",
    "barcode_type": "qr",
    "barcode_id": "id",
    "top_field_label": "POINTS",
    "top_field_value": "{{points}}",
    "front_fields": [
      { "label": "Member", "value": "{{first_name}} {{last_name}}" },
      { "label": "Tier", "value": "{{tier}}" }
    ],
    "back_fields": [
      { "label": "Terms", "value": "Points expire after 12 months of inactivity." }
    ]
  }'

Response (201)

json
{
  "data": {
    "id": "template-uuid",
    "uuid": "11111111-2222-3333-4444-555555555555",
    "name": "Gold Member Card",
    "pass_type": "LOYALTY",
    "workspace_id": "workspace-uuid",
    "project_id": "project-uuid",
    "apple_pass_type_identifier": "pass.com.example.loyalty",
    "background_color": "#1a1a2e",
    "barcode_type": "qr",
    "front_fields": [
      { "label": "Member", "value": "{{first_name}} {{last_name}}" },
      { "label": "Tier", "value": "{{tier}}" }
    ],
    "date_created": "2024-01-15T10:30:00Z",
    "user_created": "user-uuid"
  }
}

Statistics Object (read-only, present on reads)

FieldTypeDescription
passes_countnumberTotal passes created from this template
apple_registrations_countnumberPasses installed in Apple Wallet
google_registrations_countnumberPasses installed in Google Wallet
total_registrations_countnumberTotal wallet installations

SDK Example

typescript
const template = await wh.passTemplates.create({
  name: "Gold Member Card",
  workspace_id: "WORKSPACE_ID",
  project_id: "PROJECT_ID",
  uuid: crypto.randomUUID(),
  pass_type: "LOYALTY",
  apple_pass_type_identifier: "pass.com.example.loyalty",
  background_color: "#1a1a2e",
  label_color: "#ffffff",
  value_color: "#ffd700",
  barcode_type: "qr",
  front_fields: [
    { label: "Member", value: "{{first_name}} {{last_name}}" },
    { label: "Points", value: "{{points}}" },
  ],
});

// Duplicate an existing template (clones it with a new uuid and a "(Copy)" name)
const copy = await wh.passTemplates.duplicate(template.data.id);

Errors

StatusCodeDescription
400INVALID_PAYLOADMissing required fields
403FORBIDDENCaller is not a member of the workspace
404RECORD_NOT_FOUNDWorkspace or project not found

WalletHero Documentation