Menu
Schemas

Data-source schemas

Request, mapping, sampling, preview, and lifecycle contracts for the Data Sources REST API.

These schemas describe JSON exchanged by the Data Sources API. Tables use the serialized JSON field names, including sourceRecords, messageId, kindField, and idField. Fields marked Yes are required. Omitted optional fields use the listed defaults. These contracts reject unknown fields. Explicit JSON null is valid only when included in the type. String lengths count characters; array limits count items. Cross-field validation and lifecycle rules still apply.

Mapping semantics

Mappings use JSON Pointers (/output/message/content), while provider traffic filters use dotted paths (metadata.environment). A blank mapping path explicitly leaves the field unmapped. fallback is another pointer within the same field scope. scope can be current, root, or related.NAME; named related sources require mapping version 2, the span turn layout, and exactly one matching supporting span. Missing or ambiguous required evidence remains held.

A mapping rule must include exactly these ten fields keys:

KeyPurposeDefault pointer
userStable user identity./metadata/user_id
sessionConversation identity./metadata/session_id
inputUser message./input
outputAgent response./output
versionAgent version for evaluation./metadata/agent_version
referencesLearnings actually injected into this response./metadata/reflexio/retrieved_learnings
sourceRequest source label./metadata/environment
timestampEvent creation timestamp./created
completionCompletion evidence./metrics/end

These are schema defaults, not a claim that your provider logs those fields. A newly opened unmapped draft can have blank paths instead. Read its definition or explicitly supply all fields. Constants are supported only for source and version.

TransformBehavior and restrictions
noneUse the selected field without conversion.
stringExplicit scalar-to-string conversion.
jsonDecode JSON references; only valid for references.
first_text_blockInput/output only: first usable direct text block in one message's array.
text_blocksInput/output only: join usable direct text blocks with newlines.

Text-block transforms reject conversation-shaped arrays and arrays over 100 entries. Selected text must fit 100,000 characters; text_blocks also checks the joined result. See text selection and upgrades for block eligibility and draft promotion.

A rule's when predicates are combined with AND; multiple rules matching the same record are a conflict, not first-match-wins. Predicate eq needs one value, in needs at least one, and exists and missing take no values. missing matches an absent or null field; exists matches any non-null value, including empty strings, false, and zero. These operations are exact complements. Up to 20 values of at most 512 characters are accepted. Named related selectors use current scope to inspect candidate supporting spans; correlations express equality between current and related pointers. They do not join unrelated traces.

turn_layoutMeaning
spanOne response span and its mapped input/output.
turn_arrayOne complete message array. Requires messages_path.
history_idsRepeated conversation history with stable message IDs. Requires messages_path.
history_appendRepeated append-only history. Requires messages_path.
message_eventIndividual message events with sequence/settling controls.

History/event layouts require history_branch_path or an explicit history_unbranched: true. Internal system/tool/function/developer roles cannot be remapped into conversation messages for these layouts. See the conversation format guide for identity, ordering, late-message and history-edit behavior. Preview and canonical admission use the same mapping rules.

Request and response field tables

MappingDefinition and its nested defaults are expanded in the tables below. Large object defaults are described by their schema rather than repeated in every row. Collection status, retry results, evidence and setup-context dictionaries are documented with their endpoints in the API reference.

ConnectionInput

FieldTypeRequiredDefaultConstraints / meaning
api_keystringYes—min length: 1; max length: 4096; format: password; Provider read credential; never a Reflexio key.
public_keystring or nullNonullmin length: 1; max length: 4096
workspace_idstring or nullNonullmin length: 1; max length: 512
provider"braintrust" / "langfuse" / "langsmith"No"braintrust"—
region"us" / "eu" / "jp" / "hipaa-us"No"us"—
namestringYes—min length: 1; max length: 120

RotationInput

FieldTypeRequiredDefaultConstraints / meaning
api_keystringYes—min length: 1; max length: 4096; format: password
public_keystring or nullNonullmin length: 1; max length: 4096
workspace_idstring or nullNonullmin length: 1; max length: 512
revisionintegerYes—minimum: 1; Current connection revision.

