REST & policy API.
A predictable, resource-oriented API. Versioned URLs, bearer auth, idempotency keys on writes, and cursor pagination on lists. All requests are over HTTPS; responses are JSON.
Overview
Every resource follows the same shape. Here's the full surface at a glance.
| Method | Endpoint | Description |
|---|---|---|
| POST | /v1/agents | Create an agent identity |
| GET | /v1/agents/:id | Retrieve an agent |
| POST | /v1/agents/:id/revoke | Kill-switch an agent |
| POST | /v1/roles | Create a role |
| PATCH | /v1/roles/:name | Update scope or guards |
| POST | /v1/policies/evaluate | Dry-run a policy decision |
| GET | /v1/audit/events | List audit events |
| POST | /v1/tokens | Mint a scoped agent token |
| POST | /v1/webhooks | Register a webhook endpoint |
Authentication
Admin keys (hk_live_…) authenticate management calls. Agent tokens (hk_agt_…) authenticate actions at the gateway and are scoped to a role. Pass either as a bearer token.
curl https://api.hivekey.ai/v1/agents \
-H "Authorization: Bearer hk_live_8fK2…aR9" \
-H "HiveKey-Version: 2026-04-01" Agents
An agent is a verifiable identity bound to an owner and a role. Create one, retrieve it, or kill-switch it.
POST /v1/agents
Body parameters
| Field | Type | Description |
|---|---|---|
| name | string | Unique handle, e.g. helpdesk-bot. Required. |
| role | string | Role to bind. Determines scope + guards. Required. |
| owner | string | Email of the accountable human. Required. |
| metadata | object | Arbitrary key/value tags for filtering. Optional. |
curl https://api.hivekey.ai/v1/agents \
-H "Authorization: Bearer hk_live_…" \
-d '{"name":"helpdesk-bot",
"role":"support-agent",
"owner":"sam@acme.com"}' {
"id": "agt_5Kd0pN",
"object": "agent",
"name": "helpdesk-bot",
"role": "support-agent",
"owner": "sam@acme.com",
"status": "active",
"created": 1775923200
} Roles
A role bundles scope grants and guard rules. Every update creates a new immutable revision; agents always run the latest.
PATCH /v1/roles/:name
curl -X PATCH \
https://api.hivekey.ai/v1/roles/support-agent \
-H "Authorization: Bearer hk_live_…" \
-d '{"scope":{"allow":["mail.read",
"mail.send","crm.read"]}}' {
"object": "role",
"name": "support-agent",
"revision": 4,
"scope": { "allow": ["mail.read",
"mail.send", "crm.read"] },
"guards": 2,
"agents_affected": 12
} Policies
Dry-run a decision without performing the action. Useful for CI checks and policy testing — same engine the gateway uses in the path.
POST /v1/policies/evaluate
curl https://api.hivekey.ai/v1/policies/evaluate \
-H "Authorization: Bearer hk_live_…" \
-d '{"role":"support-agent",
"action":"mail.send",
"input":{"to":"x@gmail.com"}}' {
"verdict": "deny",
"matched_guard": "approved-domains",
"reason": "domain 'gmail.com' not in
allowlist",
"dry_run": true
} Audit events
The immutable action log. Filter by agent, verdict, or time; paginate with a cursor. Stream the same events to your SIEM via webhooks or the OCSF export.
GET /v1/audit/events
Query parameters
| Param | Type | Description |
|---|---|---|
| agent | string | Filter to one agent id or name. |
| verdict | enum | allow · deny · review. |
| since | timestamp | Unix seconds; events at or after. |
| limit | integer | 1–100, default 25. |
| starting_after | string | Cursor for the next page. |
{
"object": "list",
"has_more": true,
"data": [
{
"id": "evt_9hT1zP",
"ts": 1775923331,
"agent": "helpdesk-bot",
"owner": "sam@acme.com",
"action": "mail.send",
"verdict": "deny",
"matched_guard": "approved-domains",
"request_id": "act_2Nf9kR"
}
],
"next_cursor": "evt_9hT1zP"
} Tokens
Mint a short-lived, role-scoped token for an agent. The secret is shown once. Revoke it any time — or kill-switch the agent to revoke all of its tokens.
POST /v1/tokens
{
"object": "token",
"id": "tok_7Yb3wM",
"agent": "helpdesk-bot",
"secret": "hk_agt_3pQ…shown_once",
"expires": 1776009600,
"scopes": ["mail.read", "mail.send"]
} Webhooks
Subscribe to verdicts and lifecycle events. Each delivery is signed with an HMAC (HiveKey-Signature header) and is replay-safe via a timestamp.
Event types
{
"id": "whk_1aF…",
"type": "action.denied",
"created": 1775923331,
"data": {
"agent": "helpdesk-bot",
"action": "mail.send",
"matched_guard": "approved-domains",
"request_id": "act_2Nf9kR"
}
} Error codes
| Status | Code | Meaning |
|---|---|---|
| 400 | invalid_request | Malformed body or missing required field. |
| 401 | unauthorized | Missing or invalid bearer token. |
| 403 | policy_denied | Action blocked by scope or a guard rule. |
| 404 | not_found | No such resource in this workspace. |
| 409 | conflict | Idempotency key reused with a different body. |
| 429 | rate_limited | Too many requests; back off and retry. |
Need help? Talk to our team.