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

# Validate Upload

> Check for duplicate files before uploading

## Overview

Validates files before upload by checking if files with the same name already exist at the specified location. Returns a list of duplicate filenames.

## Query Parameters

<ParamField query="workspaceId" type="integer">
  Workspace ID
</ParamField>

## Request Body

<ParamField body="files" type="array" required>
  Array of files to validate

  <Expandable title="File object properties">
    <ParamField body="name" type="string" required>
      Filename to check
    </ParamField>

    <ParamField body="size" type="integer" required>
      File size in bytes
    </ParamField>

    <ParamField body="relativePath" type="string" required>
      Path where file would be uploaded
    </ParamField>
  </Expandable>
</ParamField>

## Response

<ResponseField name="errors" type="boolean">
  `true` if duplicates were found
</ResponseField>

<ResponseField name="duplicates" type="array">
  Array of filenames that already exist
</ResponseField>

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

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "https://app.drime.cloud/api/v1/uploads/validate?workspaceId=0" \
    -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{
      "files": [
        {"name": "photo1.jpg", "size": 1048576, "relativePath": "/photos"},
        {"name": "photo2.jpg", "size": 2048576, "relativePath": "/photos"}
      ]
    }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    'https://app.drime.cloud/api/v1/uploads/validate?workspaceId=0',
    {
      method: 'POST',
      headers: {
        'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        files: [
          { name: 'photo1.jpg', size: 1048576, relativePath: '/photos' },
          { name: 'photo2.jpg', size: 2048576, relativePath: '/photos' }
        ]
      })
    }
  );

  const { errors, duplicates } = await response.json();

  if (errors) {
    console.log('Duplicates found:', duplicates);
    // Handle duplicates - rename or skip
  }
  ```

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

  response = requests.post(
      'https://app.drime.cloud/api/v1/uploads/validate',
      params={'workspaceId': 0},
      headers={'Authorization': 'Bearer YOUR_ACCESS_TOKEN'},
      json={
          'files': [
              {'name': 'photo1.jpg', 'size': 1048576, 'relativePath': '/photos'},
              {'name': 'photo2.jpg', 'size': 2048576, 'relativePath': '/photos'}
          ]
      }
  )

  data = response.json()
  if data['errors']:
      print(f"Duplicates found: {data['duplicates']}")
  ```
</RequestExample>

<ResponseExample>
  ```json 200 - No duplicates theme={null}
  {
    "errors": false,
    "duplicates": [],
    "status": "success"
  }
  ```

  ```json 200 - Duplicates found theme={null}
  {
    "errors": true,
    "duplicates": ["photo1.jpg"],
    "status": "success"
  }
  ```
</ResponseExample>

<Tip>
  Use `/entry/getAvailableName` to get an alternative filename when duplicates are found.
</Tip>
