API Reference

5 REST endpoints. Base URL: https://app.keyless-ai.com/api/v3

Authentication

All requests require an API key in the Authorization header:

Authorization: Bearer ka_live_xxxxxxxxxxxx

Additionally, x-org-id and x-agent-id headers are required on all requests.

Intents

POST /intents

Declare an intent to perform an action. Every AI action starts here. The intent is risk-scored and stored before any policy evaluation or execution.

Request Body

FieldTypeRequiredDescription
agent_iduuidYesAgent performing the action
org_iduuidYesOrganization scope
actionstringYesAction name (max 200 chars)
payloadobjectNoAction metadata (max 64KB)
amountnumberNoAction cost for budget tracking
targetobjectNoStructured target data
idempotency_keystringNoPrevents duplicate intents per org

Response (201)

{
  "intent_id": "uuid",
  "status": "pending",
  "risk_score": 0.45,
  "created_at": "2026-04-05T12:00:00Z"
}

Policy

POST /policy/evaluate

Evaluate policy rules against an existing intent. Returns the policy decision without executing anything.

Request Body

FieldTypeRequiredDescription
intent_iduuidYesIntent to evaluate
org_iduuidYesOrganization scope

Response (200)

{
  "decision": "require_approval",
  "risk_score": 0.72,
  "reason": "Amount exceeds $1,000 threshold",
  "matched_rules": ["budget_threshold", "high_risk_action"]
}

Possible decisions: allow, require_approval, deny

Approval

POST /approval/request

Request human approval for a pending intent. Creates an approval record with a configurable expiry window.

Request Body

FieldTypeRequiredDescription
intent_iduuidYesIntent requiring approval
org_iduuidYesOrganization scope
expiry_minutesnumberNoApproval window (default: 60)
PUT /approval/request

Approve or reject a pending approval.

Request Body

FieldTypeRequiredDescription
approval_iduuidYesApproval record ID
decision"approved" | "rejected"YesHuman decision
approved_bystringNoReviewer identifier

Execute

POST /execute

Execute a governed intent through the 10-step pipeline. This is the core of the Kernel.

10-Step Pipeline

  1. Fetch Intent — Load intent (org-scoped)
  2. Idempotency Check — Existing execution → 409
  3. Atomic Lock — PostgreSQL advisory lock via lock_intent_execution()
  4. Policy Re-check — Verify agent is still active
  5. Approval Check — Verify non-expired approval exists (if required)
  6. Budget Check — Atomic budget deduction via increment_budget_usage()
  7. Execute — Run action via connector layer
  8. Write Execution — Record execution result
  9. Audit Log — Mandatory audit trail entry
  10. Finalize — Update intent status + trust adjustment

Request Body

FieldTypeRequiredDescription
intent_iduuidYesIntent to execute
org_iduuidYesOrganization scope

Hard rule: No execution without intent_id. Direct execution is impossible by design.

Response (200)

{
  "execution_id": "uuid",
  "intent_id": "uuid",
  "status": "completed",
  "cost": 5000,
  "duration_ms": 342,
  "steps": [
    { "step": 1, "name": "fetch_intent", "status": "ok", "ms": 12 },
    // ... all 10 steps
  ]
}

Ledger

GET /ledger

Query the audit ledger. Two modes: single intent deep view (with intent_id) or list view with summary stats.

Query Parameters

ParamTypeDescription
org_iduuidRequired. Organization scope
intent_iduuidSingle intent deep view
agent_iduuidFilter by agent
statusstringFilter by status
fromISO-8601Start date
toISO-8601End date
limitnumberMax results (default 50, max 100)

Response — List View (200)

{
  "ledger": [...],
  "summary": {
    "total": 142,
    "completed": 128,
    "failed": 8,
    "denied": 4,
    "pending": 2,
    "total_cost": 85200
  }
}

Rate Limits

TierRequests/minIntents/day
Starter (Free)60100
Growth ($199/mo)60010,000
EnterpriseCustomUnlimited

Status Codes

CodeMeaning
200Success
201Created (new intent)
400Bad request (validation error)
401Unauthorized (invalid API key)
403Forbidden (policy denied, agent inactive)
409Conflict (duplicate execution, intent locked)
410Gone (approval expired)
422Unprocessable (budget exceeded)
429Rate limited