# Google Passes Only

Operations that apply only to Google Wallet passes.


## Add message to Google Pass {#addmessagetogooglepass}

Add messages to Google Wallet passes.

[Jump to examples ↓](#addmessagetogooglepass-examples)

### `POST /pass/{passId}/message`

**Security:**

- [httpBasic]({{< ref "/developer/rest-api/wallet/introduction/" >}}#security-httpBasic)
- [oauth2Token]({{< ref "/developer/rest-api/wallet/introduction/" >}}#security-oauth2Token): wpas

**Path parameters:**

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `passId` | `string` | Required | The `Id` of the Google Pass you want to apply messages to. |

**Request headers:**

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `Api-Revision` | `string` | Required | The particular API revision you want to use. In general, this is `1.2`. Possible values: `1.2` |

**Request body**

A valid request contains one message for the pass.

**Content-Type:** `application/json`

- **`body`** `string`

  The message body text.

- **`endTime`** `object`

  The date-time when the notification will end. If you do not set an end time, the notification displays indefinitely.

  **OBJECT PROPERTIES**

  - **`date`** `string`

    Format: `date-time`

- **`header`** `string`

  The header text for the message

- **`messageType`** `string`

  Use `expirationNotification` to warn users of expiring messages, and `text` for all other notifications. `expirationNotification` is based on the `start` value in the `displayInterval`; the maximum display interval is 30 days from now. If the expiration start date is more than 30 days from now, the message will not appear until the 30-day mark.


  Possible values: `expirationNotification`, `text`

- **`startTime`** `object`

  The date-time when the notification will begin appearing to users.

  **OBJECT PROPERTIES**

  - **`date`** `string`

    Format: `date-time`

**Responses**

**`200`** A successful response returns details for the added message.

Response body:

**Content-Type:** `application/json`

- **`body`** `string`

  The body of the message.

- **`createdAt`** `string`

  The date and time when the item was created.

  Format: `date-time`

  Read only: true

- **`header`** `string`

  The header for the message.

- **`messageType`** `string`

  The type of message.

  Possible values: `expirationNotification`, `text`

- **`updatedAt`** `string`

  The date and time when the item was last updated.

  Format: `date-time`

  Read only: true

**`404`** The pass ID does not exist.

**Examples**

*Example request*

```http
POST /v1/pass/mypass/message HTTP/1.1
Authorization: Basic <authorization string>
Content-Type: application/json

{
   "body":"wallet object expires soon",
   "header":"expires",
   "startTime": "2018-06-03T21:10:00.000Z",
   "endTime": "2018-06-05T21:50:00.000Z",
   "messageType":"expirationNotification"
}

```

*Response*

```http
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

{
   "header": "expires",
   "body": "wallet object expires soon",
   "startTime": "2018-06-03T21:10:00.000Z",
   "endTime": "2018-06-05T21:50:00.000Z",
   "createdAt": "2021-08-18T23:25:05.075Z",
   "updatedAt": "2021-08-18T23:25:05.075Z",
   "messageType": "expirationNotification"
}

```

---

## Add message to Google Pass with external ID {#addmessagetogooglepassexternalid}

Add messages to Google Wallet passes.

[Jump to examples ↓](#addmessagetogooglepassexternalid-examples)

### `POST /pass/template/{templateId}/id/{passExternalId}/message`

**Security:**

- [httpBasic]({{< ref "/developer/rest-api/wallet/introduction/" >}}#security-httpBasic)
- [oauth2Token]({{< ref "/developer/rest-api/wallet/introduction/" >}}#security-oauth2Token): wpas

**Path parameters:**

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `templateId` | `string` | Required | The template of the Google Pass that you want to apply messages to. |
| `passExternalId` | `string` | Required | The external ID of the Google Pass you want to apply messages to. |

**Request headers:**

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `Api-Revision` | `string` | Required | The particular API revision you want to use. In general, this is `1.2`. Possible values: `1.2` |

**Request body**

A valid request contains one message for the pass.

**Content-Type:** `application/json`

- **`body`** `string`

  The message body text.

- **`endTime`** `object`

  The date-time when the notification will end. If you do not set an end time, the notification displays indefinitely.

  **OBJECT PROPERTIES**

  - **`date`** `string`

    Format: `date-time`

- **`header`** `string`

  The header text for the message

- **`messageType`** `string`

  Use `expirationNotification` to warn users of expiring messages, and `text` for all other notifications. `expirationNotification` is based on the `start` value in the `displayInterval`; the maximum display interval is 30 days from now. If the expiration start date is more than 30 days from now, the message will not appear until the 30-day mark.


  Possible values: `expirationNotification`, `text`

- **`startTime`** `object`

  The date-time when the notification will begin appearing to users.

  **OBJECT PROPERTIES**

  - **`date`** `string`

    Format: `date-time`

**Responses**

**`200`** A successful response returns details for the added message.

Response body:

**Content-Type:** `application/json`

- **`body`** `string`

  The body of the message.

- **`createdAt`** `string`

  The date and time when the item was created.

  Format: `date-time`

  Read only: true

- **`header`** `string`

  The header for the message.

- **`messageType`** `string`

  The type of message.

  Possible values: `expirationNotification`, `text`

- **`updatedAt`** `string`

  The date and time when the item was last updated.

  Format: `date-time`

  Read only: true

**`404`** The pass or template ID does not exist.

**Examples**

*Example request*

```http
POST /v1/pass/template/123/id/mypass/message HTTP/1.1
Authorization: Basic <authorization string>
Content-Type: application/json

{
   "body":"wallet object expires soon",
   "header":"expires",
   "startTime": "2018-06-03T21:10:00.000Z",
   "endTime": "2018-06-05T21:50:00.000Z",
   "messageType":"expirationNotification"
}

```

*Response*

```http
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

{
   "header": "expires",
   "body": "wallet object expires soon",
   "startTime": "2018-06-03T21:10:00.000Z",
   "endTime": "2018-06-05T21:50:00.000Z",
   "createdAt": "2021-08-18T23:25:05.075Z",
   "updatedAt": "2021-08-18T23:25:05.075Z",
   "messageType": "expirationNotification"
}

```

---

## Get messages for Google Pass {#getmessagesforgooglepass}

Returns an array of messages associated with the specified pass.

[Jump to examples ↓](#getmessagesforgooglepass-examples)

### `GET /pass/{passId}/message`

**Security:**

- [httpBasic]({{< ref "/developer/rest-api/wallet/introduction/" >}}#security-httpBasic)
- [oauth2Token]({{< ref "/developer/rest-api/wallet/introduction/" >}}#security-oauth2Token): wpas

**Path parameters:**

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `passId` | `string` | Required | The `Id` of the Google Pass you want to get messages from. |

**Request headers:**

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `Api-Revision` | `string` | Required | The particular API revision you want to use. In general, this is `1.2`. Possible values: `1.2` |

**Responses**

**`200`** A successful response returns details for the added messages.

Response body:

**Content-Type:** `application/json`

- **`messages`** `array[object]`

  An array of messages associated with the pass.

**`404`** The pass ID does not exist.

**Examples**

*Example request*

```http
GET /v1/pass/mypass/message HTTP/1.1
Authorization: Basic <Base64 key>
Api-Revision: 1.2

```

*Response*

```http
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

{
   "messages": [
      {
         "header": "expires",
         "body": "wallet object expiring soon",
         "createdAt": "2019-03-05T23:11:29.000Z",
         "updatedAt": "2019-03-05T23:11:29.000Z",
         "messageType": "expirationNotification"
      }
   ]
}

```

---

## Get messages for Google Pass with external ID {#getmessagesforgooglepassexternalid}

Returns an array of messages associated with the specified pass.

[Jump to examples ↓](#getmessagesforgooglepassexternalid-examples)

### `GET /pass/template/{templateId}/id/{passExternalId}/message`

**Security:**

- [httpBasic]({{< ref "/developer/rest-api/wallet/introduction/" >}}#security-httpBasic)
- [oauth2Token]({{< ref "/developer/rest-api/wallet/introduction/" >}}#security-oauth2Token): wpas

**Path parameters:**

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `templateId` | `string` | Required | The template of the Google Pass that you want to get messages from. |
| `passExternalId` | `string` | Required | The external ID of the Google Pass you want to get messages for. |

**Request headers:**

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `Api-Revision` | `string` | Required | The particular API revision you want to use. In general, this is `1.2`. Possible values: `1.2` |

**Responses**

**`200`** A successful response returns details for the added messages.

Response body:

**Content-Type:** `application/json`

- **`messages`** `array[object]`

  An array of messages associated with the pass.

**`404`** The pass or template ID does not exist.

**Examples**

*Example request*

```http
GET /v1/pass/template/123/id/mypass/message HTTP/1.1
Authorization: Basic <Base64 key>
Api-Revision: 1.2

```

*Response*

```http
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

{
   "messages": [
      {
         "header": "expires",
         "body": "wallet object expiring soon",
         "createdAt": "2019-03-05T23:11:29.000Z",
         "updatedAt": "2019-03-05T23:11:29.000Z",
         "messageType": "expirationNotification"
      }
   ]
}

```

---

## Save to Google Wallet {#createpassfromtemplate}

Creates a pass from the specified template and returns code for a "Save to Google Wallet" button. Clicking or tapping this button installs the pass.

[Jump to examples ↓](#createpassfromtemplate-examples)

### `POST /pass/{templateId}/saveToWallet`

**Security:**

- [httpBasic]({{< ref "/developer/rest-api/wallet/introduction/" >}}#security-httpBasic)
- [oauth2Token]({{< ref "/developer/rest-api/wallet/introduction/" >}}#security-oauth2Token): wpas

**Path parameters:**

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `templateId` | `string` | Required | The `id` of the template you want to generate a "Save to Google Wallet" button for. |

**Request headers:**

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `Api-Revision` | `string` | Required | The particular API revision you want to use. In general, this is `1.2`. Possible values: `1.2` |

**Request body**

The request is much like creating a pass with the addition of functions to perform upon success or failure.

**Content-Type:** `application/json`

- **`externalId`** `string`

  An external identifier for the pass that you might want to use to update the pass in the future.

- **`fields`** `object`
- **`onFail`** `string`

  A javascript function that you want to be called when a user

- **`onSuccess`** `string`

  A javascript function that you want to be called when a user successfully adds the pass to Google Wallet.

- **`tag`** `string`

  A single tag you want to add to the pass.

**Responses**

**`200`** A response includes the javascript for a "Save to Google Wallet" button.

**Examples**

*Example request*

```http
POST /v1/pass/123/saveToWallet HTTP/1.1
Content-Type: application/json
Authorization: Basic <Base64 key>
Api-Revision: 1.2

 {
    "fields": {
       "Points": {
       "value": "600"
       }
    },
    "tag": "abc",
    "externalId": "UserName",
    "onSuccess": "mySuccessFunc()",
    "onFail": "myFailureFunc()"
 }

```

*Response*

```html
<script src="https://apis.google.com/js/plusone.js" type="text/javascript"></script>
<script type="text/javascript">
function urban_airship_callback(path) {
   var script = document.createElement('script');
   script.src = path
   document.getElementsByTagName('head')[0].appendChild(script);
}
var successHandler = function (params) {
   urban_airship_callback('https://wallet-api.urbanairship.com/v1/card/register/2931580989855247863.31885_34ab7304-0148-407f-9e4a-69ae30c1efd1')
}
var failureHandler = function (params) {
   urban_airship_callback('https://wallet-api.urbanairship.com/v1/card/register/2931580989855247863.31885_34ab7304-0148-407f-9e4a-69ae30c1efd1')
}
</script>
<g:savetowallet
   jwt="eyJhbGciOiJSUzI1NiJ9..."
   onsuccess="mySuccessFunc()"
   onfailure="myFailureFunc()" size="small" theme="gray">
</g:savetowallet>

```

---

