Than-
I might reference you to Larry Zhang's comment on this question (How can I merge features in ArcGIS Online? ). I haven't found a way yet to do this programmatically. I would probably suggest the Analysis Widget. If you want to do this programmatically through (via the Spatial Analysis Service, i.e. still uses credits) check out this from ESRI Development support;
developer-support/web-js/merge-layers-tool at master · Esri/developer-support · GitHub
-Bob
var mergeLayersTool = new MergeLayers({
inputLayer: inputLayer,
mergeLayers: [mergeLayer],
map: map,
outputLayerName: "MyTestLayer",
portalUrl: "http://www.arcgis.com",
showHelp: true,
showSelectFolder: true
}, "merge");
mergeLayersTool.startup();
mergeLayersTool.on("job-result", function(result) {
map.removeLayer(inputLayer);
map.removeLayer(mergeLayer);
map.addLayer(new FeatureLayer(result.value.url));
});