# Pix QR Code

**Note:**This is a basic Pix QR Code solution for one time payment. For a complete Pix QR Code receivable, check the [Pix Invoice resource](https://docs.starkbank.com/api/v2/invoice.md).

When a Dynamic Brcode is paid, a Deposit is created with the tags parameter containing the string "dynamic-brcode/" followed by the Dynamic Brcode's uuid "dynamic-brcode/{uuid}" for conciliation.

### The Dynamic Brcode object

**Attributes**

| Name | Type | Description |
| --- | --- | --- |
| `id` | STRING | Unique id for the dynamic brcode. |
| `amount` | INTEGER | Amount in cents to be received. Example: 100 (R$1.00). |
| `created` | STRING | Creation datetime. Example: "2020-04-23T23:00:00.000000+00:00". |
| `displayDescription` | STRING | Description shown in the payer bank interface. |
| `expiration` | INTEGER | Time in seconds from creation until expiration. |
| `pictureUrl` | STRING | URL of the dynamic brcode image. |
| `rules` | LIST OF OBJECTS | List of rule objects with key and value. |
| `tags` | LIST OF STRINGS | Tags associated with the dynamic brcode. |
| `updated` | STRING | Last update datetime. Example: "2020-04-23T23:00:00.000000+00:00". |
| `uuid` | STRING | Unique UUID for the dynamic brcode. |

### Create Dynamic Brcodes

`POST /v2/dynamic-brcode`

Use this route to create up to 100 new dynamic brcodes at a time.

**Parameters**

| Name | Required | Description |
| --- | --- | --- |
| `amount` | REQUIRED | A non-negative integer that represents the amount in cents to be received. Example: 100 (R$1.00). |
| `displayDescription` | OPTIONAL | Description to be shown in the payer bank interface. ex: "Payment for service #1234" |
| `expiration` | OPTIONAL | Time in seconds counted from the creation datetime until the brcode expires. After expiration, the brcode cannot be paid anymore. Default value: 3600 (1 hour). |
| `rules` | OPTIONAL | List of rules for modifying dynamic brcode behavior. Example: ``` [{"key": "allowedTaxIds", "value": ["012.345.678-90", "45.059.493/0001-73"]}] ``` |
| `tags` | OPTIONAL | Array of strings to tag the entity for future queries. All tags will be converted to lowercase. |

**Request**

```python
import starkbank

brcodes = starkbank.dynamicbrcode.create([
    starkbank.DynamicBrcode(
        amount=4000,
        expiration=123456789,
        tags=["New sword", "DynamicBrcode #1234"],
        display_description="Payment for service #1234",
        rules=[
            {
                "key": "allowedTaxIds",
                "value": [
                    "012.345.678-90",
                    "45.059.493/0001-73"
                ]
            }
        ],
    )
])

for brcode in brcodes:
    print(brcode)
```

**Response**

```python
DynamicBrcode(
    amount=4000,
    created=2023-02-06 21:15:00.118056,
    expiration=123456789,
    id=00020101021226890014br.gov.bcb.pix2567brcode-h.sandbox.starkinfra.com/v2/80b0688d05934971a6b8ecd86cde69f25204000053039865802BR5925Stark Bank S.A. - Institu6009Sao Paulo62070503***630461C9,
    picture_url=https://sandbox.api.starkbank.com/v2/dynamic-brcode/80b0688d05934971a6b8ecd86cde69f2.png,
    tags=['new sword', 'dynamicbrcode #1234'],
    displayDescription=Payment for service #1234,
    rules=[
        Rule(
            key=allowedTaxIds,
            value=[
                '012.345.678-90',
                '45.059.493/0001-73'
            ]
        )
    ],
    updated=2023-02-06 21:15:00.449696,
    uuid=80b0688d05934971a6b8ecd86cde69f2
)
```

### List Dynamic Brcodes

`GET /v2/dynamic-brcode`

Get a list of brcodes 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. |
| `limit` | OPTIONAL | Number of results per cursor. Max = 100. |
| `tags` | OPTIONAL | Filter entities that contain the specified tags. |
| `uuids` | OPTIONAL | list of uuids to filter retrieved objects. |

**Request**

```python
import starkbank

brcodes = starkbank.dynamicbrcode.query(
    after="2023-02-01",
    before="2023-02-28",
)

for brcode in brcodes:
    print(brcode)
```

**Response**

```python
DynamicBrcode(
    amount=4000,
    created=2023-02-06 21:15:00.118056,
    expiration=123456789,
    id=00020101021226890014br.gov.bcb.pix2567brcode-h.sandbox.starkinfra.com/v2/80b0688d05934971a6b8ecd86cde69f25204000053039865802BR5925Stark Bank S.A. - Institu6009Sao Paulo62070503***630461C9,
    picture_url=https://sandbox.api.starkbank.com/v2/dynamic-brcode/80b0688d05934971a6b8ecd86cde69f2.png,
    tags=['new sword', 'dynamicbrcode #1234'],
    displayDescription=Payment for service #1234,
    rules=[
        Rule(
            key=allowedTaxIds,
            value=[
                '012.345.678-90',
                '45.059.493/0001-73'
            ]
        )
    ],
    updated=2023-02-06 21:15:00.449696,
    uuid=80b0688d05934971a6b8ecd86cde69f2
)
```

### Get a Dynamic Brcode

`GET /v2/dynamic-brcode/:uuid`

Get a single dynamic brcode by its uuid.

**Parameters**

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

**Request**

```python
import starkbank

brcode = starkbank.dynamicbrcode.get("80b0688d05934971a6b8ecd86cde69f2")

print(brcode)
```

**Response**

```python
DynamicBrcode(
    amount=4000,
    created=2023-02-06 21:15:00.118056,
    expiration=123456789,
    id=00020101021226890014br.gov.bcb.pix2567brcode-h.sandbox.starkinfra.com/v2/80b0688d05934971a6b8ecd86cde69f25204000053039865802BR5925Stark Bank S.A. - Institu6009Sao Paulo62070503***630461C9,
    picture_url=https://sandbox.api.starkbank.com/v2/dynamic-brcode/80b0688d05934971a6b8ecd86cde69f2.png,
    tags=['new sword', 'dynamicbrcode #1234'],
    displayDescription=Payment for service #1234,
    rules=[
        Rule(
            key=allowedTaxIds,
            value=[
                '012.345.678-90',
                '45.059.493/0001-73'
            ]
        )
    ],
    updated=2023-02-06 21:15:00.449696,
    uuid=80b0688d05934971a6b8ecd86cde69f2
)
```

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