---
title: Reconcile endorsement image sequence numbers with the Imaging API
summary: Check that stored image sequence numbers still exist in Imaging and clear any stale values.
status: draft
owner: Technical Writer
last_reviewed: 2026-07-31
library: SAIF.Business.Policy.Correspondence
reference_type: package
operation_id: OP-008
trigger: Caller invokes `ClearImageSequenceNumbersForDeletedImages` after loading an endorsement collection.
---

# Reconcile endorsement image sequence numbers with the Imaging API

Check that stored image sequence numbers still exist in Imaging and clear any stale values.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-008 |
| **Trigger** | Caller invokes `ClearImageSequenceNumbersForDeletedImages` after loading an endorsement collection. |
| **Inputs** | The in-memory collection image sequence numbers and the `ImagingApiUrl` configuration setting. |
| **Outputs** | Any endorsement whose image is missing has `ImageSequenceNumber` reset to `0`. |
| **Primary components** | `clsEndorsementCollection.ClearImageSequenceNumbersForDeletedImages`; `clsEndorsementCollection.ImagingApiClient` |
| **Entry point** | `Business\SAIF.Business.Policy.Correspondence\clsEndorsementCollection.vb` |

## Steps

1. Scan the collection for correspondence items that currently expose an image sequence number and copy those IDs into an `ImageListQuery`.
2. If the list is empty, return immediately without creating an API request ([BR-015](../business-rules.md#br-015-imaging-reconciliation-skips-empty-image-lists)).
3. Resolve the shared `ImagingClient` from the cached `ImagingApiClient` property and call `GetImages(DocTypeGroup.POLICY, imageListQuery)` using the configured imaging endpoint.
4. Compare the IDs returned by the Imaging API with the IDs held by the collection; any missing image ID causes the corresponding correspondence item to be reset to `0` ([BR-016](../business-rules.md#br-016-missing-images-reset-local-image-sequence-numbers-to-zero)).
5. Leave all image sequence numbers unchanged when the API confirms that the image still exists.

## Process flow

The following diagram summarizes the control flow for this operation.

```mermaid
flowchart TD
    Start([Reconcile images]) --> Collect[Collect image ids] --> Empty{Any ids?} -->|No| Done([Return])
    Empty -->|Yes| Call[Call Imaging API] --> Compare[Compare returned ids] --> Clear[Reset missing ids to 0] --> Done
```

## Failure and edge-case behavior

- Validation and framework state errors surface through the BOF error collection unless the called dependency throws directly.
- Database-dependent operations rely on the caller-supplied data portal context and Oracle connectivity.
- Imaging reconciliation and stored-procedure wrappers defer cross-system behavior to their external collaborators.

## Related documentation
- [Operations and processes](../operations-processes.md)
- [Business rules](../business-rules.md)
- [SQL catalog](../sql/index.md)
- [Database tables](../database-tables.md)

## Sources
- ``Business\SAIF.Business.Policy.Correspondence\clsEndorsementCollection.vb``
