# Factory Events

Source: https://opvs.ai/docs/api/factory-events

## `POST` /api/v1/factory/events

**Ingest Events**

**Request body**

```bash
curl -X POST 'https://app.opvs.ai/api/v1/factory/events' \
  -H 'Authorization: Bearer <token>' \
  -H 'Content-Type: application/json' \
  -d '{
  "board_id": "string",
  "agent_id": "string",
  "card_id": "string",
  "events": [
    {
      "session_id": "string",
      "kind": "session.started",
      "seq": 0,
      "source": "agent",
      "ts": "2026-01-01T00:00:00Z"
    }
  ]
}'
```

```python
import httpx

resp = httpx.post(
    "https://app.opvs.ai/api/v1/factory/events",
    headers={"Authorization": "Bearer <token>", "Content-Type": "application/json"},
    json={"board_id": "string", "agent_id": "string", "card_id": "string", "events": [{"session_id": "string", "kind": "session.started", "seq": 0, "source": "agent", "ts": "2026-01-01T00:00:00Z"}]},
)
resp.raise_for_status()
print(resp.json())
```

```javascript
const resp = await fetch("https://app.opvs.ai/api/v1/factory/events", {
  method: "POST",
  headers: { "Authorization": "Bearer <token>", "Content-Type": "application/json" },
  body: JSON.stringify({"board_id": "string", "agent_id": "string", "card_id": "string", "events": [{"session_id": "string", "kind": "session.started", "seq": 0, "source": "agent", "ts": "2026-01-01T00:00:00Z"}]})
});
const data = await resp.json();
console.log(data);
```

```go
package main

import (
	"net/http"
	"strings"
)

func main() {
	body := strings.NewReader(`{"board_id": "string", "agent_id": "string", "card_id": "string", "events": [{"session_id": "string", "kind": "session.started", "seq": 0, "source": "agent", "ts": "2026-01-01T00:00:00Z"}]}`)
	req, _ := http.NewRequest("POST", "https://app.opvs.ai/api/v1/factory/events", body)
	req.Header.Set("Authorization", "Bearer <token>")
	req.Header.Set("Content-Type", "application/json")
	resp, _ := http.DefaultClient.Do(req)
	defer resp.Body.Close()
}
```

**Responses**

- `201` — Successful Response
- `422` — Validation Error

## `GET` /api/v1/factory/events/stream

**Event Stream**

SSE feed of ``factory.session.event`` frames for one board, brand-scoped.

**Parameters**

- `board` (query, string, required) — factory board id to watch
- `brand` (query, any, optional) — brand id/slug — required for multi-brand users (EventSource can't send X-Brand-ID)

```bash
curl -X GET 'https://app.opvs.ai/api/v1/factory/events/stream' \
  -H 'Authorization: Bearer <token>'
```

```python
import httpx

resp = httpx.get(
    "https://app.opvs.ai/api/v1/factory/events/stream",
    headers={"Authorization": "Bearer <token>"},
)
resp.raise_for_status()
print(resp.json())
```

```javascript
const resp = await fetch("https://app.opvs.ai/api/v1/factory/events/stream", {
  method: "GET",
  headers: { "Authorization": "Bearer <token>" }
});
const data = await resp.json();
console.log(data);
```

```go
package main

import (
	"net/http"
)

func main() {
	req, _ := http.NewRequest("GET", "https://app.opvs.ai/api/v1/factory/events/stream", nil)
	req.Header.Set("Authorization", "Bearer <token>")
	resp, _ := http.DefaultClient.Do(req)
	defer resp.Body.Close()
}
```

**Responses**

- `200` — Successful Response
- `422` — Validation Error

## Ingest Events

`POST https://app.opvs.ai/api/v1/factory/events`

Also as: API only

| Code | When | What to do |
| --- | --- | --- |
| 422 | Validation Error |  |

## Event Stream

`GET https://app.opvs.ai/api/v1/factory/events/stream`

Also as: API only

SSE feed of ``factory.session.event`` frames for one board, brand-scoped.

| Code | When | What to do |
| --- | --- | --- |
| 422 | Validation Error |  |
