---
title: "fetchUserRecordID(completionHandler:)"
framework: cloudkit
role: symbol
role_heading: Instance Method
path: "cloudkit/ckcontainer/fetchuserrecordid(completionhandler:)"
---

# fetchUserRecordID(completionHandler:)

Fetches the user record ID of the current user.

## Declaration

```swift
func fetchUserRecordID(completionHandler: @escaping @Sendable (CKRecord.ID?, (any Error)?) -> Void)
```

```swift
func userRecordID() async throws -> CKRecord.ID
```

## Parameters

- `completionHandler`: The handler to execute with the fetch results.

## Discussion

Discussion The closure doesn’t return a value and takes the following parameters: The user record ID, or nil if the user disables iCloud or the device doesn’t have an iCloud account. An error if a problem occurs, or nil if CloudKit successfully retrieves the user record ID. CloudKit returns a CKError.Code.notAuthenticated error when any of the following conditions are met: The device has an iCloud account but the user disables iCloud. The device has an iCloud account with restricted access. The device doesn’t have an iCloud account. note: At startup, fetching the user record ID may take longer while CloudKit makes the initial iCloud account request. After the initial fetch, accessing the ID generally takes less time.

## See Also

### Discovering User Records

- [discoverAllIdentities(completionHandler:)](cloudkit/ckcontainer/discoverallidentities(completionhandler:).md)
- [discoverUserIdentity(withEmailAddress:completionHandler:)](cloudkit/ckcontainer/discoveruseridentity(withemailaddress:completionhandler:).md)
- [discoverUserIdentity(withPhoneNumber:completionHandler:)](cloudkit/ckcontainer/discoveruseridentity(withphonenumber:completionhandler:).md)
- [discoverUserIdentity(withUserRecordID:completionHandler:)](cloudkit/ckcontainer/discoveruseridentity(withuserrecordid:completionhandler:).md)
- [fetchShareParticipant(withEmailAddress:completionHandler:)](cloudkit/ckcontainer/fetchshareparticipant(withemailaddress:completionhandler:).md)
- [fetchShareParticipant(withPhoneNumber:completionHandler:)](cloudkit/ckcontainer/fetchshareparticipant(withphonenumber:completionhandler:).md)
- [fetchShareParticipant(withUserRecordID:completionHandler:)](cloudkit/ckcontainer/fetchshareparticipant(withuserrecordid:completionhandler:).md)
- [CKCurrentUserDefaultName](cloudkit/ckcurrentuserdefaultname.md)
- [CKOwnerDefaultName](cloudkit/ckownerdefaultname.md)
