# Fanavaran image receipts and upload failures The image ID is the external `Id` returned by Fanavaran's attachment upload, not the MongoDB ID of the local image. Both batch and single-image uploads persist it in `claimCases.fanavaranSync.attachments.files[].fileId`, together with `fileName`, `source`, `submittedAt`, and the response. Per-image success, failure, and skip events are saved in `fanavaranSync.attachments.attempts`. Failures include an error and, when an audited HTTP upload started, a tracking code. ## Read the IDs beside the claim references Claim detail responses that expose `fanavaran` now include: ```json { "fanavaran": { "claimId": 5190845, "fileIds": [700001], "attachments": { "status": "success", "uploadedCount": 1, "lastError": null, "files": [ { "fileId": 700001, "fileName": "image.jpg", "source": "capture:angle:front" } ], "attempts": [] } } } ``` Existing claim-reference codes remain gated on COMPLETED. Image receipts and status can appear earlier. The expertise preview also returns `fileIds` and `attachments` beside `claimId`, `dmgCaseId`, and `expertiseId`. ## Check every planned image and why it is pending `GET /v2/fanavaran/parsian/claim-cases/{claimCaseId}/attachments/preview` This returns `totalLocalImages`, `alreadySubmitted`, `pendingSubmit`, `fileIds`, `uploadStatus`, and one `attachments` row per local upload candidate. Each row includes `fileId`, `alreadySubmitted`, `localFileExists`, `status`, and `lastError`. Use `pendingSubmit` to check whether all current local candidates have saved receipts. Summary status describes recorded outcomes, not unattempted images. - `success`: confirmed external file IDs are recorded. - `partial`: receipts exist, but another recorded image failed or was skipped. - `failed` / `skipped`: inspect the per-image error and `nextRetryAt` if present. - `not_recorded`: no upload outcome is stored; this is not proof of remote absence. - `unconfirmed`: legacy upload records have no valid external file ID. `POST /v2/fanavaran/parsian/claim-cases/{claimCaseId}/attachments/submit` submits pending candidates and returns each upload's `fileId` or failure/skip reason. Already-recorded successful uploads are skipped. Missing local files are reported instead of silently excluded. A response with no external file ID is unconfirmed and is not automatically retried, to avoid duplicating a possibly accepted upload. Older batch uploads did not persist their returned IDs. This change cannot reconstruct those historical receipts from the local database; verify them with Fanavaran before deciding to re-upload. New uploads use the shared persistence path and record their outcomes. To verify remote receipts directly, use `GET /v2/fanavaran/parsian/claim-cases/{claimCaseId}/hull/files`. Retrieve one image and its Base64 content using `/hull/files/{fileId}`. See [hull retrieval](hull-retrieval.md) for all supported read routes. ## Expertise submit completes missing prerequisites The frontend can call `POST /v2/fanavaran/{client}/claim-cases/{claimCaseId}/expertise/submit` without separately retrying earlier stages. The backend completes them in order: - Third-party: base claim → damage case → pending attachments → expertise. - Hull: base claim → pending attachments → expertise. Hull has no damage-case stage. Existing claim/damage IDs and successful image receipts are reused. A previously skipped attachment stage is retried. Completion is checked against a fresh read of the saved receipts for all current local image candidates, not just the attachment stage's status or an upload response saying success. Missing local files, rejected uploads, and unconfirmed receipts stop expertise submission. If there are no local attachment candidates, there is nothing to upload. Errors identify `stage` (`baseClaim`, `damageCase`, or `attachments`) and preserve vendor details. An attachment failure includes: ```json { "statusCode": 400, "code": "FANAVARAN_ATTACHMENTS_INCOMPLETE", "stage": "attachments", "pendingFiles": [ { "fileName": "image.jpg", "error": "Upload failure reason", "skipped": false } ] } ``` Retrying resumes pending work. Even when expertise already exists, this API first repairs missing prerequisites, then returns the existing expertise response/Id without posting another expertise. Automatic final writes also check attachments.