Account

Your account: its plan, balance, month's spend, counts, limits and defaults (Account.get), changing its defaults (update), the account at a glance with what waits and what failed (status), the public endpoints a publishable key may call, what an id or key prefix names (resolve), and a one-tap payment link for its owner.

class Account

The account at a glance (GET /v1/account): its plan's planTier, balance (remaining_usd, null when it can't be read, never 0), this month's spend, how many of each thing it has (counts), its limits and features, its defaultRegion and the default a paused user is told (spendingPaused), and what the platform offers (scopes, explicitScopes). The signed-in owner also reads email, spendCap and consoleKeyId; one of the account's own secret keys reads the rest.

Attributes
idstring
emailstring | null
owner{ name?: string; email?: string; phone?: string } | null

Who owns it, as NoClick knows them (name, email, phone, each only when known): the signed-in owner's view only.

planTierstring | null
balanceJsonObject
monthJsonObject
spendCapJsonObject | null
countsRecord<string, number>
limitsRecord<string, number>
featuresRecord<string, boolean>
defaultRegionstring | null
spendingPausedPausedSpendingDefault | null
consoleKeyIdstring | null
scopesstring[]

What a key with every scope (*) holds.

explicitScopesstring[]

The scopes a key holds only when it names them.

rawJsonObject

The response JSON exactly as the API sent it.

Types
type JsonObject = { [key: string]: unknown };

getstatic

static get(options?: AccountCallOptions): Promise<Account>

Read the account: the signed-in owner, or one of the account's own secret keys acting for it (a key acting for one of its users is refused with PermissionDenied).

const account = await Account.get();
console.log(account.planTier, account.balance.remaining_usd);
Parameters
options.clientNoClick

The client to send with; defaults to the module client built from NOCLICK_API_KEY.

options.signalAbortSignal
Returns

The account.

updatestatic

static update(
  changes: AccountChanges,
  options?: { client?: NoClick },
): Promise<Account>

Change the account's defaults: only the fields given; null clears one. The signed-in owner's alone. Resolves to the account as it is now.

await Account.update({ defaultRegion: "eu", spendCapUsd: 200 });
Parameters
changesAccountChangesrequired
options.clientNoClick

The client to send with; defaults to the module client built from NOCLICK_API_KEY.

Returns

The account as it is now.

Types
/** What `Account.update` changes: only the fields given; `null` clears one. */
interface AccountChanges {
  /** The region new resources take when a call names none; `null` clears it. */
  defaultRegion?: string | null;
  /** What a paused user is told when their spending is paused without a message; `null` removes it. */
  spendingPaused?: PausedSpendingDefault | null;
  /** The monthly spending cap in whole dollars; `null` removes it. Only the signed-in owner sets, raises or removes it. */
  spendCapUsd?: number | null;
}

statusstatic

static status(options?: AccountCallOptions): Promise<AccountStatus>

The account at a glance, as the key calling sees it: which account (or which of its users the key acts for), its plan, balance, this month's spend against its caps, approvals waiting on a person, what failed in the last day and what ran last. A user's session is refused.

const status = await Account.status();
console.log(status.account.name ?? status.account.id, status.balance.remaining_usd);
Parameters
options.clientNoClick

The client to send with; defaults to the module client built from NOCLICK_API_KEY.

options.signalAbortSignal
Returns

The status.

publicEndpointsstatic

static publicEndpoints(options?: AccountCallOptions): Promise<PublicEndpoint[]>

What a publishable key may list: the account's public endpoints (a shared agent's page, a published workflow), each by kind and id. The signed-in owner's alone.

for (const endpoint of await Account.publicEndpoints()) console.log(endpoint.kind, endpoint.name, endpoint.url);
Parameters
options.clientNoClick

The client to send with; defaults to the module client built from NOCLICK_API_KEY.

options.signalAbortSignal
Returns

resolvestatic

static resolve(ref: string, options?: AccountCallOptions): Promise<ObjectRef>

What ref names in the account: an object's id, a key's prefix (nk_live_ab12…) or one of your users' ids, resolved to its type and id (and the user it belongs to). Nothing it names rejects with NotFound. The signed-in owner's alone.

const found = await Account.resolve("nk_live_ab12");
console.log(found.type, found.id);
Parameters
refstringrequired
options.clientNoClick

The client to send with; defaults to the module client built from NOCLICK_API_KEY.

options.signalAbortSignal
Returns

Its type and id, and the user it belongs to.

AccountStatus

interface AccountStatus

The account at a glance (Account.status): account (its id, name, email, or acting_for: the user a key acts for), userId, its plan, balance, month, caps with what each spent, the approvals waiting on a person (approvalsPending), what failed in the last day (failing) and what ran last (operations).

Attributes
accountJsonObject
userIdstring | null
planJsonObject | null
balanceJsonObject
monthJsonObject
capsJsonObject[]
approvalsPendingJsonObject[]
failingJsonObject[]
operationsJsonObject
rawJsonObject

The response JSON exactly as the API sent it.

Types
type JsonObject = { [key: string]: unknown };

ObjectRef

interface ObjectRef

What Account.resolve found: the object's type and id, and the user it belongs to (null: the account).

Attributes
typestring
idstring
userIdstring | null
rawJsonObject

The response JSON exactly as the API sent it.

Types
type JsonObject = { [key: string]: unknown };

PausedSpendingDefault

interface PausedSpendingDefault

What a paused user is told when a pause names no message, and the button with it.

Attributes
messagestring | null
action{ label: string; url: string } | null

PublicEndpoint

interface PublicEndpoint

Something the owner made public that a publishable key may call; name and url are null once it stopped being public.

Attributes
kindstring
idstring
namestring | null
urlstring | null
userIdstring | null
rawJsonObject

The response JSON exactly as the API sent it.

Types
type JsonObject = { [key: string]: unknown };