To give an agent access to selected iCloud Drive files, connect through Figment, which routes operations through a signed-in Mac and enforces folder-level grants, so the agent reaches only the paths the user chose to share. Drive file listing and reading endpoints are integration design pending published API contracts. The Apple sync model and the Figment authorization flow described below are accurate today. This guide covers the folder grant model, the cloud-placeholder file states that decide whether a file is readable right now, and the authorization flow your app completes.
What does "selected files" mean in iCloud Drive?
It means the folders a user approves during account connection. iCloud Drive is not a flat file server. It is a sync layer that runs on a Mac, and Figment routes all Drive operations through a signed-in isolated Mac, so the only files an agent can reach at request time are files that have already synced to that Mac.
The selection is enforced at the grant level: the agent's access token covers those paths and nothing else. A user who wants to expose a Projects/ folder but not a personal photos archive grants one and withholds the other. The Desktop and Documents folders are opt-in at the Apple Account level, because they sync to iCloud Drive only when the user has enabled Desktop and Documents in iCloud Drive settings. They are also separately opt-in at the grant level.
This limits the damage if an agent misbehaves, and it matches how most users think about sharing: a working folder for the agent, not the entire drive.
Which cloud-placeholder file states can the agent read?
Only files whose Finder status is Downloaded, Keep Downloaded or Waiting to Upload. Apple's Optimize Mac Storage can remove local copies of files to free disk space. The file still appears in Finder as a lightweight placeholder, and the bytes stay in iCloud until something requests a download. A placeholder is not readable by an agent until the Mac downloads it.
Apple's Mac Help documents the iCloud Drive status values shown in Finder's iCloud Status column. Each has a different meaning for agent access:
| Finder status | What it means | Agent can read? | What to do |
|---|---|---|---|
| In iCloud | Placeholder only; bytes are in iCloud, not on the Mac | No | Return a "not yet available" response; retry after the Mac downloads the file |
| Downloaded | Local copy is current; available with or without internet | Yes | Proceed normally |
| Keep Downloaded | Pinned locally; Mac will not evict this file | Yes | Proceed normally |
| Waiting to Upload | New or modified file on Mac; not yet synced to iCloud | Yes (local copy exists) | Readable, but a second device may see an older version until upload completes |
| Ineligible | Item exceeds the 50 GB limit for an individual file or folder, or the item type cannot be stored in iCloud | No | The file cannot live in iCloud Drive; ask the user to move it out of the granted folder |
| Out of Space | iCloud storage quota is full | Possibly (local copy may still exist) | User must free iCloud storage before reliable sync resumes |
Treat an In iCloud result as temporary unavailability, not a permanent error. Tell the caller the file is queued for download and retry after a short interval. Do not silently skip the file or report it as missing.
How do folder grants scope the connection?
Each folder the user selects becomes a named grant tied to the connection. Your app's access token covers those grants and nothing else: no other folder in iCloud Drive, no other iCloud service, and no other Apple account.
Revoking your app's grant stops access to those folders immediately without affecting other apps or services on the same Apple Account. If the user disconnects the Apple Account entirely, every grant and every queued operation tied to that connection stops.
Audit records for Drive operations should omit file contents and any personal metadata beyond what identifies the operation.
How does authorization and connection setup work?
Register your app at /icloud/developers. Figment uses PKCE-protected OAuth: generate a code verifier, derive the S256 challenge, and validate the state parameter on redirect to protect against CSRF.
GET https://figment.so/icloud/authorize
?client_id=YOUR_CLIENT_ID
&redirect_uri=https://yourapp.example/callback
&response_type=code
&scope=REQUESTED_SCOPES
&state=CSRF_TOKEN
&code_challenge=YOUR_CODE_CHALLENGE
&code_challenge_method=S256
After the user approves, exchange the code for tokens:
POST https://figment.so/api/icloud/oauth/token
Content-Type: application/x-www-form-urlencoded
grant_type=authorization_code
&client_id=YOUR_CLIENT_ID
&redirect_uri=https://yourapp.example/callback
&code=RETURNED_CODE
&code_verifier=YOUR_VERIFIER
The response includes access_token, refresh_token, expires_in (900 seconds), scope, and connection_id. Store the connection_id, because it anchors every later request. Access tokens expire after 900 seconds. Refresh before they expire using grant_type=refresh_token, and always store the rotated refresh token from the response.
Requested scopes and their exact string values are assigned during app registration in the developer dashboard. Use the values shown there.
Check connection status before any file operation:
GET https://figment.so/api/icloud/v1/connections/{connection_id}
Authorization: Bearer ACCESS_TOKEN
The response has the shape {connection:{id, mode, services, ...}}. Each entry in services is an object with state, reason, and observedAt (epoch milliseconds). Service states include connecting, needs_approval, syncing, ready, offline, reconnect_required, and revoked. Only granted services appear in the services map. A needs_approval state means the user must complete a step on their trusted device, which is an Apple account requirement and not a Figment one. A ready state does not guarantee complete history or successful delivery for any service. Non-ready services reject operations.
The connection endpoint is authorized and can reject a non-ready or revoked connection with a non-2xx response, so handle that path. For connection setup and troubleshooting, use /icloud/account.
What can an agent access once Drive is ready?
The design target below rests on confirmed Apple sync behavior. Drive-specific file listing and file-reading endpoints are not yet part of the published API surface, so treat this list as a design target and not an executable interface. A ready Drive connector is designed to give your agent:
- Synced files and folders within granted paths
- Desktop and Documents contents, if the user opted those folders into iCloud Drive and included them in their grant
- File metadata: name, path, size, modification date, and download status
- File contents: for files whose iCloud status is Downloaded or Keep Downloaded
The agent cannot access files on an iPhone or iPad filesystem directly, only what has synced to the connected Mac. Files in the In iCloud state must be downloaded to the Mac before the agent can read them.
Which Drive limits should I design around?
- Files or folders larger than 50 GB are ineligible for iCloud Drive. Apple's Mac Help confirms this limit. Such items get an Ineligible status and do not appear in Drive listings.
- Cloud-only items can fill most of a granted folder if Optimize Mac Storage has been active for a while. Work through the files that are locally available, report the cloud-only items as pending, and check back after download instead of treating them as absent.
- Desktop and Documents are opt-in at the Apple Account level and again at the grant level. Do not assume a Drive grant includes them unless the user explicitly selected them.
- Write permissions are separate from read. A read-only scope does not allow modifying or deleting files.
How do I get started?
Register your app to get a client ID and test with the free sandbox. Plans are $14 or $29 per month per connected Apple Account, and sandbox access is free.
For a broader look at Apple data connectors, including Notes, Photos, and Safari, see Connect Apple Notes, Photos, Files, and Safari. To understand the authorization model in depth, see OAuth for iCloud: Connect Apple Data to Your App. For agents that trigger actions instead of reading files, Create Apple Reminders with EventKit on Mac covers the write side of native Mac integrations.