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

# List library files

> Retrieve a list of documents in the user's library.  You can optionally specify a filter to return only files with matching labels.

When specifying qualifiers with your request, only files that match all qualifiers will be returned. For example, if you specify `label='financial'` and `status='UPLOADED'`, only files with the label 'financial' **and** status 'UPLOADED' will be returned.

## Request  parameters

The following optional parameters can be used to filter your results.

<ParamField body="name" type="string">
  The full name of the uploaded file, without any path parameters. So: "mydoc.txt", not "/users/benfranklyn/Documents/mydoc.txt". Does not match name substrings, so "doc.txt" does not match "mydoc.txt".
</ParamField>

<ParamField body="status" type="string">
  Status of the file in the library. Supported values:

  * `DB_RECORD_CREATED`
  * `UPLOADED`
  * `UPLOAD_FAILED`
  * `PROCESSED`
  * `PROCESSING_FAILED`
</ParamField>

<ParamField body="label" type="string[]">
  Return only files with this label. Label matching is case-sensitive, and will not match substrings.
</ParamField>

<ParamField body="Pagination" type="object">
  By default, the endpoint returns up to 10000 files. Pagination can be controlled using the following parameters:

  <Expandable title="properties">
    <ParamField body="offset" type="integer">
      The number of files to skip.
    </ParamField>

    <ParamField body="limit" type="integer">
      The number of files to retrieve (maximum 1,000, default 1,000)
    </ParamField>
  </Expandable>
</ParamField>

## Responses

### Response 200

A successful response returns an array of file metadata items.

<RequestExample>
  ```python Python theme={"system"}
  import requests

  url = "https://api.ai21.com/studio/v1/library/files"

  payload = {
      "name": "<string>",
      "status": "<string>",
      "label": ["<string>"],
      "Pagination": {
          "offset": 123,
          "limit": 123
      }
  }
  headers = {"Content-Type": "application/json"}

  response = requests.request("GET", url, json=payload, headers=headers)

  print(response.text)
  ```

  ```javascript JavaScript theme={"system"}
  const options = {
    method: 'GET',
    headers: {'Content-Type': 'application/json'},
    body: '{"name":"<string>","path":"<string>","status":"<string>","label":["<string>"],"Pagination":{"offset":123,"limit":123}}'
  };

  fetch('https://api.ai21.com/studio/v1/library/files', options)
    .then(response => response.json())
    .then(response => console.log(response))
    .catch(err => console.error(err));
  ```

  ```php PHP theme={"system"}
  <?php

  $curl = curl_init();

  curl_setopt_array($curl, [
    CURLOPT_URL => "https://api.ai21.com/studio/v1/library/files",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "GET",
    CURLOPT_POSTFIELDS => "{\n  \"name\": \"<string>\",\n  \"path\": \"<string>\",\n  \"status\": \"<string>\",\n  \"label\": [\n    \"<string>\"\n  ],\n  \"Pagination\": {\n    \"offset\": 123,\n    \"limit\": 123\n  }\n}",
    CURLOPT_HTTPHEADER => [
      "Content-Type: application/json"
    ],
  ]);

  $response = curl_exec($curl);
  $err = curl_error($curl);

  curl_close($curl);
  ```

  ```go Go theme={"system"}
  package main

  import (
          "fmt"
          "strings"
          "net/http"
          "io/ioutil"
  )

  func main() {

          url := "https://api.ai21.com/studio/v1/library/files"

          payload := strings.NewReader("{\n  \"name\": \"<string>\",\n  \"path\": \"<string>\",\n  \"status\": \"<string>\",\n  \"label\": [\n    \"<string>\"\n  ],\n  \"Pagination\": {\n    \"offset\": 123,\n    \"limit\": 123\n  }\n}")

          req, _ := http.NewRequest("GET", url, payload)

          req.Header.Add("Content-Type", "application/json")

          res, _ := http.DefaultClient.Do(req)

          defer res.Body.Close()
          body, _ := ioutil.ReadAll(res.Body)

          fmt.Println(res)
          fmt.Println(string(body))

  }
  ```

  ```bash cURL theme={"system"}
  curl --request GET \
    --url https://api.ai21.com/studio/v1/library/files \
    --header 'Content-Type: application/json' \
    --data '{
    "name": "<string>",
    "path": "<string>",
    "status": "<string>",
    "label": [
      "<string>"
    ],
    "Pagination": {
      "offset": 123,
      "limit": 123
    }
  ```

  ```java Java theme={"system"}
  HttpResponse<String> response = Unirest.get("https://api.ai21.com/studio/v1/library/files")
    .header("Content-Type", "application/json")
    .queryString("name", "<string>")
    .queryString("path", "<string>")
    .queryString("status", "<string>")
    .queryString("label", "<string>")
    .queryString("offset", 123)
    .queryString("limit", 123)
    .asString();
  ```
</RequestExample>
