# Issuing Invoice

The Issuing Invoice resource is used to add funds to your issuing balance.

Generate a Pix invoice (brcode) to receive deposits directly into your issuing wallet.

Once paid, the funds become available in your issuing balance for card spending.

### The Issuing Invoice object

**Attributes**

| Name | Type | Description |
| --- | --- | --- |
| `id` | STRING | Unique identifier for the issuing invoice. |
| `amount` | INTEGER | Invoice amount in cents. Example: 10000 (R$100.00). |
| `taxId` | STRING | Payer CPF (11 digits) or CNPJ (14 digits). |
| `name` | STRING | Payer full name. |
| `tags` | LIST OF STRINGS | Tags associated with the invoice. |
| `metadata` | OBJECT | Free-form map you can attach to the invoice. |
| `status` | STRING | Current invoice status. Options: "created", "paid", "overdue", "expired", "canceled". |
| `brcode` | STRING | Pix brcode string for payment. |
| `due` | STRING | Invoice due datetime. Example: "2022-01-01T00:00:00.000000+00:00". |
| `link` | STRING | Public URL to the invoice payment page. |
| `issuingTransactionId` | STRING | Id of the IssuingTransaction created when the invoice is paid. Null until payment. |
| `created` | STRING | Creation datetime. Example: "2022-01-01T00:00:00.000000+00:00". |
| `updated` | STRING | Last update datetime. Example: "2022-01-01T00:00:00.000000+00:00". |

### Create an Issuing Invoice

`POST /v2/issuing-invoice`

Use this route to create a new issuing invoice to fund your issuing balance.

**Parameters**

| Name | Required | Description |
| --- | --- | --- |
| `amount` | REQUIRED | Amount in cents to be deposited. Example: 10000 (R$100.00). |
| `taxId` | OPTIONAL | Payer CPF or CNPJ. Example: "012.345.678-90". |
| `name` | OPTIONAL | Payer full name. Example: "Tony Stark". |
| `tags` | OPTIONAL | Array of strings to tag the entity for future queries. |
| `metadata` | OPTIONAL | Free-form map you can attach to the invoice. |

**Request**

```python
import starkinfra

invoice = starkinfra.issuinginvoice.create(
    starkinfra.IssuingInvoice(
        amount=10000,
        tax_id="012.345.678-90",
        name="Tony Stark",
        tags=["department: tech"]
    )
)

print(invoice)
```

**Response**

```python
IssuingInvoice(
    id=5715709195239424,
    amount=10000,
    tax_id=012.345.678-90,
    name=Tony Stark,
    tags=['department: tech'],
    metadata={},
    status=created,
    brcode=00020101021226870014br.gov.bcb.pix2565...,
    due=2022-02-10 00:00:00,
    link=https://sandbox.api.starkinfra.com/invoicelink/5715709195239424,
    issuing_transaction_id=None,
    created=2022-01-01 00:00:00,
    updated=2022-01-01 00:00:00
)
```

### List Issuing Invoices

`GET /v2/issuing-invoice`

Get a list of issuing invoices in chunks of at most 100.

**Parameters**

| Name | Required | Description |
| --- | --- | --- |
| `limit` | OPTIONAL | Number of results per cursor. Max = 100. |
| `cursor` | OPTIONAL | String used to get the next batch of results. Our SDKs handle this for you. |
| `after` | OPTIONAL | Filter entities created after this date. |
| `before` | OPTIONAL | Filter entities created before this date. |
| `status` | OPTIONAL | Filter invoices by the specified status. |
| `tags` | OPTIONAL | Filter entities that contain the specified tags. |

**Request**

```python
import starkinfra

invoices = starkinfra.issuinginvoice.query(
    limit=10,
    status="created"
)

for invoice in invoices:
    print(invoice)
```

**Response**

```python
IssuingInvoice(
    id=5715709195239424,
    amount=10000,
    tax_id=012.345.678-90,
    name=Tony Stark,
    tags=['department: tech'],
    metadata={},
    status=created,
    brcode=00020101021226870014br.gov.bcb.pix2565...,
    due=2022-02-10 00:00:00,
    link=https://sandbox.api.starkinfra.com/invoicelink/5715709195239424,
    issuing_transaction_id=None,
    created=2022-01-01 00:00:00,
    updated=2022-01-01 00:00:00
)
```

### Get an Issuing Invoice

`GET /v2/issuing-invoice/:id`

Get a single issuing invoice by its id.

**Parameters**

| Name | Required | Description |
| --- | --- | --- |
| `id` | REQUIRED | Id of the issuing invoice entity. |

**Request**

```python
import starkinfra

invoice = starkinfra.issuinginvoice.get("5715709195239424")

print(invoice)
```

**Response**

```python
IssuingInvoice(
    id=5715709195239424,
    amount=10000,
    tax_id=012.345.678-90,
    name=Tony Stark,
    tags=['department: tech'],
    metadata={},
    status=created,
    brcode=00020101021226870014br.gov.bcb.pix2565...,
    due=2022-02-10 00:00:00,
    link=https://sandbox.api.starkinfra.com/invoicelink/5715709195239424,
    issuing_transaction_id=None,
    created=2022-01-01 00:00:00,
    updated=2022-01-01 00:00:00
)
```

### List Issuing Invoice Logs

`GET /v2/issuing-invoice/log`

Get a paged list of issuing invoice logs.

**Parameters**

| Name | Required | Description |
| --- | --- | --- |
| `limit` | OPTIONAL | Number of results per cursor. Max = 100. |
| `cursor` | OPTIONAL | String used to get the next batch of results. Our SDKs handle this for you. |
| `after` | OPTIONAL | Filter entities created after this date. |
| `before` | OPTIONAL | Filter entities created before this date. |
| `types` | OPTIONAL | Filter logs by log types. |
| `ids` | OPTIONAL | Array of invoice ids to filter logs. |

**Request**

```python
import starkinfra

logs = starkinfra.issuinginvoice.log.query(
    limit=10,
    types=["paid"]
)

for log in logs:
    print(log)
```

**Response**

```python
Log(
    id=6724771005489152,
    type=paid,
    invoice=IssuingInvoice(id=5715709195239424, amount=10000, status=paid),
    created=2022-01-01 00:00:00
)
```

### Get an Issuing Invoice Log

`GET /v2/issuing-invoice/log/:id`

Get a single issuing invoice log by its id.

**Parameters**

| Name | Required | Description |
| --- | --- | --- |
| `id` | REQUIRED | Id of the log entity. |

**Request**

```python
import starkinfra

log = starkinfra.issuinginvoice.log.get("6724771005489152")

print(log)
```

**Response**

```python
Log(
    id=6724771005489152,
    type=paid,
    invoice=IssuingInvoice(id=5715709195239424, amount=10000, status=paid),
    created=2022-01-01 00:00:00
)
```

## Available Languages

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

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