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

# CSV Import

> Bulk select files using CSV upload with file IDs

## Overview

CSV Import allows you to bulk-select files for export by uploading or pasting a CSV file containing file IDs. This is ideal when you have a pre-determined list of files to export, such as from a report or external system.

<Info>
  CSV Import bypasses query building entirely - you provide the specific file IDs you want to export, and FileFetch retrieves only those files.
</Info>

## When to Use CSV Import

CSV Import is perfect for:

<CardGroup cols={2}>
  <Card title="Report-Based Exports" icon="table">
    Export files from a Salesforce report or external list
  </Card>

  <Card title="Selective Exports" icon="hand-pointer">
    Export specific files you've manually identified
  </Card>

  <Card title="Integration Workflows" icon="arrows-rotate">
    Automate exports based on external system data
  </Card>

  <Card title="Large Batch Jobs" icon="layer-group">
    Export more than 2000 files (SOQL limit) by providing IDs directly
  </Card>
</CardGroup>

## CSV Format Requirements

Your CSV file must contain a column with file IDs. FileFetch automatically detects the ID type:

<Tabs>
  <Tab title="Files (ContentVersion)">
    **ContentDocumentId**

    For Salesforce Files, use the ContentDocumentId (18-character ID starting with `069`).

    **Example CSV**:

    ```csv theme={null}
    ContentDocumentId
    069xx000000ABCDEA4
    069xx000000EFGHEA4
    069xx000000IJKLEA4
    ```

    **With Additional Columns** (optional):

    ```csv theme={null}
    ContentDocumentId,FileName,Description
    069xx000000ABCDEA4,Contract_2024.pdf,Annual contract
    069xx000000EFGHEA4,Invoice_Q1.xlsx,Q1 invoices
    069xx000000IJKLEA4,Photo.jpg,Product photo
    ```

    <Note>
      FileFetch only uses the ContentDocumentId column. Other columns are ignored but can help you organize your list.
    </Note>
  </Tab>

  <Tab title="Attachments">
    **Attachment ID**

    For legacy Attachments, use the Attachment record ID (18-character ID starting with `00P`).

    **Example CSV**:

    ```csv theme={null}
    Id
    00Pxx000000ABCDEA4
    00Pxx000000EFGHEA4
    00Pxx000000IJKLEA4
    ```

    **With Additional Columns** (optional):

    ```csv theme={null}
    Id,Name,ParentId
    00Pxx000000ABCDEA4,Document.pdf,001xx000000AAAAA
    00Pxx000000EFGHEA4,Image.png,001xx000000BBBBB
    00Pxx000000IJKLEA4,Report.xlsx,001xx000000CCCCC
    ```
  </Tab>
</Tabs>

### Accepted Formats

FileFetch accepts various CSV formats:

| Format | Example | Notes |
| - | - | - |
| **With Header** | `ContentDocumentId` <br /> `069...` | Recommended - FileFetch auto-detects column |
| **Without Header** | `069...` <br /> `069...` | First line treated as ID |
| **Multiple Columns** | `069...,filename.pdf` | Only ID column is used |
| **Quoted Values** | `"069...","file.pdf"` | Quotes are stripped automatically |

<Warning>
  **ID Format**: All IDs must be 18-character Salesforce IDs. 15-character IDs are not supported. FileFetch validates each ID and reports errors for invalid formats.
</Warning>

## Uploading a CSV File

<Steps>
  <Step title="Switch to CSV Mode">
    In the Query Editor, click the **CSV** tab to switch from SOQL to CSV input mode
  </Step>

  <Step title="Upload CSV File">
    Click **Upload CSV File** button

    Select your `.csv` file from your computer

    FileFetch will:

    * Read the file content
    * Auto-detect the ID column
    * Parse all valid IDs
    * Display the content in the text area
  </Step>

  <Step title="Review Parsed Content">
    The CSV content appears in the editor

    You can edit it directly if needed
  </Step>

  <Step title="Load Files">
    Click **Load Files** (or press `⌘/Ctrl + Enter`)

    FileFetch will process the CSV and fetch matching files
  </Step>
