# Policy Persistence & Query API

## Overview

Policy transaction is the key capability provided by InsureMO platform for general insurance. It provides several key behaviors such as persistency, status change, query, and load.

Users can refer to this guide to learn more about the typical API for this part.

## Policy Transaction API - Create and Save and Issue

### Policy Transaction - Business Usage

* Store proposal to the database.
* Support different proposal status changes such as quote, bind, or issuance.
* Support different object models and fields for different product lines via configuration.


### Policy Transaction - API Path

* {{server}}/proposal/core/proposal/v1/createEx 
* {{server}}/proposal/core/proposal/v1/updateEx 
* {{server}}/proposal/core/proposal/v1/issuePolicyEx


### Policy Transaction - What You Can Extend

* Extend more policy JSON fields by adding new policy fields.
* Extend more policy JSON list nodes by adding new policy objects.

For more details on how to create a policy JSON, see [Sample API Json Creation Guide](https://docs.insuremo.com/gi_insurance_service/json_creation).


### Policy Transaction - Configuration Data Dictionary and Product

### Policy Transaction - API Sample

#### Create API

/proposal/core/proposal/v1/createEx

* Sample Request

```
{
    "ProductCode": "TBTI",
    "ProductVersion": "1.0",
    "ProposalDate": "2021-04-22T00:00:00",
    "EffectiveDate": "2021-04-22T00:00:00",
    "ExpiryDate": "2022-04-21T23:59:59",
    "AgentCode": "{{scCode}}",
    "BookCurrencyCode": "USD",
    "PremiumCurrencyCode": "USD",
    "OrgCode": "10002",
    "LocalCurrencyCode": "USD",
    "PremiumBookExchangeRate": 1,
    "PremiumLocalExchangeRate": 1,
    "PolicyLobList": [
        {
            "PolicyRiskList": [
                {
                    "CustomerName": "Customer",
                    "IdNo": "IdNo",
                    "IdType": "1",
                    "DateOfBirth": "1988-10-01",
                    "PolicyCoverageList": [
                        {
                            "ProductElementCode": "C100416",
                            "SumInsured": 300000
                        },
                         .....skip....
                    ],
                    "ProductElementCode": "R10007",
                    "RiskName": "Test"
                }
            ],
            "ProductCode": "TBTI",
            "TotalInsuredCount": 1
        }
    ]
}
```

* Sample Response

```
{
    "AgentCode": "XXXXX0000524XXXXX",
    "BookCurrencyCode": "USD",
    "BusinessCateCode": "1",
    "BusinessObjectId": 3517051304219,
    "EffectiveDate": "2021-04-22",
    "ExpiryDate": "2022-04-21T23:59:59",
    "FirstDataEntryDate": "2024-02-19T15:52:26",
    "IsRenewable": "Y",
    "IsTakeUpPolicy": "N",
    "LocalCurrencyCode": "USD",
    "OrgCode": "10002",
    "PolicyElementId": 10019269467,
    "PolicyId": "10019269467,D8EAF6E6320D6DECBEAA19535E8597D9",
    "PolicyLobList": [
        {
            "BusinessObjectId": 351861068,
            "ParentElementType": "POLICY",
            "ParentPolicyElementId": 10019269467,
            "PolicyElementId": 10019269473,
            "PolicyId": "10019269467,D8EAF6E6320D6DECBEAA19535E8597D9",
            "PolicyRiskList": [
                {
                    "BusinessObjectId": 351861075,
                    "CustomerName": "Customer",
                    "DateOfBirth": "1988-10-01",
                    "DetachedProductId": 351925022,
                    "IdNo": "IdNo",
                    "IdType": "1",
                    "ParentElementType": "POLICY_LOB",
                    "ParentPolicyElementId": 10019269473,
                    "PolicyCoverageList": [
                        {
                            "BusinessObjectId": 351861078,
                            "IsFinalLevelCt": "N",
                            "ParentElementType": "INSURED",
                            "ParentPolicyElementId": 10019269475,
                            "PolicyElementId": 10019269477,
                            "PolicyId": "10019269467,D8EAF6E6320D6DECBEAA19535E8597D9",
                            "PolicyStatus": 2,
                            "ProductElementCode": "C100416",
                            "ProductElementId": 351926024,
                            "SequenceNumber": 1,
                            "SumInsured": 300000
                        },
                         .....skip....
                    ],
                    "PolicyElementId": 10019269475,
                    "PolicyId": "10019269467,D8EAF6E6320D6DECBEAA19535E8597D9",
                    "PolicyStatus": 2,
                    "ProductElementCode": "R10007",
                    "ProductElementId": 351926021,
                    "RiskName": "Test",
                    "SequenceNumber": 1,
                    "TempData": {
                        "Mask-IdNo": "Jmf1vghdrScrTdpdeyKu7w==",
                        "IdNo": "Jmf1vghdrScrTdpdeyKu7w==",
                        "MaskAfter-IdNo": "IdNo"
                    }
                }
            ],
            "PolicyStatus": 2,
            "ProductCode": "TBTI",
            "ProductElementCode": "TBTI",
            "ProductElementId": 351925023,
            "ProductId": 351925022,
            "ProductLobId": 351925023,
            "SequenceNumber": 1,
            "TechProductCode": "TR_POC",
            "TechProductId": 3516410623456,
            "TotalInsuredCount": 1
        }
    ],
    "PolicyStatus": 1,
    "PolicyType": "1",
    "PremiumBookExchangeRate": 1,
    "PremiumCurrencyCode": "USD",
    "PremiumLocalExchangeRate": 1,
    "ProductCode": "TBTI",
    "ProductId": 351925022,
    "ProductVersion": "1.0",
    "ProposalDate": "2021-04-22",
    "ProposalNo": "PABTBTI0001302269",
    "ProposalStatus": "1",
    "SchemaVersion": 2,
    "TechProductCode": "TR_POC",
    "TechProductId": 3516410623456,
    "VersionSeq": 1
}
```

#### Save API

/proposal/core/proposal/v1/updateEx

* Sample Request

```
{
    "AgentCode": "XXXXX0000524XXXXX",
    "BookCurrencyCode": "USD",
    "BusinessCateCode": "1",
    "BusinessObjectId": 3517051304219,
    "EffectiveDate": "2021-05-22",
    "ExpiryDate": "2022-05-21T23:59:59",
    "FirstDataEntryDate": "2024-02-19T15:52:26",
    "IsRenewable": "Y",
    "IsTakeUpPolicy": "N",
    "LocalCurrencyCode": "USD",
    "OrgCode": "10002",
    "PolicyElementId": 10019269467,
    "PolicyId": "10019269467,D8EAF6E6320D6DECBEAA19535E8597D9",
    "PolicyLobList": [
        {
            "BusinessObjectId": 351861068,
            "ParentElementType": "POLICY",
            "ParentPolicyElementId": 10019269467,
            "PolicyElementId": 10019269473,
            "PolicyId": "10019269467,D8EAF6E6320D6DECBEAA19535E8597D9",
            "PolicyRiskList": [
                {
                    "BusinessObjectId": 351861075,
                    "CustomerName": "Customer",
                    "DateOfBirth": "1988-10-01",
                    "DetachedProductId": 351925022,
                    "IdNo": "IdNo",
                    "IdType": "1",
                    "ParentElementType": "POLICY_LOB",
                    "ParentPolicyElementId": 10019269473,
                    "PolicyCoverageList": [
                        {
                            "BusinessObjectId": 351861078,
                            "IsFinalLevelCt": "N",
                            "ParentElementType": "INSURED",
                            "ParentPolicyElementId": 10019269475,
                            "PolicyElementId": 10019269477,
                            "PolicyId": "10019269467,D8EAF6E6320D6DECBEAA19535E8597D9",
                            "PolicyStatus": 2,
                            "ProductElementCode": "C100416",
                            "ProductElementId": 351926024,
                            "SequenceNumber": 1,
                            "SumInsured": 300000
                        },
                         .....skip....
                    ],
                    "PolicyElementId": 10019269475,
                    "PolicyId": "10019269467,D8EAF6E6320D6DECBEAA19535E8597D9",
                    "PolicyStatus": 2,
                    "ProductElementCode": "R10007",
                    "ProductElementId": 351926021,
                    "RiskName": "Test",
                    "SequenceNumber": 1,
                    "TempData": {
                        "Mask-IdNo": "Jmf1vghdrScrTdpdeyKu7w==",
                        "IdNo": "Jmf1vghdrScrTdpdeyKu7w==",
                        "MaskAfter-IdNo": "IdNo"
                    }
                }
            ],
            "PolicyStatus": 2,
            "ProductCode": "TBTI",
            "ProductElementCode": "TBTI",
            "ProductElementId": 351925023,
            "ProductId": 351925022,
            "ProductLobId": 351925023,
            "SequenceNumber": 1,
            "TechProductCode": "TR_POC",
            "TechProductId": 3516410623456,
            "TotalInsuredCount": 1
        }
    ],
    "PolicyStatus": 1,
    "PolicyType": "1",
    "PremiumBookExchangeRate": 1,
    "PremiumCurrencyCode": "USD",
    "PremiumLocalExchangeRate": 1,
    "ProductCode": "TBTI",
    "ProductId": 351925022,
    "ProductVersion": "1.0",
    "ProposalDate": "2021-04-22",
    "ProposalNo": "PABTBTI0001302269",
    "ProposalStatus": "1",
    "SchemaVersion": 2,
    "TechProductCode": "TR_POC",
    "TechProductId": 3516410623456,
    "VersionSeq": 1
}
```

* Sample Response
 
```
{
    "AgentCode": "XXXXX0000524XXXXX",
    "BookCurrencyCode": "USD",
    "BusinessCateCode": "1",
    "BusinessObjectId": 3517051304219,
    "EffectiveDate": "2021-05-22",
    "ExpiryDate": "2022-05-21T23:59:59",
    "FirstDataEntryDate": "2024-02-19T15:52:26",
    "IsRenewable": "Y",
    "IsTakeUpPolicy": "N",
    "LocalCurrencyCode": "USD",
    "OrgCode": "10002",
    "PolicyElementId": 10019269467,
    "PolicyId": "10019269467,D8EAF6E6320D6DECBEAA19535E8597D9",
    "PolicyLobList": [
        {
            "BusinessObjectId": 351861068,
            "ParentElementType": "POLICY",
            "ParentPolicyElementId": 10019269467,
            "PolicyElementId": 10019269473,
            "PolicyId": "10019269467,D8EAF6E6320D6DECBEAA19535E8597D9",
            "PolicyRiskList": [
                {
                    "BusinessObjectId": 351861075,
                    "CustomerName": "Customer",
                    "DateOfBirth": "1988-10-01",
                    "DetachedProductId": 351925022,
                    "IdNo": "IdNo",
                    "IdType": "1",
                    "ParentElementType": "POLICY_LOB",
                    "ParentPolicyElementId": 10019269473,
                    "PolicyCoverageList": [
                        {
                            "BusinessObjectId": 351861078,
                            "IsFinalLevelCt": "N",
                            "ParentElementType": "INSURED",
                            "ParentPolicyElementId": 10019269475,
                            "PolicyElementId": 10019269477,
                            "PolicyId": "10019269467,D8EAF6E6320D6DECBEAA19535E8597D9",
                            "PolicyStatus": 2,
                            "ProductElementCode": "C100416",
                            "ProductElementId": 351926024,
                            "SequenceNumber": 1,
                            "SumInsured": 300000
                        },
                         .....skip....
                    ],
                    "PolicyElementId": 10019269475,
                    "PolicyId": "10019269467,D8EAF6E6320D6DECBEAA19535E8597D9",
                    "PolicyStatus": 2,
                    "ProductElementCode": "R10007",
                    "ProductElementId": 351926021,
                    "RiskName": "Test",
                    "SequenceNumber": 1,
                    "TempData": {
                        "Mask-IdNo": "Jmf1vghdrScrTdpdeyKu7w==",
                        "IdNo": "Jmf1vghdrScrTdpdeyKu7w==",
                        "MaskAfter-IdNo": "IdNo"
                    }
                }
            ],
            "PolicyStatus": 2,
            "ProductCode": "TBTI",
            "ProductElementCode": "TBTI",
            "ProductElementId": 351925023,
            "ProductId": 351925022,
            "ProductLobId": 351925023,
            "SequenceNumber": 1,
            "TechProductCode": "TR_POC",
            "TechProductId": 3516410623456,
            "TotalInsuredCount": 1
        }
    ],
    "PolicyStatus": 1,
    "PolicyType": "1",
    "PremiumBookExchangeRate": 1,
    "PremiumCurrencyCode": "USD",
    "PremiumLocalExchangeRate": 1,
    "ProductCode": "TBTI",
    "ProductId": 351925022,
    "ProductVersion": "1.0",
    "ProposalDate": "2021-04-22",
    "ProposalNo": "PABTBTI0001302269",
    "ProposalStatus": "1",
    "SchemaVersion": 2,
    "TechProductCode": "TR_POC",
    "TechProductId": 3516410623456,
    "VersionSeq": 2
}

```

## Policy Copy API

### Policy Copy - Business Usage

* Customer wants fast to create a new proposal based existing proposal/policy

### Policy Copy - API Path

* {{server}}/pa/v1/copyPolicy?policyId={{PolicyId}}

### Policy Copy - API Sample

After API is called, system will create a new copy proposal from old Policy.
If Policy Id not exists, system will not process.

* Sample Response

```
{
    "AdjustedPremium": 37.69,
    "AnnualPremium": 910,
    "AutoUwResultCode": "2",
    "BeforeVatPremium": 34.9,
    "BookCurrencyCode": "SGD",
    "BusinessCateCode": "1",
    "BusinessObjectId": 3517051304219,
    "Commission": 3.49,
    "CommissionRate": 0.1,
    "DuePremium": 37.69,
    "EffectiveDate": "2024-05-15",
    "ExpiryDate": "2025-05-14",
    "FirstDataEntryDate": "2024-05-07T15:05:02",
    "GrossPremium": 37.69,
    "InterestRate": 0,
    "IsPremiumCalcSuccess": "Y",
    "IsRenewalPolicy": "Y",
    "IsTakeUpPolicy": "N",
    "IssueUserId": XXXXX0006XXXXX,
    "IssueUserRealName": "xxxxxx.xxxx@insuremo.com",
    "LocalCurrencyCode": "SGD",
    "MaxUwLevelCode": "1",
    "OrgCode": "10001",
    "POIRate": 1,
    "PolicyLobList": [
        {
            "AdjustedPremium": 37.69,
            "BeforeVatPremium": 34.9,
            "BusinessObjectId": 351861068,
            "DuePremium": 37.69,
            "GrossPremium": 37.69,
            "PolicyRiskList": [
                {
                    "AdjustedPremium": 37.69,
                    "Age": 35,
                    "BeforeVatPremium": 34.9,
                    "BusinessObjectId": 351861075,
                    "DateOfBirth": "1988-10-01",
                    "DuePremium": 37.69,
                    "GrossPremium": 37.69,
                    "IdNo": "888666888",
                    "IdType": "1",
                    "PolicyCoverageList": [
                        {
                            "AdjustedPremium": 37.28,
                            "AnnualPremium": 900,
                            "BeforeVatPremium": 34.52,
                            "BusinessObjectId": 351861078,
                            "CoverageName": "Accident Death & Dismemberment",
                            "DuePremium": 37.28,
                            "GrossPremium": 37.28,
                            "ProductElementCode": "C100416",
                            "ProductElementId": 351926024,
                            "SequenceNumber": 1,
                            "SumInsured": 300000,
                            "Vat": 2.76
                        },
                         .....skip....
                    ],
                    "ProductElementCode": "R10007",
                    "ProductElementId": 351926021,
                    "RiskName": "Alice",
                    "SequenceNumber": 1,
                    "SumInsured": 750000,
                    "TempData": {
                        "Mask-IdNo": "4LGgRe2xYylgnm7I6r7O2w==",
                        "IdNo": "4LGgRe2xYylgnm7I6r7O2w==",
                        "MaskAfter-IdNo": "888666888"
                    },
                    "Vat": 2.79
                }
            ],
            "ProductCode": "TBTI",
            "ProductElementCode": "TBTI",
            "ProductElementId": 351925023,
            "ProductId": 351925022,
            "ProductLobId": 351925023,
            "SequenceNumber": 1,
            "SumInsured": 750000,
            "TechProductCode": "TR_POC",
            "TechProductId": 3516410623456,
            "Vat": 2.79
        }
    ],
    "PolicyType": "1",
    "PremCalcFactorHash": "20240507_150508_769,R2LgLtTE1nGY5rcgx3ulnI9PZqH+QB17K5I+iCoK2HY=",
    "PremCalcResultHash": "20240507_150508_775,sFs/QKJMx4hNS/3VIccX0BPFENiUYeopHyGdud3ehk0=",
    "PremiumBookExchangeRate": 1,
    "PremiumCurrencyCode": "SGD",
    "PremiumInterest": 0,
    "PremiumLocalExchangeRate": 1,
    "ProductCode": "TBTI",
    "ProductId": 351925022,
    "ProductVersion": "1.0",
    "ProposalDate": "2024-05-07",
    "ProposalStatus": "1",
    "SchemaVersion": 2,
    "SumInsured": 750000,
    "TaxInterest": 0,
    "TechProductCode": "TR_POC",
    "TechProductId": 3516410623456,
    "TotalInterest": 0,
    "TotalPremium": 37.69,
    "Vat": 2.79,
    "VatRate": 0.08,
    "VersionSeq": 1
}

```


## Load Policy API with Code Table Description

### Load Policy with Code Table Description - Business Usage

* Load detailed policy data from database.
* Support auto-convert code table values by configuration.


### Load Policy with Code Table Description - API Path

{{server}}/proposal/core/proposal/v1/load?policyNo={{PolicyNo}}&withCodeDesc=Y

### Load Policy with Code Table Description - What You Can Extend

* Load code table values with code descriptions for querying.
* Provide information to downstream systems such as Print or Claim.

### Load Policy with Code Table Description - Configuration Data Table and Code Table and Field Binding

Take ProposalStatus as an example, users need to create code table and bind the code table to the field in the data dictionary.

![data table](./image/product_cfg_sample/datatable.png)

![code table](./image/product_cfg_sample/codetable.png)

![field mapped with code table](./image/product_cfg_sample/field_mapping.png)

For more information on how to configure the data dictionary, see [Data Dictionary Guide](https://docs.insuremo.com/ics/app_framework/dd).


### Load Policy with Code Table Description - API Sample

The field with **_CodeDesc** represents the display information for the field’s value. For example, the value “3” for ProposalStatus corresponds to "Issued".

```
 "ProposalStatus": "3",
 "ProposalStatus_CodeDesc": "Issued",
```



```
{
    "AdjustedPremium": 680.4,
    "AgentCode": "XXXXX0000524XXXXX",
    "AnnualPremium": 630,
    "BeforeVatPremium": 630,
    "BookCurrencyCode": "USD",
    "BookCurrencyCode_CodeDesc": "USD",
    "BusinessCateCode": "1",
    "BusinessCateCode_CodeDesc": "Direct issuance",
    "BusinessObjectId": 3517051304219,
    "Commission": 63,
    "CommissionRate": 0.1,
    "DuePremium": 680.4,
    "EffectiveDate": "2021-04-22",
    "ExpiryDate": "2022-04-21T23:59:59",
    "FirstDataEntryDate": "2024-01-30T15:08:21",
    "GrossPremium": 680.4,
    "InterestRate": 0.05,
    "IsPremiumCalcSuccess": "Y",
    "IsPremiumCalcSuccess_CodeDesc": "Yes",
    "IsRenewable": "Y",
    "IsRenewable_CodeDesc": "Yes",
    "IsTakeUpPolicy": "N",
    "IsTakeUpPolicy_CodeDesc": "No",
    "IssueDate": "2024-01-30T15:08:48",
    "IssueUserId": XXXXX387,
    "IssueUserRealName": "ADMIN",
    "LocalCurrencyCode": "USD",
    "LocalCurrencyCode_CodeDesc": "USD",
    "OrgCode": "10002",
    "POIRate": 1,
    "PolicyElementId": 9943000003,
    "PolicyId": "9943000003,A15FCE5FDF40DAB310514CDC4F565C42",
    "PolicyLobList": [
        {
            "AdjustedPremium": 680.4,
            "BeforeVatPremium": 630,
            "BusinessObjectId": 351861068,
            "DuePremium": 680.4,
            "GrossPremium": 680.4,
            "ParentElementType": "POLICY",
            "ParentPolicyElementId": 9943000003,
            "PolicyElementId": 9943000009,
            "PolicyId": "9943000003,A15FCE5FDF40DAB310514CDC4F565C42",
            "PolicyRiskList": [
                {
                    "AdjustedPremium": 680.4,
                    "Age": 32,
                    "BeforeVatPremium": 630,
                    "BusinessObjectId": 351861075,
                    "CustomerName": "Customer",
                    "DateOfBirth": "1988-10-01",
                    "DetachedProductId": 351925022,
                    "DuePremium": 680.4,
                    "GrossPremium": 680.4,
                    "IdNo": "IdNo",
                    "IdType": "1",
                    "ParentElementType": "POLICY_LOB",
                    "ParentPolicyElementId": 9943000009,
                    "PolicyCoverageList": [
                        {
                            "AdjustedPremium": 648,
                            "AnnualPremium": 600,
                            "BeforeVatPremium": 600,
                            "BusinessObjectId": 351861078,
                            "CoverageName": "Accident Death & Dismemberment",
                            "DuePremium": 648,
                            "GrossPremium": 648,
                            "IsFinalLevelCt": "N",
                            "IsFinalLevelCt_CodeDesc": "No",
                            "ParentElementType": "INSURED",
                            "ParentPolicyElementId": 9943000011,
                            "PolicyElementId": 9943000013,
                            "PolicyId": "9943000003,A15FCE5FDF40DAB310514CDC4F565C42",
                            "PolicyStatus": 2,
                            "PolicyStatus_CodeDesc": "Effective",
                            "ProductElementCode": "C100416",
                            "ProductElementId": 351926024,
                            "SequenceNumber": 1,
                            "SumInsured": 300000,
                            "TempData": {},
                            "Vat": 48
                        },
                         .....skip....
                    ],
                    "PolicyElementId": 9943000011,
                    "PolicyId": "9943000003,A15FCE5FDF40DAB310514CDC4F565C42",
                    "PolicyStatus": 2,
                    "PolicyStatus_CodeDesc": "Effective",
                    "ProductElementCode": "R10007",
                    "ProductElementId": 351926021,
                    "RiskName": "Test",
                    "SequenceNumber": 1,
                    "SumInsured": 900000,
                    "TempData": {
                        "Mask-IdNo": "Jmf1vghdrScrTdpdeyKu7w==",
                        "IdNo": "Jmf1vghdrScrTdpdeyKu7w==",
                        "MaskAfter-IdNo": "IdNo"
                    },
                    "Vat": 50.4
                }
            ],
            "PolicyStatus": 2,
            "PolicyStatus_CodeDesc": "Effective",
            "ProductCode": "TBTI",
            "ProductElementCode": "TBTI",
            "ProductElementId": 351925023,
            "ProductId": 351925022,
            "ProductLobId": 351925023,
            "SequenceNumber": 1,
            "SumInsured": 900000,
            "TechProductCode": "TR_POC",
            "TechProductId": 3516410623456,
            "TempData": {},
            "TotalInsuredCount": 1,
            "Vat": 50.4
        }
    ],
    "PolicyNo": "POTBTI01230955",
    "PolicyStatus": 2,
    "PolicyStatus_CodeDesc": "Effective",
    "PolicyType": "1",
    "PolicyType_CodeDesc": "Single Policy",
    "PremCalcFactorHash": "20240130_150835_050,IxbyRQGVZfYvtV72xwplh6HooXQfc3FAgXxCADsqf7s=",
    "PremCalcResultHash": "20240130_150835_058,4CQo9jYhP1PunXQvfLocPyj17nmhNzWFGW+ScdrHK04=",
    "PremiumBookExchangeRate": 1,
    "PremiumCurrencyCode": "USD",
    "PremiumCurrencyCode_CodeDesc": "USD",
    "PremiumInterest": 31.5,
    "PremiumLocalExchangeRate": 1,
    "ProductCode": "TBTI",
    "ProductId": 351925022,
    "ProductId_CodeDesc": "TBTI-Oversea Travel (PBU for Auto Test)-1.0",
    "ProductVersion": "1.0",
    "ProposalDate": "2021-04-22",
    "ProposalNo": "PABTBTI0001300189",
    "ProposalStatus": "3",
    "ProposalStatus_CodeDesc": "Issued",
    "SchemaVersion": 2,
    "SumInsured": 900000,
    "TaxInterest": 2.52,
    "TechProductCode": "TR_POC",
    "TechProductId": 3516410623456,
    "TempData": {},
    "TotalInterest": 34.02,
    "TotalPremium": 714.42,
    "Vat": 50.4,
    "VatRate": 0.08,
    "VersionSeq": 3
}

```

## Bulk Load Policy API with Code Table Description

### Bulk Load Policy with Code Table Description - Business Usage

* Load detailed policy data from database in bulk.
* Load most **200** policies once.
* Extend from API [Load Policy API with Code Table Description](#load-policy-api-with-code-table-description).

### Bulk Load Policy with Code Table Description - API Path

{{server}}/proposal/core/proposal/v1/bulkLoad?isProposalNo=N&isPolicyNo=N&isPolicyId=Y&isQuotationNo=N&withCodeDesc=N

* Parameters
  * isProposalNo, Y-load by ProposalNo
  * isPolicyNo, Y-load by PolicyNo
  * isPolicyId, Y-load by PolicyId
  * isQuotationNo, Y-load by QuotationNo
  * withCodeDesc, Y-load with code table description; N- load without code table description

### Bulk Load Policy with Code Table Description - What You Can Extend

* Load code table values with code descriptions for querying.
* Provide information to downstream systems such as Print or Claim.


### Bulk Load Policy with Code Table Description - API Sample

* Sample Request

```
 [
    "10517950024,115BC182804F9622CBF7118F9A067323",
    "10517950012,78FA79043DF599876923112B3CBBBB3C",
    "10517960008,A2FB599729351272350EBC715F1C9F79"
]
```

* Sample Response

```
  The 3 policies' detail with code description.
  
```


## Policy Query API

### Policy Query - Business Usage

* Query policy using a set of diverse criteria from the search engine.
* Support most complex search methods, such as fuzzy search and range search.
* Support dynamic extension of search fields.


### Policy Query - API Path

{{server}}/proposal/core/proposal/v1/query

### Policy Query - What You Can Extend

* Extend more search criteria by adding new search fields.
* Check performance statistics of the specific criteria.
* Customize the platform’s search UI screen.

### Policy Query - Configuration Search Index

There are multiple index name which are related to policy transaction:

* Policy
* Endorsement
* PolicySchedule
* PolicyRisk


When new fields are added to the index, they can only be created when new records are created. For existing records, please perform **Rebuild** action. After rebuilding, the existing records' index can be recreated with newly-added fields.

For more details on how to configure index fields, see [Search Index Guide](https://docs.insuremo.com/ics/app_framework/search).

As shown in the image below, the "**Index Rebuild Job**"-"**policyAdminRebuildIndexBatch**" is the batch job name for building the Policy index which will contain all policy related index together. Click "**Rebuild**" to navigate to the batch UI and run the batch job "**policyAdminRebuildIndexBatch**".

![Policy Index](./image/product_cfg_sample/index_policy.png)

In the batch UI, search for job and then input the parameters to run the batch.

![Policy Index](./image/product_cfg_sample/index_policy_rebuild.png)

View job details as shown below:

![Policy Index](./image/product_cfg_sample/index_policy_rebuild_job_details.png)

After rebuilding, you can query the data with the newly-added fields in the response.

Special Note:

The batch policyRebuildIndexBatch is performed mainly based on the existing number of policy. If the number of policy that need to rebuild index is large, you might need to use use the batch parameters properly to narrow the rebuild scope or contact SiteOps team to evaluate the potential execution period.

Based on our internal testing, if there are **1,300,000** policies, when system runs **policyRebuildIndexBatch** without any parameters to rebuild index for all policies, it will cost **48 hours**. 


### Policy Query - API Sample

Before calling the API, users can also try using embedded UI in the platform for querying. For more details, see [platform query guide](https://docs.insuremo.com/gi_insurance_service/statistics#paas-query).


* Sample Request

```
{
    "Conditions": {
        "ProductCode": "TBTI",
        "PolicyNo": "{{PolicyNo}}"
    },
    "PageNo": 1,
    "PageSize": 100,
    "SortField": "index_time",
    "SortType": "desc",
    "Module": "Policy"
}
```


* Sample Response with search result


```
{
    "GroupField": "entity_type",
    "PageNo": 1,
    "PageSize": 100,
    "Results": [
        {
            "EsDocs": [
                {
                    "AgentCode": "XXXXX0000524XXXXX",
                    "DuePremium": 38.52,
                    "EffectiveDate": "2024-01-04",
                    "ExpiryDate": "2024-01-18",
                    "FirstDataEntryDate": "2024-01-11T10:41:09.108",
                    "FullOrgCode": "10002\n10001",
                    "IdNo": "106290*******0629",
                    "IdType": "1",
                    "InsuredCustomerNo": "",
                    "InsuredIdNo": "106290*******0629",
                    "InsuredIdType": "1",
                    "InsuredName": "InsuredName",
                    "IssueDate": "2024-01-11T10:41:09",
                    "OrgCode": "10002",
                    "PolicyHolder": "Customer",
                    "PolicyHolderIDNo": "XXXXX0629062XXXXX",
                    "PolicyId": "9854370003,64F246781A66A74A4DA130CAF3720145",
                    "PolicyNo": "POTBTI01229164",
                    "PolicyStatus": 2,
                    "PolicyType": "1",
                    "ProductCode": "TBTI",
                    "ProductId": 351925022,
                    "ProductName": "Oversea Travel (PBU for Auto Test)",
                    "ProposalNo": "PABTBTI0001298154",
                    "ProposalStatus": 3,
                    "RiskName": "InsuredName",
                    "SumInsured": 900000,
                    "entity_id": "9854370003,64F246781A66A74A4DA130CAF3720145",
                    "entity_type": "Policy",
                    "id": "Policy_9854370003",
                    "index_time": "2024-01-11T02:41:09.808Z",
                    "index_timestamp": 1704940869364,
                    "owned_agent_code": "PTY10000052462004",
                    "owned_org_code": "10002",
                    "tenant_code": "xxxxxx",
                    "TempData": {
                        "Mask-IdNo": "J5zQ8VzedT0mOa947vnlRDxlOAnBdOxPupQR4s2EsA4=",
                        "IdNo": "J5zQ8VzedT0mOa947vnlRDxlOAnBdOxPupQR4s2EsA4=",
                        "MaskAfter-IdNo": "106290*******0629",
                        "Mask-InsuredIdNo": "XXXXXVzedT0mOa947vXXXXXlOAnBdOxPupQR4s2XXXXX",
                        "InsuredIdNo": "XXXXXVzedT0mOa947vXXXXXlOAnBdOxPupQR4s2XXXXX",
                        "MaskAfter-InsuredIdNo": "106290*******0629"
                    }
                }
            ],
            "GroupTotalNum": 1,
            "GroupValue": "Policy"
        }
    ],
    "Total": 1
}
```

## Policy Revision API

### Policy Revision - Business Usage

From creation, to issuance, then to endorsement, system will save the policy as a revision foreach update. So for a policy, there are always several revisions existed.

### Policy Revision - API Path

* {{server}}/{{apigw-platform-url}}/pa/core/policy/v1/getPolicyRevisions?policyId={{PolicyId}}
* GET {{server}}/{{apigw-platform-url}}/pa/core/policy/v1/loadPolicyAtRevision?policyId={{PolicyId}}&withCodeDesc=Y&revisionId={{RevisionId}}
* GET {{server}}/{{apigw-platform-url}}/pa/v1/getPolicyAtFirstEffectiveVersion?policyId={{PolicyId}}&withCodeDesc=Y
* GET {{server}}/{{apigw-platform-url}}/pa/core/policy/v1/loadPolicyAtEffectiveDate?policyId={{PolicyId}}&withCodeDesc=Y&effectiveDate=2024-12-01

### Policy Revision - API Sample

#### /pa/core/policy/v1/getPolicyRevisions

To get a list of policy history version, including revision id and traceid, you can use the id to get policy detail at this version, and use traceid to get log at ELK.


* Sample Response


The "**Id**" of each record in response is the **revisionId**.
```
[
    {
        "EntityId": 10854350221,
        "EntityType": 1,
        "Id": 10854350231,
        "InsertBy": 10000001011247,
        "InsertTime": "2024-09-24T11:33:34",
        "IsFirstEffectiveVersion": "N",
        "IsRollbacked": "N",
        "Timestamp": 1727148813610,
        "TraceId": "XXXXX009b0d46ecc22b286a7018XXXXX",
        "UpdateBy": 10000001011247,
        "UpdateTime": "2024-09-24T11:33:34"
    },
    {
        "EntityId": 10854350221,
        "EntityType": 1,
        "Id": 10854350248,
        "InsertBy": 10000001011247,
        "InsertTime": "2024-09-24T11:33:53",
        "IsFirstEffectiveVersion": "N",
        "IsRollbacked": "N",
        "Timestamp": 1727148833371,
        "TraceId": "XXXXXcf2e9b5667e114898df456XXXXX",
        "UpdateBy": 10000001011247,
        "UpdateTime": "2024-09-24T11:33:53"
    },
    {
        "EndEffectiveDate": "9999-09-09",
        "EntityId": 10854350221,
        "EntityType": 1,
        "Id": 10854350249,
        "InsertBy": 10000001011247,
        "InsertTime": "2024-09-24T11:34:04",
        "IsFirstEffectiveVersion": "Y",
        "IsRollbacked": "N",
        "IssueTime": "2024-09-24T11:34:04",
        "StartEffectiveDate": "2021-04-22",
        "Timestamp": 1727148844241,
        "TraceId": "XXXXX9e57131731a12a7d4dd7a5XXXXX",
        "UpdateBy": 10000001011247,
        "UpdateTime": "2024-09-24T11:34:04"
    }
]

```

#### /pa/core/policy/v1/loadPolicyAtRevision

To get a history policy revision.


* Sample Response

```
{
    "@pk": 10854350221,
    "@type": "Policy-POLICY",
    "AgentCode": "XXXXX0001047XXXXX",
    "BookCurrencyCode": "USD",
    "BusinessCateCode": "1",
    "BusinessObjectId": 3517051304219,
    "EffectiveDate": "2021-04-22",
    "ExpiryDate": "2022-04-21T23:59:59",
    "FirstDataEntryDate": "2024-09-24T11:33:33",
    "IsRenewable": "Y",
    "IsTakeUpPolicy": "N",
    "LocalCurrencyCode": "USD",
    "OrgCode": "10002",
    "PolicyElementId": 10854350221,
    "PolicyId": "10854350221,32AFA952E6D0E145B6D3EFBEF7CE98C6",
    "PolicyStatus": 1,
    "PolicyType": "1",
    "PremiumBookExchangeRate": 1,
    "PremiumCurrencyCode": "USD",
    "PremiumLocalExchangeRate": 1,
    "ProductCode": "TBTI",
    "ProductId": 351925022,
    "ProductVersion": "1.0",
    "ProposalDate": "2021-04-22",
    "ProposalNo": "PABTBTI0001326297",
    "ProposalStatus": "1",
    "QuotationDate": "2024-09-24T11:33:34",
    "SchemaVersion": 2,
    "TechProductCode": "TR_POC",
    "TechProductId": 3516410623456,
    "TempData": {},
    "VersionSeq": 1,
    "BookCurrencyCode_CodeDesc": "USD",
    "BusinessCateCode_CodeDesc": "Direct issuance",
    "IsRenewable_CodeDesc": "Yes",
    "IsTakeUpPolicy_CodeDesc": "No",
    "LocalCurrencyCode_CodeDesc": "USD",
    "OrgCode_CodeDesc": "Brazil Branch",
    "PolicyLobList": [
        {
            "@pk": 10854350224,
            "@type": "PolicyLob-TR_POC",
            "BusinessObjectId": 351861068,
            "ParentElementType": "POLICY",
            "ParentPolicyElementId": 10854350221,
            "PolicyElementId": 10854350224,
            "PolicyId": "10854350221,32AFA952E6D0E145B6D3EFBEF7CE98C6",
            "PolicyStatus": 2,
            "ProductCode": "TBTI",
            "ProductElementCode": "TBTI",
            "ProductElementId": 351925023,
            "ProductId": 351925022,
            "ProductLobId": 351925023,
            "SequenceNumber": 1,
            "TechProductCode": "TR_POC",
            "TechProductId": 3516410623456,
            "TempData": {},
            "PolicyRiskList": [
                {
                    "@pk": 10854350225,
                    "@type": "PolicyRisk-R10007",
                    "BusinessObjectId": 351861075,
                    "ParentElementType": "POLICY_LOB",
                    "ParentPolicyElementId": 10854350224,
                    "PolicyElementId": 10854350225,
                    "PolicyId": "10854350221,32AFA952E6D0E145B6D3EFBEF7CE98C6",
                    "PolicyStatus": 2,
                    "ProductElementCode": "R10007",
                    "ProductElementId": 351926021,
                    "RiskName": "InsuredName",
                    "SequenceNumber": 1,
                    "TempData": {
                        "Mask-IdNo": "Jmf1vghdrScrTdpdeyKu7w==",
                        "IdNo": "Jmf1vghdrScrTdpdeyKu7w==",
                        "MaskAfter-IdNo": "IdNo"
                    },
                    "CustomerName": "Customer",
                    "DateOfBirth": "1988-10-01",
                    "IdNo": "IdNo",
                    "IdType": "1",
                    "PolicyCoverageList": [
                        {
                            "@pk": 10854350226,
                            "@type": "PolicyCoverage-PolicyCoverage",
                            "BusinessObjectId": 351861078,
                            "IsFinalLevelCt": "Y",
                            "ParentElementType": "INSURED",
                            "ParentPolicyElementId": 10854350225,
                            "PolicyElementId": 10854350226,
                            "PolicyId": "10854350221,32AFA952E6D0E145B6D3EFBEF7CE98C6",
                            "PolicyStatus": 2,
                            "ProductElementCode": "C100416",
                            "ProductElementId": 351926024,
                            "SequenceNumber": 1,
                            "SumInsured": 300000,
                            "TempData": {},
                            "IsFinalLevelCt_CodeDesc": "Yes",
                            "PolicyStatus_CodeDesc": "Effective"
                        },
                         .....skip....
                    ],
                    "PolicyStatus_CodeDesc": "Effective"
                }
            ],
            "PolicyStatus_CodeDesc": "Effective",
            "TotalInsuredCount": 1
        }
    ],
    "PolicyStatus_CodeDesc": "Not Effective",
    "PolicyType_CodeDesc": "Single Policy",
    "PremiumCurrencyCode_CodeDesc": "USD",
    "ProposalStatus_CodeDesc": "Entry"
}
```
#### /pa/v1/getPolicyAtFirstEffectiveVersion

To get the policy after first issuerance.

* Sample Response
```
{
    "AdjustedPremium": 680.4,
    "AgentCode": "XXXXX0001047XXXXX",
    "AnnualPremium": 630,
    "BeforeVatPremium": 630,
    "BookCurrencyCode": "USD",
    "BookCurrencyCode_CodeDesc": "USD",
    "BusinessCateCode": "1",
    "BusinessCateCode_CodeDesc": "Direct issuance",
    "BusinessObjectId": 3517051304219,
    "Commission": 63,
    "CommissionRate": 0.1,
    "DuePremium": 680.4,
    "EffectiveDate": "2021-04-22",
    "ExpiryDate": "2022-04-21T23:59:59",
    "FirstDataEntryDate": "2024-09-24T11:33:33",
    "GrossPremium": 680.4,
    "InterestRate": 0.05,
    "IsPremiumCalcSuccess": "Y",
    "IsPremiumCalcSuccess_CodeDesc": "Yes",
    "IsRenewable": "Y",
    "IsRenewable_CodeDesc": "Yes",
    "IsTakeUpPolicy": "N",
    "IsTakeUpPolicy_CodeDesc": "No",
    "IssueDate": "2024-09-24T11:34:04",
    "IssueUserId": XXXXX0010XXXXX,
    "IssueUserRealName": "xxxxxx.xxxx@insuremo.com",
    "IssueUserStaffCode": "PTY10000047304001",
    "LocalCurrencyCode": "USD",
    "LocalCurrencyCode_CodeDesc": "USD",
    "OrgCode": "10002",
    "OrgCode_CodeDesc": "Brazil Branch",
    "POIRate": 1,
    "PolicyElementId": 10854350221,
    "PolicyId": "10854350221,32AFA952E6D0E145B6D3EFBEF7CE98C6",
    "PolicyLobList": [
        {
            "AdjustedPremium": 680.4,
            "BeforeVatPremium": 630,
            "BusinessObjectId": 351861068,
            "DuePremium": 680.4,
            "GrossPremium": 680.4,
            "ParentElementType": "POLICY",
            "ParentPolicyElementId": 10854350221,
            "PolicyElementId": 10854350224,
            "PolicyId": "10854350221,32AFA952E6D0E145B6D3EFBEF7CE98C6",
            "PolicyRiskList": [
                {
                    "AdjustedPremium": 680.4,
                    "Age": 32,
                    "BeforeVatPremium": 630,
                    "BusinessObjectId": 351861075,
                    "CustomerName": "Customer",
                    "DateOfBirth": "1988-10-01",
                    "DuePremium": 680.4,
                    "GrossPremium": 680.4,
                    "IdNo": "IdNo",
                    "IdType": "1",
                    "ParentElementType": "POLICY_LOB",
                    "ParentPolicyElementId": 10854350224,
                    "PolicyCoverageList": [
                        {
                            "AdjustedPremium": 648,
                            "AnnualPremium": 600,
                            "BeforeVatPremium": 600,
                            "BusinessObjectId": 351861078,
                            "CoverageName": "Accident Death & Dismemberment",
                            "DuePremium": 648,
                            "GrossPremium": 648,
                            "IsFinalLevelCt": "N",
                            "IsFinalLevelCt_CodeDesc": "No",
                            "ParentElementType": "INSURED",
                            "ParentPolicyElementId": 10854350225,
                            "PolicyElementId": 10854350226,
                            "PolicyId": "10854350221,32AFA952E6D0E145B6D3EFBEF7CE98C6",
                            "PolicyStatus": 2,
                            "PolicyStatus_CodeDesc": "Effective",
                            "ProductElementCode": "C100416",
                            "ProductElementId": 351926024,
                            "SequenceNumber": 1,
                            "SumInsured": 300000,
                            "TempData": {},
                            "Vat": 48
                        },
                         .....skip....
                    ],
                    "PolicyElementId": 10854350225,
                    "PolicyId": "10854350221,32AFA952E6D0E145B6D3EFBEF7CE98C6",
                    "PolicyStatus": 2,
                    "PolicyStatus_CodeDesc": "Effective",
                    "ProductElementCode": "R10007",
                    "ProductElementId": 351926021,
                    "RiskName": "InsuredName",
                    "SequenceNumber": 1,
                    "SumInsured": 900000,
                    "TempData": {
                        "Mask-IdNo": "Jmf1vghdrScrTdpdeyKu7w==",
                        "IdNo": "Jmf1vghdrScrTdpdeyKu7w==",
                        "MaskAfter-IdNo": "IdNo"
                    },
                    "Vat": 50.4
                }
            ],
            "PolicyStatus": 2,
            "PolicyStatus_CodeDesc": "Effective",
            "ProductCode": "TBTI",
            "ProductElementCode": "TBTI",
            "ProductElementId": 351925023,
            "ProductId": 351925022,
            "ProductLobId": 351925023,
            "SequenceNumber": 1,
            "SumInsured": 900000,
            "TechProductCode": "TR_POC",
            "TechProductId": 3516410623456,
            "TempData": {},
            "TotalInsuredCount": 1,
            "Vat": 50.4
        }
    ],
    "PolicyNo": "POTBTI01245893",
    "PolicyStatus": 2,
    "PolicyStatus_CodeDesc": "Effective",
    "PolicyType": "1",
    "PolicyType_CodeDesc": "Single Policy",
    "PremCalcFactorHash": "20240924_113344_934,kc2QXjkMBHIbdVxCTsomiUWJ17a/n/PlMqaq696Od/k=",
    "PremCalcResultHash": "20240924_113344_939,FJSJZsNM+3yHF/Q9vYEnh/F0p4x/vkTnGdEUzVMtY+c=",
    "PremiumBookExchangeRate": 1,
    "PremiumCurrencyCode": "USD",
    "PremiumCurrencyCode_CodeDesc": "USD",
    "PremiumInterest": 31.5,
    "PremiumLocalExchangeRate": 1,
    "ProductCode": "TBTI",
    "ProductId": 351925022,
    "ProductVersion": "1.0",
    "ProposalDate": "2021-04-22",
    "ProposalNo": "PABTBTI0001326297",
    "ProposalStatus": "3",
    "ProposalStatus_CodeDesc": "Issued",
    "QuotationDate": "2024-09-24T11:33:34",
    "SchemaVersion": 2,
    "SumInsured": 900000,
    "TaxInterest": 2.52,
    "TechProductCode": "TR_POC",
    "TechProductId": 3516410623456,
    "TempData": {},
    "TotalInterest": 34.02,
    "TotalPremium": 714.42,
    "Vat": 50.4,
    "VatRate": 0.08,
    "VersionSeq": 3
}
```

#### /pa/core/policy/v1/loadPolicyAtEffectiveDate

To get the policy effective at a required date.

* Sample Response

```
the policy json
```


## Policy Export API

### Policy Export - Business Usage

* Export policy via Excel.
* Support different output columns and search criteria.

### Policy Export - API Path

* Real Time - Suitable for small number of records with rigid export query condition
    * {{server}}/proposal/core/proposal/v1/exportPolicy
    
* Async - - Suitable for big number of records with loose export query condition
    * {{server}}/proposal/core/proposal/v1/asyncExport 
    * {{server}}/pa/v1/attachExportFile


### Policy Export - What You Can Extend

* Extend search criteria by adding new search fields.
* Extract sample reports in Excel format.

### Policy Export - Configuration Search Index

It will share the same index configuration approach as policy query API.


### Policy Export - API Sample

| Attribute     | Description |
| ------------- | ------------------------------------------- |
| name          | Index Field Name                            |
| label         | Excel column header                         |
| codeTable     | Code-table name bound to the field          |
| datePattern   | Date format mask for Excel export           |
| numberPattern | Number format mask for Excel export         |


#### /proposal/core/proposal/v1/exportPolicy

Before calling the API, users can also try using embedded UI in the platform for querying. For more details, see [platform query guide](https://docs.insuremo.com/gi_insurance_service/statistics#paas-query).


* Sample Request

```
{
    "columList": [
        {
            "name": "PolicyNo",
            "label": "Policy No Test"
        },
        {
            "name": "ProposalNo",
            "label": "Proposal No Test"
        },
        {
            "name": "PolicyHolder",
            "label": "Customer Test"
        },
        {
            "name": "ProposalStatus",
            "label": "Proposal Status Test",
            "codeTable": "ProposalStatus"
        },
        {
            "name": "ProductCode",
            "label": "Product Code Test",
            "codeTable": "Products"
        },
        {
            "name": "PolicyStatus",
            "label": "Policy Status Test",
            "codeTable": "PolicyStatus"
        },
        {
            "name": "EffectiveDate",
            "label": "Policy Effective Date Test",
            "datePattern": "YYYY-MM-DD HH:mm:ss"
        },
        {
            "name": "ExpiryDate",
            "label": "Policy Expiry Date Test",
            "datePattern": "YYYY-MM-DD HH:mm:ss"
        },
        {
            "name": "DuePremium",
            "label": "DuePremiumTest",
            "numberPattern": "$#,##0.00"
        }
    ],
    "conditions": {
        "OrgCode": "10006",
        "IsFullOrg": false,
        "ProposalStatus": 3
    },
    "fromRangeConditions": {},
    "toRangeConditions": {},
    "fuzzyConditions": {}
}
```

* Sample Response with Excel file

 The file generated will be downloaded.


#### /proposal/core/proposal/v1/asyncExport 

* Sample Request
 
```
{
    "columList": [
        {
            "name": "PolicyNo",
            "label": "Policy No Test"
        },
        {
            "name": "ProposalNo",
            "label": "Proposal No Test"
        },
        {
            "name": "PolicyHolder",
            "label": "Customer Test"
        },
        {
            "name": "ProposalStatus",
            "label": "Proposal Status Test",
            "codeTable": "ProposalStatus"
        },
        {
            "name": "PolicyType",
            "label": "Policy Type Test",
            "codeTable": "PolicyType"
        },
        {
            "name": "ProductCode",
            "label": "Product Code Test",
            "codeTable": "Products"
        },
        {
            "name": "PolicyStatus",
            "label": "Policy Status Test",
            "codeTable": "PolicyStatus"
        },
        {
            "name": "DuePremium",
            "label": "DuePremiumTest",
            "numberPattern": "$#,##0.00"
        }
    ],
    "conditions": {
        "FullOrgCode.multiLineExact": "10001",
        "ProposalStatus": 4
    },
    "fromRangeConditions": {},
    "toRangeConditions": {},
    "fuzzyConditions": {},
    "orFuzzyConditions": {},
    "indexName": "Policy"
}
```

* Sample Response with Job Execution Id

You can fined the batch-**policyExportDataBatch** execution history with Job Execution Id returned.
If the job is finished, you can call the /pa/v1/attachExportFile to download the file.

 ```
 10594120002
 
 ```
 
 
#### /pa/v1/attachExportFile

* Sample Request

``` 
{
    "uniqueId": "policy-batch/Instance/{{job execution date}}/{{exeid}}.xls"
}
```
For example, 

```
{
    "uniqueId": "policy-batch/Instance/20240710/10594120002.xls"
}
```

* Sample Response with batch execution id 
  The file generated will be downloaded.

#### /endo/v1/exportEndo

* Sample Request

```
{
    "columList": [
        {
            "name": "EffectiveDate",
            "label": "Policy Effective Date Test",
            "datePattern": "YYYY-MM-DD HH:mm:ss"
        },
        {
            "name": "EndoEffectiveDate",
            "label": "Endorsement Effective Date Test",
            "datePattern": "YYYY-MM-DD HH:mm:ss"
        },
        {
            "name": "EndoNo",
            "label": "Endo No Test"
        },
        {
            "name": "EndoStatus",
            "label": "Endo Status Test",
            "codeTable": "EndorsementStatus"
        },
        {
            "name": "EndoType",
            "label": "Endo Type Test",
            "codeTable": "EndorsementType"
        },
        {
            "name": "ExpiryDate",
            "label": "Expiry Date Test",
            "datePattern": "YYYY-MM-DD HH:mm:ss"
        },
        {
            "name": "MasterPolicyNo",
            "label": "Master Policy No Test"
        },
        {
            "name": "ProductCode",
            "label": "Product Code Test",
            "codeTable": "Products"
        },
        {
            "name": "DuePremium",
            "label": "DuePremiumTest",
            "numberPattern": "$#,##0.00"
        }
    ],
    "conditions": {},
    "fromRangeConditions": {},
    "toRangeConditions": {},
    "fuzzyConditions": {}
}
```

* Sample Response with Excel file

 The file generated will be downloaded.


#### /endo/v1/asyncExport

* Sample Request
 
```
{
    "columList": [
        {
            "name": "EffectiveDate",
            "label": "Policy Effective Date Test",
            "datePattern": "YYYY-MM-DD HH:mm:ss"
        },
        {
            "name": "EndoEffectiveDate",
            "label": "Endorsement Effective Date Test",
            "datePattern": "YYYY-MM-DD HH:mm:ss"
        },
        {
            "name": "EndoNo",
            "label": "Endo No Test"
        },
        {
            "name": "EndoStatus",
            "label": "Endo Status Test",
            "codeTable": "EndorsementStatus"
        },
        {
            "name": "EndoType",
            "label": "Endo Type Test",
            "codeTable": "EndorsementType"
        },
        {
            "name": "ExpiryDate",
            "label": "Expiry Date Test",
            "datePattern": "YYYY-MM-DD HH:mm:ss"
        },
        {
            "name": "MasterPolicyNo",
            "label": "Master Policy No Test"
        },
        {
            "name": "PolicyHolder",
            "label": "Name (Customer) Test"
        },
        {
            "name": "PolicyNo",
            "label": "Policy No Test"
        },
        {
            "name": "PolicyType",
            "label": "Policy Type Test",
            "codeTable": "PolicyType"
        },
        {
            "name": "DuePremium",
            "label": "DuePremiumTest",
            "numberPattern": "$#,##0.00"
        }
    ],
    "conditions": {
        "FullOrgCode.multiLineExact": "10001",
        "EndoStatus": "130"
    },
    "fromRangeConditions": {},
    "toRangeConditions": {},
    "fuzzyConditions": {},
    "orFuzzyConditions": {},
    "indexName": "Endorsement"
}
```

* Sample Response with Job Execution Id

You can fined the batch-**policyExportDataBatch** execution history with Job Execution Id returned.
If the job is finished, you can call the /pa/v1/attachExportFile to download the file.



## Policy Migration API

### Policy Migration API - Business Usage

In some cases, we need to migrate policy data from legacy system into InsureMO. There are several characteristics in such scenarios:

* There's no need to do any data validation or premium calculation
* Keep old system Ids rather than generate new ones
* Large amount of values to be migrated and need performance friendly

Now we have data migration API to support such scenarios. Before calling this API, please evaluate your migrated policy Ids and contact InsureMO support team to analyze:

* Whether there could be any Id conflict
* Whether there's any performance issue

Now only effective policy and endorsement with all status are supported. We don't support migration of pending proposal so far.

### Policy Migration API - API Path

* /proposal/core/policyMigration/v1/migratePolicy
* /endo/core/endoMigration/v1/migrateEndorsement

### Policy Migration API - API Sample




