Production workflow endpoints
The current /v2 API is organized around wrapper-code runs, files, artifacts, and usage records. Send wrapperCodes instead of raw prompt templates, use idempotency for POST requests, and use trace IDs plus ledger records for production visibility.
Authentication
Use x-api-key for all API keys, including legacy keys. New zw_live_ keys may also use Bearer auth.
Idempotency
Send Idempotency-Key on POST /v2/runs. Retries return the existing run instead of duplicating execution.
Rate limits
V2 responses include X-RateLimit-Limit, X-RateLimit-Remaining, and X-RateLimit-Reset headers.
Base URL
/v2/runsList runs
Returns paginated runs for the authenticated user or API key.
/v2/runsCreate a run
Creates and optionally executes a sync or async wrapper-code workflow run. Supports wrapperCodes, model, input.text, input.files, output.format, output.artifact, model params, metadata, and overrides.
/v2/runs/{runId}Get run detail
Returns the run, steps, events, files, artifacts, approvals, and usage ledger entries.
/v2/runs/{runId}/executeExecute queued run
Executes a queued async run. Completed runs cannot be executed again.
/v2/runs/{runId}/cancelCancel run
Cancels a queued/running run when it is not already terminal.
{
"model": "openai-gpt-4o-mini",
"mode": "sync",
"wrapperCodes": ["marketing_copywriting_cold_out_ema_b2b"],
"input": {
"text": "Product: Zywrap\nAudience: SaaS developers\nGoal: Write a concise outbound email.",
"files": ["file_id"]
},
"output": {
"format": "markdown",
"artifact": true
},
"temperature": 0.4,
"metadata": {
"source": "my-app"
}
}{
"executed": true,
"run": {
"id": "run_id",
"status": "completed",
"selectedModelCode": "openai-gpt-4o-mini",
"selectedFiles": ["file_id"],
"outputSummary": "AI output summary...",
"outputMetadata": {
"billing": {
"mode": "observe_only",
"source": "SUBSCRIPTION",
"amountCredits": "13",
"amountUsd": 0.00013,
"providerCost": 0.0000642,
"ledgerId": "usage_ledger_id"
}
},
"artifacts": [
{ "id": "artifact_id", "type": "markdown", "status": "ready" }
]
}
}Create run request fields
Files are user-provided inputs. Zywrap extracts supported content and can attach it to future runs.
/v2/filesList files
Paginated uploaded files.
/v2/filesUpload file
multipart/form-data with field name file.
/v2/files/{fileId}/downloadDownload file
Downloads the original uploaded file.
Artifacts are generated outputs from runs. They are saved for preview, download, and downstream automation.
/v2/artifactsList artifacts
Paginated generated outputs.
/v2/artifacts/{artifactId}/downloadDownload artifact
Downloads markdown/text now; PDF/DOCX/XLSX can be added later.
Every successful provider call creates a ledger debit record with the run, API key, token usage, provider cost, customer cost, billing mode, and source.
/v2/usage-ledgerList usage ledger
Supports page, limit, runId, source, and type filters.
/v2/admin/observability/summaryAdmin observability
Admin-only summary of runs, costs, files, artifacts, API keys, and errors.
{
"items": [
{
"id": "ledger_id",
"runId": "run_id",
"apiKeyId": "api_key_id",
"type": "debit",
"source": "SUBSCRIPTION",
"amountCredits": "13",
"amountUsd": 0.00013,
"providerCost": 0.0000642,
"description": "V2 run usage recorded for review."
}
],
"totals": {
"amountCredits": "13",
"amountUsd": 0.00013,
"providerCost": 0.0000642
}
}curl -X POST https://api.zywrap.com/v2/files \
-H "x-api-key: zw_live_..." \
-F "file=@./customer-feedback.csv" \
-F "displayName=Customer Feedback"curl -L https://api.zywrap.com/v2/artifacts/artifact_id/download \
-H "x-api-key: zw_live_..." \
-o output.mdComplete file-to-artifact flow
This is the production pattern for workflows that need user documents, CSVs, specs, transcripts, support exports, or other uploaded context. Upload once, reference the file ID in input.files, then download the saved artifact.
# 1. Upload file
curl -X POST https://api.zywrap.com/v2/files \
-H "x-api-key: zw_live_..." \
-F "file=@./customer-feedback.csv" \
-F "displayName=Customer feedback CSV"
# 2. Run wrapper with file input and artifact output
curl -X POST https://api.zywrap.com/v2/runs \
-H "x-api-key: zw_live_..." \
-H "Content-Type: application/json" \
-H "Idempotency-Key: file-artifact-run-001" \
-d '{
"wrapperCodes": ["customer_support_reply_summary"],
"model": "openai-gpt-4o-mini",
"input": {
"text": "Summarize this file and list the top action items.",
"files": ["file_id"]
},
"output": { "format": "markdown", "artifact": true }
}'
# 3. Download generated artifact
curl -L https://api.zywrap.com/v2/artifacts/artifact_id/download \
-H "x-api-key: zw_live_..." \
-o zywrap-output.mdNeed the raw OpenAPI schema?
Use the backend OpenAPI endpoint for SDK generation and API tooling.