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

# Verify File Integrity

> Verify that the stored file content matches a SHA-256 hash

## Overview

Asks the server to recompute the **SHA-256** hash of the stored file content and compare it against
the hash you provide. Use this after an upload to confirm the file was stored without corruption,
end to end.

The server streams the stored object in 2 MB chunks, so this works for large files without
loading them in memory. When verification succeeds and the entry has no stored hash yet, the
computed SHA-256 is saved to the entry's `file_hash` field for future lookups.

<Note>
  Only the **owner** of the file can call this endpoint. Other users receive a `403` error.
</Note>

## Path Parameters

<ParamField path="entryId" type="integer" required>
  The numeric file entry ID
</ParamField>

## Request Body

<ParamField body="sha256" type="string" required>
  Expected SHA-256 hex digest of the file content (exactly 64 characters, case-insensitive)
</ParamField>

## Response

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

<ResponseField name="verified" type="boolean">
  `true` when the stored content matches the provided hash
</ResponseField>

<ResponseField name="serverHash" type="string">
  SHA-256 computed by the server from the stored content. Omitted when the file could not be read.
</ResponseField>

<ResponseField name="reason" type="string">
  Only present on failure to read the file: `file_not_found` or `read_failed`
</ResponseField>

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

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

  const response = await fetch(
    `https://app.drime.cloud/api/v1/file-entries/${entryId}/verify-integrity`,
    {
      method: 'POST',
      headers: {
        'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        sha256: localFileHash // computed before upload
      })
    }
  );

  const { verified, serverHash } = await response.json();
  if (!verified) {
    console.error(`Integrity check failed, server has ${serverHash}`);
  }
  ```

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

  entry_id = 485529678

  with open('/path/to/file.pdf', 'rb') as f:
      local_hash = hashlib.sha256(f.read()).hexdigest()

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

  result = response.json()
  print('OK' if result['verified'] else f"MISMATCH: server={result['serverHash']}")
  ```
</RequestExample>

<ResponseExample>
  ```json 200 - Verified theme={null}
  {
    "status": "success",
    "verified": true,
    "serverHash": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08"
  }
  ```

  ```json 200 - Mismatch theme={null}
  {
    "status": "success",
    "verified": false,
    "serverHash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
  }
  ```

  ```json 403 - Not the owner theme={null}
  {
    "message": "This action is unauthorized."
  }
  ```
</ResponseExample>

<Tip>
  For large files, computing the SHA-256 on the server means reading the whole object from storage.
  Prefer calling this once after upload rather than on every sync pass; afterwards you can rely on
  the `file_hash` field returned by [Get File Entry](/api-reference/files/get-file-entry).
</Tip>
