ApiMessage: Use a trait to avoid code duplication