RevisionInput

FieldTypeRequiredDefaultConstraints / meaning
revisionintegerYes—minimum: 1; Current connection revision for deletion.
lifecycle_revisioninteger or nullNonullminimum: 1; Also supply the current lifecycle revision when deleting an activated source.

StreamInput

FieldTypeRequiredDefaultConstraints / meaning
revisionintegerYes—minimum: 1; Current connection revision.
lifecycle_revisioninteger or nullNonullminimum: 1; Inherited field; does not permit editing an activated selection.
external_project_idstringYes—min length: 1; max length: 512
filtersarray of TrafficFilterNo[]max items: 10

TrafficFilter

FieldTypeRequiredDefaultConstraints / meaning
pathstringYes—max length: 160; pattern: ^(metadata\.[A-Za-z0-9_.-]+|span_attributes\.name|tags)$
op"eq" / "in" / "exists"Yes——
valuesarray of stringNo[]max items: 20

SampleInput

FieldTypeRequiredDefaultConstraints / meaning
revisionintegerYes—minimum: 1; Current stream revision.
lifecycle_revisioninteger or nullNonullminimum: 1; Inherited optional field; sampling is checked against the stream revision.
sample_windowSampleWindow or nullNonull—

SampleWindow

FieldTypeRequiredDefaultConstraints / meaning
startstringYes—format: date-time
endstringYes—format: date-time

Connection

FieldTypeRequiredDefaultConstraints / meaning
idstringYes——
project_idstringYes——
namestringYes——
provider"braintrust" / "langfuse" / "langsmith"No"braintrust"—
region"us" / "eu" / "jp" / "hipaa-us"No"us"—
revisionintegerYes——
credential_versionintegerYes——
expires_atnumber or nullYes——

ExternalProject

FieldTypeRequiredDefaultConstraints / meaning
idstringYes—min length: 1; max length: 512
workspace_idstringYes—min length: 1; max length: 512
namestringYes——

Discovery

FieldTypeRequiredDefaultConstraints / meaning
projectsarray of ExternalProjectYes——
truncatedbooleanNofalse—

Stream

FieldTypeRequiredDefaultConstraints / meaning
idstringYes——
connection_idstringYes——
project_idstringYes——
external_project_idstringYes—min length: 1; max length: 512
workspace_idstringYes—min length: 1; max length: 512
revisionintegerYes——
filtersarray of TrafficFilterYes——
filter_execution"before_download" / "partial" / "after_download"No"before_download"—
status"draft"No"draft"Setup marker only; read the status endpoint for lifecycle.
expires_atnumber or nullYes——

SampleBucket

FieldTypeRequiredDefaultConstraints / meaning
startstringYes—format: date-time
endstringYes—format: date-time
status"sampled" / "empty" / "unread"No"unread"—
retainedintegerNo0—
codestring or nullNonull—

Sample

FieldTypeRequiredDefaultConstraints / meaning
retry_atnumberNo0—
bucketsarray of SampleBucketNo[]—
example_idsarray of stringNo[]—
sample_windowSampleWindow or nullNonull—
idstringYes——
stream_idstringYes——
project_idstringYes——
status"queued" / "running" / "complete" / "failed" / "expired"Yes——
expires_atnumberYes——
recordsarray of objectNo[]Retained provider evidence, not canonical interactions.
truncatedbooleanNofalse—
coveragestringNo"Bounded recent snapshot; conversation completeness is not established."—
codestring or nullNonull—

Inspection

FieldTypeRequiredDefaultConstraints / meaning
connectionsarray of ConnectionYes——
streamsarray of StreamYes——
samplesarray of SampleYes—Inventory sample summaries; read the sample endpoint for records.
mapping_availablebooleanNotrue—
activation_availablebooleanNotrue—
sample_row_limitintegerNo50—
sample_ttl_secondsintegerNo86400—

InitializeMappingInput

FieldTypeRequiredDefaultConstraints / meaning
expected_revisionintegerNo0minimum: 0
sample_idstringYes—min length: 1; max length: 100

