Skip to Content
Documentation menu

Reference

SDKs & widget

Typed clients for your backend, guards that wrap an agent's tools, and the components your end users see.

PackageInstallFor
@authentify2026/sdknpm install @authentify2026/sdkTypeScript client: authorize, guard, tokens, outcomes, consent, verifying tokens.
authentify-sdkpip install authentify-sdkPython client (3.9+): the same core calls.
@authentify2026/agentsnpm install @authentify2026/agentsGuards for OpenAI Agents SDK, Anthropic tool use and MCP servers.
@authentify2026/langchainnpm install @authentify2026/langchainAn authorize tool for LangChain.js agents.
@authentify2026/consent-widgetnpm install @authentify2026/consent-widgetReact components for the people your agents act for (End users).

TypeScript

ts
import { AuthentifyClient } from '@authentify2026/sdk';

// x-api-key mode
const authentify = new AuthentifyClient({ apiKey: process.env.AUTHENTIFY_AGENT_KEY!, environment: 'production' });
// or OAuth 2.1 mode: short-lived tokens minted and refreshed for you
// new AuthentifyClient({ clientId: process.env.AUTHENTIFY_KEY_ID!, clientSecret: process.env.AUTHENTIFY_AGENT_KEY!, environment: 'production' });

// guard(): resolves only on allow; throws AuthentifyDecisionError on deny, escalate, or no answer (fail closed)
await authentify.guard({ action: 'ISSUE_REFUND', resource: { type: 'order', id: order.id }, context: { amount: 240 } });
await issueRefund(order); // only runs on allow
MethodCall
authorize(params)POST /api/v2/authorize, returning the full response.
guard(params)authorize(), enforced: throws unless allowed.
getDecisionToken(id, audience)A decision token for an approved request.
reportOutcome(id, { status, detail })Seal what happened.
exchangeToken({ subjectToken, audience })Token exchange for a signed-in user.
createConsentSession(params)Start a consent session (account key).
getAuthorizationRequest(id)A request as recorded (account key).
verifyAuthentifyDecision, verifyAuthentifyTokenAt your own API: verify decision tokens and access tokens offline.

Python

python
import os
from authentify import AuthentifyClient

client = AuthentifyClient(api_key=os.environ["AUTHENTIFY_AGENT_KEY"], environment="production")

result = client.authorize({
    "action": "ISSUE_REFUND",
    "resource": {"id": "order-88231", "type": "order"},
    "context": {"amount": 240},
})
if result["decision"] == "allow":
    ...  # run it
elif result["decision"] == "escalate":
    ...  # hold it: a person decides
else:
    ...  # stop

Also: mint_token, report_outcome, create_consent_session, get_authorization_request and get_audit_logs. Pass client_id and client_secret instead of api_key for OAuth mode.

Agent framework guards

Wrap the agent's tools so every call is authorized in code, before it runs, rather than offered to the model as a tool it might skip. Describe each tool once:

ts
import type { ToolPolicy } from '@authentify2026/agents';

const policy: ToolPolicy = {
  tools: {
    issue_refund: (a) => ({ action: 'ISSUE_REFUND', resource: { type: 'order', id: a.orderId }, context: { amount: a.amount } }),
    get_order: () => 'skip', // read-only: explicitly unchecked
  },
  endUserId: customer.id, // optional: check that person's consent
};

Then wrap your framework:

ts
// OpenAI Agents SDK
import { guardOpenAITools } from '@authentify2026/agents';
const agent = new Agent({ name: 'Support', tools: guardOpenAITools([issueRefund, getOrder], authentify, policy) });

// Anthropic tool use
import { createAnthropicToolRunner } from '@authentify2026/agents';
const runTools = createAnthropicToolRunner(authentify, policy, { issue_refund: (i) => refunds.issue(i) });
// ...after a tool_use stop: messages.push({ role: 'user', content: await runTools.all(message.content) });

// MCP server: covers every client that connects
import { createMcpGuard } from '@authentify2026/agents';
const guard = createMcpGuard(authentify, policy);
server.registerTool('issue_refund', { description, inputSchema }, guard('issue_refund', handler));
OutcomeWhat the guard does
allowThe tool runs.
denyNot run; the model is told it was denied and not to retry.
escalateNot run; the model is told it awaits human approval.
Authentify unreachableNot run.
Tool not listed in the policyNot run (set unlisted: 'skip' to allow).

LangChain

ts
import { createAuthentifyAuthorizeTool } from '@authentify2026/langchain';

const authorizeTool = createAuthentifyAuthorizeTool(authentify);
// Add it to the agent's tools and instruct the agent to call it before any account action.
Make it the only path

A LangChain tool is called by the model, so it works only if the agent has no other way to reach the same system. Don't also give it a raw HTTP tool that could call that API directly. Where you can, prefer the guards above, or require a decision token at your API. A Python LangChain wrapper is available on request.

Consent widget

tsx
import { AuthentifyConsentWidget, ActionApproval, ConsentManager, ActivityFeed } from '@authentify2026/consent-widget';

Four components for the people your agents act for: consent, single-action approval, connected agents and activity. Each also exists as a hosted page, so using the package is optional. See End users.

OpenAPI

The agent-facing and end-user endpoints are described in /openapi.json for code generators and API tools. The full list of calls is in the API reference.