# Split

A Split is a transaction that will distribute the values from a source account to N destination accounts, as informed by the user, in a given currency.

{% hint style="danger" %}
<mark style="color:red;">The source account must have, as long as its available balance type, a pending balance type to perform this transaction.</mark>
{% endhint %}

## Parameters <a href="#parameters" id="parameters"></a>

The user must inform the parameters:

| Parameter                     | Description                                                                                                                                                             |
| ----------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| _transaction\_type_           | The type of the transaction, as mapped in the Execution Rules                                                                                                           |
| _currency_                    | The currency of the transaction                                                                                                                                         |
| _amount_                      | The main amount of the transaction                                                                                                                                      |
| _source\_account\_id_         | The source account ID of the amount to be split                                                                                                                         |
| _source\_balance\_validation_ | Type of validation to be performed on the balance of the source account (see table below)                                                                               |
| _settled\_at_                 | The date for the transaction to be accounted in further reports. If this parameter is not informed, the system will consider the date when the transaction was created. |
| _external\_id_                | User value set for later conciliation                                                                                                                                   |

### Balance Validation <a href="#balance-validation" id="balance-validation"></a>

Balances are validated using the reserved words:

| Value            | Description                                                             |
| ---------------- | ----------------------------------------------------------------------- |
| _positive_       | The system will not allow balances to go below zero during transactions |
| _negative_       | The system will not allow balances to go above zero during transactions |
| _no\_validation_ | The system will not validate balances during transactions               |

### List of destinations <a href="#list-of-destinations" id="list-of-destinations"></a>

The user must enter a list of destinations (account IDs) and the desired values ​​for each. The system will validate whether the sum of the destination values ​​is equal to that entered in the main source value.

## Creating a split <a href="#creating-a-split" id="creating-a-split"></a>

The POST /split method must be used to perform a split.

Example of split creation:

```json
POST /split

{
  "transaction_type": "payment",
  "currency": "brl",
  "amount": 1000,
  "source_account_id": "2874d9c5-e919-8715-b3eb-4ee3440a2fe3",
  "source_balance_validation": "positive",
  "settled_at": "2023-06-01",
  "external_id": "our id 1234",
  "destinations": [
    {
      "account_id": "6bcb1802-f55b-4289-9c23-24a626457d2b",
      "amount": 800
    },
    {
      "account_id": "9d9e085a-14ba-4a11-8a6d-039b0a692c27",
      "amount": 200
    }  
  ],
  "metadata": {
    "key": "value"  
  }
}
```

Response Example:

```json
{
  "id": "96296a5c-0cf4-4025-dbc4-1a53f0a3afc6"
}
```

\
