I have added an extra action to the recordlist view;
custom/modules/Opportunities/clients/base/views/recordlist/recordlist.js:
({
    extendsFrom: 'RecordlistView',
    initialize: function(options) {
        this._super("initialize", [options]);
        //add listener for custom button
        this.context.on('list:opportunitiesexport2:fire', this.export2, this);
    },
    export2: function() {
        //gets an array of ids of all selected opportunities
        var selected = this.context.get("mass_collection").pluck('id');
        if (selected) {
            return App.api.call('read', 
            App.api.buildURL('Opportunities/Export2'),
            {'selected_ids':selected},
            {
                success: function(response) {
                    console.log("SUCCESS");
                    console.log(response);
                },
                error: function(response) {
                    console.log('ERROR');
                    console.log(response);
                },
                complete: function(response){
                    console.log("COMPLETE");
                    console.log(response);
                },
                error: function(response){
                    console.log("ERROR");
                    console.log(response);
                }
            });
        }
    },
})
The tutorial here http://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_7.7/Integration/Web_Services/v10/Extending_Endpoints/ Explains how to create an endpoint.
However it doesn't explain how to get the json data (the stringified array of selected ids);
custom/modules/Opportunities/clients/base/api/OpportunitiesApi.php:
class OpportunitiesApi extends SugarApi
{
    public function registerApiRest()
    {
        return array(
            //GET
            'MyGetEndpoint' => array(
                //request type
                'reqType' => 'GET',
                //set authentication
                'noLoginRequired' => false,
                //endpoint path
                'path' => array('Opportunities', 'Export2'),
                //endpoint variables
                'pathVars' => array('', ''),
                //method to call
                'method' => 'Export2',
                //short help string to be displayed in the help documentation
                'shortHelp' => 'Export',
                //long help to be displayed in the help documentation
                'longHelp' => 'custom/clients/base/api/help/MyEndPoint_MyGetEndPoint_help.html',
            ),
        );
    }
    /**
     * Method to be used for my MyEndpoint/GetExample endpoint
     */
    public function Export2($api, $args)
    {
        //how to access $args['selected_ids']?
    }
}
$args contains
Array
(
    [__sugar_url] => v10/Opportunities/Export2
)
Is it possible to access the json data?
 
     
    