{"openapi":"3.1.0","info":{"title":"Unira API","version":"1.0.0","description":"Unira is free during the beta. No card is collected and nothing is charged. Paid plans will come later, and we'll give you at least 30 days' notice by email before any charge. Please don't upload sensitive data.\nPublic v1 contract for organization accounts, keys, usage, webhook settings,\ndatasets, versioned rulesets and asynchronous reconciliation jobs.\nBearer API key in the Authorization header.\nSend Authorization: Bearer <your API key>. Actual keys use rc_dev_ or rc_live_ prefixes;\nunira_test_xxx is a non-working documentation placeholder, never a real credential.\nReads are organization-scoped, not filtered by key environment.\nDuring the free beta, development and production keys need no card or subscription\nand share one free record allowance. Jobs accepted during beta are permanently\nunbilled, including when they finish after billing is enabled. When billing is on,\nnew production jobs require an active subscription; only new paid production usage meters.\nJSON request bodies are limited to 2 MiB. Per-IP and per-organization request limits apply.\nOwner-only operations require the owner's verified browser console session instead of an API key.\nBrowser session mutations require a trusted Origin header. OAuth access tokens are not REST owner sessions.\n"},"servers":[{"url":"https://unira.dev"}],"security":[{"bearerAuth":[]},{"ownerSession":[]},{"ownerSessionDev":[]}],"tags":[{"name":"Datasets","description":"Upload and inspect dataset metadata."},{"name":"Rulesets","description":"Create rulesets and append immutable versions."},{"name":"Jobs","description":"Submit jobs and read their results and exports."},{"name":"Account","description":"Organization information and owner console operations."},{"name":"Keys","description":"Owner-only API-key administration."},{"name":"Usage","description":"Record usage and organization reports."},{"name":"Webhooks","description":"Owner-only customer webhook settings and delivery metadata."},{"name":"Mappings","description":"Free deterministic file mapping suggestions and validation; in-memory only","no AI or network calls.":null},{"name":"Saved reconciliations","description":"Private confirmed mappings and validated asynchronous runs."},{"name":"Presence","description":"Session-only last-seen updates without page content."}],"webhooks":{"jobEvent":{"post":{"operationId":"receiveJobEvent","tags":["Webhooks"],"summary":"Outbound customer event delivered to the configured URL","description":"Off unless CUSTOMER_WEBHOOKS_ENABLED is exactly true. Sends job.completed, job.failed,\njob.quarantined and webhook.test. There are at most four delivery attempts; non-2xx and\ntransport failures retry after 30, 120 and 600 seconds. Redirects are not followed.\nVerify Unira-Webhook-Signature with HMAC-SHA256 over timestamp + \".\" + the exact raw JSON body,\nusing the endpoint signing secret. The timestamp is Unix seconds; the signature is v1=<hex digest>.\nThe signature is computed once and reused in the deprecated compatibility header.\nAll three deprecated compatibility headers below are still sent with identical values;\nthey will not be removed earlier than six months after notice.\nThis is an outbound callback, not an additional /api/v1 endpoint.\n","security":[],"parameters":[{"name":"Unira-Webhook-Id","in":"header","required":true,"schema":{"type":"string"},"example":"wh_evt_example"},{"name":"Unira-Webhook-Timestamp","in":"header","required":true,"schema":{"type":"string","pattern":"^[0-9]+$"},"example":"1794787200"},{"name":"Unira-Webhook-Signature","in":"header","required":true,"schema":{"type":"string"},"example":"v1=signature_placeholder"},{"name":"Reconcile-Webhook-Id","in":"header","deprecated":true,"description":"Deprecated compatibility header; always identical to Unira-Webhook-Id.","schema":{"type":"string"},"example":"wh_evt_example"},{"name":"Reconcile-Webhook-Timestamp","in":"header","deprecated":true,"description":"Deprecated compatibility header; always identical to Unira-Webhook-Timestamp.","schema":{"type":"string"},"example":"1794787200"},{"name":"Reconcile-Webhook-Signature","in":"header","deprecated":true,"description":"Deprecated compatibility header; always identical to Unira-Webhook-Signature.","schema":{"type":"string"},"example":"v1=signature_placeholder"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookEvent"},"examples":{"sample":{"$ref":"#/components/examples/WebhookEvent"}}}}},"responses":{"2XX":{"description":"Receiver acknowledged the event."}}}}},"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"API key","description":"Bearer API key in the Authorization header."},"ownerSession":{"type":"apiKey","in":"cookie","name":"__Secure-better-auth.session_token","description":"Browser-managed verified owner console session on HTTPS. Not an API key or OAuth bearer token."},"ownerSessionDev":{"type":"apiKey","in":"cookie","name":"better-auth.session_token","description":"Unprefixed owner-session cookie used by HTTP development origins."}},"parameters":{"UsageEnvironment":{"name":"environment","in":"query","schema":{"type":"string","enum":["development","production"]},"description":"Select either environment for this organization. Defaults to the key's environment; console sessions default to development.","example":"development"},"Id":{"name":"id","in":"path","required":true,"schema":{"type":"string"},"description":"Organization-owned resource ID.","example":"rec_example"},"Page":{"name":"page","in":"query","schema":{"type":"integer","minimum":1,"maximum":100000,"default":1},"description":"One-based page number; page size is fixed at 50 result items.","example":1},"Classification":{"name":"classification","in":"query","schema":{"type":"string"},"description":"Optional exact classification or classification prefix. Also accepts matched\n(confirmed exact/tolerance/split), review (everything else), suggested and duplicates.\nUnknown filters return an empty page. On exceptions, filtering follows exclusion of confirmed matches.\n","example":"unmatched_a"}},"schemas":{"SavedReconciliation":{"type":"object","required":["id","org_id","created_by_user_id","name","type","label_a","label_b","mapping_a","mapping_b","header_signature_a","header_signature_b","ruleset_id","ruleset_version","version","created_at","updated_at"],"properties":{"id":{"type":"string"},"org_id":{"type":"string"},"created_by_user_id":{"type":"string"},"name":{"type":"string","minLength":1,"maxLength":60},"type":{"type":"string","const":"bank_vs_ledger"},"label_a":{"type":"string","maxLength":40},"label_b":{"type":"string","maxLength":40},"mapping_a":{"type":"object","required":["default_currency"],"description":"Confirmed ConverterMapping column and parse choices, plus the saved default currency.","properties":{"record_id":{"type":["string","null"]},"date":{"type":"string"},"amount":{"type":"string"},"reference":{"type":"string"},"currency":{"type":["string","null"]},"date_format":{"type":"string"},"amount_mode":{"type":"string","enum":["signed","debit_credit"]},"debit_column":{"type":"string"},"credit_column":{"type":"string"},"reverse_sign":{"type":"boolean"},"default_currency":{"type":"string"}}},"mapping_b":{"type":"object","required":["default_currency"],"description":"Confirmed ConverterMapping column and parse choices, plus the saved default currency.","properties":{"record_id":{"type":["string","null"]},"date":{"type":"string"},"amount":{"type":"string"},"reference":{"type":"string"},"currency":{"type":["string","null"]},"date_format":{"type":"string"},"amount_mode":{"type":"string","enum":["signed","debit_credit"]},"debit_column":{"type":"string"},"credit_column":{"type":"string"},"reverse_sign":{"type":"boolean"},"default_currency":{"type":"string"}}},"header_signature_a":{"type":"string"},"header_signature_b":{"type":"string"},"ruleset_id":{"type":"string"},"ruleset_version":{"type":"integer"},"version":{"type":"integer","minimum":1},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"},"last_run_at":{"type":["string","null"],"format":"date-time","description":"List responses include the latest run for this saved setup, independent of the recent-jobs limit."},"last_match_rate":{"type":["number","null"],"description":"Latest run matched_records divided by input_records, as a percentage rounded to one decimal; null before results."}}},"SaveReconciliationInput":{"type":"object","required":["name","sides"],"additionalProperties":false,"properties":{"name":{"type":"string","minLength":1,"maxLength":60,"description":"Trimmed; unique within the organization."},"type":{"type":"string","const":"bank_vs_ledger","default":"bank_vs_ledger"},"label_a":{"type":"string","minLength":1,"maxLength":40,"default":"Bank"},"label_b":{"type":"string","minLength":1,"maxLength":40,"default":"General Ledger"},"default_currency":{"type":"string","default":"USD"},"sides":{"type":"object","required":["a","b"],"additionalProperties":false,"description":"Bank on side a; General Ledger on side b. Both are revalidated before confirmation.","properties":{"a":{"$ref":"#/components/schemas/ConverterSideInput"},"b":{"$ref":"#/components/schemas/ConverterSideInput"}}}}},"PatchReconciliationInput":{"type":"object","required":["expected_version"],"additionalProperties":false,"properties":{"expected_version":{"type":"integer","minimum":1},"name":{"type":"string","minLength":1,"maxLength":60},"type":{"type":"string","const":"bank_vs_ledger"},"label_a":{"type":"string","minLength":1,"maxLength":40},"label_b":{"type":"string","minLength":1,"maxLength":40},"default_currency":{"type":"string","description":"Changing this requires both files."},"sides":{"type":"object","required":["a","b"],"additionalProperties":false,"description":"Bank on side a; General Ledger on side b. Both are revalidated before confirmation.","properties":{"a":{"$ref":"#/components/schemas/ConverterSideInput"},"b":{"$ref":"#/components/schemas/ConverterSideInput"}}}}},"SavedRunInput":{"type":"object","required":["sides","idempotency_key"],"additionalProperties":false,"properties":{"sides":{"type":"object","required":["a","b"],"additionalProperties":false,"description":"Bank on side a; General Ledger on side b. Both are revalidated before confirmation.","properties":{"a":{"$ref":"#/components/schemas/ConverterSideInput"},"b":{"$ref":"#/components/schemas/ConverterSideInput"}}},"default_currency":{"type":"string","default":"USD","description":"The confirmed mapping's default currency takes precedence."},"idempotency_key":{"type":"string","minLength":1,"maxLength":200}}},"ConverterMapping":{"type":"object","additionalProperties":false,"description":"Explicit user choices, using exact source column headers. Omitted fields retain the suggestion.\nrecord_id null chooses ROW-0001 style IDs; currency null chooses default_currency.\nDates with two-digit years require DD/MM/YY or MM/DD/YY; these mean 2000–2099.\nAmount signs may be reversed explicitly; choosing amount_mode confirms signed or debit/credit interpretation.\n","properties":{"record_id":{"type":["string","null"]},"date":{"type":"string"},"amount":{"type":"string"},"reference":{"type":"string"},"currency":{"type":["string","null"]},"date_format":{"type":"string","enum":["YYYY-MM-DD","DD/MM/YYYY","MM/DD/YYYY","DD/MM/YY","MM/DD/YY"]},"amount_mode":{"type":"string","enum":["signed","debit_credit"]},"debit_column":{"type":"string"},"credit_column":{"type":"string"},"reverse_sign":{"type":"boolean"}}},"ConverterSideInput":{"type":"object","required":["filename"],"additionalProperties":false,"description":"Exactly one of csv, xlsx_base64 or dataset_id. CSV or the first sheet of XLSX only.\nRole defaults to bank on side a and ledger on side b, and controls debit/credit sign.\nOutput column names always follow side a or b, independently of role. Stored datasets must belong to the\ncaller's organization and key environment. Propose and validate never store file contents.\nAt most 1000 non-empty post-header rows (including skipped rows), 100 columns, within the unchanged 2 MiB JSON body limit.\n","properties":{"role":{"type":"string","enum":["bank","ledger"]},"label":{"type":"string","maxLength":200},"filename":{"type":"string","minLength":1,"maxLength":255},"csv":{"type":"string"},"xlsx_base64":{"type":"string","contentEncoding":"base64"},"dataset_id":{"type":"string","minLength":1},"mapping":{"$ref":"#/components/schemas/ConverterMapping"}},"oneOf":[{"required":["csv"]},{"required":["xlsx_base64"]},{"required":["dataset_id"]}]},"ConverterInput":{"type":"object","required":["sides"],"additionalProperties":false,"properties":{"default_currency":{"type":"string","default":"USD","description":"Recognized ISO 4217 code."},"sides":{"type":"object","minProperties":1,"additionalProperties":false,"properties":{"a":{"$ref":"#/components/schemas/ConverterSideInput"},"b":{"$ref":"#/components/schemas/ConverterSideInput"}}}}},"ConverterIssue":{"type":"object","required":["code","message"],"properties":{"code":{"type":"string","description":"Stable blocking codes include mapping_required_field_missing, mapping_field_uncertain,\nmapping_date_format_ambiguous, mapping_unparseable_cells, mapping_duplicate_ids,\nmapping_sign_reversed_suspected. Parsing failures use mapping_header_row_not_found or mapping_unsupported_file.\n"},"message":{"type":"string"},"field":{"type":"string"},"rows":{"type":"array","items":{"type":"integer"}},"values":{"type":"array","items":{"type":"string"}}}},"ConverterField":{"type":"object","required":["column","status","score","candidates","samples"],"properties":{"column":{"type":["string","null"]},"status":{"type":"string","enum":["confident","uncertain","unavailable","saved"]},"score":{"type":"number","minimum":0,"maximum":1},"candidates":{"type":"array","maxItems":3,"items":{"type":"object","required":["column","score","valid_share"],"properties":{"column":{"type":"string"},"score":{"type":"number"},"valid_share":{"type":"number"}}}},"samples":{"type":"array","maxItems":3,"items":{"type":"object","required":["source","normalized"],"properties":{"source":{"type":"string"},"normalized":{"type":["string","null"]}}}}}},"ConverterSide":{"type":"object","required":["header_signature","header_row","sheet_name","fields","parse","validation","preview_text","normalized_preview","needs_user"],"properties":{"header_signature":{"type":"string","pattern":"^hs1:[a-f0-9]{64}$"},"header_row":{"type":"integer","minimum":1,"maximum":10},"sheet_name":{"type":["string","null"]},"fields":{"type":"object","required":["record_id","date","amount","reference","currency"],"properties":{"record_id":{"$ref":"#/components/schemas/ConverterField"},"date":{"$ref":"#/components/schemas/ConverterField"},"amount":{"$ref":"#/components/schemas/ConverterField"},"reference":{"$ref":"#/components/schemas/ConverterField"},"currency":{"$ref":"#/components/schemas/ConverterField"}}},"parse":{"type":"object","required":["date_format","date_status","amount_mode","debit_column","credit_column","reverse_sign","default_currency"],"properties":{"date_format":{"type":["string","null"]},"date_status":{"type":"string"},"amount_mode":{"type":"string","enum":["signed","debit_credit"]},"debit_column":{"type":["string","null"]},"credit_column":{"type":["string","null"]},"reverse_sign":{"type":"boolean"},"default_currency":{"type":"string"}}},"validation":{"type":"object","required":["ok","blocking","warnings","stats"],"properties":{"ok":{"type":"boolean"},"blocking":{"type":"array","items":{"$ref":"#/components/schemas/ConverterIssue"}},"warnings":{"type":"array","items":{"$ref":"#/components/schemas/ConverterIssue"}},"stats":{"type":"object","required":["data_rows","skipped_rows","parsed","total_amount","total_debits","total_credits","date_min","date_max","currencies","unparseable_count","unparseable_cells","duplicate_ids"],"properties":{"data_rows":{"type":"integer"},"skipped_rows":{"type":"integer"},"parsed":{"type":"object","additionalProperties":{"type":"integer"}},"total_amount":{"type":"string"},"total_debits":{"type":"string"},"total_credits":{"type":"string"},"date_min":{"type":["string","null"]},"date_max":{"type":["string","null"]},"currencies":{"type":"object","additionalProperties":{"type":"integer"}},"unparseable_count":{"type":"integer"},"unparseable_cells":{"type":"array","maxItems":20,"items":{"type":"object","required":["row","column","value","reason"],"properties":{"row":{"type":"integer"},"column":{"type":"string"},"value":{"type":"string"},"reason":{"type":"string"}}}},"duplicate_ids":{"type":"array","items":{"type":"string"}}}}}},"preview_text":{"type":"string"},"normalized_preview":{"type":"array","maxItems":5,"description":"Bank columns: bank_id,date,amount,reference,currency. Ledger columns: journal_id,posting_date,amount,reference,currency. Amounts are signed decimal strings.","items":{"type":"object","additionalProperties":{"type":"string"}}},"needs_user":{"type":"array","items":{"type":"string"}}}},"ConverterResponse":{"type":"object","required":["ok","sides","cross_side"],"properties":{"assist":{"type":"object","description":"Optional, off-by-default review only. Original ok, needs_user and mapping fields are unchanged. Headers and at most five redacted sample rows only; saved mappings never sent. Proposals are checked by the existing validator; applying one requires validation and explicit user confirmation.","required":["available","status","proposals"],"properties":{"available":{"type":"boolean","const":true},"status":{"type":"string","enum":["available","proposed","manual"]},"proposals":{"type":"array","maxItems":10,"items":{"type":"object","required":["side","field","mapping","validation"],"properties":{"side":{"type":"string","enum":["a","b"]},"field":{"type":"string","enum":["record_id","date","amount","reference","currency"]},"mapping":{"$ref":"#/components/schemas/ConverterMapping"},"validation":{"type":"object","required":["ok","blocking_codes"],"properties":{"ok":{"type":"boolean"},"blocking_codes":{"type":"array","items":{"type":"string"}}}}}}}}},"ok":{"type":"boolean"},"sides":{"type":"object","properties":{"a":{"$ref":"#/components/schemas/ConverterSide"},"b":{"$ref":"#/components/schemas/ConverterSide"}}},"cross_side":{"type":["object","null"],"properties":{"ok":{"type":"boolean"},"pairs":{"type":"integer"},"opposite_pairs":{"type":"integer"},"blocking":{"type":"array","items":{"type":"object","required":["code","message","reverse_sign"],"properties":{"code":{"type":"string"},"message":{"type":"string"},"reverse_sign":{"type":"boolean"}}}}}}}},"Account":{"type":"object","required":["id","name","plan","status","created_at"],"properties":{"id":{"type":"string"},"name":{"type":"string"},"plan":{"type":"string"},"status":{"type":"string"},"created_at":{"type":"string","format":"date-time"}}},"AccountInput":{"type":"object","required":["name"],"properties":{"name":{"type":"string","minLength":1,"maxLength":100}}},"Onboarding":{"type":"object","required":["key_created","job_completed","completed_job_id","results_viewed","export_downloaded"],"properties":{"key_created":{"type":"boolean","description":"A development key has been created; it may since have been revoked."},"job_completed":{"type":"boolean"},"completed_job_id":{"type":["string","null"],"description":"Newest completed job ID."},"results_viewed":{"type":"boolean","description":"Organization-wide results-view milestone exists."},"export_downloaded":{"type":"boolean","description":"Organization-wide export-download milestone exists."}}},"Overview":{"type":"object","required":["total_jobs","completed_jobs","failed_jobs","processed_records","matched_records","exception_records","recent_jobs","activity"],"properties":{"total_jobs":{"type":"integer"},"completed_jobs":{"type":"integer"},"failed_jobs":{"type":"integer"},"processed_records":{"type":"integer","description":"Input records in completed jobs."},"matched_records":{"type":"integer"},"exception_records":{"type":"integer","description":"Sum of unmatched","ambiguous and invalid summary counts; suggested counts are not added separately.":null},"recent_jobs":{"type":"array","maxItems":5,"items":{"$ref":"#/components/schemas/Job"}},"activity":{"type":"array","maxItems":8,"description":"Newest organization activity, excluding operator internal-flag changes.","items":{"type":"object","required":["id","action","created_at"],"properties":{"id":{"type":"string"},"action":{"type":"string"},"created_at":{"type":"string","format":"date-time"}}}}}},"KeyInput":{"type":"object","required":["name","environment"],"properties":{"name":{"type":"string","minLength":1,"maxLength":100},"environment":{"type":"string","enum":["development","production"]}}},"Key":{"type":"object","required":["id","name","prefix","environment","revoked_at","created_at"],"properties":{"id":{"type":"string"},"name":{"type":"string"},"prefix":{"type":"string","description":"Display prefix only; not usable as a credential."},"environment":{"type":"string","enum":["development","production"]},"revoked_at":{"type":["string","null"],"format":"date-time"},"created_at":{"type":"string","format":"date-time"}}},"CreatedKey":{"allOf":[{"$ref":"#/components/schemas/Key"},{"type":"object","required":["secret"],"properties":{"secret":{"type":"string","description":"Full key shown only in this creation response. Store it privately; listing never returns it."}}}]},"Usage":{"type":"object","required":["used","reserved","included","period_start","period_end","estimated_charge_cents","overage_records","events"],"description":"Current anchored monthly period, not calendar-month usage. No configurable spend-cap field is returned.\nestimated_charge_cents is unused during the free beta — nothing is charged.\nDuring the free beta, development and production share the Free beta allowance.\nAfter paid billing launches, production uses the organization's catalog plan.\n","properties":{"used":{"type":"integer"},"reserved":{"type":"integer","description":"Input records reserved by pending/processing jobs in this environment and period."},"included":{"type":"integer"},"period_start":{"type":"string","format":"date-time"},"period_end":{"type":["string","null"],"format":"date-time"},"estimated_charge_cents":{"type":"integer"},"overage_records":{"type":"integer"},"hint":{"type":"string","description":"Optional paid-organization hint when a development key reads development usage."},"production_key_url":{"type":"string","description":"Present with the optional development-key hint."},"events":{"type":"array","maxItems":100,"description":"Newest ledger entries in the accounting scope. Beta shares both environments; paid production excludes permanently unbilled beta history.","items":{"type":"object","required":["id","job_id","quantity","environment","created_at","report_status","reported_at","report_attempts","report_error"],"properties":{"id":{"type":"string"},"job_id":{"type":"string"},"quantity":{"type":"integer"},"environment":{"type":"string","enum":["development","production"]},"created_at":{"type":"string","format":"date-time"},"report_status":{"type":"string"},"reported_at":{"type":["string","null"],"format":"date-time"},"report_attempts":{"type":"integer"},"report_error":{"type":["string","null"]}}}}}},"DemandRow":{"type":"object","required":["use_case","data_source","environment","completed_jobs","repeat_jobs","record_volume"],"properties":{"use_case":{"type":["string","null"]},"data_source":{"type":"string"},"environment":{"type":"string","enum":["development","production"]},"completed_jobs":{"type":"integer"},"repeat_jobs":{"type":"integer","description":"Completed jobs minus one","with a floor of zero.":null},"record_volume":{"type":"integer"}}},"BillingPlan":{"type":"object","required":["id","name","monthly_cents","included_records","overage_per_thousand_cents","self_service"],"properties":{"id":{"type":"string","enum":["sandbox","starter","growth","scale","enterprise"]},"name":{"type":"string"},"monthly_cents":{"type":["integer","null"]},"included_records":{"type":["integer","null"]},"overage_per_thousand_cents":{"type":["integer","null"]},"self_service":{"type":"boolean"}}},"Billing":{"type":"object","required":["enabled","message","billing_mode","test_mode","plans","current_plan","billing_status","has_payment_method","production_enabled","has_customer"],"properties":{"enabled":{"type":"boolean"},"message":{"type":"string"},"billing_mode":{"type":["string","null"],"enum":["test","live",null]},"test_mode":{"type":"boolean"},"plans":{"type":"array","items":{"$ref":"#/components/schemas/BillingPlan"}},"current_plan":{"type":"string"},"billing_status":{"type":"string"},"has_payment_method":{"type":"boolean"},"production_enabled":{"type":"boolean"},"has_customer":{"type":"boolean"}}},"WebhookSettings":{"type":"object","required":["enabled","url","secret_hint"],"properties":{"enabled":{"type":"boolean","description":"True only when CUSTOMER_WEBHOOKS_ENABLED is exactly true."},"url":{"type":["string","null"]},"secret_hint":{"type":["string","null"]}}},"WebhookInput":{"type":"object","required":["url"],"properties":{"url":{"type":"string","minLength":1,"maxLength":2048,"description":"Public HTTPS URL on port 443, without credentials or a fragment. Private/internal and unresolvable hosts are rejected."}}},"WebhookSecret":{"type":"object","required":["url","secret_hint","secret"],"properties":{"url":{"type":"string"},"secret_hint":{"type":"string"},"secret":{"type":"string","description":"Signing secret shown only on setup/replacement or rotation. Keep it private."}}},"WebhookDelivery":{"type":"object","required":["id","event_type","job_id","status","attempts","last_http_status","last_error","created_at","last_attempt_at","next_attempt_at","delivered_at"],"properties":{"id":{"type":"string"},"event_type":{"type":"string","enum":["job.completed","job.failed","job.quarantined","webhook.test"]},"job_id":{"type":["string","null"]},"status":{"type":"string","enum":["pending","processing","retry","delivered","failed","canceled"]},"attempts":{"type":"integer"},"last_http_status":{"type":["integer","null"]},"last_error":{"type":["string","null"]},"created_at":{"type":"string","format":"date-time"},"last_attempt_at":{"type":["string","null"],"format":"date-time"},"next_attempt_at":{"type":["string","null"],"format":"date-time"},"delivered_at":{"type":["string","null"],"format":"date-time"}}},"WebhookEvent":{"type":"object","required":["id","type","created_at","data"],"description":"Job metadata only; dataset contents and result rows are not sent.","properties":{"id":{"type":"string"},"type":{"type":"string","enum":["job.completed","job.failed","job.quarantined","webhook.test"]},"created_at":{"type":"string","format":"date-time"},"data":{"type":"object","required":["job_id","status","environment","input_records","matched_records","matched_groups","exception_records","error"],"properties":{"job_id":{"type":["string","null"]},"status":{"type":"string","enum":["completed","failed","quarantined","test"]},"environment":{"type":"string","enum":["development","production"]},"input_records":{"type":"integer"},"matched_records":{"type":["integer","null"]},"matched_groups":{"type":["integer","null"]},"exception_records":{"type":["integer","null"]},"error":{"type":["string","null"]}}}}},"Error":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"properties":{"code":{"type":"string"},"message":{"type":"string"},"fields":{"type":"array","description":"Present on request-schema validation errors.","items":{"type":"object","required":["path","message"],"properties":{"path":{"type":"string","description":"Dot-separated field path."},"message":{"type":"string"}}}},"upgrade_url":{"type":"string"},"remaining_records":{"type":"integer"},"requested_records":{"type":"integer"},"renews_on":{"type":"string","format":"date"}},"additionalProperties":true}}},"Scalar":{"type":["string","number","boolean","null"]},"Record":{"type":"object","maxProperties":100,"additionalProperties":{"$ref":"#/components/schemas/Scalar"}},"DatasetInput":{"type":"object","required":["name","id_field"],"description":"Supply records or nonempty CSV text with a header and consistent columns.\nA nonempty csv together with records is rejected. Empty csv alongside records is ignored.\nEach record must have a nonempty string/number identifier at id_field, unique after string conversion.\nCSV parsing skips blank lines and supports a BOM; each CSV record is capped at 100000 characters.\nThe upload contains 1–1000 records; each record has at most 100 scalar fields.\nOptional body idempotency_key is scoped by organization and key environment.\nAn identical validated body (excluding the key) returns the original metadata with 201.\nDifferent content under that key returns 409 idempotency_conflict. Without a key, each call creates a dataset.\n","properties":{"name":{"type":"string","minLength":1,"maxLength":100},"id_field":{"type":"string","minLength":1,"maxLength":100},"records":{"type":"array","minItems":1,"maxItems":1000,"items":{"$ref":"#/components/schemas/Record"}},"csv":{"type":"string","maxLength":2000000},"idempotency_key":{"type":"string","minLength":1,"maxLength":200}},"oneOf":[{"required":["records"],"properties":{"csv":{"const":""}}},{"required":["csv"],"properties":{"csv":{"minLength":1}},"not":{"required":["records"]}}]},"Dataset":{"type":"object","required":["id","name","id_field","record_count","fields","created_at"],"properties":{"id":{"type":"string"},"name":{"type":"string"},"id_field":{"type":"string"},"record_count":{"type":"integer","minimum":1,"maximum":1000},"fields":{"type":"array","description":"Sorted union of record field names; not the uploaded records.","items":{"type":"string"}},"created_at":{"type":"string","format":"date-time"}}},"Condition":{"type":"object","required":["field_a","field_b","operator"],"description":"Amount/date tolerances must be nonnegative decimals; date tolerances are integer days from 0 through 365.\nAmount rules require an exact currency-field condition.\nReference-like exact fields normalize case, whitespace and punctuation; empty normalized references do not match.\nOther exact fields use trim/ignore_case. Amounts accept supported accounting/currency notation.\n","properties":{"field_a":{"type":"string","minLength":1},"field_b":{"type":"string","minLength":1},"operator":{"type":"string","enum":["exact","amount","date"]},"tolerance":{"type":"string","default":"0"},"ignore_case":{"type":"boolean","default":false},"trim":{"type":"boolean","default":true},"nulls_equal":{"type":"boolean","default":false}}},"Rule":{"type":"object","required":["id","name","priority","conditions"],"properties":{"id":{"type":"string","minLength":1,"description":"Unique within the rules array."},"name":{"type":"string","minLength":1},"priority":{"type":"integer","minimum":0},"conditions":{"type":"array","minItems":1,"maxItems":10,"items":{"$ref":"#/components/schemas/Condition"}}}},"RulesetInput":{"type":"object","required":["name","rules"],"description":"Explicit rules only; this REST input does not accept a preset name.","properties":{"name":{"type":"string","minLength":1,"maxLength":100},"rules":{"type":"array","minItems":1,"maxItems":10,"items":{"$ref":"#/components/schemas/Rule"}}}},"Ruleset":{"allOf":[{"$ref":"#/components/schemas/RulesetInput"},{"type":"object","required":["id","version","created_at"],"properties":{"id":{"type":"string"},"version":{"type":"integer","minimum":1},"created_at":{"type":"string","format":"date-time"}}}]},"JobInput":{"type":"object","required":["name","dataset_a_id","dataset_b_id","ruleset_id","ruleset_version","idempotency_key","use_case"],"description":"Dataset IDs must be distinct and owned by the authenticated organization.\nThe requested ruleset ID and version must exist in that organization.\nidempotency_key is a required body field, not a request header.\nSame organization/key/environment and identical validated body returns the original job with 202.\nDifferent input returns 409 idempotency_conflict. The same key in the other environment returns\n409 idempotency_key_environment_conflict, never the other job.\nJobs accepted during beta remain permanently unbilled and never meter later.\nBoth environments share the beta allowance and queued reservations while billing is off.\nProduction authorization is checked before enqueueing. Development quota is reserved for both input datasets.\n","properties":{"name":{"type":"string","minLength":1,"maxLength":100},"dataset_a_id":{"type":"string"},"dataset_b_id":{"type":"string"},"ruleset_id":{"type":"string"},"ruleset_version":{"type":"integer","minimum":1},"idempotency_key":{"type":"string","minLength":1,"maxLength":200},"use_case":{"type":"string","enum":["bank_vs_ledger","invoice_vs_payment","payout_settlement","other"]}}},"Summary":{"type":"object","description":"Counts, not monetary totals. Suggested groups are excluded from confirmed matched counts.","properties":{"input_records":{"type":"integer"},"matched_groups":{"type":"integer"},"matched_records":{"type":"integer"},"suggested_groups":{"type":"integer"},"suggested_records":{"type":"integer"},"exact_matches":{"type":"integer"},"tolerance_matches":{"type":"integer"},"unmatched_records":{"type":"integer"},"ambiguous_records":{"type":"integer"},"invalid_records":{"type":"integer"},"billable_records":{"type":"integer","description":"All input records for a completed job."},"missing_books":{"type":"integer","description":"A-only records (unmatched_a)."},"missing_bank":{"type":"integer","description":"B-only records (unmatched_b)."},"review_records":{"type":"integer"},"possible_duplicate_records":{"type":"integer","description":"Number of result items flagged possible_duplicate."}}},"Job":{"type":"object","required":["id","name","status","dataset_a_id","dataset_b_id","ruleset_id","ruleset_version","input_records","engine_version","environment","created_at","attempts","data_source","example"],"description":"Job metadata; stored input key, request hash, rule snapshot and result rows are not included.\nsummary is omitted until present; suggested_records/groups default to zero in an existing summary.\nThere is no top-level records_billed field. See summary.billable_records on completed jobs.\n","properties":{"id":{"type":"string"},"name":{"type":"string"},"status":{"type":"string","description":"Worker states: pending, processing, completed, failed, quarantined."},"dataset_a_id":{"type":"string"},"dataset_b_id":{"type":"string"},"ruleset_id":{"type":"string"},"ruleset_version":{"type":"integer"},"input_records":{"type":"integer"},"engine_version":{"type":"string"},"environment":{"type":"string","enum":["development","production"]},"created_at":{"type":"string","format":"date-time"},"completed_at":{"type":["string","null"],"format":"date-time"},"attempts":{"type":"integer"},"last_error":{"type":["string","null"]},"error":{"type":["string","null"]},"processing_time_ms":{"type":["integer","null"]},"use_case":{"type":["string","null"]},"data_source":{"type":"string"},"example":{"type":["string","null"],"description":"bank-books for the recognized official rules; otherwise null."},"saved_reconciliation_id":{"type":["string","null"]},"mapping_snapshot":{"type":["object","null"]},"summary":{"$ref":"#/components/schemas/Summary"}}},"Result":{"type":"object","required":["id","classification","a_ids","b_ids","rule_id","rule_version","explanation","values_a","values_b","candidates","match_status","confidence"],"description":"match_status/confidence default to confirmed/high for older stored results, including unmatched/invalid rows.\nUse classification as well as match_status to identify an actual match.\nSplit groups can be confirmed or suggested; suggested groups have low confidence and require review.\n","properties":{"id":{"type":"string"},"classification":{"type":"string","enum":["exact_match","tolerance_match","split_match","ambiguous_match","unmatched_a","unmatched_b","invalid_record"]},"a_ids":{"type":"array","items":{"type":"string"}},"b_ids":{"type":"array","items":{"type":"string"}},"rule_id":{"type":["string","null"]},"rule_version":{"type":"integer"},"explanation":{"type":"string"},"values_a":{"type":"array","items":{"$ref":"#/components/schemas/Record"}},"values_b":{"type":"array","items":{"$ref":"#/components/schemas/Record"}},"candidates":{"type":"array","items":{"type":"string"},"description":"Opposite-side candidate record IDs."},"possible_duplicate":{"type":"boolean"},"match_status":{"type":"string","enum":["confirmed","suggested"]},"confidence":{"type":"string","enum":["high","low"]}}},"ResultPage":{"type":"object","required":["items","total","page","page_size"],"properties":{"items":{"type":"array","maxItems":50,"items":{"$ref":"#/components/schemas/Result"}},"total":{"type":"integer","description":"Number of result items after filters","not number of input records.":null},"page":{"type":"integer"},"page_size":{"const":50}}},"JobExport":{"allOf":[{"$ref":"#/components/schemas/Job"},{"type":"object","required":["rules_snapshot","results"],"properties":{"rules_snapshot":{"type":"array","items":{"$ref":"#/components/schemas/Rule"}},"results":{"type":"array","items":{"$ref":"#/components/schemas/Result"}}}}]}},"examples":{"SavedReconciliation":{"value":{"id":"saved_example","org_id":"org_example","created_by_user_id":"user_example","name":"Monthly bank and ledger","type":"bank_vs_ledger","label_a":"Bank","label_b":"General Ledger","mapping_a":{"record_id":"id","date":"date","amount":"amount","reference":"reference","currency":"currency","date_format":"YYYY-MM-DD","amount_mode":"signed","reverse_sign":false,"default_currency":"USD"},"mapping_b":{"record_id":"journal_id","date":"posting_date","amount":"amount","reference":"reference","currency":"currency","date_format":"YYYY-MM-DD","amount_mode":"signed","reverse_sign":false,"default_currency":"USD"},"header_signature_a":"hs1:example_a","header_signature_b":"hs1:example_b","ruleset_id":"rules_example","ruleset_version":1,"version":1,"created_at":"2026-11-19T12:00:00Z","updated_at":"2026-11-19T12:00:00Z"}},"SaveReconciliation":{"value":{"name":"Monthly bank and ledger","sides":{"a":{"filename":"bank.csv","csv":"id,date,amount,reference,currency\nA1,2026-10-01,10,REF1,USD\n"},"b":{"filename":"ledger.csv","csv":"journal_id,posting_date,amount,reference,currency\nB1,2026-10-01,10,REF1,USD\n"}}}},"Account":{"value":{"id":"org_example","name":"Example organization","plan":"Sandbox","status":"active","created_at":"2026-11-16T00:00:00.000Z"}},"KeyInput":{"value":{"name":"Example development key","environment":"development"}},"KeyList":{"value":[{"id":"key_example","name":"Example development key","prefix":"unira_test_xxx","environment":"development","revoked_at":null,"created_at":"2026-11-16T00:00:00.000Z"}]},"CreatedKey":{"value":{"id":"key_example","name":"Example development key","prefix":"unira_test_xxx","environment":"development","revoked_at":null,"created_at":"2026-11-16T00:00:00.000Z","secret":"unira_test_xxx"}},"Usage":{"value":{"used":0,"reserved":0,"included":2000,"period_start":"2026-11-16T00:00:00.000Z","period_end":"2026-12-16T00:00:00.000Z","estimated_charge_cents":0,"overage_records":0,"events":[]}},"Billing":{"value":{"enabled":false,"message":"Unira is free during the beta. No card is collected and nothing is charged.","billing_mode":null,"test_mode":true,"plans":[{"id":"sandbox","name":"Sandbox","monthly_cents":0,"included_records":2000,"overage_per_thousand_cents":0,"self_service":false}],"current_plan":"Sandbox","billing_status":"unsubscribed","has_payment_method":false,"production_enabled":true,"has_customer":false}},"WebhookSecret":{"value":{"url":"https://example.com/hooks/unira","secret_hint":"rcwh_••••xxxx","secret":"unira_test_xxx"}},"WebhookEvent":{"value":{"id":"wh_evt_example","type":"job.completed","created_at":"2026-11-16T00:00:00.000Z","data":{"job_id":"rec_example","status":"completed","environment":"development","input_records":2,"matched_records":2,"matched_groups":1,"exception_records":0,"error":null}}},"DatasetInput":{"value":{"name":"Books","id_field":"id","records":[{"id":"a1","reference":"INV-1"}],"idempotency_key":"dataset-example-1"}},"Dataset":{"value":{"id":"ds_example","name":"Books","id_field":"id","record_count":1,"fields":["id","reference"],"created_at":"2026-11-16T00:00:00.000Z"}},"DatasetList":{"value":[{"id":"ds_example","name":"Books","id_field":"id","record_count":1,"fields":["id","reference"],"created_at":"2026-11-16T00:00:00.000Z"}]},"RulesetInput":{"value":{"name":"Exact reference","rules":[{"id":"reference-exact","name":"Exact reference","priority":0,"conditions":[{"field_a":"reference","field_b":"reference","operator":"exact"}]}]}},"Ruleset":{"value":{"id":"rules_example","name":"Exact reference","version":1,"created_at":"2026-11-16T00:00:00.000Z","rules":[{"id":"reference-exact","name":"Exact reference","priority":0,"conditions":[{"field_a":"reference","field_b":"reference","operator":"exact","tolerance":"0","ignore_case":false,"trim":true,"nulls_equal":false}]}]}},"RulesetList":{"value":[]},"RulesetVersion":{"value":{"id":"rules_example","name":"Exact reference","version":2,"created_at":"2026-11-16T00:00:00.000Z","rules":[{"id":"reference-exact","name":"Exact reference","priority":0,"conditions":[{"field_a":"reference","field_b":"reference","operator":"exact","tolerance":"0","ignore_case":false,"trim":true,"nulls_equal":false}]}]}},"JobInput":{"value":{"name":"Monthly comparison","dataset_a_id":"ds_example_a","dataset_b_id":"ds_example_b","ruleset_id":"rules_example","ruleset_version":1,"idempotency_key":"job-example-1","use_case":"bank_vs_ledger"}},"Job":{"value":{"id":"rec_example","name":"Monthly comparison","status":"pending","dataset_a_id":"ds_example_a","dataset_b_id":"ds_example_b","ruleset_id":"rules_example","ruleset_version":1,"input_records":2,"engine_version":"1.2.2","environment":"development","attempts":0,"last_error":null,"error":null,"processing_time_ms":null,"completed_at":null,"created_at":"2026-11-16T00:00:00.000Z","use_case":"bank_vs_ledger","data_source":"customer_data","example":null}},"JobList":{"value":[]},"ResultPage":{"value":{"items":[{"id":"result_1","classification":"unmatched_a","a_ids":["a1"],"b_ids":[],"rule_id":null,"rule_version":1,"explanation":"No rule found an eligible counterpart in Dataset B","values_a":[{"id":"a1","reference":"INV-1"}],"values_b":[],"candidates":[],"possible_duplicate":false,"match_status":"confirmed","confidence":"high"}],"total":1,"page":1,"page_size":50}},"JobExport":{"value":{"id":"rec_example","name":"Monthly comparison","status":"completed","dataset_a_id":"ds_example_a","dataset_b_id":"ds_example_b","ruleset_id":"rules_example","ruleset_version":1,"input_records":2,"engine_version":"1.2.2","environment":"development","attempts":1,"last_error":null,"error":null,"processing_time_ms":1,"created_at":"2026-11-16T00:00:00.000Z","completed_at":"2026-11-16T00:00:01.000Z","use_case":"bank_vs_ledger","data_source":"customer_data","example":null,"summary":{"input_records":2,"matched_groups":1,"matched_records":2,"suggested_groups":0,"suggested_records":0,"exact_matches":1,"tolerance_matches":0,"unmatched_records":0,"ambiguous_records":0,"invalid_records":0,"billable_records":2,"missing_books":0,"missing_bank":0,"review_records":0,"possible_duplicate_records":0},"rules_snapshot":[{"id":"reference-exact","name":"Exact reference","priority":0,"conditions":[{"field_a":"reference","field_b":"reference","operator":"exact","tolerance":"0","ignore_case":false,"trim":true,"nulls_equal":false}]}],"results":[{"id":"result_1","classification":"exact_match","a_ids":["a1"],"b_ids":["b1"],"rule_id":"reference-exact","rule_version":1,"explanation":"reference equals reference","values_a":[{"id":"a1","reference":"INV-1"}],"values_b":[{"id":"b1","reference":"INV-1"}],"candidates":[],"possible_duplicate":false,"match_status":"confirmed","confidence":"high"}]}},"Error":{"value":{"error":{"code":"invalid_key","message":"Invalid bearer API key"}}}},"responses":{"BadRequest":{"description":"Invalid input or missing required files.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":{"code":"validation_error","message":"Invalid request fields"}}}}},"Quota":{"description":"Monthly allowance exhausted; no new datasets or job committed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":{"code":"quota_exceeded","message":"Monthly allowance exhausted."}}}}},"Account":{"description":"Organization information; no owner identity or private billing identifiers.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Account"},"examples":{"sample":{"$ref":"#/components/examples/Account"}}}}},"Usage":{"description":"Current-period usage and newest 100 ledger events. During beta both environments share the free allowance; with billing on, production counters exclude permanently unbilled beta history.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Usage"},"examples":{"sample":{"$ref":"#/components/examples/Usage"}}}}},"WebhookSecret":{"description":"Configuration and newly generated signing secret, shown once.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookSecret"},"examples":{"sample":{"$ref":"#/components/examples/WebhookSecret"}}}}},"WebhookForbidden":{"description":"Owner session required; setup/rotation/test also refuse when CUSTOMER_WEBHOOKS_ENABLED is not exactly true.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":{"code":"customer_webhooks_disabled","message":"Customer webhooks are turned off for now."}}}}},"OwnerRequired":{"description":"Owner console session required; API keys and OAuth access tokens do not grant owner administration.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":{"code":"owner_required","message":"Use the organization owner's console session"}}}}},"BillingUnavailable":{"description":"Billing setup unavailable; code may be webhook_setup_required, billing_origin_invalid or setup_required.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":{"code":"setup_required","message":"Test billing portal setup is incomplete."}}}}},"Invalid":{"description":"Invalid JSON, request fields, CSV, identifiers, rules or page. The error code identifies the failure.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":{"code":"validation_error","message":"Invalid request fields","fields":[{"path":"name","message":"Required"}]}}}}},"Unauthorized":{"description":"Missing, malformed, invalid or revoked API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"examples":{"sample":{"$ref":"#/components/examples/Error"}}}}},"Forbidden":{"description":"Inactive organization, or, when billing is on, production job creation without an active subscription/payment method/current period.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":{"code":"account_inactive","message":"Organization is inactive"}}}}},"NotFound":{"description":"Resource or requested ruleset version is absent from this organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":{"code":"not_found","message":"Dataset not found"}}}}},"Conflict":{"description":"idempotency_conflict, idempotency_key_environment_conflict, or not_completed, depending on the operation.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":{"code":"idempotency_conflict","message":"This idempotency key was used with different input"}}}}},"TooLarge":{"description":"JSON body exceeds the 2 MiB limit.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":{"code":"invalid_body","message":"Request must be valid JSON of at most 2 MB"}}}}},"RateLimited":{"description":"300 requests/minute per IP or 120 requests/minute per organization. The IP limiter returns text; the organization limiter returns JSON.","headers":{"RateLimit":{"schema":{"type":"string"}},"RateLimit-Policy":{"schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":{"code":"rate_limited","message":"Maximum 120 requests per minute per organization"}}},"text/html":{"schema":{"type":"string"},"example":"Too many requests, please try again later."}}},"Internal":{"description":"Unexpected server failure.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":{"code":"internal_error","message":"Request could not be completed"}}}}}}},"paths":{"/api/v1/saved-reconciliations":{"get":{"operationId":"listSavedReconciliations","tags":["Saved reconciliations"],"summary":"List your confirmed saved reconciliations","description":"Private to the authenticated user and organization; API keys use their organization owner. Ordered by creation time and ID; no pagination.","responses":{"200":{"description":"Confirmed mappings.","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/SavedReconciliation"}},"example":[]}}},"401":{"$ref":"#/components/responses/Unauthorized"}}},"post":{"operationId":"createSavedReconciliation","tags":["Saved reconciliations"],"summary":"Revalidate files and confirm a saved reconciliation","description":"Both files must validate. Saves mappings only, reusing an identical organization bank-books preset. No datasets, jobs or usage events are created. Names are trimmed and unique per organization.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SaveReconciliationInput"},"examples":{"sample":{"$ref":"#/components/examples/SaveReconciliation"}}}}},"responses":{"201":{"description":"Confirmed mapping.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SavedReconciliation"},"examples":{"sample":{"$ref":"#/components/examples/SavedReconciliation"}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"409":{"description":"Name conflict.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":{"code":"name_conflict","message":"A saved reconciliation already uses that name."}}}}},"422":{"description":"Mapping blocked; same mapping validation codes, with the complete validation response in error.validation. No dataset, job or usage event is created.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":{"code":"mapping_date_format_ambiguous","message":"Resolve the mapping validation before continuing."}}}}}}}},"/api/v1/saved-reconciliations/{id}":{"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string"},"example":"saved_example"}],"get":{"operationId":"getSavedReconciliation","tags":["Saved reconciliations"],"summary":"Get a confirmed saved reconciliation","responses":{"200":{"description":"Confirmed mapping.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SavedReconciliation"},"examples":{"sample":{"$ref":"#/components/examples/SavedReconciliation"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"}}},"patch":{"operationId":"updateSavedReconciliation","tags":["Saved reconciliations"],"summary":"Update a saved reconciliation with an expected version","description":"Supply both files to reconfirm edited mappings. Metadata-only edits need no files. A stale expected_version returns 409 version_conflict without changing anything.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PatchReconciliationInput"},"example":{"expected_version":1,"name":"Monthly bank and ledger"}}}},"responses":{"200":{"description":"Confirmed mapping.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SavedReconciliation"},"examples":{"sample":{"$ref":"#/components/examples/SavedReconciliation"}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"description":"Stale version or duplicate name.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":{"code":"version_conflict","message":"This saved reconciliation changed. Reload it before saving."}}}}},"422":{"description":"Mapping blocked; same mapping validation codes, with the complete validation response in error.validation. No dataset, job or usage event is created.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":{"code":"mapping_date_format_ambiguous","message":"Resolve the mapping validation before continuing."}}}}}}}},"/api/v1/saved-reconciliations/{id}/validate":{"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string"},"example":"saved_example"}],"post":{"operationId":"validateSavedReconciliation","tags":["Saved reconciliations"],"summary":"Validate new files with a confirmed saved mapping","description":"Free and unmetered; stores no file contents, datasets or jobs. Supply both sides. Mapping overrides in the request are ignored; only the confirmed mapping is used.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConverterInput"},"example":{"sides":{"a":{"filename":"bank.csv","csv":"id,date,amount,reference,currency\nA1,2026-10-01,10,REF1,USD\n"},"b":{"filename":"ledger.csv","csv":"journal_id,posting_date,amount,reference,currency\nB1,2026-10-01,10,REF1,USD\n"}}}}}},"responses":{"200":{"description":"Validation, including blocking decisions.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConverterResponse"},"example":{"ok":false,"sides":{},"cross_side":null}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"}}}},"/api/v1/saved-reconciliations/{id}/runs":{"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string"},"example":"saved_example"}],"post":{"operationId":"runSavedReconciliation","tags":["Saved reconciliations"],"summary":"Validate and enqueue a run using a confirmed saved mapping","description":"Revalidates with the locked confirmed version. Blocked runs create no datasets, jobs or usage. Valid runs atomically create two converted datasets and a normal asynchronous job with saved_reconciliation_id and mapping_snapshot. Normal quota and completed-job usage apply. Reusing an idempotency key with identical input returns the same job; changed input conflicts.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SavedRunInput"},"example":{"sides":{"a":{"filename":"bank.csv","csv":"id,date,amount,reference,currency\nA1,2026-10-01,10,REF1,USD\n"},"b":{"filename":"ledger.csv","csv":"journal_id,posting_date,amount,reference,currency\nB1,2026-10-01,10,REF1,USD\n"}},"idempotency_key":"example_saved_run_1"}}}},"responses":{"202":{"description":"Queued job with a saved reconciliation identifier.","content":{"application/json":{"schema":{"type":"object","required":["id","saved_reconciliation_id"],"properties":{"id":{"type":"string"},"saved_reconciliation_id":{"type":"string"}}},"example":{"id":"rec_example","saved_reconciliation_id":"saved_example"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"402":{"$ref":"#/components/responses/Quota"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"description":"Idempotency conflict.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":{"code":"idempotency_conflict","message":"This idempotency key was used with different input"}}}}},"422":{"description":"Mapping blocked; same mapping validation codes, with the complete validation response in error.validation. No dataset, job or usage event is created.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":{"code":"mapping_date_format_ambiguous","message":"Resolve the mapping validation before continuing."}}}}}}}},"/api/v1/presence/ping":{"post":{"operationId":"pingPresence","tags":["Presence"],"summary":"Update the signed-in user's last-seen timestamp","description":"Empty body only; no page content. Verified console session required, API keys rejected. Stores at most one timestamp update per 60 seconds per user; throttled pings also return 204.","security":[{"ownerSession":[]},{"ownerSessionDev":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"maxProperties":0},"example":{}}}},"responses":{"204":{"description":"Timestamp updated or within the 60-second throttle window."},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"}}}},"/api/v1/mappings/propose":{"post":{"parameters":[{"name":"assist","in":"query","required":false,"schema":{"type":"boolean","default":false},"description":"Explicit optional AI review for unsure fields only. Off by default; missing configuration or an exhausted daily budget keeps manual choices. Saved mappings are never sent. Validate and confirm never invoke AI."}],"operationId":"proposeMapping","tags":["Mappings"],"summary":"Suggest file columns and preview conversion","description":"Free, never metered. By default, deterministic header synonyms and value-shape detection only; no AI or network calls.\nCSV and the first XLSX sheet are parsed in memory and not stored. Exactly one private saved signature match reuses its confirmed mapping, still validating new data; multiple matches return candidates without choosing. Mapping choices are saved only through explicit confirmation.\nReturns 200 with ok false for uncertain mappings, invalid cells, duplicate IDs or suspected reversed ledger signs.\nBoth sides are optional individually, but at least one is required. Include both for cross-side sign checks.\nOnly the first five converted rows are returned. A future run step must use this same validator.\n","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConverterInput"},"examples":{"csv":{"value":{"sides":{"a":{"filename":"sample.csv","csv":"id,date,amount,reference,currency\nR1,2026-10-01,100,REF1,USD\n"}}}}}}}},"responses":{"200":{"description":"Mapping decisions, validation, totals, first five normalized rows and a plain-language preview. No file-content writes or usage events. Thin content-free product telemetry is recorded. A unique match adds matched_saved_reconciliation (id, name, version) and saved field statuses; multiple matches add candidates (id, name, version).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConverterResponse"},"example":{"ok":true,"sides":{"a":{"header_signature":"hs1:0000000000000000000000000000000000000000000000000000000000000000","header_row":1,"sheet_name":null,"fields":{"record_id":{"column":"id","status":"confident","score":1,"candidates":[{"column":"id","score":1,"valid_share":1}],"samples":[{"source":"R1","normalized":"R1"}]},"date":{"column":"date","status":"confident","score":1,"candidates":[{"column":"date","score":1,"valid_share":1}],"samples":[{"source":"2026-10-01","normalized":"2026-10-01"}]},"amount":{"column":"amount","status":"confident","score":1,"candidates":[{"column":"amount","score":1,"valid_share":1}],"samples":[{"source":"100","normalized":"100"}]},"reference":{"column":"reference","status":"confident","score":1,"candidates":[{"column":"reference","score":1,"valid_share":1}],"samples":[{"source":"REF1","normalized":"REF1"}]},"currency":{"column":"currency","status":"confident","score":1,"candidates":[{"column":"currency","score":1,"valid_share":1}],"samples":[{"source":"USD","normalized":"USD"}]}},"parse":{"date_format":"YYYY-MM-DD","date_status":"confident","amount_mode":"signed","debit_column":null,"credit_column":null,"reverse_sign":false,"default_currency":"USD"},"validation":{"ok":true,"blocking":[],"warnings":[{"code":"mapping_same_sign","message":"Every amount on this side has the same sign."}],"stats":{"data_rows":1,"skipped_rows":0,"parsed":{"record_id":1,"date":1,"amount":1,"reference":1,"currency":1},"total_amount":"100","total_debits":"0","total_credits":"0","date_min":"2026-10-01","date_max":"2026-10-01","currencies":{"USD":1},"unparseable_count":0,"unparseable_cells":[],"duplicate_ids":[]}},"preview_text":"Bank file \"sample.csv\": 1 rows (0 non-data rows skipped). Dates read as YYYY-MM-DD, 1 Oct 2026 – 1 Oct 2026. Amount = \"amount\" (signed); total +100.00 (credits 0.00, debits 0.00). Reference = \"reference\". Currency = \"currency\" (USD: 1). Record ID = \"id\" (unique). Needs you: nothing.","normalized_preview":[{"bank_id":"R1","date":"2026-10-01","amount":"100","reference":"REF1","currency":"USD"}],"needs_user":[]}},"cross_side":null}}}},"400":{"description":"Invalid input, unsupported/malformed file or header, over 100 fields, or record_limit above 1000 rows. Standard error envelope.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":{"code":"mapping_unsupported_file","message":"Supply a CSV file or the first sheet of an XLSX file."}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"413":{"description":"The unchanged JSON body limit is 2 MiB.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":{"code":"invalid_body","message":"Request must be valid JSON of at most 2 MB"}}}}},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/Internal"}}}},"/api/v1/mappings/validate":{"post":{"operationId":"validateMapping","tags":["Mappings"],"summary":"Validate explicit mapping choices and preview conversion","description":"Free and never metered, with the identical deterministic validator and preview as propose.\nSupply a mapping object per side (an empty object retains suggestions). Explicit source columns\nconfirm the user's selection; invalid cells still block. date_format resolves ambiguous dates,\namount_mode selects signed or debit_credit, reverse_sign flips all normalized amounts.\nNo dataset, job, usage event, file, or saved mapping is created. ok is true only when nothing blocks.\n","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConverterInput"},"examples":{"chooseDate":{"value":{"sides":{"a":{"filename":"sample.csv","csv":"id,date,amount,reference,currency\nR1,2026-10-01,100,REF1,USD\n","mapping":{"date_format":"YYYY-MM-DD","amount_mode":"signed","reverse_sign":false}}}}}}}}},"responses":{"200":{"description":"Mapping decisions, validation, totals, first five normalized rows and a plain-language preview. No file-content writes or usage events. Thin content-free product telemetry is recorded. A unique match adds matched_saved_reconciliation (id, name, version) and saved field statuses; multiple matches add candidates (id, name, version).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConverterResponse"},"example":{"ok":true,"sides":{"a":{"header_signature":"hs1:0000000000000000000000000000000000000000000000000000000000000000","header_row":1,"sheet_name":null,"fields":{"record_id":{"column":"id","status":"confident","score":1,"candidates":[{"column":"id","score":1,"valid_share":1}],"samples":[{"source":"R1","normalized":"R1"}]},"date":{"column":"date","status":"confident","score":1,"candidates":[{"column":"date","score":1,"valid_share":1}],"samples":[{"source":"2026-10-01","normalized":"2026-10-01"}]},"amount":{"column":"amount","status":"confident","score":1,"candidates":[{"column":"amount","score":1,"valid_share":1}],"samples":[{"source":"100","normalized":"100"}]},"reference":{"column":"reference","status":"confident","score":1,"candidates":[{"column":"reference","score":1,"valid_share":1}],"samples":[{"source":"REF1","normalized":"REF1"}]},"currency":{"column":"currency","status":"confident","score":1,"candidates":[{"column":"currency","score":1,"valid_share":1}],"samples":[{"source":"USD","normalized":"USD"}]}},"parse":{"date_format":"YYYY-MM-DD","date_status":"confident","amount_mode":"signed","debit_column":null,"credit_column":null,"reverse_sign":false,"default_currency":"USD"},"validation":{"ok":true,"blocking":[],"warnings":[{"code":"mapping_same_sign","message":"Every amount on this side has the same sign."}],"stats":{"data_rows":1,"skipped_rows":0,"parsed":{"record_id":1,"date":1,"amount":1,"reference":1,"currency":1},"total_amount":"100","total_debits":"0","total_credits":"0","date_min":"2026-10-01","date_max":"2026-10-01","currencies":{"USD":1},"unparseable_count":0,"unparseable_cells":[],"duplicate_ids":[]}},"preview_text":"Bank file \"sample.csv\": 1 rows (0 non-data rows skipped). Dates read as YYYY-MM-DD, 1 Oct 2026 – 1 Oct 2026. Amount = \"amount\" (signed); total +100.00 (credits 0.00, debits 0.00). Reference = \"reference\". Currency = \"currency\" (USD: 1). Record ID = \"id\" (unique). Needs you: nothing.","normalized_preview":[{"bank_id":"R1","date":"2026-10-01","amount":"100","reference":"REF1","currency":"USD"}],"needs_user":[]}},"cross_side":null}}}},"400":{"description":"Invalid request, missing mapping object, malformed or unsupported file, header or resource-limit error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":{"code":"mapping_required_field_missing","message":"Supply a mapping for each side to validate."}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"413":{"description":"The unchanged JSON body limit is 2 MiB.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":{"code":"invalid_body","message":"Request must be valid JSON of at most 2 MB"}}}}},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/Internal"}}}},"/api/v1/account":{"get":{"operationId":"getAccount","tags":["Account"],"summary":"Get the current organization","responses":{"200":{"$ref":"#/components/responses/Account"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/Internal"}}},"patch":{"operationId":"updateAccount","tags":["Account"],"summary":"Rename the organization","security":[{"ownerSession":[]},{"ownerSessionDev":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AccountInput"},"example":{"name":"Example organization"}}}},"responses":{"200":{"$ref":"#/components/responses/Account"},"400":{"$ref":"#/components/responses/Invalid"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/OwnerRequired"},"413":{"$ref":"#/components/responses/TooLarge"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/Internal"}}}},"/api/v1/onboarding":{"get":{"operationId":"getOnboarding","tags":["Account"],"summary":"Get organization onboarding milestones","responses":{"200":{"description":"Organization-wide milestone flags.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Onboarding"},"example":{"key_created":false,"job_completed":false,"completed_job_id":null,"results_viewed":false,"export_downloaded":false}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/Internal"}}}},"/api/v1/overview":{"get":{"operationId":"getOverview","tags":["Account"],"summary":"Get job aggregates, recent jobs and activity","description":"Counts include both key environments within this organization.","responses":{"200":{"description":"Aggregates, newest 5 jobs and newest 8 activity entries.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Overview"},"example":{"total_jobs":0,"completed_jobs":0,"failed_jobs":0,"processed_records":0,"matched_records":0,"exception_records":0,"recent_jobs":[],"activity":[]}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/Internal"}}}},"/api/v1/keys":{"get":{"operationId":"listKeys","tags":["Keys"],"summary":"List API-key metadata","description":"Newest first, including revoked keys. No pagination. Full keys and hashes are never returned.","security":[{"ownerSession":[]},{"ownerSessionDev":[]}],"responses":{"200":{"description":"Key metadata array.","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Key"}},"examples":{"sample":{"$ref":"#/components/examples/KeyList"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/OwnerRequired"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/Internal"}}},"post":{"operationId":"createKey","tags":["Keys"],"summary":"Create a key and show its full value once","description":"At most 20 active keys per organization.\nDuring the free beta you can create a production API key (`rc_live_…`) without a card. Usage counts toward the free beta allowance and is never charged. The same key starts billing only after you choose a paid plan and paid billing launches. Development keys stay available and use the same allowance.\nThere is no creation idempotency field.\nsecret is returned only in this no-store creation response.\n","security":[{"ownerSession":[]},{"ownerSessionDev":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/KeyInput"},"examples":{"sample":{"$ref":"#/components/examples/KeyInput"}}}}},"responses":{"201":{"description":"Created metadata plus the once-visible secret.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreatedKey"},"examples":{"sample":{"$ref":"#/components/examples/CreatedKey"}}}}},"400":{"$ref":"#/components/responses/Invalid"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/OwnerRequired"},"409":{"description":"Maximum active-key count reached.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":{"code":"key_limit","message":"Maximum 20 active API keys"}}}}},"413":{"$ref":"#/components/responses/TooLarge"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/Internal"}}}},"/api/v1/keys/{id}":{"parameters":[{"$ref":"#/components/parameters/Id"}],"delete":{"operationId":"revokeKey","tags":["Keys"],"summary":"Revoke an organization key","description":"Retains metadata. Revoking an already-revoked owned key also returns 204.","security":[{"ownerSession":[]},{"ownerSessionDev":[]}],"responses":{"204":{"description":"Key revoked; no response body."},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/OwnerRequired"},"404":{"$ref":"#/components/responses/NotFound"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/Internal"}}}},"/api/v1/usage":{"parameters":[{"$ref":"#/components/parameters/UsageEnvironment"}],"get":{"operationId":"getUsage","tags":["Usage"],"summary":"Get current-period usage","responses":{"200":{"$ref":"#/components/responses/Usage"},"400":{"$ref":"#/components/responses/Invalid"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/Internal"}}}},"/api/v1/account/limits":{"parameters":[{"$ref":"#/components/parameters/UsageEnvironment"}],"get":{"operationId":"getAccountLimits","tags":["Usage"],"summary":"Get usage through the account-limits alias","description":"Identical to GET /api/v1/usage. This is not a spend-cap editing endpoint.","responses":{"200":{"$ref":"#/components/responses/Usage"},"400":{"$ref":"#/components/responses/Invalid"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/Internal"}}}},"/api/v1/reports/demand":{"get":{"operationId":"getDemandReport","tags":["Usage"],"summary":"Get this organization's completed-job demand report","description":"Grouped by use_case, data_source and environment; no pagination.","security":[{"ownerSession":[]},{"ownerSessionDev":[]}],"responses":{"200":{"description":"Organization-scoped aggregate rows.","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/DemandRow"}},"example":[{"use_case":"bank_vs_ledger","data_source":"customer_data","environment":"development","completed_jobs":1,"repeat_jobs":0,"record_volume":2}]}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/OwnerRequired"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/Internal"}}}},"/api/v1/billing":{"get":{"operationId":"getBilling","tags":["Account"],"summary":"Get billing availability, plans and organization billing state","description":"Returns enabled=false during the free beta. Checkout and portal operations are disabled during the free beta (403 billing_disabled_beta).","security":[{"ownerSession":[]},{"ownerSessionDev":[]}],"responses":{"200":{"description":"Catalog amounts are cents; null catalog amounts indicate arranged pricing.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Billing"},"examples":{"sample":{"$ref":"#/components/examples/Billing"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/OwnerRequired"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/Internal"}}}},"/api/v1/billing/checkout":{"post":{"operationId":"createCheckout","tags":["Account"],"summary":"Get a subscription checkout URL","description":"Disabled during the free beta (403 billing_disabled_beta).\nStarts checkout for a self-service plan. May create a billing customer and checkout session;\nan open session with the correct return URLs is reused. Existing subscriptions return 409.\nThis is an owner browser operation, not an API-key billing operation.\n","security":[{"ownerSession":[]},{"ownerSessionDev":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["plan"],"properties":{"plan":{"type":"string","enum":["starter","growth","scale"]}}},"example":{"plan":"starter"}}}},"responses":{"200":{"description":"Checkout URL.","content":{"application/json":{"schema":{"type":"object","required":["url"],"properties":{"url":{"type":["string","null"]}}},"example":{"url":"https://example.com/checkout/placeholder"}}}},"400":{"$ref":"#/components/responses/Invalid"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"description":"Owner session required, or billing_disabled_beta while billing is disabled.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":{"code":"billing_disabled_beta","message":"Unira is free during the beta. No card is collected and nothing is charged."}}}}},"409":{"description":"Organization already has a subscription.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":{"code":"already_subscribed","message":"Manage your existing subscription in the billing portal."}}}}},"413":{"$ref":"#/components/responses/TooLarge"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/Internal"},"503":{"$ref":"#/components/responses/BillingUnavailable"}}}},"/api/v1/billing/portal":{"post":{"operationId":"createBillingPortal","tags":["Account"],"summary":"Get a billing portal URL","description":"Disabled during the free beta (403 billing_disabled_beta). When enabled, requires an existing billing customer and configured portal; creates a portal session.","security":[{"ownerSession":[]},{"ownerSessionDev":[]}],"responses":{"200":{"description":"Portal URL.","content":{"application/json":{"schema":{"type":"object","required":["url"],"properties":{"url":{"type":"string"}}},"example":{"url":"https://example.com/billing/placeholder"}}}},"400":{"$ref":"#/components/responses/Invalid"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"description":"Owner session required, or billing_disabled_beta while billing is disabled.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":{"code":"billing_disabled_beta","message":"Unira is free during the beta. No card is collected and nothing is charged."}}}}},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/Internal"},"503":{"$ref":"#/components/responses/BillingUnavailable"}}}},"/api/v1/settings/webhook":{"get":{"operationId":"getWebhookSettings","tags":["Webhooks"],"summary":"Get the configured endpoint and masked secret hint","description":"Available even while customer webhooks are disabled. No full secret is returned.","security":[{"ownerSession":[]},{"ownerSessionDev":[]}],"responses":{"200":{"description":"Current configuration or null URL/hint when absent.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookSettings"},"example":{"enabled":false,"url":null,"secret_hint":null}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/OwnerRequired"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/Internal"}}},"put":{"operationId":"setWebhookSettings","tags":["Webhooks"],"summary":"Set or replace the customer endpoint and signing secret","description":"Off unless CUSTOMER_WEBHOOKS_ENABLED is exactly true. Generates a fresh once-visible secret\nand cancels queued old deliveries. An already in-flight send may have left the server.\n","security":[{"ownerSession":[]},{"ownerSessionDev":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookInput"},"example":{"url":"https://example.com/hooks/unira"}}}},"responses":{"200":{"$ref":"#/components/responses/WebhookSecret"},"400":{"$ref":"#/components/responses/Invalid"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/WebhookForbidden"},"413":{"$ref":"#/components/responses/TooLarge"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/Internal"}}},"delete":{"operationId":"deleteWebhookSettings","tags":["Webhooks"],"summary":"Remove the endpoint and cancel queued sends","description":"Available while disabled. Retains delivery history; no endpoint is also a successful deletion.","security":[{"ownerSession":[]},{"ownerSessionDev":[]}],"responses":{"204":{"description":"Endpoint removed; no response body."},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/OwnerRequired"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/Internal"}}}},"/api/v1/settings/webhook/rotate-secret":{"post":{"operationId":"rotateWebhookSecret","tags":["Webhooks"],"summary":"Rotate the signing secret and cancel queued old sends","description":"Requires an existing endpoint and CUSTOMER_WEBHOOKS_ENABLED exactly true; new secret is shown once.","security":[{"ownerSession":[]},{"ownerSessionDev":[]}],"responses":{"200":{"$ref":"#/components/responses/WebhookSecret"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/WebhookForbidden"},"404":{"$ref":"#/components/responses/NotFound"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/Internal"}}}},"/api/v1/settings/webhook/test":{"post":{"operationId":"testWebhook","tags":["Webhooks"],"summary":"Enqueue a test event","description":"Returns the event ID, not a synchronous delivery result. Requires an endpoint and CUSTOMER_WEBHOOKS_ENABLED exactly true.","security":[{"ownerSession":[]},{"ownerSessionDev":[]}],"responses":{"202":{"description":"Test event queued.","content":{"application/json":{"schema":{"type":"object","required":["id"],"properties":{"id":{"type":"string"}}},"example":{"id":"wh_evt_example"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/WebhookForbidden"},"404":{"$ref":"#/components/responses/NotFound"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/Internal"}}}},"/api/v1/settings/webhook/deliveries":{"get":{"operationId":"listWebhookDeliveries","tags":["Webhooks"],"summary":"List recent delivery metadata","description":"Newest 20 by creation time and ID. No pagination, raw bodies or signing secrets; available while disabled.","security":[{"ownerSession":[]},{"ownerSessionDev":[]}],"responses":{"200":{"description":"Recent delivery attempts and statuses.","content":{"application/json":{"schema":{"type":"array","maxItems":20,"items":{"$ref":"#/components/schemas/WebhookDelivery"}},"example":[{"id":"wh_evt_example","event_type":"webhook.test","job_id":null,"status":"pending","attempts":0,"last_http_status":null,"last_error":null,"created_at":"2026-11-16T00:00:00.000Z","last_attempt_at":null,"next_attempt_at":"2026-11-16T00:00:00.000Z","delivered_at":null}]}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/OwnerRequired"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/Internal"}}}},"/api/v1/examples/bank-books":{"post":{"operationId":"runBankBooksExample","tags":["Jobs"],"summary":"Start or reuse the official sample job","description":"No body required. Atomically creates the two sample datasets, ruleset and 49-input-record job.\nOne setup per organization and environment; retries return the existing job with 202.\nNew jobs follow the existing enqueue quota and production checks; failure rolls back sample setup.\n","responses":{"202":{"description":"New or existing official sample job.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Job"},"example":{"id":"rec_example","name":"October bank vs. books","status":"pending","dataset_a_id":"ds_example_a","dataset_b_id":"ds_example_b","ruleset_id":"rules_example","ruleset_version":1,"input_records":49,"engine_version":"1.2.2","environment":"development","attempts":0,"last_error":null,"error":null,"processing_time_ms":null,"completed_at":null,"created_at":"2026-11-16T00:00:00.000Z","use_case":"bank_vs_ledger","data_source":"official_sample","example":"bank-books"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"402":{"description":"Free beta allowance exhausted.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":{"code":"quota_exceeded","message":"Insufficient sandbox records"}}}}},"403":{"$ref":"#/components/responses/Forbidden"},"409":{"$ref":"#/components/responses/Conflict"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/Internal"}}}},"/api/v1/datasets":{"get":{"operationId":"listDatasets","tags":["Datasets"],"summary":"List dataset metadata","description":"Newest 100 datasets in the organization; no pagination parameters.","responses":{"200":{"description":"Metadata array; uploaded record contents are not returned.","content":{"application/json":{"schema":{"type":"array","maxItems":100,"items":{"$ref":"#/components/schemas/Dataset"}},"examples":{"sample":{"$ref":"#/components/examples/DatasetList"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/Internal"}}},"post":{"operationId":"createDataset","tags":["Datasets"],"summary":"Upload a dataset as JSON records or CSV text","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DatasetInput"},"examples":{"sample":{"$ref":"#/components/examples/DatasetInput"}}}}},"responses":{"201":{"description":"Created metadata, or the original metadata on an identical idempotent retry.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Dataset"},"examples":{"sample":{"$ref":"#/components/examples/Dataset"}}}}},"400":{"$ref":"#/components/responses/Invalid"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"409":{"$ref":"#/components/responses/Conflict"},"413":{"$ref":"#/components/responses/TooLarge"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/Internal"}}}},"/api/v1/datasets/{id}":{"parameters":[{"$ref":"#/components/parameters/Id"}],"get":{"operationId":"getDataset","tags":["Datasets"],"summary":"Get dataset metadata","responses":{"200":{"description":"Dataset metadata only.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Dataset"},"examples":{"sample":{"$ref":"#/components/examples/Dataset"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/Internal"}}}},"/api/v1/rulesets":{"get":{"operationId":"listRulesets","tags":["Rulesets"],"summary":"List the latest version of each organization ruleset","description":"Ordered by ID; no pagination or preset-only virtual entries.","responses":{"200":{"description":"Latest versions; no fixed result limit.","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Ruleset"}},"examples":{"sample":{"$ref":"#/components/examples/RulesetList"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/Internal"}}},"post":{"operationId":"createRuleset","tags":["Rulesets"],"summary":"Create version 1 of a ruleset","description":"No ruleset-creation idempotency field is implemented.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RulesetInput"},"examples":{"sample":{"$ref":"#/components/examples/RulesetInput"}}}}},"responses":{"201":{"description":"Created version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Ruleset"},"examples":{"sample":{"$ref":"#/components/examples/Ruleset"}}}}},"400":{"$ref":"#/components/responses/Invalid"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"413":{"$ref":"#/components/responses/TooLarge"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/Internal"}}}},"/api/v1/rulesets/{id}":{"parameters":[{"$ref":"#/components/parameters/Id"}],"get":{"operationId":"getRuleset","tags":["Rulesets"],"summary":"Get the latest ruleset version","responses":{"200":{"description":"Latest version of the organization-owned ruleset.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Ruleset"},"examples":{"sample":{"$ref":"#/components/examples/Ruleset"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/Internal"}}},"patch":{"operationId":"updateRuleset","tags":["Rulesets"],"summary":"Append a new immutable ruleset version","description":"Requires the full name and rules array. Increments the latest version; old job snapshots are unchanged.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RulesetInput"},"examples":{"sample":{"$ref":"#/components/examples/RulesetInput"}}}}},"responses":{"200":{"description":"Newly appended version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Ruleset"},"examples":{"sample":{"$ref":"#/components/examples/RulesetVersion"}}}}},"400":{"$ref":"#/components/responses/Invalid"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"413":{"$ref":"#/components/responses/TooLarge"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/Internal"}}}},"/api/v1/reconciliations":{"get":{"operationId":"listJobs","tags":["Jobs"],"summary":"List jobs","description":"Newest 100 jobs in the organization; no pagination parameters.","responses":{"200":{"description":"Job metadata array.","content":{"application/json":{"schema":{"type":"array","maxItems":100,"items":{"$ref":"#/components/schemas/Job"}},"examples":{"sample":{"$ref":"#/components/examples/JobList"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/Internal"}}},"post":{"operationId":"createJob","tags":["Jobs"],"summary":"Enqueue an asynchronous job","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/JobInput"},"examples":{"sample":{"$ref":"#/components/examples/JobInput"}}}}},"responses":{"202":{"description":"Queued job, or the original job on an identical retry.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Job"},"examples":{"sample":{"$ref":"#/components/examples/Job"}}}}},"400":{"$ref":"#/components/responses/Invalid"},"401":{"$ref":"#/components/responses/Unauthorized"},"402":{"description":"Development quota exhausted after accounting for reserved input records.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":{"code":"quota_exceeded","message":"Insufficient sandbox records","remaining_records":1,"requested_records":2,"renews_on":"2026-12-16","upgrade_url":"https://unira.dev/billing"}}}}},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"$ref":"#/components/responses/Conflict"},"413":{"$ref":"#/components/responses/TooLarge"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/Internal"}}}},"/api/v1/reconciliations/{id}":{"parameters":[{"$ref":"#/components/parameters/Id"}],"get":{"operationId":"getJob","tags":["Jobs"],"summary":"Read job status and summary","responses":{"200":{"description":"Job metadata; summary appears when available.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Job"},"examples":{"sample":{"$ref":"#/components/examples/Job"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/Internal"}}}},"/api/v1/reconciliations/{id}/results":{"parameters":[{"$ref":"#/components/parameters/Id"},{"$ref":"#/components/parameters/Page"},{"$ref":"#/components/parameters/Classification"}],"get":{"operationId":"getJobResults","tags":["Jobs"],"summary":"Page through result items","description":"Non-completed jobs may return an empty result page. A completed read records the existing results-view milestone.","responses":{"200":{"description":"Filtered result items, 50 per page.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ResultPage"},"examples":{"sample":{"$ref":"#/components/examples/ResultPage"}}}}},"400":{"$ref":"#/components/responses/Invalid"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/Internal"}}}},"/api/v1/reconciliations/{id}/exceptions":{"parameters":[{"$ref":"#/components/parameters/Id"},{"$ref":"#/components/parameters/Page"},{"$ref":"#/components/parameters/Classification"}],"get":{"operationId":"getJobExceptions","tags":["Jobs"],"summary":"Page through items other than confirmed matches","description":"Excludes confirmed exact/tolerance/split matches; includes suggested splits. Paging and classification filtering are the same as results.","responses":{"200":{"description":"Filtered exception items, 50 per page.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ResultPage"},"examples":{"sample":{"$ref":"#/components/examples/ResultPage"}}}}},"400":{"$ref":"#/components/responses/Invalid"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/Internal"}}}},"/api/v1/reconciliations/{id}/export":{"parameters":[{"$ref":"#/components/parameters/Id"},{"name":"format","in":"query","schema":{"type":"string","default":"json"},"description":"Exactly csv returns CSV; any other value or omission returns JSON.","example":"csv"}],"get":{"operationId":"exportJobResults","tags":["Jobs"],"summary":"Download a completed job as JSON or CSV","description":"JSON is a flat job metadata object plus rules_snapshot and all results, not a nested job envelope.\nCSV has the columns listed below, CRLF rows, semicolon-joined record IDs, escaped quotes and spreadsheet-formula protection.\nOnly completed jobs can be exported. Successful exports record the existing download milestone.\n","responses":{"200":{"description":"Completed export; format selects the content type.","headers":{"Content-Disposition":{"schema":{"type":"string"},"example":"attachment; filename=\"rec_example.csv\""}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/JobExport"},"examples":{"sample":{"$ref":"#/components/examples/JobExport"}}},"text/csv":{"schema":{"type":"string"},"example":"classification,a_ids,b_ids,rule_id,rule_version,explanation,possible_duplicate,match_status,confidence\n\"exact_match\",\"a1\",\"b1\",\"reference-exact\",\"1\",\"reference equals reference\",\"false\",\"confirmed\",\"high\"\n"}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"$ref":"#/components/responses/Conflict"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/Internal"}}}}}}