# Split

The Split resource is used to split an Invoice or Boleto between different receivers.

### The Split object

**Attributes**

| Name | Type | Description |
| --- | --- | --- |
| `id` | STRING | Unique id for the split. |
| `amount` | INTEGER | Split amount in cents. |
| `created` | STRING | Creation datetime. Example: "2020-04-23T23:00:00.000000+00:00". |
| `externalId` | STRING | Unique external ID for the split. |
| `receiverId` | STRING | ID of the split receiver. |
| `scheduled` | STRING | Scheduled transfer datetime. Example: "2020-04-23T23:00:00.000000+00:00". |
| `source` | STRING | Source of the split. |
| `status` | STRING | Current split status. |
| `tags` | LIST OF STRINGS | Tags associated with the split. |
| `updated` | STRING | Last update datetime. Example: "2020-04-23T23:00:00.000000+00:00". |

### List Splits

`GET /v2/split`

Get a list of Splits in chunks of at most 100. If you need smaller chunks, use the limit parameter.

**Parameters**

| Name | Required | Description |
| --- | --- | --- |
| `after` | OPTIONAL | Filter entities created after this date. |
| `before` | OPTIONAL | Filter entities created before this date. |
| `cursor` | OPTIONAL | String used to get the next batch of results. Our SDKs handle this for you. |
| `fields` | OPTIONAL | List of strings to filter response JSON keys. Not available in the SDKs. |
| `ids` | OPTIONAL | List of strings to get specific entities by ids. |
| `limit` | OPTIONAL | Number of results per cursor. Max = 100. |
| `receiverIds` | OPTIONAL | list of receiver ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']. |
| `status` | OPTIONAL | Filter splits by the specified status. |
| `tags` | OPTIONAL | Filter entities that contain the specified tags. |

**Request**

```python
import starkbank

splits = starkbank.split.query(
    after="2024-01-30",
    before="2024-02-01",
    limit=1
)

for split in splits:
    print(split)
```

**Response**

```python
Split(
    amount=10000,
    created=2024-01-30 16:10:59.874663,
    external_id=invoice/5163468596445184/receiver/5143677177430016,
    id=5745664021495808,
    receiver_id=5143677177430016,
    scheduled=2024-01-30 16:10:59.840821,
    source=invoice/5163468596445184,
    status=created,
    tags=['invoice/5163468596445184'],
    updated=2024-01-30 16:21:03.973723
)
```

### Get a Split

`GET /v2/split/:id`

Get a single Split by its id.

**Parameters**

| Name | Required | Description |
| --- | --- | --- |
| `id` | REQUIRED | Id of the Split entity |
| `fields` | OPTIONAL | List of strings to filter response JSON keys. Not available in the SDKs. |

**Request**

```python
import starkbank

split = starkbank.split.get("5155165527080960")

print(split)
```

**Response**

```python
Split(
    amount=10000,
    created=2024-01-30 16:10:59.874824,
    external_id=invoice/5163468596445184/receiver/5706627130851328,
    id=5155165527080960,
    receiver_id=5706627130851328,
    scheduled=2024-01-30 16:10:59.840821,
    source=invoice/5163468596445184,
    status=created,
    tags=['invoice/5163468596445184'],
    updated=2024-01-30 16:10:59.874829
)
```

### List Split Logs

`GET /v2/split/log`

Get a paged list of Split logs. A log tracks a change in the Split entity according to its life cycle.

**Parameters**

| Name | Required | Description |
| --- | --- | --- |
| `after` | OPTIONAL | Filter entities created after this date. |
| `before` | OPTIONAL | Filter entities created before this date. |
| `cursor` | OPTIONAL | String used to get the next batch of results. Our SDKs handle this for you. |
| `fields` | OPTIONAL | List of strings to filter response JSON keys. Not available in the SDKs. |
| `limit` | OPTIONAL | Number of results per cursor. Max = 100. |
| `splitIds` | OPTIONAL | Array of Split ids that are linked to the logs you desire. |
| `types` | OPTIONAL | Filters logs by log types. |

**Request**

```python
import starkbank

logs = starkbank.split.log.query(
    after="2020-10-01",
    before="2020-10-30"
)
for log in logs:
  print(log)
```

**Response**

```python
Log(
    created=2024-01-30 16:21:03.459601,
    errors=None,
    id=5659211052613632,
    split=Split(
        amount=10000,
        created=2024-01-30 16:10:59.874663,
        external_id=invoice/5163468596445184/receiver/5143677177430016,
        id=5745664021495808,
        receiver_id=5143677177430016,
        scheduled=2024-01-30 16:10:59.840821,
        source=invoice/5163468596445184,
        status=created,
        tags=['invoice/5163468596445184'],
        updated=2024-01-30 16:21:04.002158
    ),
    type=created
)
```

### Get a Split Log

`GET /v2/split/log/:id`

Get a single Split Log by its id.

**Parameters**

| Name | Required | Description |
| --- | --- | --- |
| `id` | REQUIRED | Id of the log entity. |
| `fields` | OPTIONAL | List of strings to filter response JSON keys. Not available in the SDKs. |

**Request**

```python
import starkbank

log = starkbank.split.log.get("5729450050191360")

print(log)
```

**Response**

```python
Log(
    created=2024-01-30 16:21:03.459601,
    errors=None,
    id=5729450050191360,
    split=Split(
        amount=10000,
        created=2024-01-30 16:10:59.874663,
        external_id=invoice/5163468596445184/receiver/5143677177430016,
        id=5745664021495808,
        receiver_id=5143677177430016,
        scheduled=2024-01-30 16:10:59.840821,
        source=invoice/5163468596445184,
        status=success,
        tags=['invoice/5163468596445184'],
        updated=2024-01-30 16:21:04.002158
    ),
    type=success
)
```

## Available Languages

Code samples on this page are in Python. The same content is available with samples in:

- [Python](https://docs.starkbank.com/api/v2/split-python.md)
- [Node.js](https://docs.starkbank.com/api/v2/split-node.md)
- [PHP](https://docs.starkbank.com/api/v2/split-php.md)
- [Java](https://docs.starkbank.com/api/v2/split-java.md)
- [Ruby](https://docs.starkbank.com/api/v2/split-ruby.md)
- [Elixir](https://docs.starkbank.com/api/v2/split-elixir.md)
- [.NET](https://docs.starkbank.com/api/v2/split-dotnet.md)
- [Go](https://docs.starkbank.com/api/v2/split-go.md)
- [Clojure](https://docs.starkbank.com/api/v2/split-clojure.md)
- [cURL](https://docs.starkbank.com/api/v2/split-curl.md)
