> ## Documentation Index
> Fetch the complete documentation index at: https://docs.abbyy.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Data Processed by Vantage Mobile Input

> Data flow and API calls used by Vantage Mobile Input on iOS and Android to create documents, upload images, and start processing transactions in Vantage.

export const VantageRegion = ({children}) => {
  const STORAGE_KEY = "abbyy.vantage.region";
  const REGIONS = [{
    code: "eu",
    label: "Europe"
  }, {
    code: "us",
    label: "North America"
  }, {
    code: "au",
    label: "Australia / Asia-Pacific"
  }];
  const [region, setRegion] = useState("eu");
  const [open, setOpen] = useState(false);
  const containerRef = useRef(null);
  const dropdownRef = useRef(null);
  function safeGetSavedRegion() {
    try {
      const saved = typeof window !== "undefined" ? window.localStorage.getItem(STORAGE_KEY) : null;
      const valid = new Set(REGIONS.map(r => r.code));
      return saved && valid.has(saved) ? saved : "eu";
    } catch {
      return "eu";
    }
  }
  function safeSetSavedRegion(code) {
    try {
      if (typeof window !== "undefined") {
        window.localStorage.setItem(STORAGE_KEY, code);
      }
    } catch {}
  }
  function dispatchRegionChanged(code) {
    try {
      if (typeof window !== "undefined") {
        window.dispatchEvent(new CustomEvent("abbyy:region-changed", {
          detail: {
            code
          }
        }));
      }
    } catch {}
  }
  function replaceRegionInString(text, currentRegion) {
    if (typeof text !== "string") return text;
    const hostRegex = /https:\/\/vantage-(eu|us|au)\.abbyy\.com/gi;
    const tokenRegex = /https:\/\/vantage-\[region\]\.abbyy\.com/gi;
    const bareHostRegex = /vantage-(eu|us|au)\.abbyy\.com/gi;
    const bareTokenRegex = /vantage-\[region\]\.abbyy\.com/gi;
    return text.replace(hostRegex, `https://vantage-${currentRegion}.abbyy.com`).replace(tokenRegex, `https://vantage-${currentRegion}.abbyy.com`).replace(bareHostRegex, `vantage-${currentRegion}.abbyy.com`).replace(bareTokenRegex, `vantage-${currentRegion}.abbyy.com`);
  }
  useEffect(() => {
    setRegion(safeGetSavedRegion());
  }, []);
  useEffect(() => {
    const root = containerRef.current;
    if (!root) return;
    const anchors = root.querySelectorAll("a[href]");
    anchors.forEach(a => {
      const href = a.getAttribute("href");
      if (href) {
        const next = replaceRegionInString(href, region);
        if (next !== href) {
          a.setAttribute("href", next);
        }
      }
    });
    const walker = typeof document !== "undefined" ? document.createTreeWalker(root, NodeFilter.SHOW_TEXT, null) : null;
    if (walker) {
      const toUpdate = [];
      let node = walker.nextNode();
      while (node) {
        const updated = replaceRegionInString(node.nodeValue, region);
        if (updated !== node.nodeValue) {
          toUpdate.push([node, updated]);
        }
        node = walker.nextNode();
      }
      toUpdate.forEach(([textNode, value]) => {
        textNode.nodeValue = value;
      });
    }
  }, [region, children]);
  useEffect(() => {
    const root = containerRef.current;
    if (!root) return;
    const anchors = root.querySelectorAll("a[href]");
    anchors.forEach(a => {
      a.style.fontWeight = "600";
      a.style.textDecoration = "underline";
      a.style.textUnderlineOffset = "2px";
    });
  }, [region, children]);
  useEffect(() => {
    const onRegionChanged = evt => {
      const code = evt && evt.detail && evt.detail.code;
      if (!code || code === region) return;
      setRegion(code);
    };
    if (typeof window !== "undefined") {
      window.addEventListener("abbyy:region-changed", onRegionChanged);
    }
    return () => {
      if (typeof window !== "undefined") {
        window.removeEventListener("abbyy:region-changed", onRegionChanged);
      }
    };
  }, [region]);
  useEffect(() => {
    const onClickAway = e => {
      if (!dropdownRef.current) return;
      if (!dropdownRef.current.contains(e.target)) {
        setOpen(false);
      }
    };
    document.addEventListener("click", onClickAway, true);
    return () => document.removeEventListener("click", onClickAway, true);
  }, []);
  const onSelect = code => {
    setRegion(code);
    safeSetSavedRegion(code);
    dispatchRegionChanged(code);
    setOpen(false);
  };
  const current = REGIONS.find(r => r.code === region) || REGIONS[0];
  return <div className="not-prose">
      <div className="mb-4 inline-flex items-center gap-2" ref={dropdownRef}>
        <span className="text-sm text-zinc-950/80 dark:text-white/80">Tenant Region:</span>
        <div className="relative">
          <button type="button" aria-haspopup="listbox" aria-expanded={open ? "true" : "false"} onClick={() => setOpen(v => !v)} className="h-8 px-3 rounded-md bg-zinc-900/5 dark:bg-white/5 border border-zinc-950/20 dark:border-white/20 text-sm inline-flex items-center gap-2">
            <span className="text-zinc-950 dark:text-white">{current.label}</span>
            <svg width="8" height="24" viewBox="0 -9 3 24" className="transition-transform text-gray-400 overflow-visible dark:text-gray-600 ml-auto" style={{
    transform: open ? "rotate(270deg)" : "rotate(90deg)"
  }}>
              <path d="M0 0L3 3L0 6" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round"></path>
            </svg>
          </button>
          {open ? <div role="listbox" className="absolute z-50 left-full top-0 ml-2 w-56 rounded-xl border border-zinc-950/20 dark:border-white/20 bg-white dark:bg-zinc-900 shadow-lg p-2">
              {REGIONS.map(r => {
    const selected = r.code === region;
    return <button key={r.code} type="button" role="option" aria-selected={selected ? "true" : "false"} onClick={() => onSelect(r.code)} className={"w-full flex items-center justify-between px-3 py-2 rounded-lg text-sm hover:bg-zinc-950/5 dark:hover:bg-white/10 text-zinc-950 dark:text-white" + (selected ? " font-medium" : "")}>
                    <span style={selected ? {
      color: "#ff2038"
    } : undefined}>{r.label}</span>
                    <span className={selected ? "ml-3" : "ml-3 invisible"} style={selected ? {
      color: "#ff2038"
    } : undefined}>✓</span>
                  </button>;
  })}
            </div> : null}
        </div>
      </div>
      <div ref={containerRef} className="prose dark:prose-invert max-w-none">{children}</div>
    </div>;
};

