API Retry Logic