# Create events

URL: https://docs.hanzo.ai/docs/openapi/agent/post-agent-sessions-by-id-events

> Records one turn of a session's transcript and answers 201 with it.

`POST /v1/agent/sessions/{id}/events`

> [Agent →](https://docs.hanzo.ai/docs/openapi/agent) · [All API references →](https://docs.hanzo.ai/docs/openapi) · [Get started →](https://docs.hanzo.ai/docs/guides)

|               |                                                      |
| ------------- | ---------------------------------------------------- |
| **Address**   | `https://api.hanzo.ai/v1/agent/sessions/{id}/events` |
| **Method**    | `POST`                                               |
| **Operation** | `post_agent_sessions_by_id_events`                   |
| **Auth**      | `Authorization: Bearer $HANZO_API_KEY`               |

Records one turn of a session's transcript and answers 201 with it.

A `progress` turn additionally MOVES THE SESSION'S PROGRESS, marked as the run's
own word rather than an estimate, and pushes the updated session onto the live
stream — so a board's bar follows the run without polling and without a second
write path. See progress.go.

THE TURN IS SCANNED BEFORE IT IS STORED. The same engine the code-security
surface runs reads the payload at this boundary, and a credential in it refuses
the append with 422 rather than redacting it — a redacted transcript is one
that still had the secret in it once, and this way the author learns which
value to rotate. The refusal carries every finding: the rule, the severity, the
line, a MASKED preview and the fingerprint. The secret is never in the answer.

## Request

5 fields, body `application/json` (required).

| Field     | In   | Type   | Required | Description                                                                             |
| --------- | ---- | ------ | -------- | --------------------------------------------------------------------------------------- |
| `id`      | path | string | yes      | ID is the session to append to, from the path.                                          |
| `actor`   | body | string | —        | Actor is who produced the turn.                                                         |
| `id`      | body | string | —        | ID is the session to append to, from the path.                                          |
| `kind`    | body | string | —        | Kind is what this turn IS: message, tool-call, spawn, log, status, control or progress. |
| `payload` | body | any    | —        | Payload is the turn's own body, any valid JSON up to 64 KiB.                            |

## Response

| Status    | Body            | Meaning |
| --------- | --------------- | ------- |
| `201`     | agent.eventView | created |
| `default` | problem-details | refused |

`201` body — 7 fields.

| Field       | In   | Type            | Always | Description                                                                                                                                                                                  |
| ----------- | ---- | --------------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `actor`     | body | string          | —      | Actor is who produced the turn.                                                                                                                                                              |
| `createdAt` | body | string          | —      | CreatedAt is when the turn was recorded, RFC 3339 in UTC to the second.                                                                                                                      |
| `id`        | body | string          | —      | ID is the event's own handle, minted as "evt\_" + 32 hex characters.                                                                                                                         |
| `kind`      | body | string          | —      | Kind is what the turn IS, from a closed six: message (a model turn), tool-call, spawn (a subagent started), log, status, control (a steering command the running surface consumes).          |
| `payload`   | body | any             | —      | Payload is the turn's body, embedded as JSON rather than as a string — whatever the writer sent, up to 64 KiB, checked for well-formedness and scanned for credentials before it was stored. |
| `seq`       | body | integer (int64) | —      | Seq is the turn's position in this session's log: monotonic from 1, assigned by the store inside the insert, and unique PER SESSION rather than globally.                                    |
| `sessionId` | body | string          | —      | SessionID is the session this turn belongs to.                                                                                                                                               |

Failure carries the platform error shape — see [Errors](https://docs.hanzo.ai/docs/errors).

## Examples

**CLI**

```bash
hanzo agent sessions events <id>
```

**SDK**

**.ts**

```ts
import { Configuration, AgentApi } from 'hanzoai';

const api = new AgentApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.postAgentSessionsByIdEvents({ id: 'id', actor: "<actor>", id: "<id>" });
```

**.py**

```python
from hanzoai.cloud import ApiClient, Configuration
from hanzoai.cloud.api import AgentApi

client = ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"]))
result = AgentApi(client).post_agent_sessions_by_id_events(id='id', actor="<actor>", id="<id>")
```

**.go**

```go
cfg := hanzoai.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := hanzoai.NewAPIClient(cfg)

resp, _, err := client.AgentAPI.PostAgentSessionsByIdEvents(context.Background()).Execute()
if err != nil {
	return err
}
```

**.rs**

```rust
use hanzo_client::apis::{configuration::Configuration, agent_api};

let mut cfg = Configuration::new();
cfg.bearer_access_token = std::env::var("HANZO_API_KEY").ok();

let result = agent_api::post_agent_sessions_by_id_events(&cfg, Default::default()).await?;
```

**.java**

```java
import ai.hanzo.cloud.ApiClient;
import ai.hanzo.cloud.api.AgentApi;

ApiClient client = new ApiClient();
client.setBearerToken(System.getenv("HANZO_API_KEY"));

var result = new AgentApi(client).postAgentSessionsByIdEvents();
```

**HTTP**

```bash
curl -X POST https://api.hanzo.ai/v1/agent/sessions/<id>/events \
  -H "Authorization: Bearer $HANZO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
       "actor": "<actor>",
       "id": "<id>"
     }'
```

**MCP**

MCP reaches **agent** through the `agent` tool, which names its 38 operations with its own verbs — this one among them, under a name only MCP declares. `describe` explains any of them:

```bash
curl -X POST https://api.hanzo.ai/v1/mcp \
  -H "Content-Type: application/json" \
  -d '{
       "jsonrpc": "2.0",
       "id": 1,
       "method": "tools/call",
       "params": {
         "name": "describe",
         "arguments": {
           "op": "list_agents"
         }
       }
     }'
```

---

[Agent API](https://docs.hanzo.ai/docs/openapi/agent) · [All Hanzo APIs](https://docs.hanzo.ai/docs/openapi) · [Interactive reference](https://docs.hanzo.ai/docs/openapi/reference)
