> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nekt.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Rede as a data source

> Bring your Rede card sales, payments and receivables to your Lakehouse.

Rede is the card acquirer of Itaú Unibanco. The connector uses Rede's Sales Management API (Gestão de Vendas), its reconciliation package, to extract the card sales of each point of sale (PV), the installments of installment sales, the payments made or scheduled to your bank account with their credit orders, the debits and adjustments discounted from them (cancellations, chargebacks, fees), and the receivables schedule. With it you can reconcile sales with the money received and follow your cash flow in your Lakehouse.

## Configuring Rede as a Source

In the [Sources](https://app.nekt.ai/sources) tab, click on the "Add source" button located on the top right of your screen. Then, select the Rede option from the list of connectors.

Click **Next** and you'll be prompted to add your access.

### 1. Add account access

Rede gives access to the Sales Management API through credentials it issues to your company: a **Client ID** and a **Client Secret**. There is no self-service page for production credentials: they are only issued by Rede's integrations team, by e-mail, and only after Rede has certified the integration in its sandbox (test) environment. The steps are:

1. **Request access by e-mail.** Send an e-mail to `ecommerce@userede.com.br` (or to your Linha Direta box, if you are a Rede wholesale customer) with:
   * the name, CNPJ, e-mail and phone number of your company;
   * your company's segment;
   * the name and e-mail of the person who will receive the credentials;
   * the API you want to access: **Gestão de Vendas** (Sales Management).
2. **Sandbox certification.** Before releasing production, Rede certifies the integration in its sandbox. Sandbox credentials are free: create an account in [Rede's developer portal](https://developer.userede.com.br), open **Meus Projetos** (My Projects) and create a project with the **Gestão de Vendas** API package. Rede's sandbox only answers for its own test points of sale (`13381369` and `22523510`). To run the certification through Nekt, create a source with the sandbox credentials, the **Sandbox** option enabled and those PVs, and contact Nekt support if Rede asks for anything else.
3. **Production credentials.** Once certified, Rede registers your organization, user and application and sends the production Client ID and Client Secret by e-mail. Use them in a source with the **Sandbox** option disabled.

<Note>
  This process is handled between your company and Rede, so start it before you need the data, and reply to the same e-mail thread if Rede asks for more information.
</Note>

You also need the numbers of your **points of sale (PV)**: the establishment numbers Rede shows in Portal Rede and on your statements.

The following configurations are available:

* **Client ID**: the Client ID sent by Rede. Required.

* **Client Secret**: the Client Secret sent together with the Client ID. Required.

* **Points of sale (PV)**: the PV numbers whose data you want to extract, one per item. Each PV must belong to the company Rede issued the credentials to. Required.

* **Start Date**: the first date read on the first sync (the sale date for sales, the payment date for payments). Later syncs continue from where the previous one stopped. Leave it empty to read the last 365 days. A full sync also reads from this date, so with it empty a full sync keeps only the last 365 days in the tables.

* **Lookback Days** (advanced): how many days before the last extracted date every sync reads again. The default is 30. Sales can be cancelled or charged back and payments change status after they first appear, so recent days are read again to keep them up to date.

* **Days Ahead** (advanced): how many days after today are read for scheduled values (future payments, credit orders, debits and receivables). The default is 365.

* **Sandbox** (advanced): uses Rede's test environment. Enable it only with sandbox credentials created in Rede's developer portal.

Once you're done, click **Next**.

### 2. Select streams

Choose which data streams you want to sync. For faster extractions, select only the streams that are relevant to your analysis. You can select entire groups of streams or pick specific ones.

> Tip: The stream can be found more easily by typing its name.

<Note>
  Rede answers for one point of sale and a limited date range per request (62 days for sales, 30 days for the other data), so the extraction time grows with the number of PVs and with the history requested on the first sync.
</Note>

Select the streams and click **Next**.

### 3. Configure data streams

Customize how you want your data to appear in your catalog. Select the desired layer where the data will be placed, a folder to organize it inside the layer, a name for each table (which will effectively contain the fetched data) and the type of sync.

* **Layer**: choose between the existing layers on your catalog. This is where you will find your new extracted tables as the extraction runs successfully.
* **Folder**: a folder can be created inside the selected layer to group all tables being created from this new data source.
* **Table name**: we suggest a name, but feel free to customize it. You have the option to add a **prefix** to all tables at once and make this process faster!
* **Sync Type**: all streams except `adjustment_types` are INCREMENTAL: each sync brings the new dates and reads the recent ones again (see **Lookback Days**). `adjustment_types` is FULL\_TABLE. A full sync rebuilds the tables from the **Start Date**; it is the way to pick up changes Rede makes to records older than the lookback (for example a chargeback months after the sale). Read more about Sync Types [here](https://docs.nekt.com/get-started/core-concepts/types-of-sync).

Once you are done configuring, click **Next**.

### 4. Configure data source

Describe your data source for easy identification within your organization, not exceeding 140 characters.

To define your [Trigger](https://docs.nekt.com/get-started/core-concepts/triggers), consider how often you want data to be extracted from this source. Rede updates the statement once a day (with the previous day's data), so a daily trigger is usually enough.

Optionally, you can define some additional settings:

* Configure Delta Log Retention and determine for how long we should store old states of this table as it gets updated. Read more about this resource [here](https://docs.nekt.com/get-started/core-concepts/resource-control).

Once you are ready, click **Next** to finalize the setup.

### 5. Check your new source

You can view your new source on the [Sources](https://app.nekt.ai/sources) page. If needed, manually trigger the source extraction by clicking on the arrow button. Once executed, your data will appear in your Catalog.

<Warning>For you to be able to see it on your [Catalog](https://app.nekt.ai/catalog), you need at least one successful source run.</Warning>

# Streams and Fields

Below you'll find all available data streams from Rede and their corresponding fields. API reference: [Rede Sales Management API](https://developer.userede.com.br/gestao-vendas).

<Note>
  Every table (except `adjustment_types`) has a `merchant_id` column with the point of sale the record was requested for, and every table has a `raw_payload` column with the whole record exactly as Rede returned it, so information without a column of its own is still available. Lists and objects are stored as JSON text. The sales summary number (`sale_summary_number`, the RV) links sales, credit orders and charges; `payment_id` links payments and credit orders.
</Note>

<AccordionGroup>
  <Accordion title="Sales">
    Card sales of each point of sale, one record per transaction: gross amount, MDR discount, net amount, brand, modality, installments, status and chargeback status. Incremental on the sale date.

    Table: `sales` · Primary key: `merchant_id`, `sale_date`, `nsu` · Sync: Incremental

    | Field | Type | Description |
    | :- | :- | :- |
    | `merchant_id` | String | Number of the point of sale (PV) the record was requested for. |
    | `company_number` | String | Number of the point of sale (PV) as Rede returned it on the record. |
    | `document_number` | String | Tax id (CNPJ or CPF) of the establishment. |
    | `company_name` | String | Legal name of the establishment. |
    | `trade_name` | String | Trade name of the establishment. |
    | `sale_date` | Date | Date of the sale, used as the incremental replication key. |
    | `sale_hour` | String | Time of the sale (HH:MM:SS). |
    | `movement_date` | Date | Date on which Rede processed the transaction. |
    | `nsu` | String | NSU (unique sequential number) of the transaction. |
    | `tid` | String | Transaction ID of e-commerce transactions. |
    | `order_number` | String | Order number the merchant sent with the e-commerce transaction. |
    | `authorization_code` | String | Authorization code of the transaction given by the card issuer. |
    | `sale_summary_number` | Integer | Number of the sales summary (resumo de vendas, RV) that groups the sale; links sales to their payments and credit orders. |
    | `brand_code` | Integer | Code of the card brand in Rede's Sales Management API (1 = Mastercard, 2 = Visa, 13 = Amex, 14 = Elo, ...). |
    | `brand_name` | String | Name of the card brand (Mastercard, Visa, Elo, Amex, ...). |
    | `modality_type` | String | Type of the modality: CREDIT or DEBIT. |
    | `modality_code` | Integer | Code of the modality. |
    | `modality_product` | String | Product of the sale (NO\_INSTALLMENTS, IN\_INSTALLMENTS\_NO\_INTEREST, IN\_INSTALLMENTS\_WITH\_INTEREST, NO\_INSTALLMENTS\_DEBIT, ...). |
    | `modality_product_code` | Integer | Code of the product of the sale. |
    | `installment_quantity` | Integer | Number of installments of the sale. |
    | `status` | String | Status of the sale: APPROVED or CANCELLED. |
    | `chargeback_status` | String | Chargeback status, for sales that received a retrieval request or a chargeback. |
    | `device_type` | String | Capture technology of the transaction (for example ECO for e-commerce). |
    | `device` | String | Code of the terminal of the establishment. |
    | `capture_type` | String | Capture type of the transaction (for example ECOMMERCE). |
    | `capture_type_code` | Integer | Code of the capture type. |
    | `amount` | Number | Gross amount of the sale, before the MDR discount. |
    | `mdr_fee` | Number | MDR rate applied to the sale (%). |
    | `mdr_amount` | Number | MDR amount charged on the sale. |
    | `flex` | Boolean | Whether the sale was made under the Flex product. |
    | `flex_fee` | Number | Flex rate applied to the sale (%). |
    | `flex_amount` | Number | Flex amount charged on the sale. |
    | `fee_total` | Number | Total fees charged on the sale. |
    | `discount_amount` | Number | Total discount applied to the sale (fees). |
    | `net_amount` | Number | Net amount of the sale, after the discounts. |
    | `boarding_fee_amount` | Number | Boarding fee amount, for IATA (airline) transactions. |
    | `tokenized` | Boolean | Whether the transaction was made with a card token. |
    | `card_number` | String | Masked card number (first six and last four digits). |
    | `token_number` | String | Masked card number of tokenized transactions. |
    | `tracking` | String (JSON) | Life cycle of the transaction: its events with amount, date and status (JSON array of objects). |
    | `raw_payload` | String (JSON) | The whole record exactly as Rede returned it (JSON object), including fields that have no column of their own. |
  </Accordion>

  <Accordion title="Sales Installments">
    Installments of the installment sales, with the due date and the amounts of each installment. Incremental on the sale date.

    Table: `sales_installments` · Primary key: `merchant_id`, `sale_date`, `nsu`, `installment_number` · Sync: Incremental

    | Field | Type | Description |
    | :- | :- | :- |
    | `merchant_id` | String | Number of the point of sale (PV) the record was requested for. |
    | `company_number` | String | Number of the point of sale (PV) as Rede returned it on the record. |
    | `nsu` | String | NSU (unique sequential number) of the sale. |
    | `tid` | String | Transaction ID of e-commerce sales. |
    | `sale_date` | Date | Date of the sale, used as the incremental replication key. |
    | `movement_date` | Date | Date on which Rede processed the sale. |
    | `expiration_date` | Date | Due date of the installment. |
    | `installment_quantity` | Integer | Number of installments of the sale. |
    | `installment_number` | Integer | Number of this installment within the sale. |
    | `sale_summary_number` | Integer | Number of the sales summary (resumo de vendas, RV) of the sale. |
    | `amount` | Number | Gross amount of the installment. |
    | `sale_amount` | Number | Gross amount of the whole sale. |
    | `mdr_fee` | Number | MDR rate applied (%). |
    | `mdr_amount` | Number | MDR amount charged on the installment. |
    | `discount_amount` | Number | Discount applied to the installment. |
    | `net_amount` | Number | Net amount of the installment. |
    | `raw_payload` | String (JSON) | The whole record exactly as Rede returned it (JSON object), including fields that have no column of their own. |
  </Accordion>

  <Accordion title="Payments">
    Payments settled or scheduled for each point of sale: the net amount paid into the bank account, with its status. Future payments are included (see **Days Ahead**). Incremental on the payment date.

    Table: `payments` · Primary key: `merchant_id`, `payment_id` · Sync: Incremental

    | Field | Type | Description |
    | :- | :- | :- |
    | `merchant_id` | String | Number of the point of sale (PV) the record was requested for. |
    | `payment_id` | String | Identifier of the payment. |
    | `payment_date` | Date | Date of the payment, used as the incremental replication key. |
    | `company_number` | String | Number of the point of sale (PV) as Rede returned it on the record. |
    | `document_number` | String | Tax id (CNPJ or CPF) of the establishment. |
    | `company_name` | String | Legal name of the establishment. |
    | `trade_name` | String | Trade name of the establishment. |
    | `brand_code` | Integer | Code of the card brand in Rede's Sales Management API (1 = Mastercard, 2 = Visa, 13 = Amex, 14 = Elo, ...). |
    | `brand_name` | String | Name of the card brand (Mastercard, Visa, Elo, Amex, ...). |
    | `bank_code` | Integer | Code of the bank. |
    | `bank_branch_code` | Integer | Code of the bank branch. |
    | `account_number` | Integer | Number of the bank account. |
    | `net_amount` | Number | Net amount of the payment. |
    | `status` | String | Status of the payment (PAID, PENDING, SUSPENDED, REJECTED, ...). |
    | `status_code` | Integer | Code of the payment status. |
    | `type` | String | Type of the payment (CREDIT, DEBIT, ...). |
    | `type_code` | String | Code of the payment type (CRE, DEB, ...). |
    | `raw_payload` | String (JSON) | The whole record exactly as Rede returned it (JSON object), including fields that have no column of their own. |
  </Accordion>

  <Accordion title="Payment Credit Orders">
    Credit orders of each payment. A credit order ties a payment to the sales summary (RV) it pays, which is how sales are reconciled with the money received. Incremental on the payment date.

    Table: `payment_credit_orders` · Primary key: `merchant_id`, `payment_id`, `credit_order_number` · Sync: Incremental

    | Field | Type | Description |
    | :- | :- | :- |
    | `merchant_id` | String | Number of the point of sale (PV) the record was requested for. |
    | `payment_id` | String | Identifier of the payment the credit order belongs to. |
    | `payment_date` | Date | Date of the payment, used as the incremental replication key. |
    | `credit_order_number` | Integer | Number of the credit order. |
    | `sale_summary_number` | Integer | Number of the sales summary (resumo de vendas, RV) the credit order pays; links to the sale\_summary\_number of the sales. |
    | `company_number` | String | Number of the point of sale (PV) as Rede returned it on the record. |
    | `brand_code` | Integer | Code of the card brand in Rede's Sales Management API (1 = Mastercard, 2 = Visa, 13 = Amex, 14 = Elo, ...). |
    | `brand_name` | String | Name of the card brand (Mastercard, Visa, Elo, Amex, ...). |
    | `amount` | Number | Gross amount of the credit order. |
    | `discount_amount` | Number | Discount applied to the credit order. |
    | `net_amount` | Number | Net amount of the credit order. |
    | `type` | String | Type of the payment (CREDIT, DEBIT, ...). |
    | `type_code` | String | Code of the payment type (CRE, DEB, ...). |
    | `raw_payload` | String (JSON) | The whole record exactly as Rede returned it (JSON object), including fields that have no column of their own. |
  </Accordion>

  <Accordion title="Charges">
    Debits and adjustments Rede discounts from the payments: sale cancellations, chargebacks, fees and other adjustments, with the amount already compensated and the amount still to compensate. Incremental on the payment date.

    Table: `charges` · Primary key: `merchant_id`, `debit_number`, `credit_order_number` · Sync: Incremental

    | Field | Type | Description |
    | :- | :- | :- |
    | `merchant_id` | String | Number of the point of sale (PV) the record was requested for. |
    | `debit_number` | Integer | Number identifying the debit. |
    | `credit_order_number` | Integer | Number of the credit order the debit is compensated against. |
    | `payment_date` | Date | Date of the payment the debit applies to, used as the incremental replication key. |
    | `compensated_date` | Date | Date on which the debit was compensated. |
    | `credit_order_expiration_date` | Date | Expiration date of the credit order. |
    | `company_number` | String | Number of the point of sale (PV) as Rede returned it on the record. |
    | `document_number` | String | Tax id (CNPJ or CPF) of the establishment. |
    | `company_name` | String | Legal name of the establishment. |
    | `trade_name` | String | Trade name of the establishment. |
    | `sale_summary_number` | Integer | Number of the sales summary (resumo de vendas, RV) the debit refers to. |
    | `adjustment_type_code` | Integer | Code of the debit adjustment type (see the adjustment\_types stream). |
    | `adjustment_type_description` | String | Description of the debit adjustment type (for example sale cancellation). |
    | `cancellation_notice_number` | Integer | Cancellation notice number, when the debit comes from a sale cancellation. |
    | `debit_amount` | Number | Amount of the debit. |
    | `debit_compensated_amount` | Number | Amount of the debit already compensated. |
    | `debit_to_be_compensated_amount` | Number | Amount of the debit still to be compensated. |
    | `type` | String | Type of the charge (for example NET). |
    | `raw_payload` | String (JSON) | The whole record exactly as Rede returned it (JSON object), including fields that have no column of their own. |
  </Accordion>

  <Accordion title="Adjustment Types">
    Reference list of the debit adjustment codes used in `charges`. Extracted in full on every sync.

    Table: `adjustment_types` · Primary key: `code` · Sync: Full table

    | Field | Type | Description |
    | :- | :- | :- |
    | `code` | Integer | Code of the debit adjustment type. |
    | `description` | String | Description of the debit adjustment type. |
    | `raw_payload` | String (JSON) | The whole record exactly as Rede returned it (JSON object), including fields that have no column of their own. |
  </Accordion>

  <Accordion title="Receivables Installments">
    Receivables schedule of each point of sale: every installment to receive (or received), with its date, original and updated amounts, net amount and bank account. Future dates are included (see **Days Ahead**). Incremental on the receivable date.

    Table: `receivables_installments` · Primary key: `hash_unique` · Sync: Incremental

    | Field | Type | Description |
    | :- | :- | :- |
    | `merchant_id` | String | Number of the point of sale (PV) the record was requested for. |
    | `hash_unique` | String | Unique hash of the installment given by Rede. |
    | `hash_unique_sale` | String | Unique hash of the sale the installment belongs to. |
    | `receivable_date` | Date | Date on which the installment is (or was) received, used as the incremental replication key. |
    | `sale_date` | Date | Date of the sale. |
    | `central_merchant_id` | String | Point of sale (PV) that receives the payment (centralizer). |
    | `merchant_name` | String | Name of the establishment. |
    | `nsu` | String | NSU (unique sequential number) of the sale. |
    | `tid` | String | Transaction ID of e-commerce sales. |
    | `authorization_code` | String | Authorization code of the sale. |
    | `order_number` | String | Order number of the sale. |
    | `card_number` | String | Masked card number used in the sale. |
    | `brand_code` | Integer | Code of the card brand in Rede's Sales Management API. |
    | `brand_name` | String | Name of the card brand. |
    | `modality` | String | Modality of the sale (CREDIT, DEBIT). |
    | `installment_number` | Integer | Number of this installment within the sale. |
    | `installment_quantity` | Integer | Number of installments of the sale. |
    | `sale_summary_number` | Integer | Number of the sales summary (resumo de vendas, RV) of the sale. |
    | `amount` | Number | Amount to receive before discounts, updated with cancellations and other changes. |
    | `original_amount` | Number | Amount to receive before discounts, as originally scheduled. |
    | `discount_amount` | Number | Amount discounted from the installment. |
    | `net_amount` | Number | Net amount to receive. |
    | `sale_amount` | Number | Gross amount of the whole sale. |
    | `mdr_fee` | Number | MDR rate of the sale (%). |
    | `mdr_amount` | Number | MDR amount of the installment. |
    | `flex` | Boolean | Whether the establishment has the Flex plan. |
    | `flex_fee` | Number | Flex rate (%). |
    | `flex_amount` | Number | Flex amount. |
    | `credit_order_number` | Integer | Number of the credit order that pays the installment. |
    | `credit_order_amount` | Number | Amount of the credit order. |
    | `credit_order_origin_percentage_value` | Number | Share of the originating credit order this record refers to (%). |
    | `bank_code` | Integer | Code of the bank. |
    | `bank_branch_code` | Integer | Code of the bank branch. |
    | `account_number` | Integer | Number of the bank account. |
    | `negotiation_type` | String | Type of negotiation of the receivable (for example FREE\_AMOUNT). |
    | `status` | String | Status of the installment (for example SCHEDULLED, as Rede spells it). |
    | `type` | String | Type of the view (DAY, MONTH). |
    | `tokenized` | Boolean | Whether the sale was made with a card token. |
    | `raw_payload` | String (JSON) | The whole record exactly as Rede returned it (JSON object), including fields that have no column of their own. |
  </Accordion>
</AccordionGroup>

## Troubleshooting

* **"Rede rejected the Client ID or Client Secret"**: check that both values were copied exactly as Rede sent them and that they are production credentials. Sandbox credentials only work with the **Sandbox** option enabled.
* **"Rede did not allow this connection to read the statement of point of sale"**: the PV does not belong to the company the credentials were issued to, or its access was not approved. Check the PV number; if the access was requested through Rede, the PV owner approves it in the logged area of Portal Rede.
* **"Rede rejected the request"** with a message about dates: Rede may not keep history as old as the configured start date. Try a more recent **Start Date**.
* **"Rede returned an inconsistent page"** or **"Rede answered ... in an unexpected format"**: the sync stopped on purpose so that it would not finish with records missing. Nothing was deleted: in a full sync the table keeps its previous data, and in an incremental sync the records read before the stop may already have been saved (added or updated) while the rest are read again by the next sync. If the message repeats, contact Nekt support.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.