Guides
Credential issuance
Direct
Templates
Google Digital Pass

How to create a Google digital pass template

A Google digital pass template is required to format a Compact or Compact Semantic Credential as a Google digital pass.

Overview

Creating a Google digital pass template comprises the following steps:

  1. Design a template
  2. Create a MATTR VII template

Sample templates: You can download the following sample templates to better understand how to structure your own templates as you follow along this guide:

Prerequisites

Design a template

Create your template in a JSON file and then bundle it into a .zip file. The JSON file contains the digital pass information, identifiers and value mappings. It is structured as follows:

The template .zip file cannot be larger than 1mb.

"genericClass": {
    "textModulesData": [
        {
            "header": "Name",
            "body": "{{ decoded.name }}"
        },
        {
            "header": "Certification",
            "body": "{{ decoded.certificationName }}"
        },
        {
            "header": "Code",
            "body": "{{ decoded.code }}"
        },
        {
            "header": "Certified for",
            "body": "{{ decoded.certificationLevel }}"
        },
        {
            "header": "Expires on",
            "body": "{{ date decoded.expiry 'dd MMM yyyy' }}"
        },
        {
            "header": "Issued by",
            "body": "{{ decoded.issuerName }}"
        }
    ]
    "genericObject": {
    "genericType": "GENERIC_TYPE_UNSPECIFIED",
    "cardTitle": {
        "defaultValue": {
            "language": "en-US",
            "value": "Working at Heights Certification"
        }
    },
    "header": {
        "defaultValue": {
            "language": "en-US",
            "value": "{{ decoded.certificationName }}"
        }
    },
    "subHeader": {
        "defaultValue": {
            "language": "en-US",
            "value": "Advanced Safety Training"
        }
    },
    "logo": {
        "sourceUri": {
            "uri": "https://YOUR_WEB_DOMAIN/LINK_TO_LOGO_IMAGE.png",
            "description": ""
        }
    },
    "hexBackgroundColor": "#CACACA",
    "heroImage": {
        "sourceUri": {
            "uri": "https://YOUR_WEB_DOMAIN/LINK_TO_HERO_IMAGE.png",
            "description": ""
        }
    },
    "barcode": {
        "type": "QR_CODE",
        "value": "{{encoded}}",
        "alternateText": "QR code"
    }
    }
}
  • genericClass : Contains common data across objects. Text fields on the pass face are defined here. Each text module contains a header and a body for each row. To add text to the pass details, set the values in the textModulesData.
  • genericObject : Represents each Generic Pass a user has in their Google Wallet app. It contains a number of configurable attributes such as card title, header, sub header, logo, background color, hero image and barcode. The image assets should be uploaded and publicly accessible.

Create a MATTR VII template

Request

Make a multipart/form-data request with the template .zip file included as a binary file to create a Compact Credential Google digital pass template:

POST /v2/credentials/compact/digital-pass/google/templates

You can make a similar request to a different endpoint to create a Compact Semantic Credential Apple digital pass template:

POST /v2/credentials/compact-semantic/digital-pass/google/templates
Request keys
KeyTypeDescription
templateFileInclude your template .zip file.
nameTextInsert a name to identify this Google digital pass template.
issuerIdTextGoogle Wallet Pass signer issuer ID.
serviceAccountClientEmailTextEmail address of the Google Cloud Platform service account for accessing the Google Pay Passes API.
serviceAccountPrivateKeyTextPrivate key PEM of the Google Cloud Platform service account.

Learn how to grant access to your service account to call the Google Wallet API (opens in a new tab).

Response

{
    "id": "0793fade-bd27-46a8-8dfe-67c4d3e9cf09",
    "name": "example",
    "passType": "google",
    "metadata": {
        "issuerId": "xxxxx",
        "serviceAccountClientEmail": "xxxxx",
        "payPassId": "xxxxx"
    }
}

Troubleshooting

Errors may occur in the following scenarios:

  • Unable to decompress the template .zip file.
  • template.json is missing from the bundle or it is malformed.
  • The template .zip file exceeds the maximum size allowed (1mb).

To avoid potential impact on previously generated Google digital passes, updating an existing template will always create a new template in the Google Pay Business Console.