{"openapi":"3.1.0","info":{"title":"Zirnay Decision-as-a-Service (DaaS) Platform API","version":"1.0.0","description":"High-throughput, ultra-low-latency System 1 Decisioning at Scale. Supports non-autoregressive models like Laya and distributed decision graphs like Strands-dc."},"servers":[{"url":"http://localhost:8000","description":"Local Development Server"},{"url":"https://api.zirnay.com","description":"Production Edge Gateway"}],"components":{"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"Organization & Team JWT token obtained via SSO or User Login"},"ApiKeyAuth":{"type":"apiKey","in":"header","name":"X-API-Key","description":"High-performance data plane API key (e.g. zrn_live_...)"}},"schemas":{"DecisionRequest":{"type":"object","properties":{"raw_text":{"type":"string","example":"Subject: Urgent wire transfer request. Account 4819-2049. Please send $45,000 immediately."},"json_state":{"type":"object","example":{"amount_cents":4500000,"velocity_1h":8,"geo_entropy":0.85}},"query":{"type":"object","properties":{"type":{"type":"string","enum":["choice","score","yes_no"],"example":"choice"},"target":{"type":"string","example":"Classify incoming email security risk"},"options":{"type":"array","items":{"type":"string"},"example":["Clean Business","Billing Inquiry","Phishing Threat","Executive Fraud"]}}},"features":{"type":"object","example":{"risk_score":0.82}},"options":{"type":"object","properties":{"checkpoint_id":{"type":"string"},"explain":{"type":"boolean"}}}}},"DecisionResponse":{"type":"object","properties":{"request_id":{"type":"string","example":"req_8819d-29384"},"decision":{"type":"string","example":"Executive Fraud"},"confidence":{"type":"number","example":0.9842},"probabilities":{"type":"object","additionalProperties":{"type":"number"},"example":{"Executive Fraud":0.9842,"Phishing Threat":0.0124,"Billing Inquiry":0.0021,"Clean Business":0.0013}},"score_value":{"type":"number"},"checkpoint_id":{"type":"string","example":"chk_89f02c77"},"model_type":{"type":"string","example":"laya"},"execution_nanos":{"type":"integer","example":1842000},"timestamp":{"type":"string"},"metering":{"type":"object","properties":{"event_billed":{"type":"boolean","example":true},"unit_charge_cents":{"type":"number","example":0.015}}}}},"FeedbackRequest":{"type":"object","required":["request_id","actual_outcome","feedback_type"],"properties":{"request_id":{"type":"string","example":"req_8819d-29384","description":"Correlation ID from the original POST /decide invocation"},"actual_outcome":{"oneOf":[{"type":"string"},{"type":"number"},{"type":"boolean"}],"example":"Move to Queue 2","description":"Human-in-the-loop ground truth verified outcome"},"feedback_type":{"type":"string","enum":["CORRECTION","AFFIRMATION","ESCALATION"],"example":"CORRECTION","description":"Type of review: CORRECTION (disagreement), AFFIRMATION (agreement), or ESCALATION"},"reviewer":{"type":"object","properties":{"reviewer_id":{"type":"string","example":"usr_ops_lead_42"},"reviewer_role":{"type":"string","example":"SUPERVISOR"},"notes":{"type":"string","example":"Enterprise billing discrepancy escalated to tier-2"}}},"metadata":{"type":"object","additionalProperties":true,"example":{"client_session_id":"sess_91204a"}}}},"FeedbackResponse":{"type":"object","properties":{"feedback_id":{"type":"string","example":"fb_77e02b19"},"request_id":{"type":"string","example":"req_8819d-29384"},"model_slug":{"type":"string","example":"triage-modernbert"},"predicted_outcome":{"type":"string","example":"Move to Queue 1"},"actual_outcome":{"type":"string","example":"Move to Queue 2"},"feedback_type":{"type":"string","example":"CORRECTION"},"cache_cleared":{"type":"boolean","example":true},"ingested_to_buffer":{"type":"boolean","example":true},"created_at":{"type":"string","example":"2026-11-01T12:30:01Z"}}},"ModelListResponse":{"type":"object","properties":{"object":{"type":"string","example":"list"},"data":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","example":"zirnay/anyjev-fast-router:latest"},"object":{"type":"string","example":"model"},"created":{"type":"integer","example":1729728000},"owned_by":{"type":"string","example":"zirnay"},"root":{"type":"string","example":"anyjev"},"parent":{"type":"string","nullable":true},"metadata":{"type":"object","properties":{"engine":{"type":"string","example":"anyjev"},"p99_latency_ms":{"type":"number","example":17.8},"ece":{"type":"number","example":0.019},"capabilities":{"type":"array","items":{"type":"string"},"example":["decisions","scoring"]}}}}}}}},"OpenAIDecisionRequest":{"type":"object","required":["model","input"],"properties":{"model":{"type":"string","example":"acme-corp/secops/anyjev-fast-router:v2-strict"},"input":{"type":"object","example":{"deal_id":"356401732297","customer":"Stripe","stage":"Appointment Scheduled","target_close_days":65,"crm_assertions":{"metrics":"GREEN","economic_buyer":"YELLOW","paper_process":"YELLOW"},"evidence_sources":[{"source":"gong","id":"call_14","snippet":"VP Infra engaged; legal review queued."}]}},"decision_type":{"type":"string","example":"categorical_choice"},"candidates":{"type":"array","items":{"type":"object","required":["id"],"properties":{"id":{"type":"string","example":"COMMIT_APPROVED"},"label":{"type":"string","example":"Commit to Current Quarter Forecast"}}}},"constraints":{"type":"object","properties":{"max_ece_threshold":{"type":"number","example":0.03},"min_confidence":{"type":"number","example":0.85}}},"arbitration_strategy":{"type":"string","example":"calibrated_utility"}}},"OpenAIDecisionResponse":{"type":"object","properties":{"id":{"type":"string","example":"dec-zirnay-88e2c39a"},"object":{"type":"string","example":"decision"},"created":{"type":"integer","example":1729729050},"model":{"type":"string","example":"acme-corp/secops/anyjev-fast-router:v2-strict"},"decision":{"type":"object","properties":{"selected_candidate_id":{"type":"string","example":"BEST_CASE_GATED"},"confidence":{"type":"number","example":0.942},"calibrated_probability":{"type":"number","example":0.938},"margin_over_second":{"type":"number","example":0.881}}},"candidate_scores":{"type":"array","items":{"type":"object","properties":{"candidate_id":{"type":"string","example":"BEST_CASE_GATED"},"raw_logit":{"type":"number","example":3.84},"calibrated_prob":{"type":"number","example":0.938},"utility_score":{"type":"number","example":0.912}}}},"audit_trail":{"type":"object","properties":{"reasoning_code":{"type":"string","example":"VR_GATE_ECONOMIC_BUYER_UNVALIDATED"},"explanation":{"type":"string","example":"Economic Buyer confirmed uncontacted at C-level; paper process is unstarted with procurement."},"citations":{"type":"array","items":{"type":"object","properties":{"source":{"type":"string","example":"gong"},"id":{"type":"string","example":"call_14"},"relevance":{"type":"number","example":0.96}}}}}},"telemetry":{"type":"object","properties":{"latency_ms":{"type":"number","example":17.2},"expected_calibration_error":{"type":"number","example":0.018},"permutation_rounds":{"type":"integer","example":4},"data_retention":{"type":"string","example":"DISABLED"}}}}},"DatasetFieldFormat":{"type":"object","required":["name","datatype"],"properties":{"name":{"type":"string","example":"amt"},"datatype":{"type":"string","enum":["number","float","integer","string","boolean","datetime","category"],"example":"number","description":"Tabular datatype used for streaming validation"},"role":{"type":"string","enum":["feature","target","timestamp","metadata","id"],"example":"feature","description":"Field role in model training"},"nullable":{"type":"boolean","default":false},"description":{"type":"string","example":"Transaction amount in USD"}}},"DatasetFormat":{"type":"object","required":["fields"],"properties":{"dataset_name":{"type":"string","example":"sparkov_credit_card_fraud"},"description":{"type":"string","example":"Decoupled schema definition for transaction fraud detection"},"target_field":{"type":"string","example":"is_fraud"},"fields":{"type":"array","items":{"":"#/components/schemas/DatasetFieldFormat"}}}},"DatasetValidationRejection":{"type":"object","properties":{"error":{"type":"string","example":"Dataset validation failed under strict mode (1 invalid records detected)."},"validation_mode":{"type":"string","example":"strict"},"summary":{"type":"object","properties":{"total_rows_scanned":{"type":"integer","example":1000},"valid_rows":{"type":"integer","example":999},"invalid_rows":{"type":"integer","example":1},"pass_rate_percentage":{"type":"number","example":99.9}}},"sample_errors":{"type":"array","items":{"type":"object","properties":{"line_number":{"type":"integer","example":42},"field":{"type":"string","example":"amt"},"error":{"type":"string","example":"Expected datatype 'number', received string 'USD_45.00'"},"raw_snippet":{"type":"string"}}}}}},"ModelUpdateRequest":{"type":"object","properties":{"name":{"type":"string","example":"Laya Card Fraud Guard v2"},"description":{"type":"string","example":"Production micro-latency fraud reflex engine."},"format":{"":"#/components/schemas/DatasetFormat"},"classes":{"type":"array","items":{"type":"string"},"example":["APPROVE","CHALLENGE","DECLINE"]},"p99_latency_budget_ms":{"type":"number","example":2.5},"status":{"type":"string","enum":["ACTIVE","DISABLED","ARCHIVED"],"example":"ACTIVE"},"metadata":{"type":"object"}}}}},"paths":{"/health":{"get":{"summary":"Platform Liveness & Readiness Healthcheck","description":"Returns healthy status and service version for monitoring probes, container orchestrators, and load balancers.","responses":{"200":{"description":"Service is healthy and ready to accept traffic","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","example":"healthy"},"service":{"type":"string","example":"zirnay-daas-backend"},"version":{"type":"string","example":"1.0.0"},"timestamp":{"type":"string","example":"2026-10-12T00:00:00.000Z"}}}}}}}}},"/v1/teams/{team_slug}/models/{model_slug}/decide":{"post":{"summary":"Execute Real-Time System 1 Decision","description":"Ultra-low latency decision invocation using warm in-memory model checkpoint (Laya, Strands-dc, or Custom).","security":[{"ApiKeyAuth":[]},{"BearerAuth":[]}],"parameters":[{"name":"team_slug","in":"path","required":true,"schema":{"type":"string"}},{"name":"model_slug","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DecisionRequest"}}}},"responses":{"200":{"description":"Decision evaluated successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DecisionResponse"}}}}}}},"/v1/teams/{team_slug}/models/{model_slug}/feedback":{"post":{"summary":"Submit Human-in-the-Loop (HITL) Decision Feedback","description":"Records human supervisor reviews, ground-truth corrections, or affirmations for a prior decision event. Automatically purges stale predictions from the fast-path route cache and streams records into continuous retraining datasets.","security":[{"ApiKeyAuth":[]},{"BearerAuth":[]}],"parameters":[{"name":"team_slug","in":"path","required":true,"schema":{"type":"string"}},{"name":"model_slug","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FeedbackRequest"}}}},"responses":{"201":{"description":"Feedback registered, route cache cleared, and queued for continuous learning","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FeedbackResponse"}}}},"400":{"description":"Invalid feedback payload or missing request_id"},"404":{"description":"Decision request_id or model not found"}}}},"/v1/teams/{team_slug}/models":{"get":{"summary":"List Models for Team","parameters":[{"name":"team_slug","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"List of models"}}}},"/v1/teams/{team_slug}/models/{model_slug}/checkpoints":{"get":{"summary":"List Model Checkpoints","parameters":[{"name":"team_slug","in":"path","required":true,"schema":{"type":"string"}},{"name":"model_slug","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"List of checkpoints"}}}},"/v1/teams/{team_slug}/models/{model_slug}/checkpoints/{checkpoint_id}/activate":{"post":{"summary":"Promote / Activate Checkpoint in Production (Zero-Downtime Hot Swap)","parameters":[{"name":"team_slug","in":"path","required":true,"schema":{"type":"string"}},{"name":"model_slug","in":"path","required":true,"schema":{"type":"string"}},{"name":"checkpoint_id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Checkpoint successfully activated in production with zero downtime via POSIX mmap"}}}},"/v1/teams/{team_slug}/models/{model_slug}/datasets/upload":{"post":{"summary":"Upload Training Dataset to Isolated Workspace","description":"Uploads training dataset (JSONL / NDJSON) via authenticated Control Plane API without exposing cloud storage buckets. Returns an immutable dataset_id.","parameters":[{"name":"team_slug","in":"path","required":true,"schema":{"type":"string"}},{"name":"model_slug","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"multipart/form-data":{"schema":{"type":"object","required":["file","format"],"properties":{"file":{"type":"string","format":"binary","description":"Clean JSONL data stream without embedded metadata envelopes"},"format":{"":"#/components/schemas/DatasetFormat"},"validation":{"type":"string","enum":["strict","lenient"],"default":"strict","description":"Ingestion validation mode: strict rejects corrupt rows; lenient quarantines"},"max_rejections":{"type":"integer","default":5000}}}},"application/x-ndjson":{"schema":{"type":"string"}},"application/json":{"schema":{"type":"object","required":["data"],"properties":{"filename":{"type":"string","example":"transactions-train.jsonl"},"data":{"type":"string","description":"Clean newline-delimited JSON rows (JSONL)"},"format":{"":"#/components/schemas/DatasetFormat"},"validation":{"type":"string","enum":["strict","lenient"],"default":"strict"},"max_rejections":{"type":"integer","default":5000}}}}}},"responses":{"201":{"description":"Dataset uploaded and verified successfully","content":{"application/json":{"schema":{"type":"object","properties":{"dataset_id":{"type":"string","example":"ds_9a12c84e"},"filename":{"type":"string","example":"fraud-train-v1.jsonl"},"status":{"type":"string","example":"READY"},"record_count":{"type":"integer","example":35000},"size_bytes":{"type":"integer","example":1048576},"sha256":{"type":"string","example":"4b227777d4dd1fc61c6f884f48641d02b4d121d3fd328cb08b5531fcacdabf8a"}}}}}},"400":{"description":"Validation failure under strict mode","content":{"application/json":{"schema":{"":"#/components/schemas/DatasetValidationRejection"}}}}}}},"/v1/teams/{team_slug}/datasets":{"get":{"summary":"List Team Training Datasets","description":"Returns all datasets uploaded to the tenant team workspace.","parameters":[{"name":"team_slug","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"List of datasets"}}}},"/v1/teams/{team_slug}/models/{model_slug}/train":{"post":{"summary":"Trigger Asynchronous Model Training","description":"Triggers training using an uploaded dataset_id and hyperparameter configuration.","parameters":[{"name":"team_slug","in":"path","required":true,"schema":{"type":"string"}},{"name":"model_slug","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"dataset_id":{"type":"string","example":"ds_9a12c84e"},"hyperparameters":{"type":"object","properties":{"epochs":{"type":"integer","example":12},"learning_rate":{"type":"number","example":0.0005},"batch_size":{"type":"integer","example":128}}}}}}}},"responses":{"200":{"description":"Training job started"}}}},"/v1/orgs/{org_slug}/billing/usage":{"get":{"summary":"Get Org Stripe Usage Stats","parameters":[{"name":"org_slug","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Usage stats"}}}},"/v1/auth/register":{"post":{"summary":"Register New Account & Organization","description":"Registers a new user, hashes password with scrypt, provisions organization and team workspace, and returns JWT session token.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["email","password","name"],"properties":{"email":{"type":"string","example":"engineer@acme.com"},"password":{"type":"string","example":"Password123!"},"name":{"type":"string","example":"Sarah Chen"},"org_name":{"type":"string","example":"Acme Financial Services"}}}}}},"responses":{"201":{"description":"User created and authenticated"},"400":{"description":"Validation error"},"409":{"description":"Account already exists"}}}},"/v1/auth/login":{"post":{"summary":"Sign In with Email & Password","description":"Authenticates user credentials against scrypt hash and returns JWT session token.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["email","password"],"properties":{"email":{"type":"string","example":"engineer@acme.com"},"password":{"type":"string","example":"Password123!"}}}}}},"responses":{"200":{"description":"Authenticated successfully with JWT token"},"401":{"description":"Invalid email or password"}}}},"/v1/auth/forgot-password":{"post":{"summary":"Request Password Reset Link","description":"Generates cryptographically random reset token, stores hash in database, and dispatches reset email.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["email"],"properties":{"email":{"type":"string","example":"engineer@acme.com"}}}}}},"responses":{"200":{"description":"Reset email dispatched (anti-enumeration protected)"}}}},"/v1/auth/verify-reset-token":{"get":{"summary":"Verify Password Reset Token","parameters":[{"name":"token","in":"query","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Token is valid and active"},"400":{"description":"Token is invalid or expired"}}}},"/v1/auth/reset-password":{"post":{"summary":"Update Password Using Reset Token","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["token","new_password"],"properties":{"token":{"type":"string"},"new_password":{"type":"string","example":"NewStrongPassword456!"}}}}}},"responses":{"200":{"description":"Password updated successfully"},"400":{"description":"Invalid or expired token"}}}},"/v1/auth/emails/preview":{"get":{"summary":"List Dispatched Transactional Emails (Dev & Sandbox)","responses":{"200":{"description":"Recent email logs and previews"}}}},"/v1/auth/me":{"get":{"summary":"Get Authenticated User Profile","security":[{"BearerAuth":[]}],"responses":{"200":{"description":"Current user context"}}}},"/v1/auth/sso/login":{"post":{"summary":"Simulate SSO Authentication","responses":{"200":{"description":"JWT session token"}}}},"/v1/models":{"get":{"summary":"Dynamic RBAC-Scoped Instance Discovery (OpenAI Compatible)","description":"Lists public baseline models and dynamically provisioned tenant instances accessible to the authenticated token.","security":[{"ApiKeyAuth":[]},{"BearerAuth":[]}],"parameters":[{"name":"X-Fireworks-Account-ID","in":"header","required":false,"schema":{"type":"string"},"description":"Fireworks Aggregator multi-tenant account identifier"}],"responses":{"200":{"description":"List of accessible model instances","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ModelListResponse"}}}}}}},"/v1/decisions":{"post":{"summary":"OpenAI Decisions & Calibrated Arbitration API","description":"Deterministic decision engine returning calibrated probabilities, multi-candidate arbitration, audit trails, and sub-25ms telemetry without autoregressive token overhead.","security":[{"ApiKeyAuth":[]},{"BearerAuth":[]}],"parameters":[{"name":"X-Fireworks-Account-ID","in":"header","required":false,"schema":{"type":"string"},"description":"Fireworks Aggregator multi-tenant account identifier"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/OpenAIDecisionRequest"}}}},"responses":{"200":{"description":"Calibrated decision result with audit reasoning and telemetry","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OpenAIDecisionResponse"}}}},"404":{"description":"Model not found or cross-tenant access rejected (zero information leak)"}}}},"/v1/systemone":{"post":{"summary":"Fireworks AI SystemOne Decision Endpoint","description":"Fireworks AI SystemOne compatible endpoint (POST /inference/v1/systemone / /v1/systemone) with hierarchical slug routing and JIT dynamic instance provisioning.","security":[{"ApiKeyAuth":[]},{"BearerAuth":[]}],"parameters":[{"name":"X-Fireworks-Account-ID","in":"header","required":false,"schema":{"type":"string"},"description":"Fireworks Aggregator multi-tenant account identifier"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/OpenAIDecisionRequest"}}}},"responses":{"200":{"description":"Calibrated decision result with audit reasoning and telemetry","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OpenAIDecisionResponse"}}}},"404":{"description":"Model not found or cross-tenant access rejected (zero information leak)"}}}},"/inference/v1/systemone":{"post":{"summary":"Fireworks AI SystemOne Decision Endpoint","description":"Fireworks AI SystemOne compatible endpoint (POST /inference/v1/systemone / /v1/systemone) with hierarchical slug routing and JIT dynamic instance provisioning.","security":[{"ApiKeyAuth":[]},{"BearerAuth":[]}],"parameters":[{"name":"X-Fireworks-Account-ID","in":"header","required":false,"schema":{"type":"string"},"description":"Fireworks Aggregator multi-tenant account identifier"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/OpenAIDecisionRequest"}}}},"responses":{"200":{"description":"Calibrated decision result with audit reasoning and telemetry","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OpenAIDecisionResponse"}}}},"404":{"description":"Model not found or cross-tenant access rejected (zero information leak)"}}}},"/v1/teams/{team_slug}/models/{model_slug}":{"get":{"summary":"Retrieve Model Details & Active Checkpoint","description":"Returns model configuration, active checkpoint metadata, and registered dataset schema format.","parameters":[{"name":"team_slug","in":"path","required":true,"schema":{"type":"string"}},{"name":"model_slug","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Model details, registered format, and active checkpoint"},"404":{"description":"Model not found"}}},"patch":{"summary":"Update Model Configuration & Registered Data Format","description":"Updates model configuration, including registering or updating its default dataset schema format, classes, and latency budget.","parameters":[{"name":"team_slug","in":"path","required":true,"schema":{"type":"string"}},{"name":"model_slug","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"":"#/components/schemas/ModelUpdateRequest"}}}},"responses":{"200":{"description":"Model updated successfully with registered data format"},"400":{"description":"Invalid update payload"},"404":{"description":"Model not found"}}},"put":{"summary":"Update Model Configuration & Registered Data Format","description":"Updates model configuration, including registering or updating its default dataset schema format, classes, and latency budget.","parameters":[{"name":"team_slug","in":"path","required":true,"schema":{"type":"string"}},{"name":"model_slug","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"":"#/components/schemas/ModelUpdateRequest"}}}},"responses":{"200":{"description":"Model updated successfully with registered data format"},"400":{"description":"Invalid update payload"},"404":{"description":"Model not found"}}}}}}