ScuteAdminApi calls the API with the app's secret key. Use it only on your server. Every method returns { data, error }.
Create it#
import { ScuteAdminApi } from "@scute/js-core";const admin = new ScuteAdminApi({ appId: process.env.SCUTE_APP_ID, secretKey: process.env.SCUTE_SECRET,});Client IP#
A sign-in your server starts (creating a user, looking one up, starting a challenge) comes from your server's address. Pass the person's address so the workspace's IP rules apply to it. Without it, the sign-in is not checked against IP rules and Scute records that the check was skipped.
await admin.withClientIp(personIp).createUser(email);withClientIp(ip) returns a copy that sends X-Scute-Client-IP: <ip> on calls made with the secret key. null or undefined keeps the client's own clientIp. The value must be one IPv4 or IPv6 address: a list (a raw X-Forwarded-For) or a range throws.
Take the address from the connection, or from a proxy you run or trust. Never take the leftmost X-Forwarded-For entry as is: the browser can set it. isClientIp(value) and normalizeClientIp(value) validate a value; SCUTE_CLIENT_IP_HEADER is the header name.
Users#
| Method | Does |
|---|---|
| listUsers(params?) | Pages of users. params: id, email, phone, created_before, status, page, limit. Returns { users, pagination } with total_pages, current_page, next_page, prev_page, per_page. |
| getUser(id) | { user } with metadata. |
| getUserByIdentifier(identifier) | Basic user data by email or phone. Needs no key. |
| createUser(identifier, meta?) | Creates a user. |
| updateUser(id, data) | Changes email or phone. |
| inviteUser(identifier, meta?) | Creates a pending user and sends an invite. Returns { user, user_meta_errors? }. |
| activateUser(id) / deactivateUser(id) | A deactivated user cannot sign in. |
| deleteUser(id) | Deletes the user. |
| previousAccounts(userId) | The person's earlier, deleted accounts: { id, status, created_at, deleted_at, merged_into?, roles, passkeys, mfa_methods }[]. |
| mergeUser(userId, fromId) | Moves roles, resource roles, passkeys, MFA factors and data from a deleted account into the live one. The live account wins where both have a value; history stays on the old account. |
| getUserByUserId(userId) | Deprecated alias of getUser. |
const { data, error } = await admin.listUsers({ status: "active", limit: 50 });for (const user of data?.users ?? []) console.log(user.email);Sessions#
| Method | Does |
|---|---|
| listUserSessions(id) | Every session of a user. |
| revokeUserSession(userId, sessionId) | Ends one session; its tokens stop working at once. |
Both work with the secret key alone; no user session is needed.
Tokens#
| Method | Does |
|---|---|
| refresh(refreshToken) | New tokens from a refresh token. |
| refreshWithAccess(accessToken) | Exchanges an access token for a session with a refresh token (secret key). @scute/nextjs-handlers uses it at sign-in. |
| forceRefresh(refreshToken) | New access token from a refresh token (secret key). |
| signOut(accessToken) | Ends that access token's session. |
App and SSO#
| Method | Does |
|---|---|
| getAppData() | The app's public settings. |
| discoverSSO(email) | SAML home-realm discovery for the email's domain. |
| Topic | Page |
|---|---|
| Permission checks, step-up, access requests, decision log | Authorization |
| Resources, permissions, roles, settings | Policy |
| Impersonation | Impersonation |
| Agent keys, monitoring, reports | Agents |