---
title: "Get Agent Sample Record"
method: POST
path: "/agents/sample-record"
tags: ["Agents"]
---

# Get Agent Sample Record

`POST /agents/sample-record`

Pull the latest record from the topic that matches ``topicPattern``.

Used by the wizard's persistent test pane to pre-fill the Monaco editor
with a concrete sample, so the user doesn't have to hand-craft one.
Returns 200 in every "no record" case (regex matches no topic, every
matched topic is empty, deserialization fails) so the FE can render
inline state without retry logic.

``read:agents`` is the right gate - this is observation, not config
mutation, and the response is the same record any team member with
Kafka topic-read access could pull manually.

Per-tenant rate limit: 30 req/min/bucket -> 429 with ``Retry-After``.

## Request body

- SampleRecordRequest — Request body for ``POST /agents/sample-record``. Mirrors the shape of :class:`AgentInputConfig` so the FE can forward the wizard's input config straight through without remapping field names.
  - `topicPattern` string, required — Regex pattern for input topics, e.g. '^(orders)$'
  - `inputSerialization` 'AvroConfluent' | 'JsonConfluent' | 'Protobuf' | 'String', required — Input deserialization formats accepted by ``POST /agents/sample-record``. Wider than :class:`AgentSerializationEnum` (which only governs the agent runtime contract) - this endpoint also accepts the raw shapes a topic may carry in the wild so the FE can pre-fill the test pane regardless of how the source upstream is producing.

## Response `200`

Successful Response

- SampleRecordResponse — Response body for ``POST /agents/sample-record``. All three fields nullable because every "no record found" branch (regex matches no topic, every matched topic is empty, or deserialization fails) is a 200 with explanatory state - not an HTTP error - so the FE can render a hint inline without retry logic.
  - `record` object, nullable — The latest deserialized record, or null if none was found
  - `sourceTopic` string, nullable — Concrete topic name the record came from after regex resolution
  - `errorMessage` string, nullable — Set when a topic was found but its latest record could not be read or deserialized

## Other responses

- `422` — Validation Error

---

[API](https://skmtc.net/streamkap/apis/streamkap-rest-api.md) · [All operations](https://skmtc.net/streamkap/apis/streamkap-rest-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/streamkap/streamkap-rest-api/revisions/8aea6143d003/schema)
