Skip to main content

Sync All Balances

Synchronize all wallet and custody account balances with their respective blockchain networks and custody providers.

Endpoint

POST /manage/users/balances/sync

Authentication

This endpoint requires an OAuth 2.0 access token with tenant administrator or global administrator role:

Authorization: Bearer {access_token}

Request

This endpoint does not require a request body.

Response

200 OK

A successful response will include detailed information about the synchronization results:

{
"wallets_updated": 5,
"wallet_errors": [],
"custody_accounts_updated": 2,
"custody_errors": [],
"sync_time": "2025-04-19T12:34:56.789Z"
}

Response Fields

FieldTypeDescription
wallets_updatednumberNumber of wallets successfully updated
wallet_errorsarrayArray of errors encountered during wallet updates
custody_accounts_updatednumberNumber of custody accounts successfully updated
custody_errorsarrayArray of errors encountered during custody account updates
sync_timestringTimestamp of when the sync was performed

Error Objects

If errors occur during synchronization, they will be included in the wallet_errors or custody_errors arrays:

{
"wallet_id": "wallet-123",
"blockchain": "ETH",
"error": "Failed to connect to blockchain network"
}
{
"account_id": "account-123",
"error": "API rate limit exceeded"
}

401 Unauthorized

Occurs when the OAuth 2.0 access token is missing or invalid:

{
"detail": "Not authenticated"
}

403 Forbidden

Occurs when the authenticated user doesn't have tenant administrator role:

{
"detail": "Only tenant administrators can access this endpoint"
}

Example Request

curl -X POST "https://api.cryptofuse.io/manage/users/balances/sync" \
-H "Authorization: Bearer eyJ0eXAiOiJPQXV0aFRva2VuIiwiYWxnIjoiUlMyNTYifQ..."

Example Response

{
"wallets_updated": 5,
"wallet_errors": [
{
"wallet_id": "wallet-789",
"blockchain": "SOL",
"error": "Failed to connect to Solana RPC node"
}
],
"custody_accounts_updated": 2,
"custody_errors": [],
"sync_time": "2025-04-19T12:34:56.789Z"
}

Usage Notes

  1. This endpoint initiates a synchronization of all wallet and custody account balances in the tenant, which may take some time to complete for tenants with many wallets.

  2. The synchronization process involves:

    • Querying the respective blockchain networks for wallet balances
    • Contacting custody providers for custody account balances
    • Updating the stored balances in the database
  3. The response includes information about any errors that occurred during synchronization, which can be useful for troubleshooting.

  4. Regular synchronization is recommended to ensure that the system's records match the actual blockchain and custody provider balances.

  5. After synchronization, you can use the /manage/users/balances endpoint to view the updated balances.

  6. It's a good practice to synchronize balances before processing large withdrawals to ensure you have accurate balance information.

  7. This operation may have performance implications and should not be called excessively. A reasonable frequency would be once per hour or when specific balance checks are needed before large operations.