# Brcode Preview

A Brcode Preview allows you to fetch the information encoded in a QR code before initiating a Pix payment or accepting a Pix Subscription.

Here we will show you how to retrieve Brcode previews.

### The Brcode Preview Object

**Attributes**

| Name | Type | Description |
| --- | --- | --- |
| `id` | STRING | QR code content (the EMV string from the QR code). |
| `payerId` | STRING | CPF or CNPJ of the payer. |
| `endToEndId` | STRING | Unique end-to-end ID of the Pix transaction associated with this preview. |
| `status` | STRING | Status of the QR code. Options: "created", "overdue", "paid", "voided", "canceled", "expired". |
| `name` | STRING | Receiver name. |
| `taxId` | STRING | CPF or CNPJ of the receiver. |
| `bankCode` | STRING | Bank ISPB code of the receiver. |
| `branchCode` | STRING | Branch code of the receiver's account. |
| `accountNumber` | STRING | Account number of the receiver. |
| `accountType` | STRING | Account type of the receiver. |
| `senderFinalName` | STRING | Full name of the final sender (The debtor). |
| `senderFinalTaxId` | STRING | CPF or CNPJ of the final sender (The debtor). |
| `amount` | INTEGER | Amount in cents to be paid. If 0, the BR Code accepts any value. |
| `nominalAmount` | INTEGER | Nominal amount in cents before discounts, fines and interest. |
| `amountType` | STRING | Type of amount. If the amount type is "custom" the BR Code's amount can be changed by the sender at the moment of payment. Options: "fixed", "custom". |
| `reconciliationId` | STRING | Reconciliation ID from the QR code. A dynamic BR Code carries 26 to 35 alphanumeric characters here; a static one carries up to 25. |
| `description` | STRING | Description of the payment. |
| `cashierType` | STRING | Cashier type for Pix Saque/Troco. Options: "merchant", "other", "participant". |
| `cashierBankCode` | STRING | Bank ISPB code of the cashier. |
| `cashAmount` | INTEGER | Cash amount in cents for Pix Saque/Troco. |
| `discountAmount` | INTEGER | Discount amount in cents. |
| `fineAmount` | INTEGER | Fine amount in cents for late payment. |
| `interestAmount` | INTEGER | Interest amount in cents for late payment. |
| `reductionAmount` | INTEGER | Reduction (abatement) amount in cents. |
| `due` | STRING | Due date and time for payment of the dynamic QR code. Example: "2020-04-23T23:00:00.000000+00:00". |
| `expired` | STRING | Date and time after which the dynamic QR code is considered expired. Example: "2020-04-23T23:00:00.000000+00:00". |
| `keyId` | STRING | Pix key of the receiver. |
| `data` | LIST OF OBJECTS | List of additional data objects with key and value. |
| `scheduled` | STRING | Date and time the payment is scheduled for. Example: "2020-04-23T23:00:00.000000+00:00". |
| `jws` | STRING | JWS (JSON Web Signature) of the dynamic QR code. Returned only when "jws" is passed in the expand query parameter. |
| `subscription.amount` | INTEGER | Fixed amount in cents to be pulled on each cycle. Returns 0 when the receiver registered no fixed amount and the amount of each pull is variable. Example: 1000 (R$10.00). |
| `subscription.amountMinLimit` | INTEGER | Minimum amount in cents the receiver accepts on a pull of a variable-amount subscription. Returns 0 when no minimum was registered. Example: 500 (R$5.00). |
| `subscription.bacenId` | STRING | Central Bank's unique id for the recurring authorization. Example: "RR20220101200181830000000000001". |
| `subscription.created` | STRING | Datetime when the recurring authorization was created at the Central Bank. Example: "2022-01-01T10:00:00+00:00". |
| `subscription.description` | STRING | Description of the recurring authorization, presented to the payer. Returns an empty string when the receiver registered none. Example: "Streaming subscription". |
| `subscription.installmentEnd` | STRING | Last instant at which a pull of this subscription is allowed. The Central Bank registers a date, and the API returns its last microsecond in São Paulo time, converted to UTC. Returns an empty string when the authorization has no end date. Example: "2023-01-02T02:59:59.999999+00:00" for a subscription registered to end on 2023-01-01. |
| `subscription.installmentStart` | STRING | Instant from which a pull of this subscription is allowed, built from the registered start date the same way as **subscription.installmentEnd**. Example: "2022-01-02T02:59:59.999999+00:00" for a subscription registered to start on 2022-01-01. |
| `subscription.interval` | STRING | Interval between two pulls of this subscription. Options: "week", "month", "quarter", "semester", "year". |
| `subscription.pullRetryLimit` | INTEGER | Number of retries the receiver may attempt for a failed pull. Options: 0 (retries not allowed) or 3 (up to 3 retries inside 7 days). |
| `subscription.receiverBankCode` | STRING | Bank ISPB code of the receiver of the recurring authorization. Example: "20018183". |
| `subscription.receiverName` | STRING | Name of the receiver of the recurring authorization. Example: "Stark Bank S.A.". |
| `subscription.receiverTaxId` | STRING | CNPJ of the receiver of the recurring authorization, returned exactly as registered at the Central Bank and therefore usually unformatted. Example: "20018183000180". |
| `subscription.referenceCode` | STRING | Code the receiver uses to identify the contract behind the subscription. Example: "contract-12345". |
| `subscription.senderFinalName` | STRING | Name of the final payer of the recurring authorization. Returns an empty string when the authorization registers no final payer. Example: "Jon Snow". |
| `subscription.senderFinalTaxId` | STRING | CPF or CNPJ of the final payer, returned exactly as registered at the Central Bank and therefore usually unformatted. Returns an empty string when the authorization registers no final payer. Example: "01234567890". |
| `subscription.status` | STRING | Status of the recurring authorization, read from its latest update at the Central Bank. Options: "created", "approved", "denied", "expired", "canceled". |
| `subscription.type` | STRING | How this BR Code combines payment and recurring authorization. Options: "qrcode" (authorization only, no payment data), "qrcodeAndPayment" (immediate payment plus authorization), "paymentAndOrQrcode" (static or due BR Code plus authorization). |
| `subscription.updated` | STRING | Datetime of the latest update of the recurring authorization at the Central Bank. Example: "2022-01-01T10:05:00+00:00". |

