# dataSources.importFiles

Import up to 25 files from a data source into Oatmilk: receipts (processed like uploaded receipts), tax_sources (supporting originals, no expense), signing_files (documents to send for signature), executed_agreements (agreements signed elsewhere; targetOptions parties, executedOn, title) contractor_agreements (draft documents; optional targetOptions contractorId, expectedContractorRevision and title create the draft agreement) or company_documents (incorporation papers and other company records: each is filed through intake as a company record, read, and fills the company profile's empty fields; the record is the document id). Sources are notion and google_drive. Each file is downloaded server-side, checked against its target's size limit and file types by its contents, and run through that target's usual upload path. Importing the same file into the same place again returns the existing record. Returns a result for each file. Supply idempotencyKey.

`POST /api/v1/accounting/dataSources.importFiles`

Permissions: `accounting:read`, `accounting:write` · Roles: admin, finance · Idempotency key required

MCP tool: `accounting_data_sources_import_files`

## Fields

| Field | Type | Required | Notes |
| --- | --- | --- | --- |
| `source` | enum | Yes | Where the record came from. One of: `notion`, `google_drive`, `onedrive`. |
| `target` | enum | Yes | One of: `receipts`, `tax_sources`, `signing_files`, `executed_agreements`, `contractor_agreements`, `company_documents`. |
| `items` | array of objects | Yes | 1–25 items. |
| `items[].itemId` | string | Yes | 1–200 characters; Matches ^[A-Za-z0-9_.:-]+$. |
| `items[].fileId` | string | Yes | 1–200 characters; Matches ^[A-Za-z0-9_.:-]+$. |
| `targetOptions` | map |  |  |
| `idempotencyKey` | string | Yes | Any unique text you generate once per intended change, so a retried request only happens once. Send it as the Idempotency-Key header instead if you prefer; if you send both they must match. 8–200 characters. |

## Example request

```bash
curl https://app.getoatmilk.com/api/v1/accounting/dataSources.importFiles \
  -H "Authorization: Bearer $OATMILK_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
  "source": "notion",
  "target": "receipts",
  "items": [
    {
      "itemId": "item_id",
      "fileId": "file_id"
    }
  ]
}'
```

Reference page: https://app.getoatmilk.com/docs/api/dataSources.importFiles
