Account
Operator sign-in with email codes, sessions, account tokens, and the account itself
An account is a person who works in Arky: a store owner, a team member or a platform administrator. It is a sign-in email; store access comes from memberships. Storefront customers are a separate identity and never get accounts.
import type { EpochMilliseconds } from "arky-sdk";
interface Account {
id: string;
email: string;
status: { type: "active" } | { type: "deleting" };
test_stores: number;
created_at: EpochMilliseconds;
updated_at: EpochMilliseconds;
}
test_stores counts the test stores the account owns, one still being
deleted included.
Sign In With A Code
/v1/auth/code sdk.account.auth.requestCode() /v1/auth/verify sdk.account.auth.verify() /v1/stores/{store_id}/auth/code sdk.account.auth.requestCode({ session_id, store_id, language }) /v1/stores/{store_id}/auth/verify sdk.account.auth.verify({ store_id }) import { createAdmin } from "arky-sdk/admin";
const sdk = createAdmin({ apiUrl: "https://api.arky.io" });
const pending = await sdk.account.auth.requestCode({ session_id: crypto.randomUUID(), email: "[email protected]" });
await sdk.account.auth.verify({ session_id: pending.session_id, code: "123456" });
const me = await sdk.account.getMe();
The Arky sign-in code is one of Arky’s own emails, sent through Arky’s own Resend account from
Arky’s address. The first accepted code for an email creates its account. requestCode carries the
pending session’s session_id, a UUID v4 the app picks once per “send code” press and sends again
on a retry: the same id and email while that code is open answer the same pending session and send
no second code, and the same id with another email, through the other sign-in or after its code was
used is refused with 409 GENERAL.CONFLICT. A code lasts ten minutes. An address gets at most one
new code a minute in each sign-in (409 ACCOUNT_SIGN_IN.CODE_RECENT), after five wrong tries every
try for that address is refused until the code expires (409 ACCOUNT_SIGN_IN.ATTEMPTS_EXHAUSTED),
and a wrong or expired code, or none waiting, is refused with 409 ACCOUNT_SIGN_IN.CODE_INVALID.
With store_id, requestCode and verify sign in through a store’s own login page: the code goes
out as the store’s own store_admin_sign_in email, from the store’s sender, in the language the
request names (one of the store’s). The request is refused at once with
409 STORE_SIGN_IN.UNAVAILABLE, leaving no pending session or email, while the store has no
store_admin_sign_in email selected, its email sending is paused or its Arky plan has no access;
Arky’s own sign-in still works then. A store that is closing refuses them. The session a store’s
sign-in opens works only in that store, with the account’s role there: other stores, platform
administration, creating a store, accepting another store’s invite and deleting the account refuse
it with 403 ACCOUNT.ARKY_SIGN_IN_REQUIRED, and a platform administrator signed in that way has no
platform powers. Arky’s own sign-in opens every store the account works in. The Admin client keeps
the session and refreshes it. Transferring a store, closing a live store, making an account token,
adding or removing a platform administrator and deleting an account that holds a platform-administrator grant
need a sign-in within the last 15 minutes.
Sessions
/v1/accounts/me/sessions sdk.account.session.find() /v1/accounts/me/sessions/{id} sdk.account.session.revoke() A session is pending_verification (with its failed attempts and expiry), active, superseded
or revoked. One session is one sign-in; finished sessions are removed after 30 days. Its scope
is { type: "arky" } for Arky’s own sign-in or { type: "store", store_id } for a store’s, set by
the sign-in that sent its code and kept by every refresh. A store session lists and revokes only
that store’s sessions of the account, itself included, so signing out keeps working. Closing a store
removes its store sessions, pending codes included, and refreshing one is then refused with
403 GENERAL.UNAUTHORIZED, as an unknown refresh token is; the account’s Arky sessions stay.
Account Tokens
/v1/accounts/me/tokens sdk.account.token.create() /v1/accounts/me/tokens sdk.account.token.find() /v1/accounts/me/tokens/{id}/revoke sdk.account.token.revoke() /v1/accounts/me/tokens/{id}?expected_updated_at= sdk.account.token.delete() const made = await sdk.account.token.create({
id: crypto.randomUUID(),
name: "CI",
stores: { type: "test_stores" },
permissions: [{ type: "admin" }],
expires_at: null,
});
if (made.type === "secret_created") console.log(made.value);
const ci = createAdmin({ apiUrl: "https://api.arky.io", accountToken: process.env.ARKY_API_TOKEN });
An account token (arky_at_...) lets a script, a CI job or an agent act as the account without
signing in. It works where the account’s session works, apart from what the list below names, and acts
as the account: history records the account with the token that acted. Only an Arky sign-in made within
the last 15 minutes makes one. Its value is answered once, in secret_created; Arky keeps only its hash
and the token_hint, the value’s first 16 characters, so you can tell which token a secret holds. The
same create again answers existing without the value, and the same id with anything else is refused
with 409 GENERAL.CONFLICT.
storesis where it works:all, every store where the account is an active member, and it makes stores;onlywithstore_ids, at most 100 stores the account is an active member of, each once, and it makes none; ortest_stores, which makes, reaches and closes test stores and never makes or reaches a live one. A store outside them is refused with403 ACCOUNT_TOKEN.STORE_NOT_COVERED. A deleted store leaves everyonlylist, and a token whose last store it was is deleted. Through a token,sdk.account.getMe()works, and the account’s stores and memberships list only the stores it reaches.permissionsareadminalone or the role permissions it needs, each once (orders,paymentsandcustomerswith their access,fulfillmentandinventorywithlocations: { type: "everywhere" }). In each store it does only what both its permissions and the account’s roles there allow, and it stops working in a store as soon as the account’s membership there ends.expires_atis required: a later moment, ornullfor never.- A token has no platform powers and is never a recent sign-in. Platform routes, the account’s tokens
and sessions, accepting an invite and deleting the account refuse it with
403 ACCOUNT.ARKY_SIGN_IN_REQUIRED, and transferring a store and closing a live one with403 ACCOUNT.RECENT_SIGN_IN_REQUIRED. The owner’s token holdingadmincloses a test store. - Revoking takes effect at once and keeps the token listed as revoked; only a revoked token can be
deleted (
409 ACCOUNT_TOKEN.ACTIVEotherwise). Tokens are never edited: to rotate one, make a new one, deploy it, then revoke the old one. An account holds at most 50, revoked ones included until they are deleted (409 ACCOUNT_TOKEN.LIMIT). - A revoked or expired token, and every token of an account that is being deleted, answers
401. Calls through a token count against its own quota of about 10,000 a minute, not its client address.
Account
/v1/accounts/me sdk.account.getMe() /v1/accounts/search sdk.account.find() /v1/accounts sdk.account.delete() Deleting your account marks it deleting; one cleanup step then removes its sessions, its account
tokens, its memberships and any platform administrator grant, and then the account. Its account
tokens answer 401 from the moment it is marked. An account that owns an active store can’t be
deleted: transfer or close the store first; a store that is being closed doesn’t stop it. The last
platform administrator’s account can’t be deleted. Only an Arky sign-in deletes the account: a store
session or an account token is refused with 403 ACCOUNT.ARKY_SIGN_IN_REQUIRED, and an account that
holds a platform-administrator grant also needs a sign-in within the last 15 minutes
(403 ACCOUNT.RECENT_SIGN_IN_REQUIRED).
Platform administrators are their own record; see Platform.