Skip to main content
Beta. The Taps API is stable but may add fields or refine response shapes in upcoming releases. Existing endpoints will remain backward-compatible where possible.

List Taps

Returns all registered taps. Response: JSON array of tap configurations.

Get Tap

Returns a single tap configuration plus the Python script body from MinIO. Parameters: Response (success):
Response when the stored script is missing from object storage:
scriptMissing only appears when scriptPath is set but the object is absent — typically after an interrupted edit or re-generation wiped the old script before the new one landed. Distinguish from “never generated” (scriptPath null, script null, no scriptMissing key). The Edit Tap UI uses this flag to render a recoverable-state banner instead of the generic “Generate a script first” validation.

Create or Update Tap

Body:
Document-tap compatibility rule. When tapType == "document" and targetPipeline is non-empty, the server validates that the pipeline has:
  • source.fileAttributes.unstructuredAttributes != null
  • A vector-store destination (one of qdrant, pgvector, weaviate, milvus, chroma)
Mismatches return HTTP 400 with a message naming the violation. Also enforced at run time in TapRunner.feedDocumentPipeline in case the pipeline is reshaped after the tap is saved.

Delete Tap

Deletes the tap configuration and its script from MinIO. For document taps, also clears the ledger entries and deletes all staged MinIO objects for that tap.

Brainstorm (AI Chat)

Multi-turn conversational endpoint that helps the user refine a vague tap idea into a clear instruction. The UI calls this on every message in the brainstorm chat panel of the tap creation wizard. The AI:
  • Asks one focused clarifying question at a time
  • Suggests specific data sources (e.g., yfinance, Alpha Vantage, Open-Meteo)
  • Recognizes Datris platform tables and uses the metadata/query endpoints
  • Returns an updated instruction draft on every turn so the UI can keep the instruction box in sync
  • Returns suggestedEnvVars when an external API requires authentication
Body:
Response:
After the user picks Alpha Vantage, a subsequent call returns:
The AI never suggests DATRIS_POSTGRES_DATABASE, DATRIS_MONGODB_DATABASE, DATRIS_PLATFORM_HOST, or DATRIS_PLATFORM_PORT in suggestedEnvVars — those are always injected by the platform.

Generate Script (AI)

Uses AI to generate a Python fetch() script from a plain-English description. The system prompt branches on tapType — document taps get instructions to return {uri, filename, content} dicts and a different set of rules (no chunking, no embedding, no local-filesystem fallback). Body:
Response:

Fix Script (AI Diagnosis)

Uses AI to fix a script based on a diagnosis of what went wrong. Body:
Response: Same format as Generate Script.

Test Tap

Executes the tap script without sending data to a pipeline. Returns results, logs, and AI diagnosis if issues detected. Query parameters: Body: A TapConfig JSON object (same as Create). Structured response (dataType: "csv" shown):
Document-tap response (dataType: "document"):
If errors or 0 records are detected, aiExplanation contains an AI-generated diagnosis. durationMs is the end-to-end test wall time in milliseconds — this is what the Optimize Script endpoint uses as the baseline timing for its perf rewrite. For dataType: "csv", column names in columns and the keys inside each record in records are normalized by the platform: lowercase, [a-z0-9_] only, with % rewritten to percent. Source data with names like EPS Estimate or Surprise(%) will appear as eps_estimate and surprise_percent. JSON/XML results destined for MongoDB are not normalized. See Schema Definition → Column Naming Rules. Document-tap records pass through unchanged — the platform never rewrites URI, filename, content, or metadata keys.

Review Script (Post-Run)

After a successful test, asks the LLM to scan the script’s captured stderr/stdout for signals that the script itself should change — not for performance. The reviewer looks for rate-limit / throttle / burst warnings, deprecation hints, pagination / partial-response cues, and schema-drift / auth warnings. When a signal is found, the script is regenerated with the appropriate fix (add time.sleep, switch to the recommended endpoint, add pagination, update parsing for renamed fields) and persisted to MinIO as a new version. When no signal is found, the script is returned unchanged. The UI invokes this automatically before Optimize Script — if the reviewer rewrites the script, the optimizer is skipped on that pass (correctness from output outranks speed). Callers integrating directly should follow the same order: call /tap/review first, re-test on rewritten=true, and only call /tap/optimize when rewritten=false. Body:
Response:
When rewritten is false, script / scriptPath match the input and changes is empty — the reviewer found nothing in the output worth acting on. Prompt fragments configured via Tap Prompt Fragments are auto-injected into the reviewer’s system prompt when their key or any alias appears in the script.

Optimize Script

After a successful test, asks the LLM to restructure a working script for performance — e.g. swap serial HTTP calls for a ThreadPoolExecutor, reuse a requests.Session(), or drop unnecessary time.sleep() — while preserving correctness (fetch() signature, DATRIS_TAP_TEST_LIMIT handling, Vault env-var reads, retry/backoff behavior, and raise_for_status calls). The UI invokes this automatically after a green test in the Create Tap wizard, with a regression guard that auto-reverts if the rewrite runs ≥20% slower. Callers integrating this endpoint directly should implement the same re-test + revert pattern. Body:
Response:
If the LLM concludes the script is already well-optimized, changes is an empty array and script / scriptPath match the input. In that case no re-test is needed.

