> ## 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.

# Get workspace file

> Retrieve metadata about a specific file.

The `file_id` is generated by AI21 when you upload the file.

## Path Parameters

<ParamField path="file_id" type="string">
  The unique ID of the file to retrieve.
</ParamField>

## Responses

### Response 200

A successful response returns metadata about the requested file.

<ParamField path="id" type="string">
  The file ID.
</ParamField>

<ParamField path="name" type="string">
  The file name.
</ParamField>

<ParamField path="size" type="int">
  File size in bytes.
</ParamField>

<ParamField path="created_at" type="string">
  File creation timestamp.
</ParamField>

<ParamField path="labels" type="array">
  Labels assigned to the file
</ParamField>

<ParamField path="errorCode" type="int">
  Error code, if any.
</ParamField>

<ParamField path="errorMessage" type="string">
  Error message, if any.
</ParamField>

### Response 422

No matching ID is found.

<RequestExample>
  ```python Python theme={"system"}
  from ai21 import AI21Client

  client = AI21Client()

  # Replace with your actual file_id
  file_id = "file_123abc"

  # Retrieve file metadata
  file_metadata = client.library.files.get(file_id=file_id)

  print(file_metadata)
  ```

  ```javascript JavaScript theme={"system"}
  const options = {method: 'GET'};

  fetch('https://api.ai21.com/studio/v1/library/files/{file_id}', 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/{file_id}",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "GET",
  ]);

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

  curl_close($curl);

  if ($err) {
    echo "cURL Error #:" . $err;
  } else {
    echo $response;
  }
  ```

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

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

  func main() {

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

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

          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/{file_id}
  ```

  ```java Java theme={"system"}
  HttpResponse<String> response = Unirest.get("https://api.ai21.com/studio/v1/library/files/{file_id}")
    .asString();
  ```
</RequestExample>

<ResponseExample>
  ```json JSON theme={"system"}
  {
    "id": "file_123abc",
    "name": "customer_data.pdf",
    "size": 204800,
    "created_at": "2025-10-20T14:23:11Z",
    "labels": ["invoices", "Q3"]
  }
  ```
</ResponseExample>
