Skip to main content

Schedule-Based Sync Integrations

New to building integrations? Start with our step-by-step contributor guide for a quick overview.
Schedule-based integrations run on a cron schedule to poll external APIs and fetch new activities. This reference guide uses GitHub as the detailed example.

When to Use Schedule-Based Sync

Choose schedule-based integrations when:
  • The service doesn’t provide webhook events
  • You want to batch process multiple API calls
  • The service has rate limits that require careful timing
  • Real-time sync isn’t critical (5-15 minute delays acceptable)
  • You need to poll multiple endpoints and aggregate data

Architecture Overview

Key Concepts

State Management

Schedule-based integrations maintain state between runs:
State is persisted by returning a state message:

Pagination

Handle large datasets by paginating through results:

Incremental Sync

Only fetch new data since last sync:

Full Example: GitHub Integration

spec.json

index.ts

schedule.ts

Best Practices

1. State Management

Always persist state to track sync progress:

2. Default Sync Window

On first sync, fetch last 24 hours of data:

3. Efficient Pagination

Stop paginating when no more data:

4. Error Resilience

Continue processing even if individual items fail:

5. Rate Limit Handling

Respect API rate limits:

6. Multiple Data Sources

Fetch from multiple endpoints and aggregate:

7. Schedule Configuration

Choose appropriate sync frequency:

Handling Account Setup

Set initial sync schedule during OAuth:

Testing Schedule-Based Integrations

  1. Manual Trigger: Call SYNC event handler directly with test state
  2. Time Travel: Mock date/time to simulate different sync scenarios
  3. State Testing: Test with various lastSyncTime values
  4. Pagination: Test with large datasets requiring multiple pages
  5. Error Scenarios: Test with network failures, rate limits, invalid tokens

Performance Optimization

Batch API Calls

Cache Frequently Used Data

Next Steps