Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.alterauth.com/llms.txt

Use this file to discover all available pages before exploring further.

import { App, Agent } from "@alter-ai/alter-sdk";

App

The operator/admin client. Constructed with an app key (alter_key_app_…).

Signature

new App(options: {
  apiKey: string;
  timeout?: number;
  caller?: string;
  callerType?: CallerType;
  userTokenGetter?: () => string | Promise<string>;
});

Parameters

NameTypeDefaultDescription
apiKeystringrequiredApp API key.
timeoutnumber30000HTTP request timeout in ms.
callerstringundefinedAudit attribution label. Free-form string or a managed-agent UUID. See Concepts → Caller.
callerTypeCallerTypeSERVICESERVICE (default) or AGENT.
userTokenGetterfunctionundefinedSync or async function returning a JWT for identity resolution.

Properties

PropertyTypeNotes
actorIdstring | nullCached actor UUID.
agentsAgentsNamespaceSee Agents reference.
baseUrlstringResolved Alter Vault endpoint. Diagnostic only.
lastRetryInfoRetryInfo | nullRetry metadata from the most recent request().

Example

import { App } from "@alter-ai/alter-sdk";

const vault = new App({
  apiKey: "alter_key_app_...",
  caller: "email-research-bot",
  userTokenGetter: () => getJwt(),
});

Agent

The workload client. Constructed with an agent key (alter_key_agent_…).

Signature

new Agent(options: {
  apiKey: string;
  timeout?: number;
  caller?: string;
  userTokenGetter?: () => string | Promise<string>;
});

Parameters

Same as App, except callerType is implicit (always AGENT). userTokenGetter is allowed but per-call combination of an agent key with a userToken returns HTTP 400 — see Agents → Overview.

Example

import { Agent } from "@alter-ai/alter-sdk";

const vault = new Agent({ apiKey: "alter_key_agent_..." });
const me = await vault.me();
console.log(me.id, me.name);

Lifecycle

Always call close() to release the underlying HTTP pool when the SDK instance is no longer needed:
const vault = new App({ apiKey: KEY });
try {
  const response = await vault.request("GET", url, { grantId: g });
} finally {
  await vault.close();
}

See also