---
title: "contentKeySession(_:contentKeyRequest:didFailWithError:)"
framework: avfoundation
role: symbol
role_heading: Instance Method
path: "avfoundation/avcontentkeysessiondelegate/contentkeysession(_:contentkeyrequest:didfailwitherror:)"
---

# contentKeySession(_:contentKeyRequest:didFailWithError:)

Tells the receiver that the content key request failed.

## Declaration

```swift
optional func contentKeySession(_ session: AVContentKeySession, contentKeyRequest keyRequest: AVContentKeyRequest, didFailWithError err: any Error)
```

## Parameters

- `session`: The content key session that initiated the content key request.
- `keyRequest`: The content key request that failed.
- `err`: An instance of doc://com.apple.documentation/documentation/Foundation/NSError that describes the failure that occurred.

## See Also

### Updating and retrying content key requests

- [contentKeySession(_:didProvide:forInitializationData:)](avfoundation/avcontentkeysessiondelegate/contentkeysession(_:didprovide:forinitializationdata:).md)
- [contentKeySession(_:externalProtectionStatusDidChangeFor:)](avfoundation/avcontentkeysessiondelegate/contentkeysession(_:externalprotectionstatusdidchangefor:).md)
- [contentKeySession(_:didUpdatePersistableContentKey:forContentKeyIdentifier:)](avfoundation/avcontentkeysessiondelegate/contentkeysession(_:didupdatepersistablecontentkey:forcontentkeyidentifier:).md)
- [contentKeySession(_:shouldRetry:reason:)](avfoundation/avcontentkeysessiondelegate/contentkeysession(_:shouldretry:reason:).md)
- [AVContentKeyRequest.RetryReason](avfoundation/avcontentkeyrequest/retryreason.md)
- [contentKeySessionContentProtectionSessionIdentifierDidChange(_:)](avfoundation/avcontentkeysessiondelegate/contentkeysessioncontentprotectionsessionidentifierdidchange(_:).md)
- [contentKeySession(_:contentKeyRequestDidSucceed:)](avfoundation/avcontentkeysessiondelegate/contentkeysession(_:contentkeyrequestdidsucceed:).md)
- [contentKeySessionDidGenerateExpiredSessionReport(_:)](avfoundation/avcontentkeysessiondelegate/contentkeysessiondidgenerateexpiredsessionreport(_:).md)
