<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: 15.0.0 -",
    "macOS: 12.0.0 -",
    "tvOS: 15.0.0 -",
    "visionOS: -",
    "watchOS: 8.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CloudKit",
  "identifier" : "/documentation/CloudKit/CKDatabase/records(for:desiredKeys:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "CloudKit"
    ],
    "preciseIdentifier" : "s:So10CKDatabaseC8CloudKitE7records3for11desiredKeysSDySo10CKRecordIDCs6ResultOySo0H0Cs5Error_pGGSayAHG_SaySSGSgtYaKF"
  },
  "title" : "records(for:desiredKeys:)"
}
-->

# records(for:desiredKeys:)

Fetches the specified records and returns them to an awaiting caller.

```
func records(for ids: [CKRecord.ID], desiredKeys: [CKRecord.FieldKey]? = nil) async throws -> [CKRecord.ID : Result<CKRecord, any Error>]
```

## Parameters

`ids`

The identifiers of the records to fetch.

`desiredKeys`

The fields to include on each fetched record. To include all fields, specify `nil`; to fetch only system fields, specify an empty array.

## Return Value

A dictionary that contains the fetched records. The dictionary uses the identifiers you specify in `ids` as its keys. The value of each key is a <doc://com.apple.documentation/documentation/Swift/Result> that contains either the corresponding fetched record, or an error that describes why CloudKit can’t provide that record.

## Discussion

If you’re fetching records of different types, make sure that `desiredKeys` is the union of all the fields you require across each distinct record type.

This method throws an error if the request fails, such as when the network is unavailable or the device doesn’t have an active iCloud account; otherwise, the returned dictionary includes any individual record errors.

For information on a more configurable way to fetch specific records, see [`CKFetchRecordsOperation`](/documentation/CloudKit/CKFetchRecordsOperation).

---

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)