Overview
When you create an expense transaction, Sync2Books stores it in the database and queues it for sync to the connected accounting system. The actual synchronization happens asynchronously, allowing you to create multiple expenses efficiently.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)
Create a single 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
Response
syncBatchId is used to track the sync status. See Sync transactions for monitoring sync progress.
Create multiple expenses (batch)
You can create multiple expenses in a single request for better efficiency:Request
Response
syncBatchId.
Transaction types
Payment
A standard expense payment. This is the most common transaction type.DirectCost
A direct cost expense, typically used for cost of goods sold (COGS).Expense line items
Basic line item
Line item with tracking
Billable expense line item
Data model
Expense Entity
Expense Line
Getting reference IDs
Before creating expenses, you need valid IDs from your accounting system. See Map transactions for details on retrieving account, tax rate, supplier, and customer IDs.Error handling
Validation errors
If required fields are missing or invalid:Invalid reference IDs
If a reference ID doesn’t exist in the accounting system, the sync will fail. Check the sync batch status for error details.Best practices
- Use UUIDs for expense IDs - Ensures uniqueness across your system
- Batch multiple expenses - More efficient than individual requests
- Validate data before sending - Ensure all required fields are present
- Use company-level defaults - Reduce transaction complexity by setting defaults
- Handle errors gracefully - Implement retry logic for transient failures
Read next
- Sync transactions - Learn how to track sync status
- Upload receipts - Attach files to expenses
- Map transactions - Configure expense mapping preferences