> For the complete documentation index, see [llms.txt](https://docs.eyepop.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.eyepop.ai/platform/outputs.md). Agents can also search and read this documentation through its [MCP server](https://docs.eyepop.ai/~gitbook/mcp).

# Outputs (e.g. Webhooks)

Send a source's results to a webhook as they happen

By default a source's results come back to the caller that set it. **Outputs** send them to another sink too: e.g. a webhook receiving results as they happen, for as long as the source runs.

They belong to the source, not the Pop: the Pop says how media is processed, the source says what media and where its results go. So two cameras running the same Pop can deliver to two different systems.

<figure><img src="https://1072321683-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDoCvfjveqiJFmk0cnXCp%2Fuploads%2Fgit-blob-ce43ddd7661d7892e49464acc63473a7f6d8b343%2Foutputs-overview.svg?alt=media" alt="An EyePop client, using the Python SDK, the Node SDK or the CLI, sends a pop, media and the source&#x27;s outputs to EyePop&#x27;s cloud. In the cloud the pipeline API runs the pop, scaling out on GPU compute. The results come back to the client as the response. When the source declares an output, the cloud also sends the results, as they happen, to a webhook sink on the public internet, such as your CRM."><figcaption><p>Results come back to the client that set the source; an output sends them to a webhook as well.</p></figcaption></figure>

## Name an output

An output has a `name`, a `type` and, for a webhook, a url and optional headers. `name` is required: it must be unique among the source's outputs, and it is how warnings, health and metrics refer to the output.

{% tabs %}
{% tab title="Python" %}

```python
from eyepop import EyePopSdk
from eyepop.worker.outputs import Output, OutputEvent, WebhookTarget

crm = Output(
    name="crm",
    type="webhook",
    webhook=WebhookTarget(
        url="https://hooks.example.com/eyepop",
        headers={"Authorization": "Bearer 7f3c..."},
    ),
)

with EyePopSdk.sync_worker(pop=pop) as endpoint:
    job = endpoint.load_from("https://example.com/lobby.mp4", outputs=[crm])
    while result := job.predict():
        print(result)
```

{% endtab %}

{% tab title="Node" %}

```typescript
import { EyePop } from '@eyepop.ai/eyepop'

const endpoint = await EyePop.workerEndpoint({ pop }).connect()
const results = await endpoint.process({
    source: { url: 'https://example.com/lobby.mp4' },
    outputs: [{
        name: 'crm',
        type: 'webhook',
        webhook: {
            url: 'https://hooks.example.com/eyepop',
            headers: { Authorization: 'Bearer 7f3c...' },
        },
    }],
})
for await (const result of results) {
    console.log(result)
}
await endpoint.disconnect()
```

{% endtab %}

{% tab title="CLI" %}

```bash
export CRM_TOKEN='Bearer 7f3c...'
eyepop run --pop people-common-objects --media-path https://example.com/lobby.mp4 \
  --output webhook=https://hooks.example.com/eyepop,header=Authorization:env:CRM_TOKEN
```

The CLI reads a header's value from an environment variable, so it never sits in your shell history.
{% endtab %}
{% endtabs %}

The run prints its results as usual, and the webhook gets them as well.

Outputs need eyepop-worker 4.26.2 or later, and the Python SDK `eyepop` 4.3.0 or later, the Node SDK `@eyepop.ai/eyepop` 4.4.0 or later, or the EyePop CLI 0.28.0 or later for `--output`.

## Filter events sent to outputs

An output gets the events it names in `events`. Without `events`, on eyepop-worker 4.31.2 or later, it gets every event its location delivers except `prediction.tracked`, whose frames `prediction.made` already carries: in EyePop's cloud `stream.status_changed`, `prediction.made` and `prediction.selected`; on an on-premise instance also `track.started`, `track.ended`, `insight.completed` and `journey.matched`.

| Event                   | When it is sent                                                                                                                                                                                                                          |
| ----------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `prediction.made`       | Every prediction, one per processed frame.                                                                                                                                                                                               |
| `prediction.tracked`    | A prediction in which a track starts or ends, sent whole. Fewer requests than `prediction.made`, and enough to count who came and went.                                                                                                  |
| `prediction.selected`   | A [selected prediction](https://docs.eyepop.ai/platform/response-format/predictions/tracks-and-selected-predictions.md): the best frame of a track, with the results of the components that run on it, such as a face's identity vector. |
| `stream.status_changed` | The source started, ended, failed or was stopped.                                                                                                                                                                                        |

`prediction.made` already contains every tracked prediction, so an output cannot name both.

{% tabs %}
{% tab title="Python" %}

```python
crm = Output(
    name="crm",
    type="webhook",
    webhook=WebhookTarget(url="https://hooks.example.com/eyepop"),
    events=[OutputEvent.PREDICTION_SELECTED, OutputEvent.STREAM_STATUS_CHANGED],
)
```

{% endtab %}

{% tab title="Node" %}

```typescript
const crm = {
    name: 'crm',
    type: 'webhook',
    webhook: { url: 'https://hooks.example.com/eyepop' },
    events: ['prediction.selected', 'stream.status_changed'],
}
```

{% endtab %}

{% tab title="CLI" %}

```bash
--output webhook=https://hooks.example.com/eyepop,events=prediction.selected+stream.status_changed
```

`eyepop run` asks for prediction version 4, which carries selected predictions, so an output that names `prediction.selected` gets them, and the run prints them too.
{% endtab %}
{% endtabs %}

### Filter events returned to the client

`events` on the source itself, beside `outputs`, filters what comes back to *you*: with `events=["prediction.tracked"]` your code gets only the predictions where tracks start or end, while the webhook still gets what it asked for. It takes the three prediction events; status messages always come back. A still image never starts a track, so its `events` must include `prediction.made`.

{% tabs %}
{% tab title="Python" %}

```python
job = endpoint.load_from(
    "rtsp://camera.example.com/stream1",
    outputs=[crm],
    events=[OutputEvent.PREDICTION_TRACKED],
)
```

{% endtab %}

{% tab title="Node" %}

```typescript
const results = await endpoint.process({
    source: { url: 'rtsp://camera.example.com/stream1' },
    outputs: [crm],
    events: ['prediction.tracked'],
})
```

{% endtab %}
{% endtabs %}

## What the webhook receives

Each event is a `POST` with a JSON body:

```json
{
  "schema": "eyepop.agent_event.v1",
  "event_id": "86c72c78-01a1-4882-bf5e-95b6129abaa6:source-2:25",
  "event_type": "prediction.made",
  "occurred_at_ns": 1796000116868654384,
  "pipeline_id": "86c72c78-01a1-4882-bf5e-95b6129abaa6",
  "source_id": "source-2",
  "content": {
    "timestamp": 958333333,
    "seconds": 0.958333333,
    "source_width": 1280,
    "source_height": 720,
    "objects": [
      {
        "classLabel": "person",
        "confidence": 0.9179,
        "x": 578.281,
        "y": 305.947,
        "width": 119.062,
        "height": 353.496
      }
    ]
  }
}
```

* `event_type` names the event, and `content` is the prediction, as your own code receives it (shortened here).
* `event_id` is unique per event and stays the same on every retry and in every output, so a receiver that sees an id twice drops the second. The request carries it as `X-EyePop-Event-ID`, and the type as `X-EyePop-Event-Type`.
* A `stream.status_changed` event carries `status` instead of `content`: `running` when the source starts, then `completed`, `error`, `stopped` or `preempted`.

`format` changes the body: `full` (the default) as above, `envelopeOnly` without the prediction, `contentOnly` with only the prediction.

### Batches

With `batch`, the webhook gets up to `maxEvents` events at a time as a JSON array, sent once that many are waiting or `maxDelay` after the first:

{% tabs %}
{% tab title="Python" %}

```python
from eyepop.worker.outputs import OutputBatch

crm = Output(
    name="crm",
    type="webhook",
    webhook=WebhookTarget(url="https://hooks.example.com/eyepop"),
    batch=OutputBatch(maxEvents=100, maxDelay="5s"),
)
```

{% endtab %}

{% tab title="Node" %}

```typescript
const crm = {
    name: 'crm',
    type: 'webhook',
    webhook: { url: 'https://hooks.example.com/eyepop' },
    batch: { maxEvents: 100, maxDelay: '5s' },
}
```

{% endtab %}
{% endtabs %}

A batched request carries `X-EyePop-Event-Count`, and `X-EyePop-Event-ID` names its first event.

## Delivery

* **At least once, in order.** A `5xx`, `408` or `429` answer, a timeout or a connection error is retried, backing off from 1 s to 60 s, for up to 10 minutes. Any other `4xx` drops the event: the receiver said it does not want it. `retry` changes the policy: `initialBackoff`, `maxBackoff`, and `giveUpAfter` (at most `1h`).
* **A bounded queue.** Each output holds up to 1,000 undelivered events (`queue`) and drops its oldest when full.
* **After the source ends**, what an output still holds is delivered, until it gives up.
* **No redirects.** A webhook that answers with a redirect is not followed.
* **Public addresses only.** In the cloud a webhook must be on a public address; a url that is, or resolves to, a private, loopback or link-local address is refused when the source is set. On an [on-premise instance](https://docs.eyepop.ai/deploying/on-premise.md) the instance delivers, from your own network: its [persistent streams](https://docs.eyepop.ai/deploying/on-premise/streams.md) always can send to a private address, such as a webhook behind your firewall ([example](https://docs.eyepop.ai/deploying/on-premise/relay.md#relay-a-stream)), and its ad-hoc sources can when the instance's operator allows it, with [`--outputs-allow-private-targets`](https://docs.eyepop.ai/deploying/on-premise/settings.md#outputs-allow-private-targets).

Header values and credentials in a url are never shown back or logged.

## Other output types

A webhook is the type that works everywhere. An on-premise instance has three more:

| Type      | What it does                                                                                                                                                            |
| --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `webhook` | Sends each event, or each batch, as an HTTP `POST` with a JSON body to a url.                                                                                           |
| `mqtt`    | Publishes each event to an MQTT broker (`mqtt.brokerUrl`), on the topic `<topicPrefix>/<event type>`, the event type's dots becoming slashes: `site-a/prediction/made`. |
| `nats`    | Publishes each event to a NATS server (`nats.url`), on the subject `<subjectPrefix>.<event type>`: `site-a.prediction.made`.                                            |
| `stdout`  | Writes each event as a JSON line to the instance's own output, where its log collector picks it up; the operator has to allow it.                                       |

## Where outputs work

| Where                                                                                                 | Output types                                                                            |
| ----------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- |
| EyePop's cloud: sessions and pipelines                                                                | `webhook`                                                                               |
| An [on-premise instance](https://docs.eyepop.ai/deploying/on-premise.md)'s ad-hoc source              | `webhook`, `mqtt`, `nats`, and `stdout` when the operator allows it                     |
| An on-premise instance's [persistent streams](https://docs.eyepop.ai/deploying/on-premise/streams.md) | `webhook`, private addresses included, set with `eyepop instance stream start --output` |

Outputs go with a url, a group or an asset. A file you upload takes no outputs on an on-premise instance; set it from a url instead.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.eyepop.ai/platform/outputs.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
