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

# Set File Metadata

> Set the original modification time (SetModTime), EXIF data or Live Photo link of a file

## Overview

Updates metadata on an existing file **without re-uploading its content**. This is the endpoint to use when you need to:

* **Preserve the original modification time** of a file after upload (equivalent to rclone's `SetModTime`)
* Attach or merge **EXIF data** after the file content has been uploaded
* Link an iOS **Live Photo** to its video counterpart

<Note>
  At least one of `lastModified` or `exifData` must be provided, otherwise the request fails with a `422` error.
</Note>

## Path Parameters

<ParamField path="entryId" type="integer" required>
  The **numeric** file entry ID. Entry hashes are not accepted on this endpoint.
</ParamField>

## Request Body

<ParamField body="lastModified" type="integer">
  Original client-side modification time as a **Unix epoch in milliseconds** (e.g. `1712345678000`).
  Stored in the entry's `client_last_modified` field and merged into its EXIF data.

  <Warning>
    Milliseconds, not seconds. `1712345678` (seconds) would be interpreted as January 1970.
  </Warning>
</ParamField>

<ParamField body="exifData" type="string | object">
  EXIF metadata to merge into the entry. Accepts either:

  * A **base64-encoded JSON** string
  * A raw **JSON string**
  * A plain **JSON object**

  Existing EXIF keys are preserved; provided keys overwrite matching ones. If the merged EXIF
  contains a capture date, the entry's `captured_at` (used by the photo timeline) is updated too.
</ParamField>

<ParamField body="livePhotoCID" type="string">
  Apple Live Photo content identifier. Only stored if the entry does not already have one.
</ParamField>

## Response

<ResponseField name="status" type="string">
  Request status (`success`)
</ResponseField>

<ResponseField name="updated" type="boolean">
  `true` when the metadata was stored
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST https://app.drime.cloud/api/v1/file-entries/485529678/metadata \
    -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{
      "lastModified": 1712345678000
    }'
  ```

  ```javascript JavaScript theme={null}
  const entryId = 485529678;

  // Preserve the file original mtime after upload
  const response = await fetch(
    `https://app.drime.cloud/api/v1/file-entries/${entryId}/metadata`,
    {
      method: 'POST',
      headers: {
        'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        lastModified: file.lastModified // ms epoch from the File API
      })
    }
  );

  const { updated } = await response.json();
  ```

  ```python Python theme={null}
  import os
  import requests

  entry_id = 485529678
  path = '/path/to/local/file.pdf'

  # os.path.getmtime returns seconds - convert to milliseconds
  mtime_ms = int(os.path.getmtime(path) * 1000)

  response = requests.post(
      f'https://app.drime.cloud/api/v1/file-entries/{entry_id}/metadata',
      headers={'Authorization': 'Bearer YOUR_ACCESS_TOKEN'},
      json={'lastModified': mtime_ms}
  )

  print(response.json())  # {'status': 'success', 'updated': True}
  ```
</RequestExample>

<ResponseExample>
  ```json 200 - Success theme={null}
  {
    "status": "success",
    "updated": true
  }
  ```

  ```json 422 - No metadata provided theme={null}
  {
    "status": "error",
    "message": "No metadata provided"
  }
  ```

  ```json 404 - Entry not found theme={null}
  {
    "message": "No query results for model [FileEntry] 999999999"
  }
  ```
</ResponseExample>

<Tip>
  You can also set `lastModified` **directly at upload time** by including it in the
  [Upload File](/api-reference/uploads/upload-file) or [Create S3 Entry](/api-reference/uploads/create-s3-entry)
  request body. Use this endpoint when the file already exists, or to fix timestamps after the fact.
</Tip>
