1 var REST = library.REST.REST();
  2 
  3 function getKey(theKeyName) {
  4   theKeyName = !theKeyName ? "REST Api Key" : theKeyName;
  5   return apiKeyManager.getOrCreateApiKey(
  6     theKeyName,
  7     context.getUser().username
  8   );
  9 }
 10 
 11 /**
 12  * @name GetApiKey
 13  * @class Get an Api Key for the current user in MB
 14  * @description  This endpoint fetches or creates an api key for the current user
 15  * @param [name] The Key Name (used to differentiate keys) default is 'REST Api Key'
 16  * @returns {"key": <theKey>}
 17  *
 18  * @example /wf/restapi/v2/getApiKey
 19  *
 20  * Parameters:
 21  *
 22  Response:
 23     "9F04CB70-B947-4DF2-BE7E-1D73E91DA2C2"
 24  */
 25 (function main() {
 26   return getKey(context.getParameter("name"));
 27 })();
 28