I assume you do not want to edit API XML manually for all the APIs to engage a custom handler. Instead, you want to be able to engage a handler to all the APIs automatically when you publish the APIs. You can do it by editing the $APIM_HOME/repository/resources/api_templates/velocity_template.xml. This is the template file which decides which handlers to be engaged with APIs by default. In this file, at the end, you will find a handlers section. You need to edit this file and add your handler there, as shown below.
## print the handlers
#if($handlers.size() > 0)
<handlers xmlns="http://ws.apache.org/ns/synapse">
<handler class="org.wso2.carbon.samples.handlers.MyCustomHandler"/>
#foreach($handler in $handlers)
<handler xmlns="http://ws.apache.org/ns/synapse" class="$handler.className">
#if($handler.hasProperties())
#set ($map = $handler.getProperties() )
#foreach($property in $map.entrySet())
<property name="$!property.key" value="$!property.value"/>
#end
#end
</handler>
#end
</handlers>
#end
As you can see, I have added my handler org.wso2.carbon.samples.handlers.MyCustomHandler
. That's it you should do. If you create and publish an API now, MyCustomHandler will be engaged with your API automatically. However, already published APIs won't have an effect even if you update velocity_templates.xml. You need to republish them in order to get the effect.