MappingWrite

FieldTypeRequiredDefaultConstraints / meaning
expected_revisionintegerYes—minimum: 0
definitionMappingDefinitionYes——

MappingUpgradeInput

FieldTypeRequiredDefaultConstraints / meaning
expected_revisionintegerYes—minimum: 1

PreviewInput

FieldTypeRequiredDefaultConstraints / meaning
sample_idstringYes—min length: 1; max length: 100
expected_revisionintegerYes—minimum: 0
definitionMappingDefinition or nullNonullOptional unsaved proposal; preview does not save it.

ValidateInput

FieldTypeRequiredDefaultConstraints / meaning
sample_idstringYes—min length: 1; max length: 100
expected_revisionintegerYes—minimum: 0
definitionMappingDefinition or nullNonullMust be omitted (or null); validation rejects a supplied definition.
sample_digeststringYes—pattern: ^[a-f0-9]{64}$

SuggestInput

FieldTypeRequiredDefaultConstraints / meaning
sample_idstringYes—min length: 1; max length: 100
expected_revisionintegerYes—minimum: 0
definitionMappingDefinition or nullNonull—
sample_digeststringYes—pattern: ^[a-f0-9]{64}$
consentbooleanNofalseMust be true to request advisory suggestions.

MappingDefinition

FieldTypeRequiredDefaultConstraints / meaning
version1 / 2No1—
rulesarray of MappingRuleNoOne default MappingRulemin items: 1; max items: 10; 1–10 rules; omitted value supplies one MappingRule with its defaults.
unmatched"held" / "excluded"No"held"—
evaluation_onlybooleanNofalse—

MappingRule

FieldTypeRequiredDefaultConstraints / meaning
related_sourcesobject of RelatedSourceNo{}max keys: 5
namestringNo"Response"min length: 1; max length: 100
whenarray of PredicateNo[]max items: 10
layout"standard" / "nested"No"standard"—
authority"unresolved" / "current" / "root"No"unresolved"—
fieldsobject of FieldRuleNoSee mapping semanticsExactly the ten keys listed above; defaults use the listed pointers.
kindFieldstringNo"/kind"max length: 512; pattern: ^(|/.*)$
idFieldstringNo"/learning_id"max length: 512; pattern: ^(|/.*)$
reference_response_id_pathstringNo""max length: 512; pattern: ^(|/.*)$
reference_kind"" / "profile" / "user_playbook" / "agent_playbook"No""—
turn_layout"span" / "turn_array" / "history_ids" / "history_append" / "message_event"No"span"—
messages_pathstringNo""max length: 512; pattern: ^(|/.*)$
message_content_pathstringNo"/content"max length: 512; pattern: ^/.*$
message_role_pathstringNo"/role"max length: 512; pattern: ^/.*$
message_references_pathstringNo"/retrieved_learnings"max length: 512; pattern: ^(|/.*)$
role_mapobject of "User" / "Agent"NoSee mapping semanticsmax keys: 20; Defaults map user/User to User and assistant/Agent to Agent.
allow_user_onlybooleanNofalse—
message_id_pathstringNo"/id"max length: 512; pattern: ^/.*$
history_branch_pathstringNo""max length: 512; pattern: ^(|/.*)$
history_unbranchedbooleanNofalse—
event_sequence_pathstringNo"/metadata/message_sequence"max length: 512; pattern: ^/.*$
event_message_pathstringNo"/metadata/message"max length: 512; pattern: ^/.*$
event_settle_secondsintegerNo15minimum: 0; maximum: 300

FieldRule

FieldTypeRequiredDefaultConstraints / meaning
scopestringNo"current"pattern: ^(current|root|related\.[a-z][a-z0-9_]{0,39})$
pathstringNo""max length: 512; pattern: ^(|/.*)$
fallbackstringNo""max length: 512; pattern: ^(|/.*)$
transform"none" / "string" / "json" / "text_blocks" / "first_text_block"No"none"—
constantstringNo""max length: 1000

Predicate

