
Appifio Creator · Lesson AM06 · API REFERENCE §5 · 12 methods
full methods - params · returns · notes
Do not read/write login.json by hand. Username: 3-50 characters (letters/digits/_/-/.). Password minimum 6 characters.
validateAdminSession() - do not rely on isLoggedIn() alone. The “still logged in” field is named authenticated.A. Login · session

appifio_login(username, password) · Publicconst r = await appifio_client.appifio_login('admin', 'pass123');data returns: admin_token, admin_id, username, role, expires_at, expires_in.
Note: The client keeps the session after success - you do not “hash passwords” in the browser. Too many failures → temporary lock (“Try again later”).
appifio_logout() · Requires being logged inawait appifio_client.appifio_logout();
Returns: { success: true } - clears the session on the server and in the browser.
appifio_getSession() · Public**Needs a session in the request to get authenticated: true.
const r = await appifio_client.appifio_getSession(); // r.data.authenticated - true | false // when true: admin_id, username, role, display_name?, avatar?, bio?, social?, expires_at?
Do not look for a field named logged_in - the correct name is authenticated.
validateAdminSession() - client helperWhat it does: Asks the server if you are still logged in; clears the browser side if the session is bad. Use when opening an admin page.
const s = await appifio_client.validateAdminSession();
// { authenticated, username?, role?, admin_id?, expires_at? }
if (!s.authenticated) location.href = '/login.html';Note: Do not replace this with isLoggedIn().
isLoggedIn() - helper · no awaitconst maybe = appifio_client.isLoggedIn(); // boolean
Returns: true/false - only whether the browser has session hints, not server verification. UI hints only - not a security gate.
B. First-time setup · register
appifio_getAuthSetupStatus() · Publicconst r = await appifio_client.appifio_getAuthSetupStatus(); // r.data.needs_setup === true → no admin exists yet
appifio_registerAdmin(username, password, role?)Who can call: First time (no admin yet) → Public; the first account is always super admin (role ignored). After that → only super admin can create more.
role parameter: 'user' | 'admin' | 'superadmin'
await appifio_client.appifio_registerAdmin('editor', 'pass', 'user');data returns: admin_id, username, role, is_first_admin?
C. Your own profile
appifio_changePassword(oldPassword, newPassword) · Admin+ (any role)await appifio_client.appifio_changePassword('old', 'new');Note: New password ≥ 6 characters. Other sessions for the same account are revoked.
appifio_updateProfile(params) · Admin+Parameters (each optional): username, display_name, avatar, bio, social, and/or old_password + new_password.
const r = await appifio_client.appifio_updateProfile({ display_name: 'Shop owner' });
// data: username, display_name, avatar, bio, social, password_changed?D. Super admin team management
appifio_listAdmins() · Admin+ (role user blocked)const r = await appifio_client.appifio_listAdmins();
// data.admins: [{ admin_id, username, role, display_name, avatar, bio, social,
// created_at, updated_at, last_active_at }]appifio_updateAdmin(adminId, changes) · Super adminchanges parameter: { role?, new_password? }
await appifio_client.appifio_updateAdmin('adm_xxx', { role: 'user' });
await appifio_client.appifio_updateAdmin('adm_yyy', { new_password: '...' });Note: Changing password → revokes that person’s sessions. You cannot demote the last super admin.
appifio_deleteAdmin(adminId) · Super adminawait appifio_client.appifio_deleteAdmin('adm_xxx');Note: You cannot delete yourself; you cannot delete the last super admin.
Example - login / setup
const setup = await appifio_client.appifio_getAuthSetupStatus();
if (setup.data.needs_setup) {
await appifio_client.appifio_registerAdmin(username, password);
await appifio_client.appifio_login(username, password);
} else {
await appifio_client.appifio_login(username, password);
}
const session = await appifio_client.validateAdminSession();AM07 - executeBackendFunction (§6)
Internal navigation (same language)
Appifio Creator · Method series · AM06