# Conversion

This method allows creating one or more documents of conversion between customers’ accounts.

## Params

A document array with the following attributes:

- `UniqueId` — globally unique identifier, required

  An unique ID of the document in the external (caller) system (Guid).

- `DocumentNo` — string

  A document number.

- `SourceAccountNumber` — string

  An account number of a currency to sell.

- `SourceCurrency` — string

  A currency to sell.

- `DestinationAccountNumber` — string

  An account number of a currency to buy.

- `DestinationCurrency` — string

  A currency to buy.

- `Amount` — decimal number

  An amount

- `Rate` — decimal number

  An exchange rate. Should be filled in case of using a conversion rate individually agreed with a Bank.

- `AdditionalInfo` — string

  An additional info. Is not used for transfers in a national currency

- `CheckUniqueId` — boolean

  When `true`, before the document is created it is checked whether a document with the same `UniqueId` has already been created within the last 7 days. If a duplicate is found, no new document is created and result code `702` is returned.

**JSON**

```api
POST api/documents/conversion
Content-Type: application/json
```

```json
[
  {
    "UniqueId": "fdbf64d0-d481-426f-9799-9a6920728e0c",
    "DocumentNo": "sample string 2",
    "SourceAccountNumber": "sample string 3",
    "SourceCurrency": "sample string 4",
    "DestinationAccountNumber": "sample string 5",
    "DestinationCurrency": "sample string 6",
    "Amount": 7.0,
    "Rate": 8.0,
    "AdditionalInfo": "sample string 9"
  },
  {
    "UniqueId": "fdbf64d0-d481-426f-9799-9a6920728e0c",
    "DocumentNo": "sample string 2",
    "SourceAccountNumber": "sample string 3",
    "SourceCurrency": "sample string 4",
    "DestinationAccountNumber": "sample string 5",
    "DestinationCurrency": "sample string 6",
    "Amount": 7.0,
    "Rate": 8.0,
    "AdditionalInfo": "sample string 9"
  }
]
```

**xml**

```api
POST api/documents/conversion
Content-Type: application/xml
```

```xml
<ArrayOfConversionPayment xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/CIBApi.Models">
  <ConversionPayment>
    <AdditionalInfo>sample string 9</AdditionalInfo>
    <Amount>7</Amount>
    <DestinationAccountNumber>sample string 5</DestinationAccountNumber>
    <DestinationCurrency>sample string 6</DestinationCurrency>
    <DocumentNo>sample string 2</DocumentNo>
    <Rate>8</Rate>
    <SourceAccountNumber>sample string 3</SourceAccountNumber>
    <SourceCurrency>sample string 4</SourceCurrency>
    <UniqueId>fdbf64d0-d481-426f-9799-9a6920728e0c</UniqueId>
  </ConversionPayment>
  <ConversionPayment>
    <AdditionalInfo>sample string 9</AdditionalInfo>
    <Amount>7</Amount>
    <DestinationAccountNumber>sample string 5</DestinationAccountNumber>
    <DestinationCurrency>sample string 6</DestinationCurrency>
    <DocumentNo>sample string 2</DocumentNo>
    <Rate>8</Rate>
    <SourceAccountNumber>sample string 3</SourceAccountNumber>
    <SourceCurrency>sample string 4</SourceCurrency>
    <UniqueId>fdbf64d0-d481-426f-9799-9a6920728e0c</UniqueId>
  </ConversionPayment>
</ArrayOfConversionPayment>
```

## Response

- `UniqueId` — globally unique identifier

  An unique ID in the external system (Guid).

- `UniqueKey` — integer

  An unique ID of the document in the business online.

- `ResultCode` — integer

  A result code of an operation. (With a link to the ResultCode page).
  [result code](../result/result-codes.md)

- `Match` — decimal number

  For the internal transfers a matched coefficient of provided recipient name. For legal entities a match of an owner of a provided IBAN to the entity name is being checked, while for the individuals - to the name and surname. A match coefficient in percent will be shown as a result of such a comparison.

**JSON**

```json
[
  {
    "UniqueId": "93fb404b-5f8e-486b-8b35-610d71a41675",
    "UniqueKey": 2,
    "ResultCode": 1,
    "Match": 1.0
  },
  {
    "UniqueId": "93fb404b-5f8e-486b-8b35-610d71a41675",
    "UniqueKey": 2,
    "ResultCode": 1,
    "Match": 1.0
  }
]
```

**xml**

```xml
<ArrayOfDocumentKey xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/CIBApi.Models">
  <DocumentKey>
    <Match>1</Match>
    <ResultCode>1</ResultCode>
    <UniqueId>93fb404b-5f8e-486b-8b35-610d71a41675</UniqueId>
    <UniqueKey>2</UniqueKey>
  </DocumentKey>
  <DocumentKey>
    <Match>1</Match>
    <ResultCode>1</ResultCode>
    <UniqueId>93fb404b-5f8e-486b-8b35-610d71a41675</UniqueId>
    <UniqueKey>2</UniqueKey>
  </DocumentKey>
</ArrayOfDocumentKey>
```
