<!--
{
  "availability" : [
    "iOS: 12.0.0 - 17.0.0",
    "iPadOS: 12.0.0 - 17.0.0",
    "macCatalyst: 13.1.0 - 17.0.0",
    "macOS: 11.0.0 - 14.0.0",
    "visionOS: 1.0.0 - 1.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "AuthenticationServices",
  "identifier" : "/documentation/AuthenticationServices/ASCredentialIdentityStore/replaceCredentialIdentities(with:completion:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Authentication Services"
    ],
    "preciseIdentifier" : "c:objc(cs)ASCredentialIdentityStore(im)replaceCredentialIdentitiesWithIdentities:completion:"
  },
  "title" : "replaceCredentialIdentities(with:completion:)"
}
-->

# replaceCredentialIdentities(with:completion:)

Replaces existing credential identities with new credential identities.

```
func replaceCredentialIdentities(with newCredentialIdentities: [ASPasswordCredentialIdentity], completion: (@Sendable (Bool, (any Error)?) -> Void)? = nil)
```

## Parameters

`newCredentialIdentities`

An array of new credential identity objects to replace the old ones.

`completion`

An optional completion block called after the operation finishes.

## Discussion

This method deletes existing credential identities that are persisted in the store and saves the newly provided credential identity objects. If the operation fails, an error with domain [`ASCredentialIdentityStoreErrorDomain`](/documentation/AuthenticationServices/ASCredentialIdentityStoreErrorDomain) is provided and none of the new credential identities are saved.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)