Vantage Mobile Upload communicates with the Vantage server by using API calls. These calls are used to create documents, upload images, and start processing transactions with certain parameters.

## API calls by platform

### iOS platform

The iOS micro application of Vantage Mobile Input uses the following API calls:

1. Sending parameters of the input session to the Vantage Mobile Upload Backend
2. Getting parameters of the input session from the Vantage Mobile Upload Backend
3. Getting status of the transaction
4. Downloading models for analyzing images of the documents
5. Getting list of the documents in the transaction
6. Deleting existing documents in the transaction
7. Creating a document in the transaction
8. Uploading captured images to the document
9. Starting the transaction

### Android platform

The Android micro application of Vantage Mobile Input uses the following API calls:

1. Getting status of the transaction
2. Downloading models for analyzing images of the documents
3. Getting list of the documents in the transaction
4. Deleting existing documents in the transaction
5. Creating a document in the transaction
6. Uploading captured images to the document
7. Starting the transaction

## Sending input session parameters to the Vantage Mobile Upload Backend

Vantage Mobile Input sends input session parameters to the Vantage Mobile Upload Backend. These parameters are used for the upload session in the Android micro application or in the web browser.

### Input session parameters

| Key           | Description                                                                                                         |
| :------------ | :------------------------------------------------------------------------------------------------------------------ |
| BaseURL       | The main domain of Vantage server.                                                                                  |
| TransactionID | The identifier of the transaction.                                                                                  |
| Token         | The encoded authorization access token that is used for authorized access to the Vantage API.                       |
| v             | The version of the Vantage API.                                                                                     |
| md            | The quantity of the documents that will be captured in one transaction.                                             |
| redirect\_uri | The redirect link that opens once Vantage Mobile Upload is finished.                                                |
| dt            | The document type.                                                                                                  |
| ma            | The ABBYY Vantage cloud environment address that is used to start micro applications for on-premises installations. |

Request:

```
curl -X POST "https://mobilesessionmanager-eu.abbyy.com/api/v1/mobilesessions"
-H "accept: text/plain" \
-H "Content-Type: application/json" \
-F "Body=
    {
      "sessionAuxiliaryKey": "string",
      "sessionData": "string"
    }
```

