Move API event handler to a plugin.