Skip to content

TypeScript

The Actera TypeScript SDK authorizes AI agent actions at trusted server-side boundaries before external side effects execute. Install and configure the client as shown in the Quickstart, then use authorizeAction() at each call site that Actera should govern.

async function createRefund(input: RefundInput) {
const decision = await actera.authorizeAction({
agent: { id: input.agentId },
action: { type: 'refund.create', attributes: input.refund },
context: { customer: input.customer },
idempotencyKey: input.requestId,
})
if (decision.effect === 'BLOCK') throw new Error(decision.explanation || 'Action blocked')
if (decision.effect === 'REQUIRE_APPROVAL') {
return { status: 'pending_approval', decisionId: decision.id }
}
return refundProvider.create(input.refund)
}
  • Call Actera before the side effect, from a trusted server boundary.
  • Reuse the same idempotency key only when retrying the same logical input.
  • Handle all three decision effects and approval states explicitly.
  • Treat authorization infrastructure errors as a separate failure mode and do not run the action unless your application deliberately implements fail-open behavior.
  • Do not claim exactly-once external execution. The external provider’s idempotency behavior still matters.

SDK enforcement covers only call sites that invoke authorizeAction() and enforce its result. It does not intercept arbitrary model output or calls that bypass the integrated boundary. For MCP tools, use the adapter in the MCP integration instead of wrapping each call site. See API conventions for request IDs, errors, and retry guidance.