FieldTypeRequiredDefaultConstraints / meaning
scope"current" / "root"No"current"—
pathstringYes—max length: 512; pattern: ^/.*$
op"eq" / "in" / "exists" / "missing"No"eq"—
valuesarray of stringNo[]max items: 20

RelatedSource

FieldTypeRequiredDefaultConstraints / meaning
whenarray of PredicateYes—min items: 1; max items: 10
correlationsarray of CorrelationNo[]max items: 10

Correlation

FieldTypeRequiredDefaultConstraints / meaning
current_pathstringYes—max length: 512; pattern: ^/.*$
related_pathstringYes—max length: 512; pattern: ^/.*$

MappingDocument

FieldTypeRequiredDefaultConstraints / meaning
example_idstring or nullNonull—
example_idsarray of stringNo[]—
rule_evidenceobject of stringNo{}—
warningsarray of stringNo[]—
stream_idstringYes——
revisionintegerYes——
definitionMappingDefinitionYes——
validated_revisioninteger or nullNonull—

PreviewResult

FieldTypeRequiredDefaultConstraints / meaning
field_guidancearray of FieldGuidanceNo[]—
recordsarray of TurnProposalYes——
readyintegerYes——
heldintegerYes——
excludedintegerYes——
sourceRecordsintegerYes——
messagesintegerYes——
sample_digeststringYes——
mapping_revisionintegerYes——
mapping_digeststringYes——
policy_digeststringYes——
blockersarray of MappingBlockerNo[]—
rule_coveragearray of RuleCoverageNo[]—
advisorybooleanNotrue—

TurnProposal

FieldTypeRequiredDefaultConstraints / meaning
idstringYes——
messageIdstringYes——
userstringNo""—
sessionstringNo""—
inputstringNo""—
outputstringNo""—
versionstringNo""—
sourcestringNo""—
referencesarray of object of stringNo[]—
capture"missing" / "empty" / "valid" / "malformed" / "unresolvable" / "ambiguous"No"missing"—
diagnosticsarray of stringNo[]—
errorsarray of stringNo[]—
provenanceobject of stringNo{}—
messagesarray of objectNo[]—
disposition"ready" / "held" / "excluded"No"held"—
evaluation_readinessstringNo"unknown_version"—
learning_eligibilityobjectNo{}—
rule_namestringNo""—
historyobjectNo{}—

FieldGuidance

FieldTypeRequiredDefaultConstraints / meaning
codestringYes——
messagestringYes——
candidatesarray of objectNo[]—

MappingBlocker

FieldTypeRequiredDefaultConstraints / meaning
codestringYes——
countintegerYes——

RuleCoverage

FieldTypeRequiredDefaultConstraints / meaning
conflictedintegerNo0—
rule_namestringYes——
matchedintegerYes——
readyintegerYes——
heldintegerYes——
excludedintegerYes——

ActivateInput

FieldTypeRequiredDefaultConstraints / meaning
revisionintegerYes—minimum: 1; Current stream revision.
mapping_revisionintegerYes—minimum: 1
operation_keystringYes—min length: 1; max length: 100
historybooleanNotrue—
history_startnumber or nullNonull—
history_endnumber or nullNonull—

HistoryDraftInput

FieldTypeRequiredDefaultConstraints / meaning
revisionintegerYes—minimum: 1; Current stream revision; draft only.
historybooleanNotrue—
history_startnumber or nullNonull—
history_endnumber or nullNonull—

OperationInput

FieldTypeRequiredDefaultConstraints / meaning
revisionintegerYes—minimum: 1
action"pause" / "resume" / "disable" / "enable" / "cancel_backfill"Yes——

ExtendBackfillInput

FieldTypeRequiredDefaultConstraints / meaning
revisionintegerYes—minimum: 1
message_limitinteger or nullYes—maximum: 9007199254740991; greater than: 0; New cumulative historical budget; null selects all matching history.

TrafficFiltersInput

FieldTypeRequiredDefaultConstraints / meaning
stream_revisionintegerYes—minimum: 1; Current stream revision.
revisionintegerYes—minimum: 1; Current lifecycle revision.
filtersarray of TrafficFilterYes—max items: 10