Response:

```
Status code of the request
```

## Getting input session parameters from Vantage Mobile Upload Backend

To get the input session parameters, Vantage Mobile Upload sends requests to Vantage Mobile Upload Backend.

### Input session parameters

| Key           | Description                                                                                                         |
| :------------ | :------------------------------------------------------------------------------------------------------------------ |
| BaseURL       | The main domain of Vantage server.                                                                                  |
| TransactionID | The identifier of the transaction.                                                                                  |
| Token         | The encoded authorization access token that is used for authorized access to the Vantage API.                       |
| v             | The version of the Vantage API.                                                                                     |
| md            | The quantity of the documents that will be captured in one transaction.                                             |
| redirect\_uri | The redirect link that opens once Vantage Mobile Upload is finished.                                                |
| dt            | The document type.                                                                                                  |
| ma            | The ABBYY Vantage cloud environment address that is used to start micro applications for on-premises installations. |

Request:

```
curl -X POST "https://mobilesessionmanager-eu.abbyy.com/api/v1/mobilesessions/retrive"
-H "accept: text/plain" \
-H "Content-Type: application/json" \
-F "Body=
    {
      "userCode": "String"
    }
```

Response:

```
{
   "sessionData": "<Input Session Parameters>"
}
```

Sample of input session parameters:

```
{
\"sessionData\": \"https://mobilesessionmanager-eu.abbyy.com/mobile?baseUrl=<https://vantage-us.abbyy.com>&transactionId=<transaction-id>&token=<token>&v=<release_version>\"
}
```

## Getting the status of the transaction

Vantage Mobile Upload sends a request to get the transaction identifier and status. Only transactions with the **New** status are valid for uploading documents.

**Key parameters**

| Key           | Description                                                                         |
| :------------ | :---------------------------------------------------------------------------------- |
| TransactionID | The identifier of the transaction.                                                  |
| Status        | The status of the transaction. Possible values: New, Started, Processing, Processed |

Request:

<VantageRegion>
  ```
  GET https://vantage-us.abbyy.com/api/publicapi/v1/transactions/transaction-id
  ```
</VantageRegion>

Response:

```
{
   "id": "<TransactionID>",
   "status": "<Status>"
}
```

## Downloading the models for analyzing images of the documents

Vantage Mobile Upload sends requests to download models for detecting page edges on the images of the documents for the iOS micro application.

**Key parameters**

| Key                 | Description                                                                                                                                                                                                                                                                                                                         |
| :------------------ | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| AbbyyRtrSDK-version | The version of AbbyyRtrSDK framework used to request the relevant pattern files. The value may change depending on the version of Vantage.                                                                                                                                                                                          |
| PatternFileName     | The name of the AbbyyRtrSDK file pattern that is used for detecting page edges on the images of the documents. There are six types of file patterns: `FactCrop.imodel`, `CnnCrop.Classifier.cnnmodel`, `DIQClassifier.imodel`, `CnnCrop.Detector.GenericWithID.cnnmodel`, `DIQBlockClassifier.imodel`, `CropClassifierPhoto.imodel` |

Request:

<VantageRegion>
  ```
  GET https://vantage-us.abbyy.com/app_clip/mobile_sdk_assets/AbbyyRtrSDK-version/patterns/PatternFileName
  ```
</VantageRegion>

Response:

```
File pattern
```

## Getting a list of the documents in the transaction

Before uploading documents to the transaction, Vantage Mobile Upload sends a request to check the transaction for previously created documents. If the transaction is not empty, Vantage Mobile Upload sends a **Delete document** request to delete all existing documents before a new upload session.

**Key parameters**

| Key            | Description                                                                                                                                                                                        |
| :------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| TransactionID  | The identifier of the transaction.                                                                                                                                                                 |
| DocumentID     | The identifier of the document received from the **Creating a document** request.                                                                                                                  |
| SourceFileID   | The identifier of the document image.                                                                                                                                                              |
| SourceFileName | The name of the document image. Vantage Mobile Upload automatically generates file names for each image and uploads images to the document using the **Uploading Images to the document** request. |

Request:

<VantageRegion>
  ```
  GET https://vantage-us.abbyy.com/api/publicapi/v1/transactions/transaction-id/documents
  ```
</VantageRegion>

Response:

