# Dynamic Brcode

A Dynamic Brcode is a QR Code that returns payment details dynamically from your server when scanned.

The "subscription", "subscriptionAndInstant" and "dueAndOrSubscription" types let a Dynamic Brcode initiate a Pix Automático recurring authorization.

Here we will show you how to create and manage them.

### The Dynamic Brcode Object

**Attributes**

| Name | Type | Description |
| --- | --- | --- |
| `id` | STRING | Unique id for the dynamic Brcode. |
| `name` | STRING | Receiver name displayed in the QR code. |
| `city` | STRING | City of the receiver. |
| `externalId` | STRING | Your internal ID for this Brcode, used to prevent duplicates. |
| `type` | STRING | Type of dynamic Brcode. Options: "instant", "due", "subscription", "subscriptionAndInstant", "dueAndOrSubscription". |
| `tags` | LIST OF STRINGS | Tags associated with the dynamic Brcode. |
| `uuid` | STRING | Unique UUID used to identify this QR code. |
| `url` | STRING | URL for the QR code image. |
| `created` | STRING | Creation datetime. Example: "2020-04-23T23:00:00.000000+00:00". |
| `updated` | STRING | Last update datetime. Example: "2020-04-23T23:00:00.000000+00:00". |

### Create Dynamic Brcodes

`POST /v2/dynamic-brcode`

Create dynamic Pix QR codes that fetch payment details from your server.

You can create up to 100 dynamic Brcodes in a single request.

**Parameters**

| Name | Required | Description |
| --- | --- | --- |
| `city` | REQUIRED | City of the receiver. |
| `externalId` | REQUIRED | Your internal ID used to match payment callbacks and to prevent duplicates. |
| `name` | REQUIRED | Receiver name displayed in the QR code. |
| `type` | OPTIONAL | Type of dynamic Brcode. Options: "instant", "due", "subscription", "subscriptionAndInstant", "dueAndOrSubscription". Defaults to "instant" when omitted. |
| `tags` | OPTIONAL | Array of strings to tag the entity for future queries. |

**Request**

```python
import starkinfra

brcodes = starkinfra.dynamicbrcode.create([
    starkinfra.DynamicBrcode(
        name="Jon Snow",
        city="São Paulo",
        external_id="my-dynamic-brcode-id-1",
        type="subscription",
        tags=["dynamic", "subscription"]
    )
])

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

**Response**

```python
[
    DynamicBrcode(
        id="5656565656565656",
        name="Jon Snow",
        city="São Paulo",
        external_id="my-dynamic-brcode-id-1",
        type="subscription",
        tags=["dynamic", "subscription"],
        uuid="b2c3d4e5-f6a7-8901-bcde-f12345678901",
        url="https://brcode.starkinfra.com/dynamic-qrcode/b2c3d4e5-f6a7-8901-bcde-f12345678901.png",
        created="2022-01-01T00:00:00+00:00",
        updated="2022-01-01T00:00:00+00:00"
    )
]
```

### List Dynamic Brcodes

`GET /v2/dynamic-brcode`

List and filter all dynamic Brcodes. Results are paged.

**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. |
| `externalIds` | OPTIONAL | Filter by external IDs. |
| `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. |
| `tags` | OPTIONAL | Filter entities that contain the specified tags. |
| `uuids` | OPTIONAL | Filter by UUIDs. |

**Request**

```python
import starkinfra

brcodes = starkinfra.dynamicbrcode.query(
    limit=10,
    after="2022-01-01",
    before="2022-12-31",
    tags=["dynamic"]
)

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

**Response**

```python
DynamicBrcode(
    id="5656565656565656",
    name="Jon Snow",
    city="São Paulo",
    external_id="my-dynamic-brcode-id-1",
    type="instant",
    tags=["dynamic"],
    uuid="b2c3d4e5-f6a7-8901-bcde-f12345678901",
    url="https://brcode.starkinfra.com/dynamic-qrcode/b2c3d4e5-f6a7-8901-bcde-f12345678901.png",
    created="2022-01-01T00:00:00+00:00",
    updated="2022-01-01T00:00:00+00:00"
)
```

### 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 dynamic Brcode. |

**Request**

```python
import starkinfra

brcode = starkinfra.dynamicbrcode.get("b2c3d4e5-f6a7-8901-bcde-f12345678901")

print(brcode)
```

**Response**

```python
DynamicBrcode(
    id="5656565656565656",
    name="Jon Snow",
    city="São Paulo",
    external_id="my-dynamic-brcode-id-1",
    type="instant",
    tags=["dynamic", "instant"],
    uuid="b2c3d4e5-f6a7-8901-bcde-f12345678901",
    url="https://brcode.starkinfra.com/dynamic-qrcode/b2c3d4e5-f6a7-8901-bcde-f12345678901.png",
    created="2022-01-01T00:00:00+00:00",
    updated="2022-01-01T00:00: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/dynamic-brcode-python.md)
- [Node.js](https://docs.starkinfra.com/api/v2/dynamic-brcode-node.md)
- [PHP](https://docs.starkinfra.com/api/v2/dynamic-brcode-php.md)
- [Java](https://docs.starkinfra.com/api/v2/dynamic-brcode-java.md)
- [Ruby](https://docs.starkinfra.com/api/v2/dynamic-brcode-ruby.md)
- [Elixir](https://docs.starkinfra.com/api/v2/dynamic-brcode-elixir.md)
- [.NET](https://docs.starkinfra.com/api/v2/dynamic-brcode-dotnet.md)
- [Go](https://docs.starkinfra.com/api/v2/dynamic-brcode-go.md)
- [Clojure](https://docs.starkinfra.com/api/v2/dynamic-brcode-clojure.md)
- [cURL](https://docs.starkinfra.com/api/v2/dynamic-brcode-curl.md)