Run Tap

Executes a saved tap. Optionally sends data to the configured pipeline. Body:
Response:
mode=run does not return the records themselves — the data is in transit to targetPipeline, and the agent / caller should verify completion via get_pipeline_status, not read from the response body. recordCount summarizes how many records were submitted. To preview what a script produces, call the same endpoint with mode=test, which returns up to 20 sample rows in a records array (with recordsTruncated: true set when the script produced more than that). persisted: true means the records were submitted to targetPipeline. When persisted: false, a persistedReason field names the cause — one of test_mode, run_error, no_records, no_target_pipeline, or debounced. On persisted runs, publisherToken groups every ingestion job this run submitted; pipelineTokens lists each. Document taps fan out to many pipelineTokens but share one publisherToken.

Run debounce (mode=run only)

/tap/run debounces mode=run requests per tap on a 5-second window to suppress accidental duplicates — agents that emit parallel tool_use blocks, UI buttons that get double-clicked, or transport-level retries. If a second run hits within the window, the response is HTTP 200 with status: "skipped", persisted: false, persistedReason: "debounced", and an error string explaining how long ago the previous run started. The previous run keeps executing — pivot via get_tap_logs and get_pipeline_status to track its outcome. mode=test is read-only and is never debounced.

Watching a tap run

A /tap/run response comes back as soon as records are handed off to the async ingestion pipeline — the actual load is still in progress. Use publisherToken to poll:
Returns a {rollup, events} wrapper covering every ingestion job this tap run submitted (for structured taps that’s one job; for document taps it’s one per submitted document). Poll until rollup.allDone is true, then read rollup.status for the outcome and rollup.jobs[].lastError for any failure. See the Pipeline Status API → Rollup Response for the full shape.

Generate CRON Expression (AI)

Converts a plain-English schedule description to a Quartz CRON expression. Body:
Response:

Run History

Returns the last 50 run log entries for a tap, sorted by most recent first. Response:

Document Ledger

Document taps track which files they’ve already processed in a ledger — a MongoDB collection keyed by {tapName}|{uri}. See Document Taps → The Document Ledger for the concept; these endpoints manage it.

Read ledger

Returns every ledger entry owned by the tap. Response:

Delete one entry (force re-process)

Removes a single entry and its staged MinIO object. The next tap run will re-ingest that specific document from source.

Clear the entire ledger (force full re-scan)

Removes every entry for the tap plus all staged MinIO objects. The next run re-ingests every document the source exposes. Also triggered automatically when:
  • The tap is deleted (DELETE /api/v1/tap).
  • The target pipeline’s data is cleared (DELETE /api/v1/pipeline?pipeline=X&deleteData=true). Without this, the tap would skip docs it already “processed” and the pipeline would stay empty.

Available Vector Stores

Returns the subset of [qdrant, weaviate, pgvector, milvus, chroma] whose Vault secret is present and whose service is currently reachable. Used by the document-tap pipeline wizard to drive the store picker. Secret presence alone isn’t sufficient — the dev stack seeds placeholder secrets for every store, so the endpoint actually probes each service. Response:
Probes use the same logic as /api/v1/health/services, with a 2-second timeout per store (~10 s worst case if everything is unreachable).

Tap Prompt Fragments

User-configured system prompt fragments that auto-inject into tap AI flows when the user’s text matches the fragment’s key or any alias. See Tap Prompt Fragments for the full concept; this section covers the REST endpoints. Fragments are per-tenant, stored in MongoDB at {env}-tap-prompt, and matched case-insensitively with word boundaries.

List Fragments

Response: Array of TapPromptFragment objects.

Get Fragment

Returns a single fragment or HTTP 404 if {key} is not found. {key} should be URL-encoded.

Create or Update Fragment

Create-or-update semantics — if a fragment with the same key already exists, it is overwritten. createdAt is preserved across updates; updatedAt is refreshed on every write. Writing through this endpoint invalidates the in-process fragment cache immediately, so the next tap generation / fix / optimize / brainstorm call sees the change without restart. Body:
Response: {"status": "ok"} on success.

Delete Fragment

Deletes the fragment and invalidates the cache. URL-encode {key}. Returns {"status": "ok"}.

Suggest Fragment Content

Asks the LLM to draft a content body from the fragment’s key and aliases. Useful as a starting point when creating a fragment — the UI exposes this via the Suggest button next to the Content field. If content is non-empty in the request, the LLM is instructed to refine/expand it rather than replace. Body:
Response:
The response is plain text — the UI drops it into the Content textarea for the user to review before saving.

Authentication

All endpoints require the x-api-key header if API key authentication is enabled.