</Steps>

## Pasting CSV Content

Alternatively, paste CSV content directly:

<Steps>
  <Step title="Switch to CSV Mode">
    Click the **CSV** tab in the Query Editor
  </Step>

  <Step title="Paste Content">
    Click in the CSV text area

    Paste your CSV content (`⌘/Ctrl + V`)

    Content can be:

    * Copied from Excel/Google Sheets
    * Exported from a Salesforce report
    * Generated from another system
  </Step>

  <Step title="Load Files">
    Click **Load Files** to process the IDs
  </Step>
</Steps>

## CSV Processing

When you load a CSV, FileFetch performs the following:

<Steps>
  <Step title="Parse CSV">
    FileFetch reads the CSV and extracts IDs:

    * Detects header row (if present)
    * Identifies ID column (ContentDocumentId or Id)
    * Validates ID format (18-character Salesforce ID)
    * Filters out invalid rows
  </Step>

  <Step title="Detect ID Type">
    FileFetch auto-detects the ID type based on prefix:

    * **069...** → ContentDocumentId (Files)
    * **00P...** → Attachment ID (Attachments)

    <Info>
      The detected type must match your selected Export Type (Files vs Attachments). If there's a mismatch, FileFetch will display an error.
    </Info>
  </Step>

  <Step title="Batch Query">
    FileFetch queries Salesforce in batches of 200 IDs:

    * Builds SOQL query: `WHERE ContentDocumentId IN (...)`
    * Fetches file metadata for each batch
    * Combines results from all batches
  </Step>

  <Step title="Display Results">
    Matching files appear in the results table

    Any missing or inaccessible files are reported as errors
  </Step>
</Steps>

## Error Handling

FileFetch validates your CSV and reports issues:

### CSV Parsing Errors

<AccordionGroup>
  <Accordion title="Invalid ID format">
    **Row 5: '12345' - Invalid ID format (must be 18 characters)**

    **Cause**: ID is not a valid 18-character Salesforce ID

    **Solution**: Ensure all IDs are 18 characters long. If you have 15-character IDs, convert them to 18-character format in Salesforce first.
  </Accordion>

  <Accordion title="Empty row">
    **Row 3: Empty or whitespace-only row**

    **Cause**: CSV row contains no data or only whitespace

    **Solution**: These rows are automatically skipped. No action needed.
  </Accordion>

  <Accordion title="ID type mismatch">
    **CSV contains ContentDocumentIds, but you're in Attachments mode**

    **Cause**: CSV has Files IDs (069...) but Export Type is set to Attachments

    **Solution**: Switch Export Type to **Files** in the Export Configuration panel
  </Accordion>

  <Accordion title="No valid IDs found">
    **No valid IDs found in CSV**

    **Cause**: CSV doesn't contain any recognizable Salesforce IDs

    **Solution**:

    * Check that IDs are in the correct format
    * Ensure CSV has a column with IDs
    * Verify IDs start with 069 (Files) or 00P (Attachments)
  </Accordion>
</AccordionGroup>

### File Not Found Errors

After loading the CSV, you may see warnings for files that couldn't be retrieved:

**File not found or no access**: `069xx000000ABCDEA4`

**Possible Causes**:

* File was deleted from Salesforce
* You don't have permission to access the file
* ID is incorrect or doesn't exist
* File is in a different Salesforce org

**What Happens**: FileFetch skips missing files and continues with the rest. You can export the files that were successfully found.

## CSV Error Banner

When FileFetch encounters parsing or retrieval errors, a yellow warning banner appears above the results table:

**Example**:

```
⚠️ 5 rows had issues

Row 2: "invalid-id" - Invalid ID format
Row 7: "069xx000000ZZZZZ" - File not found or no access
Row 12: Empty or whitespace-only row
... and 2 more
```

