---
updatedAt: 2025-09-25T21:09:55.000Z
agentTools:
  projectIndex: https://developers.toriihq.com/llms.txt
---

# Automating Expense Data Imports into Torii

Learn how to automate expense data imports into Torii using n8n and Workato. Get the API steps, see real-world workflows, and take away best practices to accelerate your own financial data integrations.

<Image align="center" src="https://files.readme.io/2dcc6e255c603d488706793a9707b3bec6671c5eb49569f9d913fb5c6c8de984-ChatGPT_Image_Aug_7_2025_01_25_10_PM.png" />

### **1. Introduction — The Problem and the Goal**

Expense data powers many of Torii’s most valuable insights — from SaaS spend optimization to license reclamation and governance. Yet for many organizations, that data sits siloed in ERP systems, expense platforms, or spreadsheets, requiring manual uploads to stay current.

In this guide, we’ll walk through two field-tested solutions: one built in **n8n** and one in **Workato**. Both achieve the same goal — automatically pushing expense data into Torii — but take different paths to get there. Along the way, we’ll share the API calls, field mapping tips, and best practices that make these workflows efficient and reliable.

***

### **2. How Torii Accepts Expense Data** *(Best Practices + API How-To)*

Torii’s expense data ingestion process has two main steps: uploading and parsing.

**Step 1 — Upload the file**\
Use the [`POST /files/upload`](https://developers.toriihq.com/reference/postfilesupload) endpoint to upload the file as multipart form data.

```bash
curl --request POST \
     --url https://api.toriihq.com/v1.0/files/upload \
     --header 'accept: */*' \
     --header 'content-type: multipart/form-data' \
     --form type=expenseReport
```

Example response:

```json
{
  "id": 1000
}
```

This `id` value becomes the `idFile` for the next step.

**Step 2 — Parse the file**\
Use the [`PUT /parsings/manual`](https://developers.toriihq.com/reference/putparsingsmanual) endpoint to map CSV columns to Torii’s fields.

```bash
curl --request PUT \
     --url https://api.toriihq.com/v1.0/parsings/manual \
     --header 'accept: */*' \
     --header 'content-type: application/json' \
     --data '
{
  "parseConfig": {
    "dateFormat": "DD/MM/YYYY",
    "transactionDateColumn": "A",
    "descriptionColumn": "B",
    "amountColumn": "C",
    "currencyColumn": "D",
    "reportingUserColumn": "E",
    "currency": "USD",
    "idFile": 1000
  }
}'
```

Adjust `parseConfig` to match your CSV.

**Best practices:**

* Confirm file format before upload.
* Map columns to match Torii’s expected schema.
* Test in staging before production.
* Monitor for parsing errors.

***

### **3. Example 1 — n8n Automation Flow**

**Goal:** Automatically push expense reports into Torii.

**Implementation:**

* Fetch expense data from source.
* Save as CSV.
* Send file to `/files/upload` (n8n handles multipart automatically).
* Call `/parsings/manual` with `parseConfig`.

**Advantages:**

* No extra code for multipart.
* Quick to implement.
* Easy scheduling.

**Impact:**

* No manual uploads.
* Real-time spend visibility.

***

### **4. Example 2 — Workato Automation Flow**

**Goal:** Upload and parse CSV expense data into Torii.

**Implementation:**

* Retrieve expense data and save as CSV.
* Convert to multipart form using a Ruby step:

```ruby
def process_csv_to_multipart(csv_content)
 require 'csv'
 rows = CSV.parse(csv_content, headers: true).map(&:to_h)
 multipart = []
 rows.each_with_index do |row, index|
  row.each do |header, value|
   multipart.push({
     name: "row#{index + 1}_#{header}",
     content: value.to_s,
     "content-type": "text/plain"
   })
  end
 end
 multipart
end
```

* Upload via `/files/upload`.
* Parse with `/parsings/manual`.

**Advantages:**

* Full transformation control.
* Handles complex preprocessing.

**Impact:**

* Works even with multipart limitations.
* Consistent expense ingestion.

***

### **5. Lessons Learned & Best Practices**

1. Choose the right tool — n8n for speed, Workato for flexibility.
2. Validate before sending — check formats, mappings, and configs.
3. Automate schedules for consistent updates.
4. Plan error handling — log and alert on failures.
5. Collaborate with finance and IT early.
6. Monitor API usage and batch large datasets.

***

### **6. Conclusion — Why This Matters**

Torii’s API makes it simple to automate expense data ingestion, whether you use low-code tools like n8n or enterprise integration platforms like Workato. Both approaches deliver the same outcome — up-to-date SaaS spend insights — freeing teams to focus on strategy instead of file management.

**Next steps:**

* Visit the [Torii Developer Docs](https://developers.toriihq.com)
* Review [`/files/upload`](https://developers.toriihq.com/reference/postfilesupload) and [`/parsings/manual`](https://developers.toriihq.com/reference/putparsingsmanual)
* Build your own automated pipeline today.

***