# Personalization

> \[!IMPORTANT]
>
> The Push Notifications API is currently available as a
> Private Beta product. The information contained in this document is subject to change. You acknowledge
> and agree that your use of the Twilio Push Notifications API is subject to the terms of the [Services in
> Private Beta](https://www.twilio.com/en-us/legal/service-country-specific-terms/private-beta). This
> means that some features are not yet implemented and others may be changed before the product is
> declared as Generally Available. Private Beta products are not covered by the Twilio Support Terms or
> Twilio Service Level Agreement.

The Push Notifications API supports [Liquid](https://shopify.github.io/liquid/) templating for personalizing notification content. You can use variables, default values, and control flow to tailor each notification to its recipient.

## Personalize notifications inline

Define notification content inline and enclose each variable name in double curly braces (`{{ }}`). Provide a default value for every variable to ensure that the notification renders correctly when a recipient's `variables` object doesn't contain the corresponding key.

Pass recipient-specific values in the `variables` object for each entry in the `to` array.

```bash {title:"Personalize a notification with inline variables"}
curl -X POST 'https://comms.twilio.com/v1/PushNotifications' \
     -H 'Content-Type: application/json' \
     -d '{
          "to": [
            {
              "token": "FCM_DEVICE_TOKEN_1",
              "provider": "FCM",
              "variables": {
                "name": "Fred"
              }
            },
            {
              "token": "APN_DEVICE_TOKEN_1",
              "provider": "APN",
              "variables": {
                "name": "Sonny"
              }
            }
          ],
          "content": {
            "title": "Your order update",
            "body": "Hello {{name | default: '\''there'\''}}! Your order has shipped."
          }
        }' \
     -u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

In this example, Fred receives "Hello Fred! Your order has shipped." and Sonny receives "Hello Sonny! Your order has shipped." If a recipient's `variables` object is missing the `name` key, the notification falls back to "Hello there! Your order has shipped."

## Advanced templating

In addition to simple variable replacement, you can use Liquid control flow structures like `if` and `else` to conditionally render parts of a notification for specific recipients.

```bash {title:"Conditionally render content with Liquid"}
curl -X POST 'https://comms.twilio.com/v1/PushNotifications' \
     -H 'Content-Type: application/json' \
     -d '{
          "to": [
            {
              "token": "FCM_DEVICE_TOKEN_1",
              "provider": "FCM",
              "variables": {
                "name": "Fred",
                "tierName": "Gold"
              }
            },
            {
              "token": "APN_DEVICE_TOKEN_1",
              "provider": "APN",
              "variables": {
                "name": "Sonny",
                "tierName": "Silver"
              }
            }
          ],
          "content": {
            "title": "Your weekly rewards update",
            "body": "Hi {{name | default: '\''there'\''}}! {% if tierName == '\''Gold'\'' %}As a Gold member, you'\''ve earned double points this week.{% else %}You'\''re one step away from Gold status. Keep earning!{% endif %}"
          }
        }' \
     -u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

## Next steps

* Review the [PushNotifications API reference](/docs/push-notifications/api/notification-resource) for the full list of content fields.
* To track the status of your push notifications, see [Operations and Notification Tracking](/docs/push-notifications/operations-and-notification-tracking).
