Sync & Monitoring
Learn how to track sync status, handle errors, and retry failed syncs.
Overview
When you create an expense, bill, or invoice, Sync2Books automatically queues it for sync to your connected accounting system. This guide shows you how to monitor the sync process and handle any issues.
Sync Lifecycle
┌─────────────┐
│ PENDING │ ← Expense created, waiting to sync
└──────┬──────┘
│
▼
┌─────────────┐
│ PROCESSING │ ← Currently syncing to accounting system
└──────┬──────┘
│
├─────────▶ ┌─────────────┐
│ │ SUCCESS │ ← Synced successfully
│ └──────────────┘
│
└─────────▶ ┌─────────────┐
│ FAILED │ ← Sync failed (can retry)
└──────────────┘Getting Sync Batch Status
After creating expenses, you receive a syncBatchId. Use this to check the sync status:
Endpoint
Request
Response
Batch Status Values
pending
Batch is queued, waiting to be processed
processing
Currently syncing items to accounting system
completed
All items processed (may include failures)
failed
Batch processing failed entirely
Item Status Values
pending
Item is queued
processing
Currently syncing
success
Successfully synced to accounting system
failed
Sync failed (can retry)
Listing Sync Batches
Get All Batches for a Company
Query Parameters
page(number, default: 1) - Page numberlimit(number, default: 20) - Items per pagestatus(string, optional) - Filter by status:pending,processing,completed,failedstartDate(string, optional) - Filter batches from this date (ISO 8601)endDate(string, optional) - Filter batches until this date (ISO 8601)
Example
Response
Handling Failed Syncs
Get Failed Items
Example
Response
Retry Failed Items
Request Body
If itemIds is empty or omitted, all failed items will be retried.
Example
Response
Polling Strategy
For real-time status updates, poll the sync batch status:
Recommended Approach
Initial Poll: Wait 2 seconds after creating expense
Poll Interval: Check every 2-3 seconds
Timeout: Stop polling after 60 seconds (syncs typically complete in 5-15 seconds)
Exponential Backoff: If status is
processing, increase interval slightly
Example Implementation (JavaScript)
Webhooks (Coming Soon)
Instead of polling, you can configure webhooks to receive real-time notifications when syncs complete. Contact support for early access.
Common Error Messages
Invalid account ID
Account doesn't exist in accounting system
Verify account ID or create account first
Invalid tax rate ID
Tax rate doesn't exist
Verify tax rate ID or create tax rate first
Connection expired
OAuth token expired
Reconnect the accounting system via Link
Rate limit exceeded
Too many requests to accounting system
Wait and retry with exponential backoff
Validation error
Invalid data format
Check request body against API schema
Best Practices
Always check sync status - Don't assume syncs succeed immediately
Implement retry logic - Handle transient failures gracefully
Log sync errors - Track failed syncs for debugging
Monitor batch completion - Set up alerts for high failure rates
Use webhooks when available - More efficient than polling
Next Steps
Expense Management - Create and sync expenses
Attachments - Upload files to synced transactions
Link Integration - Connect accounting systems
Last updated