HiveKey
Docs/API reference

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.

Base URL · https://api.hivekey.ai Version · 2026-04-01

Overview

Every resource follows the same shape. Here's the full surface at a glance.

Method Endpoint
POST /v1/agents
GET /v1/agents/:id
POST /v1/agents/:id/revoke
POST /v1/roles
PATCH /v1/roles/:name
POST /v1/policies/evaluate
GET /v1/audit/events
POST /v1/tokens
POST /v1/webhooks

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.

shell · curl
curl https://api.hivekey.ai/v1/agents \
  -H "Authorization: Bearer hk_live_8fK2…aR9" \
  -H "HiveKey-Version: 2026-04-01"
POST

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

FieldTypeDescription
namestringUnique handle, e.g. helpdesk-bot. Required.
rolestringRole to bind. Determines scope + guards. Required.
ownerstringEmail of the accountable human. Required.
metadataobjectArbitrary key/value tags for filtering. Optional.
Requestcurl
curl https://api.hivekey.ai/v1/agents \
  -H "Authorization: Bearer hk_live_…" \
  -d '{"name":"helpdesk-bot",
       "role":"support-agent",
       "owner":"sam@acme.com"}'
Response201 Created
{
  "id": "agt_5Kd0pN",
  "object": "agent",
  "name": "helpdesk-bot",
  "role": "support-agent",
  "owner": "sam@acme.com",
  "status": "active",
  "created": 1775923200
}
PATCH

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

Requestcurl
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"]}}'
Response200 OK
{
  "object": "role",
  "name": "support-agent",
  "revision": 4,
  "scope": { "allow": ["mail.read",
    "mail.send", "crm.read"] },
  "guards": 2,
  "agents_affected": 12
}
POST

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

Requestcurl
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"}}'
Response200 OK
{
  "verdict": "deny",
  "matched_guard": "approved-domains",
  "reason": "domain 'gmail.com' not in
    allowlist",
  "dry_run": true
}
GET

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

ParamTypeDescription
agentstringFilter to one agent id or name.
verdictenumallow · deny · review.
sincetimestampUnix seconds; events at or after.
limitinteger1–100, default 25.
starting_afterstringCursor for the next page.
Response200 OK
{
  "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"
}
POST

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

Response201 Created
{
  "object": "token",
  "id": "tok_7Yb3wM",
  "agent": "helpdesk-bot",
  "secret": "hk_agt_3pQ…shown_once",
  "expires": 1776009600,
  "scopes": ["mail.read", "mail.send"]
}
POST

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

action.allowedaction.deniedaction.review_requestedrole.updatedagent.revokedtoken.expired
Delivery payloadaction.denied
{
  "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

StatusCodeMeaning
400invalid_requestMalformed body or missing required field.
401unauthorizedMissing or invalid bearer token.
403policy_deniedAction blocked by scope or a guard rule.
404not_foundNo such resource in this workspace.
409conflictIdempotency key reused with a different body.
429rate_limitedToo many requests; back off and retry.

Need help? Talk to our team.