---
title: "Preview one contact's agent-written message, streaming the research"
method: POST
path: "/sequences/{sequence_id}/agent/preview/stream/"
tags: ["sequences"]
---

# Preview one contact's agent-written message, streaming the research

`POST /sequences/{sequence_id}/agent/preview/stream/`

## Request

- Base URL: `https://api.getoneprofile.ai` (the document declares no server; this is the origin it was published from)
- URL: `https://api.getoneprofile.ai/sequences/{sequence_id}/agent/preview/stream/`
- Auth: HTTP bearer

Have the sequence's agent write one contact's whole sequence as a preview, in one call the way the real first send writes it (each later step reads the drafts before it), researching the contact on the web the way the real first message would, and stream its work as Server-Sent Events. The `result` frame carries the step asked for; each of the contact's other agent-written steps on their path that comes back with words is saved as a sample of its own step, read through the sequence's agent examples. A step that only runs on a branch this contact does not take, or a contact already sent a message, gets the asked step alone. Nobody receives the preview and it costs no credits; it counts against the workspace's daily preview allowance once for each step it writes, where a preview that researches counts for more than one that does not. The agent researches only when its research switch is on, the contact has never been researched and the workspace has credits; otherwise it writes from the contact's row and what earlier research found. The same preview asked for again the same day is shown again at no further cost, unless `fresh` asks for another, which writes the whole sequence again from its first step.

The first frame is `turn`, carrying the `preview_id` a Stop is sent to; then a `step` frame for each thing the agent did (searching, reading pages, writing, checking), each with its measured duration; then one `result` frame with the asked step's message, the agent's confidence, the independent quality score, its reasoning and what the checks found.

Failures arrive as an `error` frame, because the stream has already answered 200: reason `not_found` when the sequence, the step or the contact is gone, `limit` when today's preview allowance is spent, `stopped` when the caller stopped it, `ai_unavailable` when the agent's model cannot be asked right now (nothing about the workspace; a retry does not help until it is back), and no reason for anything else.

Closing the connection does not stop the preview; the Stop route does.

## Path parameters

- `sequence_id` string, uuid, required

## Request body

- SequenceAgentPreviewRequestSchema: Which message to preview, for which contact.
  - `fresh` boolean: Write a new message instead of showing the one already written for this step, contact and agent version. Set it when someone asks for another example: without it the same ask the same day is answered from what was written before, so a second ask returns the first message word for word. For a contact the sequence has not written to yet, a fresh write writes the contact's whole sequence again from its first step; it takes the daily preview allowance for each step it writes.
  - `record_id` string, uuid, required: The contact: a row of the sequence's audience table.
  - `step_id` string, uuid, required: An agent-written step of this sequence: the one the `result` frame carries. The rest of the contact's sequence is written with it.

## Response `200`

A stream of Server-Sent Events; the final `result` frame's `data` is the asked step's preview message.

## Other responses

- `401`: Unauthorized
- `403`: Forbidden
- `422`: Invalid request made to the API.
- `500`: Internal server error.
- `502`: Bad gateway error.
- `503`: Service unavailable.

---

[API](https://skmtc.dev/getoneprofile/apis/api-reference-oneprofile.md) · [All operations](https://skmtc.dev/getoneprofile/apis/api-reference-oneprofile/llms.txt) · [OpenAPI document](https://skmtc.dev/getoneprofile/apis/api-reference-oneprofile/revisions/4a6bd71e3f02?raw)
