{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/arcnautical-com/json-schema/arcnautical-com-export-schema.json",
  "title": "Export",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/arcnautical-com-exports-api-openapi.yml#/components/schemas/Export",
  "type": "object",
  "required": [
    "id",
    "resource",
    "format",
    "status",
    "filters",
    "created_at",
    "expires_at"
  ],
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid"
    },
    "resource": {
      "$ref": "#/$defs/ExportResource"
    },
    "format": {
      "type": "string",
      "enum": [
        "csv",
        "jsonl"
      ]
    },
    "status": {
      "type": "string",
      "enum": [
        "queued",
        "running",
        "completed",
        "failed"
      ]
    },
    "filters": {
      "type": "object",
      "description": "The filters as applied, including the pinned created_before."
    },
    "estimated_row_count": {
      "type": [
        "integer",
        "null"
      ],
      "description": "Rows matched when the export was accepted."
    },
    "row_count": {
      "type": [
        "integer",
        "null"
      ],
      "description": "Rows actually written. Null until completed."
    },
    "byte_size": {
      "type": [
        "integer",
        "null"
      ]
    },
    "checksum_sha256": {
      "type": [
        "string",
        "null"
      ],
      "description": "SHA-256 of the file body, hex."
    },
    "download_url": {
      "type": "string",
      "description": "Present only when status is completed."
    },
    "error": {
      "$ref": "#/$defs/ApiErrorEnvelope"
    },
    "download_count": {
      "type": "integer"
    },
    "downloaded_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    },
    "completed_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "expires_at": {
      "type": "string",
      "format": "date-time",
      "description": "When the FILE is deleted. The records it was built from are unaffected."
    }
  },
  "$defs": {
    "ApiErrorEnvelope": {
      "type": "object",
      "required": [
        "code",
        "message",
        "request_id"
      ],
      "properties": {
        "code": {
          "type": "string",
          "enum": [
            "missing_idempotency_key",
            "invalid_idempotency_key",
            "invalid_json",
            "unauthorized",
            "invalid_api_key",
            "quota_exhausted",
            "insufficient_scope",
            "entitlement_inactive",
            "ip_not_allowed",
            "records_need_rpsl",
            "monitoring_unavailable_in_test",
            "simulation_unavailable_in_live",
            "not_found",
            "unsupported_api_version",
            "method_not_allowed",
            "unsupported_media_type",
            "idempotency_conflict",
            "idempotency_in_progress",
            "export_not_ready",
            "delivery_in_flight",
            "endpoint_disabled",
            "endpoint_deleted",
            "monitor_limit_exceeded",
            "vessel_monitor_limit_exceeded",
            "vessel_monitor_exists",
            "crew_ship_exists",
            "crew_ship_limit_exceeded",
            "export_unavailable",
            "validation_failed",
            "route_not_found",
            "export_too_large",
            "webhook_url_blocked",
            "webhook_url_unresolvable",
            "rate_limit_exceeded",
            "concurrency_limit",
            "service_concurrency_limit",
            "export_concurrency_limit",
            "internal_error",
            "assessment_failed",
            "screening_failed",
            "export_failed",
            "export_row_count_grew",
            "api_paused",
            "assessment_timeout",
            "screening_timeout"
          ],
          "description": "Stable machine code. Branch on this, never on the message text, which we reword. Generated from the list the server throws from rather than restated here, because a hand-kept copy of a server-side vocabulary has drifted on us before. The HTTP status does NOT tell you whether to retry: 409 idempotency_in_progress resolves by waiting while 409 idempotency_conflict never resolves, and 500 export_row_count_grew fails identically on every retry. Retryability per code:\n\n- `missing_idempotency_key` (400) — not retryable. A POST arrived with no Idempotency-Key header.\n- `invalid_idempotency_key` (400) — not retryable. The Idempotency-Key was present but unusable (empty or over-long).\n- `invalid_json` (400) — not retryable. The body did not parse as JSON.\n- `unauthorized` (401) — not retryable. No credential was supplied.\n- `invalid_api_key` (401) — not retryable. The key is unknown, revoked, expired, or its prefix does not match the environment.\n- `quota_exhausted` (402) — not retryable. The allowance for this resource is spent: the month's (GET /api/v1/usage carries the reset date), or a one-time total (live screenings on an account opened from 2026-10-01, or a pilot), which does not reset.\n- `insufficient_scope` (403) — not retryable. The key does not hold the scope this endpoint requires.\n- `entitlement_inactive` (403) — not retryable. The account has no active entitlement.\n- `ip_not_allowed` (403) — not retryable. The key is IP-restricted and this source address is not on its list.\n- `records_need_rpsl` (403) — not retryable. The crew check PDF record comes with an RPSL licence linked to the account in the app. The check, its sha256 and verify_url are available without one.\n- `monitoring_unavailable_in_test` (403) — not retryable. Vessel and corridor monitors are not available on a test key.\n- `simulation_unavailable_in_live` (403) — not retryable. Simulated monitor events are available only on a test key. A synthetic risk change on a live monitor would enter your compliance record as a real finding about a real vessel.\n- `not_found` (404) — not retryable. No such resource, or it is not yours. A malformed id answers this way too, deliberately.\n- `unsupported_api_version` (404) — not retryable. The path names an /api/vN this service does not publish. Answered by the edge, so it is the one code that carries no rate-limit headers. NEVER retry: our own guidance says an HTML body means a network layer answered and should be retried, and this exists so that advice is not applied to a permanent 404.\n- `method_not_allowed` (405) — not retryable. The path exists but not with this verb. The Allow header names the verbs that do work.\n- `unsupported_media_type` (415) — not retryable. Content-Type declared something other than application/json. Omitting the header is accepted; declaring the wrong one is not.\n- `idempotency_conflict` (409) — not retryable. This Idempotency-Key was already used with a different body. Never resolves — use a new key.\n- `idempotency_in_progress` (409) — RETRYABLE. The original request with this key is still running, and this retry waited for it (up to 30s) without it finishing. Retry with the same key: the next retry waits again and returns the original result the moment it lands, flagged X-ArcNautical-Idempotent-Joined: true. Carries Retry-After.\n- `export_not_ready` (409) — RETRYABLE. The export job has not finished. Poll it; carries Retry-After.\n- `delivery_in_flight` (409) — RETRYABLE. That webhook delivery is being attempted right now.\n- `endpoint_disabled` (409) — not retryable. The webhook endpoint is disabled. Re-enable it first.\n- `endpoint_deleted` (409) — not retryable. The webhook endpoint no longer exists.\n- `monitor_limit_exceeded` (409) — not retryable. Corridor monitor ceiling reached. Delete one first.\n- `vessel_monitor_limit_exceeded` (409) — not retryable. Vessel monitor ceiling reached. Delete one first.\n- `vessel_monitor_exists` (409) — not retryable. A monitor already watches this hull.\n- `crew_ship_exists` (409) — not retryable. This IMO is already on your crew list; the message names its id.\n- `crew_ship_limit_exceeded` (409) — not retryable. Crew list ceiling reached for this account (larger with an RPSL licence linked in the app). Delete one first.\n- `export_unavailable` (410) — not retryable. The export file has aged out. The records behind it are unaffected — create a new one.\n- `validation_failed` (422) — not retryable. One or more fields are invalid; field_violations names each one.\n- `route_not_found` (422) — not retryable. Both ports are known but no sea route connects them.\n- `export_too_large` (422) — not retryable. The requested range exceeds the per-export row cap. Narrow the filters and export in parts.\n- `webhook_url_blocked` (422) — not retryable. The URL resolves to a private, loopback or link-local address.\n- `webhook_url_unresolvable` (422) — not retryable. The URL host does not resolve.\n- `rate_limit_exceeded` (429) — RETRYABLE. Over the per-key request rate. Shed RATE; back off to X-RateLimit-Reset.\n- `concurrency_limit` (429) — RETRYABLE. Over your own in-flight ceiling. Shed CONCURRENCY, or use the batch endpoint. Retry-After carries a live estimate, not a fixed number.\n- `service_concurrency_limit` (429) — RETRYABLE. The shared pool is full and your account is within its allowance. A graded screen QUEUES for that pool first and is served round-robin between accounts, so this means the queue itself ran out of time — you were not stuck behind one customer's batch. Reducing your fan-out will NOT help; retry unchanged after Retry-After. include_vetting: false skips this queue entirely, and /api/v1/screening-batches is not subject to it at all.\n- `export_concurrency_limit` (429) — RETRYABLE. Too many exports building at once. Wait for one to finish.\n- `internal_error` (500) — RETRYABLE. An unhandled failure. Retry with backoff; quote request_id if it persists.\n- `assessment_failed` (500) — RETRYABLE. Voyage scoring failed to produce a result.\n- `screening_failed` (500) — RETRYABLE. The screening engine failed to produce a verdict. No unit is charged.\n- `export_failed` (500) — RETRYABLE. The export job failed while building.\n- `export_row_count_grew` (500) — not retryable. The matching rows grew past the cap while the file was being written, so it was abandoned rather than shipped short. Narrow the filters — an identical retry fails identically.\n- `api_paused` (503) — RETRYABLE. The API is paused for a short while (an operator lever against abuse, rarely pulled). Nothing ran and nothing was charged. Retry the same request after Retry-After.\n- `assessment_timeout` (504) — RETRYABLE. Scoring exceeded its deadline. Retry; a warm route usually succeeds.\n- `screening_timeout` (504) — RETRYABLE. The screening exceeded its time budget (screeningComputeBudgetMs) and was abandoned before it could be stored. No unit is charged, and the Idempotency-Key is RELEASED — so retry with the SAME key; it is a clean attempt, not a replay. Deliberately raised below the socket timeout at the edge, so this arrives as JSON with a request_id rather than as a gateway 504 we never see."
        },
        "message": {
          "type": "string"
        },
        "request_id": {
          "type": "string"
        },
        "field_violations": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/FieldViolation"
          }
        }
      }
    },
    "ExportResource": {
      "type": "string",
      "description": "What to export. Each is governed by the same scope that governs reading it one record at a time: screenings by vessel:screen, cargo_screenings by cargo:screen, access_log by logs:read.",
      "enum": [
        "screenings",
        "cargo_screenings",
        "access_log",
        "voyage_assessments"
      ]
    },
    "FieldViolation": {
      "type": "object",
      "required": [
        "field",
        "message"
      ],
      "properties": {
        "field": {
          "type": "string"
        },
        "message": {
          "type": "string"
        }
      }
    }
  }
}