Reference
SDKs & widget
Typed clients for your backend, guards that wrap an agent's tools, and the components your end users see.
| Package | Install | For |
|---|---|---|
@authentify2026/sdk | npm install @authentify2026/sdk | TypeScript client: authorize, guard, tokens, outcomes, consent, verifying tokens. |
authentify-sdk | pip install authentify-sdk | Python client (3.9+): the same core calls. |
@authentify2026/agents | npm install @authentify2026/agents | Guards for OpenAI Agents SDK, Anthropic tool use and MCP servers. |
@authentify2026/langchain | npm install @authentify2026/langchain | An authorize tool for LangChain.js agents. |
@authentify2026/consent-widget | npm install @authentify2026/consent-widget | React components for the people your agents act for (End users). |
TypeScript
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| Method | Call |
|---|---|
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, verifyAuthentifyToken | At your own API: verify decision tokens and access tokens offline. |
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:
... # stopAlso: 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:
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:
// 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));| Outcome | What the guard does |
|---|---|
| allow | The tool runs. |
| deny | Not run; the model is told it was denied and not to retry. |
| escalate | Not run; the model is told it awaits human approval. |
| Authentify unreachable | Not run. |
| Tool not listed in the policy | Not run (set unlisted: 'skip' to allow). |
LangChain
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.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
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.