AgentGate API Reference
Register AI agents, evaluate authorization requests through a 5-gate pipeline, inspect a tamper-evident audit trail, and programmatically revoke access โ all from your own code.
https://agent-gate-theta.vercel.appAuthorization Pipeline
TypeScript SDK
The official SDK wraps the REST API โ one import, one call. Full TypeScript types included, zero runtime dependencies.
npm install @damitha-perera/agentgateimport { AgentGate } from '@damitha-perera/agentgate';
const gate = new AgentGate({
baseUrl: 'https://agent-gate-theta.vercel.app',
apiKey: process.env.AGENTGATE_API_KEY!,
});
// 1. Register your agent once โ store the token
const agent = await gate.register({
name: 'my-crewai-agent',
framework: 'crewai',
capabilities: ['gmail.read', 'github.write'],
trustLevel: 1,
});
// 2. Authorize before every action
const result = await gate.authorize({
agentToken: agent.token,
action: { type: 'read', operation: 'list_emails', service: 'gmail' },
resource: { type: 'email' },
context: { recipientExternal: false },
});
if (!result.allowed) throw new Error(result.reason);
console.log(result.decision); // 'ALLOWED' | 'DENIED' | 'ESCALATED'gate.register(opts)Register a new agent, get identity tokengate.authorize(opts)Run the 5-gate pipeline, get decision + scoped tokengate.revokeAgent(id)Revoke a specific agent by IDgate.revokeService(svc)Revoke all agents for a servicegate.panic()Emergency โ revoke all agents immediatelyAuthentication
Most endpoints require authentication. AgentGate supports two methods:
Generate an API key from the dashboard and include it in every request:
Authorization: Bearer ag_live_...
Log in via Auth0. The session cookie is automatically sent by the browser from the dashboard UI.
Cookie: appSession=...
Agents
5 endpoints/api/agents/registerRegister a new agent. Returns the agent record and a signed JWT for the agent to use in subsequent authorization requests.
{
"name": "My Research Agent",
"framework": "crewai",
"capabilities": ["github.read", "gmail.send"],
"trustLevel": 2
}/api/agentsList all registered agents including their status, trust level, and last activity.
{
"agents": [
{
"id": "agt_7x3k...",
"name": "My Research Agent",
"framework": "crewai",
"status": "active",
"trustLevel": 2,
"lastActivity": "2025-04-01T12:05:00Z"
}
]
}/api/revoke/agentRevoke a specific agent. Triggers cascade revocation โ all downstream tokens for this agent are destroyed.
{ "agentId": "agt_7x3k..." }/api/revoke/serviceRevoke all agents that have capabilities for a given service (e.g. "github", "gmail").
{ "service": "github" }/api/revoke/panicEmergency: revoke ALL active agents immediately. Use with caution โ this destroys every active agent token.
{ "success": true, "revokedAgents": 7, "revokedTokens": 24 }Audit
3 endpoints/api/auditRetrieve audit log entries with pagination. Each entry includes a SHA-256 hash linking to the previous entry โ forming a tamper-evident chain.
{
"entries": [
{
"id": "aud_x9k...",
"timestamp": "2025-04-01T12:05:00Z",
"sequenceNumber": 42,
"type": "TOKEN_ISSUED",
"agentId": "agt_7x3k...",
"action": "gmail.write:send_email",
"resource": "email",
"decision": "ALLOWED",
"hash": "a3f9c2...",
"previousHash": "7b2d14..."
}
]
}/api/audit/verifyVerify the integrity of the audit hash chain. Checks every entry's hash against the previous entry to detect tampering.
{
"valid": true,
"entriesChecked": 42,
"firstEntry": "aud_001...",
"lastEntry": "aud_042..."
}/api/audit/exportExport the full audit log as a JSON file download.
// Returns: application/json file download
// Content-Disposition: attachment; filename="audit-export-2025-04-01.json"
[{ "id": "aud_x9k...", "timestamp": "...", ... }]Policy
2 endpoints/api/policy/rulesGet all policy rules. Rules are evaluated in priority order: DENY โ ESCALATE โ ALLOW. First matching rule wins.
{
"rules": [
{
"id": "allow-read-trusted",
"name": "Allow reads by trusted agents",
"condition": { "actionTypes": ["read"], "minTrustLevel": 2 },
"decision": "ALLOW",
"enabled": true
}
]
}/api/policy/rulesSave (replace) all policy rules. Sends the complete array.
{
"rules": [
{
"id": "my-rule",
"name": "Block all deletes",
"description": "Deny all delete operations",
"condition": { "actionTypes": ["delete"] },
"decision": "DENY",
"enabled": true
}
]
}API Keys
3 endpoints/api/keysList your API keys. Returns display-safe fields only โ the raw key is never returned after creation.
{
"keys": [
{
"id": "key_abc123...",
"name": "Production Agent",
"keyPrefix": "ag_live_ABCD...",
"createdAt": "2025-04-01T10:00:00Z",
"lastUsedAt": "2025-04-01T12:05:00Z",
"isActive": true
}
]
}/api/keysGenerate a new API key. The raw key is returned exactly once โ store it securely.
{ "name": "Production Agent" }/api/keys/[id]Revoke an API key immediately. Future requests using it return 401.
{ "success": true }