Mighty
Why MightyCitadel
Use cases
LendingIncome files before you fundInsuranceAppraisals to claim photosClaimsPhotos and estimates at first noticeAll use cases
SecurityDocsLog in
See it on your files

Docs

Direct SaaS purchase is no longer offered

New commercial terms are enterprise or custom, scoped on a call.

See it on your files
Browse docs
Start Here
Citadel Docs5-Minute QuickstartMighty PlatformUse CasesFAQ
Core Concepts
How Citadel WorksModalities And AttacksModes And ToleranceChoose Scan SettingsGlossarySessions And Scan GroupsDriftBilling, SCU, And Limits
Integration Guides
Integration GuidesMultimodal SupportScan Text And OCR OutputScan File UploadsDamage Photo AI Fraud ReviewScan Model OutputAsync Deep ScansError Handling
Frameworks
Framework Integration MapVercel AI SDK Chat GuardrailNext.js Upload GuardrailBackend API HelpersDocument Processing PipelineLangChain + LangGraph Guardrail
Workflows
Workflow Playbooks
API Reference
POST /v1/scan
Use With AI
Use With AI
Start Here
Citadel Docs5-Minute QuickstartMighty PlatformUse CasesFAQ
Core Concepts
How Citadel WorksModalities And AttacksModes And ToleranceChoose Scan SettingsGlossarySessions And Scan GroupsDriftBilling, SCU, And Limits
Integration Guides
Integration GuidesMultimodal SupportScan Text And OCR OutputScan File UploadsDamage Photo AI Fraud ReviewScan Model OutputAsync Deep ScansError Handling
Frameworks
Framework Integration MapVercel AI SDK Chat GuardrailNext.js Upload GuardrailBackend API HelpersDocument Processing PipelineLangChain + LangGraph Guardrail
Workflows
Workflow Playbooks
API Reference
POST /v1/scan
Use With AI
Use With AI
Loading docs…
Mighty

Citadel is Mighty's product. It finds generated or AI-edited fakes in customer files.

See it on your files

Platform

  • For Lending
  • For Insurance
  • For Claims
  • Product
  • Use Cases
  • Contact
  • Docs

Company

  • Why Mighty
  • Blog

Trust

  • Security
  • Status
  • Privacy
  • Terms
© 2026 Nine Suns Inc. All rights reserved.Citadel, from Mighty

Error Handling

Handle common Citadel errors, billing states, limits, rate limits, and async states.

Goal

Build safe fallback behavior for scan errors.

High-risk workflows should fail to review. Low-risk workflows can retry or degrade with clear limits.

Error Shape

Errors may include an error message, code, request ID, and scan group ID.

{
  "error": "scan_phase must be 'input' or 'output'",
  "code": "invalid_scan_phase",
  "request_id": "ab82f4ad-8d64-4bb4-b4ed-77df63291198",
  "scan_group_id": "9b3e4f8d-96c9-4f42-8338-8cf9571c1c70"
}

Status Codes

StatusMeaningFix
202Scan durably accepted and pending.Store scan_id, poll Location, and honor Retry-After. Do not route as final.
400Bad request.Check scan_phase, content_type, UUID fields, and payload shape.
402Billing, quota, spending limit, or tier cap.Show upgrade, route to admin, or route to review.
409Idempotency or duplicate request conflict.Fetch existing result or retry with a new request_id.
413Payload too large, PDF page cap, embedded image cap, or payload complexity.Reduce size, split the file, remove excess embedded images, or review manually.
429Capacity or request rate limited; no new scan was accepted.Honor Retry-After, then retry idempotently.
503Queue, durable store, or required backend unavailable; no new scan was accepted.Retry idempotently after Retry-After when present, then route to review.
500Server error.Retry safely, then route to review.

Safe Fallback Policy

export function fallbackForScanError(status: number, workflowRisk: "low" | "high") {
  if (status === 400) return "fix_request";
  if (status === 402) return "billing_or_tier_action";
  if (status === 413) return "reduce_or_review";
  if (status === 429) return "retry_with_backoff";

  return workflowRisk === "high" ? "manual_review" : "retry_then_degrade";
}

Common 400 Causes

  • Missing scan_phase.
  • scan_phase=output without scan_group_id.
  • Invalid UUID in request_id or scan_group_id.
  • content_type outside auto, text, image, pdf, or document.
  • Invalid focus outside the canonical steg, ai, edits, all, and supported combination values (deprecated aliases are accepted only for compatibility). Structured documents accept canonical focus values and report non-applicable visual surfaces in document_integrity.unsupported_surfaces.
  • Base64 missing when JSON contains non-text content.
  • Multipart request without file or content.

Billing And PDF Limit Errors

PDFs have two separate dimensions:

  • Page count.
  • Unique embedded image count.

Billing is additive. Pages stay 2 SCU each. Unique embedded images use the active focus image-unit price:

Focused PDF SCU = pages * 2 + unique embedded images * 4
All-evidence PDF SCU = pages * 2 + unique embedded images * 12

Tier caps are separate from SCU. A scan can be blocked before billing if the PDF exceeds the tier's page or embedded image limit.

ConditionTypical statusRoute
Missing payment method, quota, spending limit, or tier upgrade required402Show billing or admin action.
PDF exceeds allowed page count402 or 413 depending on entry pointAsk user to split the PDF or upgrade.
PDF exceeds allowed unique embedded image count402 or 413 depending on entry pointAsk user to reduce images, split the PDF, or upgrade.
Raw upload is too large413Reduce file size or route to manual review.

Async States

StateMeaningRoute
pendingDeep scan is still running.Keep pending or poll again.
completeFinal result is ready.Route by action.
failedDeep scan failed.Manual review or safe stop.

Retry Rules

  • Honor Retry-After on 202 polling and 429 capacity responses; add bounded backoff and jitter.
  • Retry 503 idempotently only when your workflow can confirm it did not already receive a 202 for that scan.
  • Retry network errors with a unique request_id unless your app already committed the prior request.
  • Do not retry 400 until the request is fixed.
  • Do not hide 402 or 413. Those need product routing.
  • Keep webhook processing idempotent.
Next step

Ready to scan real traffic?

Book a working session on your files. Starting October 1, 2026, new commercial terms are enterprise or custom.

See it on your filesSCU and limits

AI-Agent Prompt

AI-ready prompt
Add Citadel error handling

Paste this into Cursor, Codex, Claude Code, or Windsurf.

Add Citadel error handling.

Requirements:
- Parse non-2xx responses.
- Handle 400 as a developer or request shape error.
- Handle 402 as billing, quota, or tier cap.
- Handle 409 as idempotency conflict.
- Handle 413 as file size, PDF page cap, embedded image cap, or payload complexity.
- Handle 429 with backoff.
- Treat async pending as pending, not as final.
- Treat async failed as manual review for high-risk workflows.
- Include request_id and scan_id in logs when available.

Acceptance criteria:
- Tests cover 400, 402, 409, 413, 429, network error, pending, complete, and failed.
- High-risk workflows never continue silently after a scan failure.

On this page

GoalError ShapeStatus CodesSafe Fallback PolicyCommon 400 CausesBilling And PDF Limit ErrorsAsync StatesRetry RulesAI-Agent Prompt