Verifying Actions
The verification endpoint is the performance-critical core of Mandaitor. It allows any service to check in real-time whether an AI agent is authorized to perform a specific action.
Work in Progress
This guide is currently being written. Check back soon for the full content.
Basic Verification
import { MandaitorClient } from "@mandaitor/sdk";
const client = new MandaitorClient({
apiKey: process.env.MANDAITOR_API_KEY!,
tenantId: "tnt_your_tenant_id",
});
const result = await client.verify({
delegate_subject_id: "monco:agent:validation-v3",
action: "construction.validation.approve",
resource: "monco:project:proj_12345/zone:A",
});
console.log(result.decision); // "ALLOW" or "DENY"
Verification with Proof-of-Mandate
To receive a cryptographic proof alongside the verification result, use the verifyWithPoM method:
const result = await client.verifyWithPoM(
{
delegate_subject_id: "monco:agent:validation-v3",
action: "construction.validation.approve",
resource: "monco:project:proj_12345/zone:A",
},
{ pom: "sd-jwt-vc" },
);
if (result.proof_of_mandate) {
console.log(result.proof_of_mandate.compact);
}
Error Handling
import { MandataApiError, ErrorCodes } from "@mandaitor/sdk";
try {
await client.verify({
/* ... */
});
} catch (err) {
if (err instanceof MandataApiError) {
if (err.code === ErrorCodes.MANDATE_NOT_FOUND) {
console.log("No matching mandate found.");
}
}
}