Agent credentials
256-bit generated keys, hashed at rest, revocable and bound to one agent.
Authenticate the agent once, describe the exact requested action and let CAPYN return the only three outcomes your integration needs.
import { Capyn } from "@capyn/sdk";
const capyn = new Capyn({
apiKey: process.env.CAPYN_API_KEY!
});
const result = await capyn.authorize({
capability: "spend.compute",
amount: {
value: "18.42",
currency: "USD"
},
vendor: { id: "openai" },
metadata: {
purpose: "Purchase inference capacity"
}
});
if (result.decision === "ALLOW") {
// Continue with this exact action.
}The demo runs in memory and exercises the real Fastify handlers, identity adapter and policy engine. No database service is required.
corepack pnpm install
corepack pnpm demoREST API / v1
Agent identity always comes from the bearer key. `agentId` is not accepted in the authorization payload.
/v1/meResolve the authenticated agent identity.
/v1/mandateInspect the agent's current active authority.
/v1/authorizeRequest a decision for one consequential action.
/v1/authorizations/:idRetrieve the request, decision and policy trace.
/v1/authorizations/:id/executeExecute one valid authorization through the configured adapter.
Deterministic response
Reason codes are safe for machines, support tooling and audit views. Human-readable descriptions stay available without replacing the canonical code.
{
"decision": "ALLOW",
"authorizationId": "auth_12928",
"reasonCodes": [
"CAPABILITY_ALLOWED",
"VENDOR_ALLOWED",
"DAILY_LIMIT_OK"
]
}{
"decision": "DENY",
"authorizationId": "auth_90411",
"reasonCodes": [
"VENDOR_NOT_ALLOWED"
]
}{
"decision": "REQUIRE_APPROVAL",
"authorizationId": "auth_58201",
"approvalId": "apr_72f83",
"reasonCodes": [
"APPROVAL_THRESHOLD_EXCEEDED"
]
}256-bit generated keys, hashed at rest, revocable and bound to one agent.
The same key and payload returns the same logical authorization result.
Approval pauses one authorization and is consumed by that request alone.
A unique execution claim prevents the provider adapter from being invoked twice.
The SDK is a thin typed client over the same REST contract. Use curl, another language or your existing agent runtime.
curl -X POST http://localhost:4000/v1/authorize \
-H "Authorization: Bearer $CAPYN_API_KEY" \
-H "Idempotency-Key: inference-order-0001" \
-H "Content-Type: application/json" \
-d '{
"capability": "spend.compute",
"amount": { "value": "18.42", "currency": "USD" },
"vendor": { "id": "openai", "name": "OpenAI" },
"metadata": { "purpose": "Inference capacity" }
}'