> ## Documentation Index
> Fetch the complete documentation index at: https://docs.extend.app/llms.txt
> Use this file to discover all available pages before exploring further.

# List Files

> List files in your account.

This endpoint allows you to fetch the files in your account.

This endpoint returns a paginated response. You can use the `nextPageToken` to fetch subsequent pages.

### Query Parameters

<ParamField query="nameContains" type="string" optional>
  Filters files by the name of the file.
</ParamField>

<ParamField query="sortBy" type="string" default="createdAt" optional>
  Sorts the files by the given field.

  Possible values include:

  * `createdAt`
</ParamField>

<ParamField query="sortDir" type="string" default="desc" optional>
  Sorts the files in ascending or descending order.

  Possible values include:

  * `asc`: sort in ascending order
  * `desc`: sort in descending order
</ParamField>

<ParamField query="nextPageToken" type="string" optional>
  The token used to fetch the page of results from a previous request.

  **Note**: if parameters other than `nextPageToken` change in subsequent requests, you are likely to receive incomplete results.
</ParamField>

<ParamField query="maxPageSize" type="number" default="10" optional>
  The maximum number of results to return per page.

  You are not guaranteed to receive this many results per page, but you will not receive more than this.

  * Max: 1000
  * Min: 1
</ParamField>

### Response

<ResponseField name="success" type="boolean">
  A true or false value indicating whether the request was successful or not.
</ResponseField>

<ResponseField name="files" type="array">
  An array of [File](/api-reference/objects/file) objects.
</ResponseField>

<ResponseField name="nextPageToken" type="string" optional>
  The token used to fetch the next page of results.

  If there are no more pages, the token will not be present.

  The general pattern for collecting all results is to keep calling the endpoint with the `nextPageToken` and the same parameters, until the token is not present, for example:

  ```
  files = []
  token = None
  while True:
    response = list_files(nextPageToken=token)
    files.extend(response.files)
    token = response.nextPageToken
    if not token:
      break
  ```
</ResponseField>

### Error Responses

<ResponseField name="success" type="boolean">
  Will be `false` if the request failed.
</ResponseField>

<ResponseField name="error" type="string">
  A description of the error that occurred.
</ResponseField>

#### Possible Errors

* **404 Not Found**: If the specified file does not exist.
* **400 Bad Request**: If invalid query parameters are provided.

<ResponseExample>
  ```json Example Success Response theme={null}
  {
    "success": true,
    "nextPageToken": "abc123",
    "files": [
      {
          "object": "file",
          "id": "file_1234",
          "name": "example_file",
          "type": "PDF",
          "presignedUrl": "https://s3.example.com/file_1234.pdf",
          "metadata": {
              "pageCount": 10
          }
          "createdAt": "2024-01-01T00:00:00Z",
          "updatedAt": "2024-01-01T00:00:00Z"
      }
    ]
  }
  ```
</ResponseExample>
