# Create events

URL: https://docs.hanzo.ai/docs/openapi/train/post-train-jobs-by-id-events

> An executor's report for the task it holds: status changes, the lead's coordinator address, metrics, log lines, stored artifacts and, last, the lead's result.

`POST /v1/train/jobs/{id}/events`

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

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

An executor's report for the task it holds: status changes,
the lead's coordinator address, metrics, log lines, stored artifacts and, last,
the lead's result. It must carry the task's lease; a report under any other is
409 lease\_lost and the executor stops. A report with no events is a heartbeat,
due at least every `report` seconds the claim answered — a task silent for the
lease's life is lost, and a lost lead fails its job. Each report meters the
task by the clock: its devices times the seconds since it was claimed, no more
than is held, charged to the job's payer for a job Hanzo runs. The answer says
how many device-seconds are held now. When the next window cannot be held and
what is held runs low, the job ends stopped and the answer says cancel: kill
the trainer and report nothing more. Once the job has ended a report records
nothing and answers the job's status; cancel says it was cancelled or stopped.

## Request

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

| Field    | In   | Type   | Required | Description                                          |
| -------- | ---- | ------ | -------- | ---------------------------------------------------- |
| `id`     | path | string | yes      | ID names the job, from the path.                     |
| `events` | body | any\[] | —        | Events are the task's new events, in order.          |
| `id`     | body | string | —        | ID names the job, from the path.                     |
| `lease`  | body | string | —        | Lease is the task's lease, as the claim answered it. |
| `task`   | body | string | —        | Task is the reporting task.                          |

## Response

| Status    | Body            | Meaning |
| --------- | --------------- | ------- |
| `200`     | train.reportOut | ok      |
| `default` | problem-details | refused |

`200` body — 4 fields.

| Field    | In   | Type            | Always | Description                                                                                                                          |
| -------- | ---- | --------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------ |
| `cancel` | body | boolean         | —      | Cancel says the job was cancelled, or stopped at what its payer or its own bounds could hold: kill the trainer, report nothing more. |
| `held`   | body | integer (int64) | —      | Held is the device-seconds held for the task now.                                                                                    |
| `seq`    | body | integer (int64) | —      | Seq is the job's last event seq.                                                                                                     |
| `status` | body | string          | —      | Status is the job's status after this report.                                                                                        |

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

## Examples

**CLI**

`hanzo` has no subcommand for this operation — the CLI serves only what cloud's live route table confirms. Use HTTP or an SDK.

**SDK**

**.ts**

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

const api = new TrainApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.postTrainJobsByIdEvents({ id: 'id', events: ["<events>"], id: "<id>" });
```

**.py**

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

client = ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"]))
result = TrainApi(client).post_train_jobs_by_id_events(id='id', events=["<events>"], id="<id>")
```

**.go**

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

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

**.rs**

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

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

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

**.java**

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

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

var result = new TrainApi(client).postTrainJobsByIdEvents();
```

**HTTP**

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

**MCP**

MCP declares no tool for **train** — `tools/list` on `https://api.hanzo.ai/v1/mcp` names the products it does reach. Use HTTP or an SDK.

---

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