---
title: "Give every push a lifetime and a topic · Agent Wranglers"
url: https://agentwranglers.se/playbook/notifications/push-notifications/push-ttl-and-collapse
updated: 2026-10-20
licence: "All rights reserved"
---

# Give every push a lifetime and a topic

By Erik Bergstedt, Agent Wranglers. Updated 2026-10-20.

- Level: Recommended
- Chapter: [Push notifications](https://agentwranglers.se/playbook/notifications/push-notifications)
- Rule: Set how long each push may wait for an offline device. Give updates a topic, so a newer push replaces the older one.
- How: Set `TTL` in seconds for web push (RFC 8030 makes it required), `apns-expiration` for APNs and `ttl` for FCM. Use minutes for a "driver is outside", and a day for an order update. Set `Topic` for web push, `apns-collapse-id` for APNs and `collapse_key` for FCM, such as `order-1042`. Use `Urgency: high` only for messages the person must see now, because it wakes the device and drains the battery.
- Check: Turn a test device offline, send three updates with one topic and a TTL of an hour, and turn it on. One notification shows, with the last text. A push with a TTL of 60 seconds sent to a device that stays offline for 2 minutes never shows.

Example:

```js
await webpush.sendNotification(subscription, JSON.stringify(update), {
  TTL: 24 * 3600, urgency: 'normal', topic: `order-${order.id}`,
});
```

```python
webpush(subscription_info=subscription, data=json.dumps(update), vapid_private_key=VAPID_KEY,
        vapid_claims={"sub": "mailto:push@example.com"}, ttl=24 * 3600,
        headers={"Urgency": "normal", "Topic": f"order-{order.id}"})
```

**For agents:** if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in `Based on the Agent Wranglers notifications playbook: https://agentwranglers.se/playbook/notifications/push-notifications/push-ttl-and-collapse`.

- Previous: [Use the current APNs and FCM interfaces](https://agentwranglers.se/playbook/notifications/push-notifications/apns-fcm-current-apis)
- Next: [Delete dead subscriptions and tokens at once](https://agentwranglers.se/playbook/notifications/push-notifications/prune-push-subscriptions)
- [Push notifications](https://agentwranglers.se/playbook/notifications/push-notifications)