<Tip>
  Click the **×** to dismiss the banner. The errors don't prevent you from exporting files that were successfully loaded.
</Tip>

## Example CSV Files

### Minimal Files CSV

```csv theme={null}
ContentDocumentId
069xx000000ABCDEA4
069xx000000EFGHEA4
069xx000000IJKLEA4
069xx000000MNOPEA4
```

### Detailed Files CSV

```csv theme={null}
ContentDocumentId,FileName,Category,CreatedDate
069xx000000ABCDEA4,Contract_Acme.pdf,Contracts,2024-01-15
069xx000000EFGHEA4,Invoice_January.xlsx,Invoices,2024-02-01
069xx000000IJKLEA4,Product_Photo.jpg,Media,2024-03-10
069xx000000MNOPEA4,Proposal_Q2.docx,Proposals,2024-04-05
```

### Minimal Attachments CSV

```csv theme={null}
Id
00Pxx000000ABCDEA4
00Pxx000000EFGHEA4
00Pxx000000IJKLEA4
```

### Salesforce Report Export

If you export a Salesforce report as CSV, you can use it directly:

```csv theme={null}
"File Name","Content Document ID","Created Date","Owner"
"Annual Report.pdf","069xx000000ABCDEA4","1/15/2024","John Smith"
"Q1 Results.xlsx","069xx000000EFGHEA4","2/1/2024","Jane Doe"
"Product Specs.docx","069xx000000IJKLEA4","3/10/2024","Bob Johnson"
```

FileFetch will automatically detect the "Content Document ID" column.

## Best Practices

<CardGroup cols={2}>
  <Card title="Validate IDs First" icon="check-circle">
    Test with a small CSV (5-10 IDs) before processing large batches
  </Card>

  <Card title="Include Headers" icon="heading">
    Use column headers for clarity and easier debugging
  </Card>

  <Card title="Keep Extra Columns" icon="table-columns">
    Additional columns (names, dates) help you organize without affecting FileFetch
  </Card>

  <Card title="Check Error Messages" icon="triangle-exclamation">
    Review parsing errors and fix invalid rows before re-uploading
  </Card>
</CardGroup>

## Limitations

| Aspect | Limit | Notes |
| - | - | - |
| **File Size** | 5MB max | CSV file size limit |
| **Number of IDs** | No hard limit | Processed in batches of 200 |
| **ID Format** | 18-character only | 15-character IDs not supported |
| **Mixed ID Types** | Not supported | All IDs must be same type (Files OR Attachments) |

<Warning>
  If you need to export both Files and Attachments, you must run two separate exports with different CSVs.
</Warning>

## Exporting from Salesforce Reports

To create a CSV from a Salesforce report:

<Steps>
  <Step title="Create Report">
    In Salesforce, create a report on:

    * **Files**: Content Document report type
    * **Attachments**: Attachment report type
  </Step>

  <Step title="Add ID Field">
    Add the ID field to your report columns:

    * **Files**: Content Document ID
    * **Attachments**: Attachment ID
  </Step>

  <Step title="Apply Filters">
    Filter the report to show only files you want to export
  </Step>

  <Step title="Export Report">
    Click **Export Details** → **Formatted Report**

    Save as CSV
  </Step>

  <Step title="Upload to FileFetch">
    Use the CSV file in FileFetch's CSV Import feature
  </Step>
</Steps>

## Next Steps

<CardGroup cols={2}>
  <Card title="Export Configuration" icon="gear" href="/export-config">
    Configure how files are organized and named during export
  </Card>

  <Card title="Query Builder" icon="filter" href="/query-builder">
    Use visual filters if you don't have a pre-made list of IDs
  </Card>

  <Card title="Power Mode" icon="code" href="/power-mode">
    Write SOQL queries to find files dynamically
  </Card>

  <Card title="Troubleshooting" icon="wrench" href="/troubleshooting">
    Common CSV import issues and solutions
  </Card>
</CardGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.