MappingActivationInput

FieldTypeRequiredDefaultConstraints / meaning
revisionintegerYes—minimum: 1
mapping_revisionintegerYes—minimum: 1

RetryInput

FieldTypeRequiredDefaultConstraints / meaning
revisionintegerYes—minimum: 1
mapping_revisionintegerYes—minimum: 1
record_idsarray of stringYes—min items: 1; max items: 50; Use inbox IDs returned by the held-records endpoint.
append_latebooleanNofalseExplicit append-as-late confirmation; does not rewrite consumed learning windows.
preserve_user_messagebooleanNofalseExplicitly confirm a snapshot of the recorded user message from selected unfinished executions with an explicitly empty response. Requires preview; later source changes need review.
preview_digeststring or nullNonullRequired by retry execution; obtain from retry-preview for the exact selection.

Recovery and health

GET /streams/{id}/recovery returns health and repair. Health includes reasons, unmatched, checked_at, first_detected_at, earliest_expiry, last_read_at, and last_import_at; timestamps are Unix seconds and unavailable times are null.

Repair states are queued, generating, validating, proposed, retrying, complete, failed, outdated, expired, or cancelled. An empty repair object means no repair has been requested. A valid proposal includes an id, the proposed definition, conversation examples, ready, sample_count, working_examples, model identity, warnings, and expiry. Valid proposals also include changes: added_rule_indices (zero-based indices into definition.rules) and unchanged_rules (the number of existing rules retained unchanged). This metadata is omitted when the proposal is outdated or expired. Warnings describe specific coverage or conversation-format issues; the former generic related-context warning is no longer emitted and is omitted from retained proposal responses. Retry progress uses processed and affected; completion means retry processing finished, not that all records matched or learning extraction finished. New completed jobs include completed_at (Unix seconds) and result: matched, review, and excluded counts measured from retained records at completion. review includes held and conflicting records. These counts describe retry outcomes, not extraction results; older jobs can omit them. Completed jobs also include review_remaining, the current count of retained held/conflicting records for the source; it can change after manual resolution or new arrivals. Health refreshes after retry completion.

The preference endpoint is retired and returns 410. Suggestion requests contain consent and model. Approval requests contain the reviewed proposal_id. Credentials, worker lease tokens, and encrypted proposal storage never appear in these responses.

Legacy suggestion requests require an explicit model destination. Only one_click: true requests may omit model for deterministic repairs; unknown formats are never sent to an implicit model. Mixed known and unknown formats preserve compatible additions while the selected model handles the unknown examples.

Recovery requests accept optional auto_apply: boolean (default false). When true, only disjoint selector extensions preserving the established extraction and identity contract can be automatically applied after eligible-backlog validation. The same response operation may use direct answer-block extraction instead of assuming the first block is text. Other changes remain proposed for explicit approval. Recovery progress additionally exposes formats_done, formats_total, attempt, retry_at, validation_checked, review_reason, auto_applied, and optional format_outcomes; it never exposes encrypted partial proposals. Each of up to three format outcomes includes zero-based index, status (repaired means a candidate was prepared; needs_review means unresolved), optional failure-code reason, and normalization error-code errors. The validating status continues in the background before automatic application.

Recovery across providers

Import recovery supports Braintrust, Langfuse, LangSmith, Phoenix and OpenTelemetry. It preserves user/session identity and existing valid answers. Confirmed completed failures with a null response can import the user message without an empty or invented agent answer. Missing output remains distinct from a confirmed failure. The four pull providers can refresh bounded source examples; OpenTelemetry receives pushes only, so resend the completed trace when evidence is missing.

Recovery status includes evidence_refresh (pull or push), resolution_scope.filter_execution (remote, local, or push), and proposed changes.updated_rule_indices for failure-policy upgrades to existing rules. failed_response_policy identifies a confirmed failure requiring that policy; response_evidence_missing identifies an omitted response requiring fresh evidence. These records remain visible until resolved.