Skip to main content
This guide covers how to create, sync, and manage expenses in Sync2Books.

Overview

The expense management flow consists of three main steps:
  1. Create Expense - Submit expense data to Sync2Books
  2. Automatic Sync - Sync2Books automatically syncs to the connected accounting system
  3. 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 tax
  • taxAmount (number, required): Tax amount
  • taxRateRef (object, required): Reference to tax rate
  • accountRef (object, required): Reference to expense account
Optional fields:
  • trackingRefs (array): Tracking categories for reporting
  • invoiceTo (object): Customer to invoice (for billable expenses)

Example: Simple Expense

Example: Multiple Expenses (Batch)

You can create multiple expenses in a single request:

Response

The 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

  1. 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
  2. Or use Sync2Books reference endpoints (coming soon)

Xero

Similar process using Xero’s API or UI.

Tracking Sync Status

After creating an expense, use the syncBatchId to monitor progress:
See Sync & Monitoring for detailed status tracking.

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

  1. Use UUIDs for expense IDs - Ensures uniqueness across your system
  2. Batch multiple expenses - More efficient than individual requests
  3. Poll sync status - Check every 2-3 seconds until complete
  4. Handle errors gracefully - Implement retry logic for transient failures
  5. Validate data before sending - Ensure all required fields are present

Next Steps