---
title: "List files in a directory on the device"
method: POST
path: "/sessions/{sessionId}/device/listFiles"
tags: ["Device File Management"]
---

# List files in a directory on the device

`POST /sessions/{sessionId}/device/listFiles`

## Request

- Base URL: `https://api.us-west-1.saucelabs.com/rdc/v2`
- URL: `https://api.us-west-1.saucelabs.com/rdc/v2/sessions/{sessionId}/device/listFiles`
- Auth: HTTP basic
- TypeScript: <https://skmtc.dev/saucelabs/apis/real-device-access-api-reference/docs/sessions/:sessionId/device/listFiles/post.ts> (a function with typed inputs; its response is checked against the schema)

Returns a list of files and directories at the specified path on the device storage.

## Path parameters

- `sessionId` string, required

## Request body

- ListFilesRequest
  - `path` string, required: The path to the directory to list files from.
  - `bundleId` string: The iOS app bundle identifier (e.g., `com.example.app`). Required for iOS devices, not needed for Android. On iOS, each app runs in its own **sandbox** — an isolated file system container that restricts access to only that app's data. This means you must specify which app's sandbox to operate on by providing its bundle ID. You can find the bundle ID in Xcode, in the app's `Info.plist`, or via the Sauce Labs app management API. See [Apple's File System documentation](https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html) for more details.

## Response `200`

List of files retrieved successfully

- string[]

## Other responses

- `400`: Bad request or missing bundleId for iOS file operations
- `404`: Not Found
- `422`: Capability not supported
- `500`: Device File Operation Error

---

[API](https://skmtc.dev/saucelabs/apis/real-device-access-api-reference.md) - [All operations](https://skmtc.dev/saucelabs/apis/real-device-access-api-reference/llms.txt) - [OpenAPI document](https://skmtc.dev/saucelabs/apis/real-device-access-api-reference/revisions/f845a4b66e37?raw)
