Backend Secrets manager with Add secret and appifio.secrets.get tip
Secrets manager

Appifio Creator · Lesson AM07 · API REFERENCE §6 · 1 method (+ Secrets UI)

Server functions
executeBackendFunction - full structure

Run sensitive logic on the server (send mail, read secrets…) - keep keys off the visitor-facing page.

Only §6 method

appifio_executeBackendFunction(functionName, params?)

What it does: Call a function stored in backend/functions/{name}.js on the server.

Who can call: Public when CMS security tightening is off. When on → requires admin login (Admin+).

Parameters:

  • functionName - letters/digits/_/- only (e.g. sendMail, greetUser). Must match the function file name.
  • params - optional object → available in the handler as appifio.params.

How to call:

const res = await appifio_client.appifio_executeBackendFunction('sendMail', {
  to: 'guest@mail.com',
  subject: 'Hello'
});
if (res.success) {
  console.log(res.data.result);
  console.log(res.data.function_name, res.data.execution_time);
} else {
  alert(res.message || 'Server function failed');
}

Return value:

{ success, data: {
  function_name: string,
  result: any,           // whatever the handler returned
  execution_time: number // runtime
} }

Notes:

  • Call rate is limited - do not spam from the page.
  • Writing functions + secrets: see Backend functions & secrets in the Aura Storage guide (and AS06).
  • When CMS tightens permissions: call after validateAdminSession() (AM06).

Secrets in the UI (not an appifio_* method)

  1. Backend tab → Secrets managerAdd secret (use a memorable name).
  2. Only the server handler can read the secret - do not read secret files with readFsFile from the page.

Function file skeleton (create with writeFsFile - AM04)

Creator Files and Code workspace used to create backend function files
Function file via Files
// backend/functions/greetUser.js
exports.handler = async function (appifio) {
  const { name } = appifio.params || {};
  if (!name) return { success: false, error: 'Missing name' };
  // Secret (if needed): appifio.secrets.get('SECRET_NAME')
  return { success: true, message: 'Hello ' + name };
};

await appifio_client.appifio_writeFsFile(
  'backend/functions/greetUser.js',
  codeString
);
Do not put SMTP passwords / payment keys in page HTML - only Secrets manager + server functions.
§6 checklist: executeBackendFunction = 1/1 (+ Secrets UI workflow)

AM08 - Synchronous helpers (§7 - 5 functions)

Appifio Creator · Method series · AM07