### Create Brcode Previews

`POST /v2/brcode-preview`

Fetch and preview the details of one or more Pix QR codes before payment.

You can preview up to 100 Brcodes in a single request.

**Parameters**

| Name | Required | Description |
| --- | --- | --- |
| `id` | REQUIRED | QR code content (the EMV string from the QR code). |
| `payerId` | REQUIRED | CPF or CNPJ of the payer for dynamic QR codes. |
| `scheduled` | OPTIONAL | Date the payment is scheduled to be processed. This affects the preview values for due dynamic QR codes. Example: "2022-01-31". |
| `endToEndId` | OPTIONAL | Unique end-to-end ID of the Pix transaction associated with this preview. One will be generated if none is provided. |
| `cityCode` | OPTIONAL | IBGE city code of the payer, with 7 digits. Example: "5300108". |
| `expand` | OPTIONAL | Entity fields to expand in the response. Options: "jws". |

**Request**

```python
import starkinfra

previews = starkinfra.brcodepreview.create([
    starkinfra.BrcodePreview(
        id="00020126580014br.gov.bcb.pix0136a629532e-7693-4846-852d-1bbff817b5a8520400005303986540510.005802BR5905Stark6009Sao Paulo62070503***63041D3D",
        payer_id="012.345.678-90",
        end_to_end_id="E20018183202201201450u34sDGd19lz",
        scheduled="2022-01-31"
    )
])

for preview in previews:
    print(preview)
```

**Response**

```python
[
    BrcodePreview(
        id="00020126580014br.gov.bcb.pix0136a629532e-7693-4846-852d-1bbff817b5a8520400005303986540510.005802BR5905Stark6009Sao Paulo62070503***63041D3D",
        payer_id="012.345.678-90",
        end_to_end_id="E20018183202201201450u34sDGd19lz",
        status="active",
        name="Jon Snow",
        tax_id="012.345.678-90",
        bank_code="20018183",
        branch_code="0001",
        account_number="10000-0",
        account_type="checking",
        amount=1000,
        nominal_amount=1000,
        amount_type="fixed",
        reconciliation_id="my-reconciliation-id",
        description="Payment for services",
        cashier_type="merchant",
        cashier_bank_code="20018183",
        cash_amount=0,
        discount_amount=0,
        fine_amount=0,
        interest_amount=0,
        reduction_amount=0,
        due="2022-01-31T00:00:00+00:00",
        expired="2022-02-01T00:00:00+00:00",
        key_id="+5511989898989",
        data=[
            {"key": "additional-info", "value": "order #12345"}
        ],
        scheduled="2022-01-31T00:00:00+00:00",
        jws="eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9...",
        subscription=Subscription(
            bacen_id="RR20220101200181830000000000001",
            amount=1000,
            amount_min_limit=0,
            interval="month",
            description="Subscription for services",
            reference_code="contract-12345",
            installment_start="2022-01-01T00:00:00+00:00",
            installment_end="2023-01-01T00:00:00+00:00",
            pull_retry_limit=3,
            receiver_name="Stark Bank S.A.",
            receiver_tax_id="20.018.183/0001-80",
            receiver_bank_code="20018183",
            sender_final_name="Jon Snow",
            sender_final_tax_id="012.345.678-90",
            type="qrcodeAndPayment",
            status="approved",
            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/brcode-preview-python.md)
- [Node.js](https://docs.starkinfra.com/api/v2/brcode-preview-node.md)
- [PHP](https://docs.starkinfra.com/api/v2/brcode-preview-php.md)
- [Java](https://docs.starkinfra.com/api/v2/brcode-preview-java.md)
- [Ruby](https://docs.starkinfra.com/api/v2/brcode-preview-ruby.md)
- [Elixir](https://docs.starkinfra.com/api/v2/brcode-preview-elixir.md)
- [.NET](https://docs.starkinfra.com/api/v2/brcode-preview-dotnet.md)
- [Go](https://docs.starkinfra.com/api/v2/brcode-preview-go.md)
- [Clojure](https://docs.starkinfra.com/api/v2/brcode-preview-clojure.md)
- [cURL](https://docs.starkinfra.com/api/v2/brcode-preview-curl.md)
