Documentation
JavaScript SDK
The SDK is published as @behalfid/sdk and uses fetch, so it works in Node 18+ without extra dependencies.
Install
npm install @behalfid/sdk
Initialize
import { BehalfID } from "@behalfid/sdk";
export const behalf = new BehalfID({
apiKey: process.env.BEHALFID_API_KEY!,
});Verify before execution
const decision = await behalf.verify({
agentId: "agent_xxx",
action: "deploy_production",
vendor: "vercel.com",
});
if (!decision.allowed) {
throw new Error(`Blocked: ${decision.reason}`);
}
// Safe to proceedCreate a permission
await behalf.createPermission({
agentId: "agent_xxx",
action: "deploy_production",
resource: "vercel.com",
requiresApproval: true,
});