SugarCRM SupportDocumentationSugar DeveloperSugar Developer Guide 8.0ArchitectureLogic HooksAPI Hooksbefore_respond



The before_respond hook executes before the v10+ REST Service call returns data to the user.


function before_respond($event, $response){}


Name Type Description
event String The name of the logic hook event
response Object The RestResponse Object


  • This is a global logic hook where the logic hook reference must be placed in ./custom/modules/logic_hooks.php.
  • It is not advised to remove or unset any data. Sugar may be using this data and it can adversely affect your instance.
  • This hook should not be used for any type of display output.
  • This hook should be used when you want to add data to all API responses. If you are looking to modify data received from one specific endpoint, It is a much better approach to override that specific endpoint rather than to use this logic hook.

Change Log

Version Note
7.0.0RC1 Added before_respond hook




    $hook_version = 1;
    $hook_array = Array();

    $hook_array['before_respond'] = Array();
    $hook_array['before_respond'][] = Array(
        //Processing index. For sorting the array.

        //Label. A string value to identify the hook.
        'after_routing example', 

        //The PHP file where your class is located.

        //The class the method is in. 

        //The method to call. 




    if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');

    class logic_hooks_class
        function before_respond_method($event, $response)



Last modified: 2018-04-26 03:57:24