---
title: "remove(_:for:options:task:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/urlcredentialstorage/remove(_:for:options:task:)"
---

# remove(_:for:options:task:)

Removes the specified credential from the credential storage for the specified protection space, on behalf of the given task and using the given options.

## Declaration

```swift
func remove(_ credential: URLCredential, for protectionSpace: URLProtectionSpace, options: [String : Any]? = nil, task: URLSessionTask)
```

## Parameters

- `credential`: The credential to remove.
- `protectionSpace`: The protection space from which to remove the credential.
- `options`: A dictionary containing options to consider when removing the credential. For possible keys, see doc://com.apple.foundation/documentation/Foundation/dictionary-key-for-credential-removal-options. You should use this when trying to delete a credential that has the doc://com.apple.foundation/documentation/Foundation/URLCredential/Persistence-swift.enum/synchronizable policy. note: When credential objects that have a synchronizable policy are removed, the credential will be removed on all devices that contain this credential.
- `task`: The task using the protection space that you wish to remove the credential for.

## Discussion

Discussion The credential is removed from both persistent and temporary storage.

## See Also

### Adding and removing credentials

- [remove(_:for:)](foundation/urlcredentialstorage/remove(_:for:).md)
- [remove(_:for:options:)](foundation/urlcredentialstorage/remove(_:for:options:).md)
- [Dictionary key for credential removal options](foundation/dictionary-key-for-credential-removal-options.md)
- [set(_:for:)](foundation/urlcredentialstorage/set(_:for:).md)
- [set(_:for:task:)](foundation/urlcredentialstorage/set(_:for:task:).md)
