Message api refactoring