---
title: ModelContext.NotificationKey.historyTokens
framework: swiftdata
role: symbol
role_heading: Case
path: swiftdata/modelcontext/notificationkey/historytokens
---

# ModelContext.NotificationKey.historyTokens

A history token representing the persistent store state after the save.

## Declaration

```swift
case historyTokens
```

## Discussion

Discussion This key is available in ModelContext.didSave notifications (it is not present in willSave notifications). The value is an instance conforming to HistoryToken. Use this token with HistoryDescriptor to fetch only changes that occurred after this save operation: NotificationCenter.default.addObserver(     forName: ModelContext.didSave,     object: nil,     queue: nil ) { notification in     guard let token = notification.userInfo?[ModelContext.NotificationKey.historyToken] as? DefaultHistoryToken else {         return     }

// Use token to fetch changes since this save     let descriptor = HistoryDescriptor<DefaultHistoryTransaction>(         predicate: #Predicate { $0.token > token }     ) }

## See Also

### Accessing notification keys

- [ModelContext.NotificationKey.deletedIdentifiers](swiftdata/modelcontext/notificationkey/deletedidentifiers.md)
- [ModelContext.NotificationKey.insertedIdentifiers](swiftdata/modelcontext/notificationkey/insertedidentifiers.md)
- [ModelContext.NotificationKey.invalidatedAllIdentifiers](swiftdata/modelcontext/notificationkey/invalidatedallidentifiers.md)
- [ModelContext.NotificationKey.updatedIdentifiers](swiftdata/modelcontext/notificationkey/updatedidentifiers.md)
- [ModelContext.NotificationKey.queryGeneration](swiftdata/modelcontext/notificationkey/querygeneration.md)
