Skip to main content

Offline Sync API Reference

API endpoints untuk batch synchronization dan conflict resolution dalam offline-first architecture.

🔐 Authentication

Semua endpoint memerlukan JWT authentication token.

📡 Endpoints

1. Batch Sync

Sync multiple transactions, payments, dan voids dalam satu request.

Request Body

array
required
Array of offline transactions to sync
array
default:"[]"
Array of offline payments to sync
array
default:"[]"
Array of offline voids to sync
string
required
Device identifier
datetime
required
ISO 8601 timestamp when sync initiated

Response (Success)

integer
HTTP status code (200)
object

Response Example

Response (With Conflict)

Error Responses


2. Resolve Conflict

Resolve detected conflict dengan strategy tertentu.

Path Parameters

string
required
Conflict ID from batch sync response

Request Body

string
required
Resolution strategy:
  • keep_server: Keep server data, discard local
  • keep_local: Keep local data, overwrite server (not yet implemented)
  • merge: Merge both data (not yet implemented)
object
Required if strategy is “merge”

Response (Success)

Error Responses


🔄 Sync Flow Diagram


📊 Rate Limiting


💡 Best Practices

Batch Size

Limit batch size to 50 transactions per request untuk optimal performance.

Retry Logic

Implement exponential backoff untuk retry:
  • 1st retry: 5 seconds
  • 2nd retry: 10 seconds
  • 3rd retry: 30 seconds
  • Max retries: 3

Idempotency

Gunakan offline_reference sebagai idempotency key. Server akan detect duplicate dan return existing data.

Error Handling


🧪 Testing

Postman Collection

Download Postman collection: offline-sync-api.postman_collection.json

REST Client Examples

See complete examples in: api/pos/offline-sync.http

Backend Implementation

Complete backend guide

Flutter Implementation

Step-by-step Flutter guide

Transaction Flow

Transaction state machine

Error Codes

Complete error codes reference

🆘 Support

Need Help?