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

# Update file

> Update the specified parameters of a specific document in the user's library. This operation currently supports updating the publicUrl and labels parameters.

## Request body

<ParamField body="publicUrl" type="string">
  The updated public URL of the document.
</ParamField>

<ParamField body="labels" type="string[]">
  The updated labels associated with the file. Separate multiple labels with commas.
</ParamField>

## Responses

If the update is successful, the server will return an HTTP status code 200 with no body content. If the document ID does not exist, a 422 error message will be returned.

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

  client = AI21Client()

  file_id = client.library.files.create(
      labels=["label1", "label2"],
      public_url="www.example.com",
  )

  uploaded_file = client.library.files.get(file_id)
  ```

  ```javascript JavaScript theme={"system"}
  const options = {
    method: 'PUT',
    headers: {'Content-Type': 'application/json'},
    body: '{"publicUrl":"<string>","labels":["<string>"]}'
  };

  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 => "PUT",
    CURLOPT_POSTFIELDS => "{\n  \"publicUrl\": \"<string>\",\n  \"labels\": [\n    \"<string>\"\n  ]\n}",
    CURLOPT_HTTPHEADER => [
      "Content-Type: application/json"
    ],
  ]);

  $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"
          "strings"
          "net/http"
          "io/ioutil"
  )

  func main() {

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

          payload := strings.NewReader("{\n  \"publicUrl\": \"<string>\",\n  \"labels\": [\n    \"<string>\"\n  ]\n}")

          req, _ := http.NewRequest("PUT", 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 PUT \
    --url https://api.ai21.com/studio/v1/library/files/{file_id} \
    --header 'Content-Type: application/json' \
    --data '{
    "publicUrl": "<string>",
    "labels": [
      "<string>"
    ]
  }'
  ```

  ```java Java theme={"system"}
  HttpResponse<String> response = Unirest.put("https://api.ai21.com/studio/v1/library/files/{file_id}")
    .header("Content-Type", "application/json")
    .body("{\n  \"publicUrl\": \"<string>\",\n  \"labels\": [\n    \"<string>\"\n  ]\n}")
    .asString();
  ```
</RequestExample>
