# Webhooks

9 endpoints at `https://api.kosa8.com`, sent with `Authorization: Bearer $KOSA8_API_KEY`. Generated from the API's own [OpenAPI description](https://api.kosa8.com/openapi.json), which a test holds to the router.

## List webhook endpoints[#]

GET`/v1/webhooks`scope admin

Responses

200401403

```
curl -s -X GET https://api.kosa8.com/v1/webhooks \
  -H "Authorization: Bearer $KOSA8_API_KEY"
```

## Add an endpoint; the whsec_ signing secret is shown once[#]

POST`/v1/webhooks`scope admin

JSON body

`url`requiredstring

—

`events`array of "sandbox.created" | "sandbox.deleted" | "sandbox.slept" | "sandbox.woke" | "sandbox.error" | "sandbox.killed" | "sandbox.oom" | "function.deployed" …

—

`description`string

—

Responses

201400401403

```
curl -s -X POST https://api.kosa8.com/v1/webhooks \
  -H "Authorization: Bearer $KOSA8_API_KEY" \
  -H 'Content-Type: application/json' -d @body.json
```

## Stop sending, including retries[#]

DELETE`/v1/webhooks/{id}`scope admin

Parameters

`id`requiredpath · string

Id

Responses

200401403404

```
curl -s -X DELETE https://api.kosa8.com/v1/webhooks/$SBX \
  -H "Authorization: Bearer $KOSA8_API_KEY"
```

## Recent deliveries[#]

GET`/v1/webhooks/{id}/deliveries`scope admin

Parameters

`id`requiredpath · string

Id

`limit`query · integer

How many

Responses

200401403

```
curl -s -X GET https://api.kosa8.com/v1/webhooks/$SBX/deliveries \
  -H "Authorization: Bearer $KOSA8_API_KEY"
```

## Send a webhook.test event now[#]

POST`/v1/webhooks/{id}/test`scope admin

Parameters

`id`requiredpath · string

Id

Responses

200401403

```
curl -s -X POST https://api.kosa8.com/v1/webhooks/$SBX/test \
  -H "Authorization: Bearer $KOSA8_API_KEY"
```

## Record an agent hook decision or session event from a developer's machine (kosa8 hooks install --cloud)[#]

POST`/v1/agent-hooks/events`scope sandboxes:write

The decision was made by kosa8's rules on the machine; the answer may only be stricter (a frozen organization refuses every call). agent.tool_call.blocked (deny or ask) and agent.tool_call.decided are recorded in the audit log and sent to webhooks that subscribe to them.

JSON body

`event`requiredobject

—

`event.action`required"agent.tool_call.decided" | "agent.tool_call.blocked" | "agent.session.started" | "agent.session.stopped" | "agent.session.ended" | "agent.file.edited"

—

`event.harness`required"claude-code" | "cursor" | "codex" | "gemini" | "copilot"

—

`event.event`string

—

`event.tool`string

—

`event.effect`"allow" | "flag" | "ask" | "deny"

—

`event.reason`string

—

`event.rules`array of string

—

`event.subject`string

the command or path, clipped to 300 characters; never a file's contents

`event.args_sha256`string

—

`event.session`string

—

`event.cwd`string

—

`event.mode`"check" | "sandbox"

—

`event.sandboxed`boolean

—

Responses

200400401403

```
curl -s -X POST https://api.kosa8.com/v1/agent-hooks/events \
  -H "Authorization: Bearer $KOSA8_API_KEY" \
  -H 'Content-Type: application/json' -d @body.json
```

## The organization's agent hook policy, which `kosa8 hooks install --org` caches and decides with on each machine[#]

GET`/v1/agent-hooks/policy`scope sandboxes:read

Version 0 is the default policy (nothing changed). frozen: the organization is frozen, and every checked call is refused.

Responses

200401403

```
curl -s -X GET https://api.kosa8.com/v1/agent-hooks/policy \
  -H "Authorization: Bearer $KOSA8_API_KEY"
```

## Replace the organization's agent hook policy[#]

PUT`/v1/agent-hooks/policy`scope admin

rules: [{id, effect: deny|ask|flag, tool, match, reason}] with tool and match regular expressions (RE2: no lookaround or backreferences) on the tool name and on the call's command, path or URL; disabled_rules turns built-in K8- rules off; fail: closed|open when a machine has no usable copy. Machines pick a change up within ttl_seconds.

JSON body

`fail`"closed" | "open"

—

`ttl_seconds`integer

—

`max_stale_seconds`integer

—

`disabled_rules`array of string

—

`rules`array of object

—

Responses

200400401403

```
curl -s -X PUT https://api.kosa8.com/v1/agent-hooks/policy \
  -H "Authorization: Bearer $KOSA8_API_KEY" \
  -H 'Content-Type: application/json' -d @body.json
```

## Record agent hook decisions forwarded from a machine's audit log (kosa8 hooks install --org --forward-audit)[#]

POST`/v1/agent-hooks/audit`scope sandboxes:write

batch is the JSON of the forwarded entries (chain, seq, time, action, hash, event), signed with the machine's audit key (Ed25519 over "kosa8.hooks.forward/v1\n" + batch). Each entry is recorded once per chain and seq, and reaches the SIEM export with the rest of the audit log. Metadata only: never file contents or command output.

JSON body

`batch`requiredstring

—

`key`object

—

`sig`string

—

Responses

200400401403

```
curl -s -X POST https://api.kosa8.com/v1/agent-hooks/audit \
  -H "Authorization: Bearer $KOSA8_API_KEY" \
  -H 'Content-Type: application/json' -d @body.json
```

---
Source: https://docs.kosa8.com/api/webhooks/
