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

Status
Description

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

Status
Description

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 number

  • limit (number, default: 20) - Items per page

  • status (string, optional) - Filter by status: pending, processing, completed, failed

  • startDate (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:

  1. Initial Poll: Wait 2 seconds after creating expense

  2. Poll Interval: Check every 2-3 seconds

  3. Timeout: Stop polling after 60 seconds (syncs typically complete in 5-15 seconds)

  4. 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

Error Message
Cause
Solution

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

  1. Always check sync status - Don't assume syncs succeed immediately

  2. Implement retry logic - Handle transient failures gracefully

  3. Log sync errors - Track failed syncs for debugging

  4. Monitor batch completion - Set up alerts for high failure rates

  5. Use webhooks when available - More efficient than polling

Next Steps

Last updated