# Split Receiver

You can create a Receiver to an Invoice or Boleto split by using the Split Receiver resource.

### The Split Receiver object

**Attributes**

| Name | Type | Description |
| --- | --- | --- |
| `id` | STRING | Unique id for the split receiver. |
| `accountNumber` | STRING | Receiver bank account number. |
| `accountType` | STRING | Receiver bank account type. Options: "checking", "savings", "salary", "payment". |
| `bankCode` | STRING | Receiver bank code or ISPB. |
| `branchCode` | STRING | Receiver bank account branch. |
| `created` | STRING | Creation datetime. Example: "2020-04-23T23:00:00.000000+00:00". |
| `name` | STRING | Receiver full name. |
| `status` | STRING | Current split receiver status. |
| `tags` | LIST OF STRINGS | Tags associated with the split receiver. |
| `taxId` | STRING | Receiver CPF or CNPJ. |
| `updated` | STRING | Last update datetime. Example: "2020-04-23T23:00:00.000000+00:00". |

### Create Split Receiver

`POST /v2/split-receiver`

Send a list of Split Receiver objects for creation in the Stark Bank API

**Parameters**

| Name | Required | Description |
| --- | --- | --- |
| `accountNumber` | REQUIRED | receiver bank account number. Use '-' before the verifier digit. ex: '876543-2' |
| `accountType` | REQUIRED | Receiver bank account type. This parameter only has effect on Pix SplitReceivers. ex: 'checking', 'savings', 'salary' or 'payment' |
| `bankCode` | REQUIRED | Code of the receiver bank institution in Brazil. If an ISPB (8 digits) is informed, a PIX splitReceiver will be created, else a Ted will be issued. ex: '20018183' or '341' |
| `branchCode` | REQUIRED | Receiver bank account branch. Use '-' in case there is a verifier digit. ex: '1357-9' |
| `name` | REQUIRED | Receiver full name. ex: 'Anthony Edward Stark' |
| `taxId` | REQUIRED | Receiver account tax ID (CPF or CNPJ) with or without formatting. ex: '01234567890' or '20.018.183/0001-80' |
| `tags` | OPTIONAL | list of strings for reference when searching for receivers. ex: ['seller/123456'] |

**Request**

```python
import starkbank

receiver = starkbank.splitreceiver.create(
      receiver=starkbank.SplitReceiver(
        name="Daenerys Targaryen Stormborn",
        tax_id="594.739.480-42",
        bank_code="665",
        branch_code="2201",
        account_number="76543-8",
        account_type="salary"
    )
)

print(receiver)
```

**Response**

```python
SplitReceiver(
    account_number=76543-8,
    account_type=salary,
    bank_code=665,
    branch_code=2201,
    created=2024-01-30 20:17:12.586145,
    id=5710191014182912,
    name=Daenerys Targaryen Stormborn,
    status=created,
    tags=[],
    tax_id=594.739.480-42,
    updated=2024-01-30 20:17:12.586152
)
```

### List Split Receivers

`GET /v2/split-receiver`

Get a list of Split Receivers 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 split receivers by the specified status. |
| `tags` | OPTIONAL | Filter entities that contain the specified tags. |
| `taxIds` | OPTIONAL | List of up to 100 tax IDs (CPF or CNPJ) to filter retrieved splitReceivers. Example: ["012.345.678-90", "45.059.493/0001-73"]. |

**Request**

```python
import starkbank

receivers = starkbank.splitreceiver.query(limit=1)

for receiver in receivers:
    print(receiver)
```

**Response**

```python
SplitReceiver(
    account_number=73068305-0,
    account_type=salary,
    bank_code=18236120,
    branch_code=250,
    created=2024-01-30 20:17:12.586344,
    id=5147241060761600,
    name=Lucille Jette,
    status=created,
    tags=[],
    tax_id=949.887.518-99,
    updated=2024-01-30 20:17:13.685002
)
```

### Get a Split Receiver

`GET /v2/split-receiver/:id`

Retrieve a single Split Receiver object previously created in the Stark Bank API by its id.

**Parameters**

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

**Request**

```python
import starkbank

receiver = starkbank.splitreceiver.get("5155165527080960")

print(receiver)
```

**Response**

```python
SplitReceiver(
    account_number=73068305-0,
    account_type=salary,
    bank_code=18236120,
    branch_code=250,
    created=2024-01-30 20:17:12.586344,
    id=5155165527080960,
    name=Lucille Jette,
    status=created,
    tags=[],
    tax_id=949.887.518-99,
    updated=2024-01-30 20:17:13.685002
)
```

### List Split Receiver Logs

`GET /v2/split-receiver/log`

Get a paged list of Split Receiver logs. A log tracks a change in the Split Receiver 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. |
| `receiverIds` | OPTIONAL | List of Split Receiver ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']. |
| `types` | OPTIONAL | filter retrieved objects by event types. ex: 'processing' or 'success' |

**Request**

```python
import starkbank

log = starkbank.splitreceiver.log.get(
    after="2024-10-30",
    before="2024-10-01"
)

print(log)
```

**Response**

```python
Log(
    created=2024-01-30 20:17:12.611535,
    errors=None,
    id=4865766084050944,
    receiver=SplitReceiver(
        account_number=73068305-0,
        account_type=salary,
        bank_code=18236120,
        branch_code=250,
        created=2024-01-30 20:17:12.586344,
        id=5147241060761600,
        name=Lucille Jette,
        status=created,
        tags=[],
        tax_id=949.887.518-99,
        updated=2024-01-30 20:17:13.712424
    ),
    type=created
)
```

### Get a Split Receiver Log

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

Get a single Split Receiver 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.splitreceiver.log.get("5155165527080960")

print(log)
```

**Response**

```python
Log(
    created=2024-01-30 20:17:12.611535,
    errors=None,
    id=5155165527080960,
    receiver=SplitReceiver(
        account_number=73068305-0,
        account_type=salary,
        bank_code=18236120,
        branch_code=250,
        created=2024-01-30 20:17:12.586344,
        id=5147241060761600,
        name=Lucille Jette,
        status=created,
        tags=[],
        tax_id=949.887.518-99,
        updated=2024-01-30 20:17:13.712424
    ),
    type=created
)
```

## 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-receiver-python.md)
- [Node.js](https://docs.starkbank.com/api/v2/split-receiver-node.md)
- [PHP](https://docs.starkbank.com/api/v2/split-receiver-php.md)
- [Java](https://docs.starkbank.com/api/v2/split-receiver-java.md)
- [Ruby](https://docs.starkbank.com/api/v2/split-receiver-ruby.md)
- [Elixir](https://docs.starkbank.com/api/v2/split-receiver-elixir.md)
- [.NET](https://docs.starkbank.com/api/v2/split-receiver-dotnet.md)
- [Go](https://docs.starkbank.com/api/v2/split-receiver-go.md)
- [Clojure](https://docs.starkbank.com/api/v2/split-receiver-clojure.md)
- [cURL](https://docs.starkbank.com/api/v2/split-receiver-curl.md)