```
[
   {
      "documentId": "<DocumentID>",
      "sourceFiles": 
      [
         {
           "id": "<SourceFileID>",
           "name": "<SourceFileName>.JPG"
         }
      ]
   }, 
   {
      "documentId": "<DocumentID>",
      "sourceFiles": 
      [
         {
           "id": "<SourceFileID>",
           "name": "<SourceFileName>.JPG"
         }
      ]
   }
]
```

## Deleting existing documents in the transaction

To remove a document from the transaction before starting processing, use `DELETE /api/publicapi/v1/transactions/{transactionId}/documents/{documentId}`.

This allows users to:

* Remove incorrectly captured documents
* Clear documents before re-capturing
* Manage document sets in the transaction

<Info>
  Documents can only be deleted before the transaction starts processing.
</Info>

## Creating a document in the transaction

To upload images Vantage Mobile Upload sends a request to create document instances for each document in the transaction.

**Key parameters**

| Key           | Description                                                                                   |
| :------------ | :-------------------------------------------------------------------------------------------- |
| Token         | The encoded authorization access token that is used for authorized access to the Vantage API. |
| TransactionID | The identifier of the transaction.                                                            |
| DocumentID    | The identifier of the document.                                                               |

Request:

<VantageRegion>
  ```
  curl -X POST "https://vantage-us.abbyy.com/api/publicapi/v1/transactions/transaction-id/documents"
  -H "accept: */*" \
  -H "Authorization: Bearer token" \
  -H "Content-Type: application/json; charset=utf-8" \
  -F "Model=
      {
        "index": <Unsigned Integer Value: document index in UI>,
        "imageProcessingOptions": 
          {
             "autoOrientationCorrection": "<Yes/No/Default>",
             "autoCrop": "<Yes/No/Default>"
          }
      }
  ```
</VantageRegion>

Response:

```
{
   "documentId": "<DocumentID>"
}
```

## Uploading captured images to the document

Once the document instance has been created, Vantage Mobile Upload sends a request to upload all the images to the document. All images for one document are uploaded in a single request.

**Key parameters**

| Key            | Description                                                                                                                                 |
| :------------- | :------------------------------------------------------------------------------------------------------------------------------------------ |
| Token          | The encoded authorization access token that is used for authorized access to the Vantage API.                                               |
| TransactionID  | The identifier of the transaction.                                                                                                          |
| DocumentID     | The identifier of the document received from the **Creating a document** request.                                                           |
| SourceFileID   | The identifier of the document image.                                                                                                       |
| SourceFileName | The name of the document image. Vantage Mobile Upload automatically generates file names for each image and uploads images to the document. |
| ImageData      | The encoded information from the image files. Used to upload images to documents.                                                           |

Request:

<VantageRegion>
  ```
  curl -X POST "https://vantage-us.abbyy.com/api/publicapi/v1/transactions/transaction-id/documents/document-id/sourceFiles"
  -H "accept: */*" \
  -H "Authorization: Bearer token" \
  -H "Content-Type: multipart/form-data; boundary=<Boundary>" \
  -F "Body=
      {
        "files": [
         {
           "index": 0,
           "registrationParameters": [
             {
              "key": "SourceType",
              "value": "Vantage Mobile Capture"
             }
           ]
          }
         ]
      },
      {
        "index": 1,
        ...
      },
        ...
     ]
   }

  <Boundary>
  Content-Disposition: form-data; name="Files"; filename="<SourceFileName>.JPG"
  Content-Type: image/jpeg
  <ImageData>

  ...
  <Boundary>
  Content-Disposition: form-data; name="Files"; filename="<SourceFileName>.JPG"
  Content-Type: image/jpeg
  <ImageData>
  ...
  <Boundary>
  ```
</VantageRegion>

Response:

```
Status code of the request
```

## Starting the transaction

Once all the documents have been created and all the images have been uploaded to the documents, Vantage Mobile Upload sends a request to start the transaction.

**Key parameters**

| Key           | Description                                                                                   |
| :------------ | :-------------------------------------------------------------------------------------------- |
| Token         | The encoded authorization access token that is used for authorized access to the Vantage API. |
| TransactionID | The identifier of the transaction.                                                            |

Request:

<VantageRegion>
  ```
  curl -X POST "https://vantage-us.abbyy.com/api/publicapi/v1/transactions/transaction-id/start"
  -H "accept: */*" \
  -H "Authorization: Bearer token" \
  -H "Content-Type: application/json; charset=utf-8" \
  ```
</VantageRegion>

Response:

```
Status code of the request
```
