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

# Check File Hash

> Check whether a file with a given content hash already exists (deduplication)

## Overview

Checks whether the authenticated user already owns a file with the given **content hash** in a workspace.
Use this before uploading to implement **instant uploads / deduplication**: if the content already exists,
you can skip the upload entirely and reuse the existing entry.

<Note>
  Drime stores a **SHA-256** hex digest of the file content in the `file_hash` field. The official
  clients compute it at upload time and send it as `fileHash`, so the lookup only matches files
  uploaded with a hash.
</Note>

## Request Body

<ParamField body="fileHash" type="string" required>
  SHA-256 hex digest of the file content (64 lowercase hex characters)
</ParamField>

<ParamField body="workspaceId" type="integer">
  Workspace to search in. Defaults to `0` (personal space).
</ParamField>

## Response

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

<ResponseField name="exists" type="boolean">
  Whether a file with this content hash already exists for the current user in the workspace
</ResponseField>

<ResponseField name="entry" type="object">
  The matching file entry object. Only present when `exists` is `true`.
</ResponseField>

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

  ```javascript JavaScript theme={null}
  // Compute SHA-256 of a File in the browser
  const buffer = await file.arrayBuffer();
  const digest = await crypto.subtle.digest('SHA-256', buffer);
  const fileHash = [...new Uint8Array(digest)]
    .map(b => b.toString(16).padStart(2, '0'))
    .join('');

  const response = await fetch(
    'https://app.drime.cloud/api/v1/file-entries/hash/check',
    {
      method: 'POST',
      headers: {
        'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({ fileHash, workspaceId: 0 })
    }
  );

  const { exists, entry } = await response.json();
  if (exists) {
    console.log(`Already uploaded as entry ${entry.id}, skipping upload`);
  }
  ```

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

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

  response = requests.post(
      'https://app.drime.cloud/api/v1/file-entries/hash/check',
      headers={'Authorization': 'Bearer YOUR_ACCESS_TOKEN'},
      json={'fileHash': file_hash, 'workspaceId': 0}
  )

  data = response.json()
  if data['exists']:
      print(f"Already uploaded as entry {data['entry']['id']}")
  ```
</RequestExample>

<ResponseExample>
  ```json 200 - File exists theme={null}
  {
    "status": "success",
    "exists": true,
    "entry": {
      "id": 485529678,
      "name": "document.pdf",
      "type": "pdf",
      "file_size": 1048576,
      "file_hash": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
      "workspace_id": 0
    }
  }
  ```

  ```json 200 - File does not exist theme={null}
  {
    "status": "success",
    "exists": false
  }
  ```
</ResponseExample>
