Overview
The expense management flow consists of three main steps:- Create Expense - Submit expense data to Sync2Books
- Automatic Sync - Sync2Books automatically syncs to the connected accounting system
- Monitor Status - Track sync progress and handle any errors
Core Flow
Prerequisites
Before creating expenses, ensure you have:- ✅ API Key - Your application’s API key
- ✅ Connection ID - A connected accounting system (QuickBooks, Xero, or Sage)
- ✅ Account IDs - Valid account IDs from the accounting system
- ✅ Tax Rate IDs - Valid tax rate IDs (if applicable)
Creating an Expense
Endpoint
Request Body
Field Descriptions
Expense Lines
Each expense line item requires:netAmount(number, required): Net amount before taxtaxAmount(number, required): Tax amounttaxRateRef(object, required): Reference to tax rateaccountRef(object, required): Reference to expense account
trackingRefs(array): Tracking categories for reportinginvoiceTo(object): Customer to invoice (for billable expenses)
Example: Simple Expense
Example: Multiple Expenses (Batch)
You can create multiple expenses in a single request:Response
syncBatchId is used to track the sync status.
Data Model
Expense Entity
Expense Line
Getting Account and Tax Rate IDs
Before creating expenses, you need valid IDs from your accounting system:QuickBooks Online
-
Use the QuickBooks API or UI to find:
- Account ID: Chart of Accounts → Account → ID
- Tax Rate ID: Tax Rates → Tax Rate → ID
- Supplier ID: Vendors → Supplier → ID
- Customer ID: Customers → Customer → ID
- Or use Sync2Books reference endpoints (coming soon)
Xero
Similar process using Xero’s API or UI.Tracking Sync Status
After creating an expense, use thesyncBatchId to monitor progress:
Querying Expenses
Get a Single Expense
Get Expenses by Connection
Error Handling
Validation Errors
If required fields are missing or invalid:Sync Errors
If the sync fails, check the sync batch status for error details. See Sync & Monitoring for error handling.Best Practices
- Use UUIDs for expense IDs - Ensures uniqueness across your system
- Batch multiple expenses - More efficient than individual requests
- Poll sync status - Check every 2-3 seconds until complete
- Handle errors gracefully - Implement retry logic for transient failures
- Validate data before sending - Ensure all required fields are present
Next Steps
- Sync & Monitoring - Learn how to track sync status
- Attachments - Upload files to expenses
- Link Integration - Connect accounting systems