> ## 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 file download link

> Retrieve a signed URL you can use to download a file’s contents from your workspace library.

## Path parameters

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

## Response 200

Returns a string containing the signed download URL for the requested file.

Example response:

```json theme={"system"}
"https://storage.ai21.com/files/file_123abc/download?token=xyz"
```

### Response 422

No matching ID is found.

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

  file_id = "your_file_id_here"
  url = f"https://api.ai21.com/studio/v1/library/files/{file_id}/download"
  headers = {"Authorization": "Bearer your_api_key_here"}

  response = requests.get(url)

  if response.status_code == 200:
      print("Download URL:", response.text)
  else:
      print("Error:", response.status_code, response.text)
  ```

  ```javascript JavaScript theme={"system"}
  const file_id = "your_file_id_here";

  fetch(`https://api.ai21.com/studio/v1/library/files/${file_id}/download`, {
    method: "GET",
    headers: {
      "Authorization": "Bearer YOUR_API_KEY",
    },
  })
    .then(res => res.text())
    .then(link => console.log("Download URL:", link))
    .catch(err => console.error("Error:", err));
  ```

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

  $file_id = "your_file_id_here";
  $curl = curl_init();

  curl_setopt_array($curl, [
    CURLOPT_URL => "https://api.ai21.com/studio/v1/library/files/$file_id/download",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "GET",
    CURLOPT_HTTPHEADER => [
      "Authorization: Bearer YOUR_API_KEY"
    ],
  ]);

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

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

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

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

  func main() {
      fileID := "your_file_id_here"
      url := fmt.Sprintf("https://api.ai21.com/studio/v1/library/files/%s/download", fileID)

      req, err := http.NewRequest("GET", url, nil)
      if err != nil {
          fmt.Println("Error creating request:", err)
          return
      }

      req.Header.Add("Authorization", "Bearer YOUR_API_KEY")

      client := &http.Client{}
      resp, err := client.Do(req)
      if err != nil {
          fmt.Println("Error sending request:", err)
  ```

  ```cURL theme={"system"}
  curl -X GET "https://api.ai21.com/studio/v1/library/files/{file_id}/download" \
    -H "Authorization: Bearer YOUR_API_KEY"
  ```
</RequestExample>
