Retrieve the contents of a directory by specifying a path using segments. This method is useful when you want to navigate through directories based on a custom path.

try {
  const segments = 'folder1-ID/subfolder1-ID/subfolder2-ID' // Replace with your desired path
  const response = await sdk.directory.getBySegment(segments)
  const { directories, files } = response.data

  console.log('Directories:')
  directories.forEach((directory) => {
    console.log(directory.name)
  })

  console.log('Files:')
  files.forEach((file) => {
    console.log(file.name)
  })
} catch (error) {
  console.error(error.message)
}

Params

  • segments (string): A custom path to the directory, where segments are separated by slashes ('/'). Specify the path to the directory you want to retrieve.

Required API Key Permission

  • Read Directory