> This page is for BaaS.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://en.docs.api.corpx.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://en.docs.api.corpx.com/_mcp/server.

# Preview boleto before payment

POST https://tenant.api.corpx.com/v1/accounts/{accountId}/boleto/preview
Content-Type: application/json

Queries boleto data by barcode or "linha digitável". Returns beneficiary info,
amounts (original, interest, fine, discount, total), due date, and payment type.
Requires feature flag `boleto_payment` to be enabled for the tenant.

**Pay with `totalUpdated`, not `amount`.** `amount` is the face value encoded
in the barcode; `totalUpdated` is what the settlement bank accepts today
(face + interest + fine − discount). For an overdue slip they differ, the
settlement bank rejects any other value with `boleto_amount_mismatch`, and
`totalUpdated` changes every day — so query it on the day you pay.


Reference: https://en.docs.api.corpx.com/baas/referencia/boleto-pay/preview-boleto

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, where token is your auth token.

## Request

### Path parameters

- `accountId` (string, required) — Account identifier.

### Headers

- `X-Tenant-Id` (string, required) — Tenant context used for authorization and routing.
- `Idempotency-Key` (string, optional) — Optional client-generated idempotency token (recommended for safe retries).

### Body (application/json)

This endpoint expects an object.

- `barcode` (string, required) — Barcode (47/48 digits) or linha digitável

## Response

### 200

Boleto preview data

- `type` (enum, optional)
  - Allowed values: `boleto-payment`, `utility-payment`, `tax-payment`
- `bank` (string, optional) — Issuing bank name
- `bankCode` (string, optional)
- `receiverName` (string, optional)
- `receiverTaxId` (string, optional)
- `payerName` (string, optional)
- `payerTaxId` (string, optional)
- `dueDate` (date, optional)
- `amount` (double, optional) — Face value in BRL — the amount encoded in the barcode. Do NOT use it to pay an overdue slip.
- `discountAmount` (double, optional)
- `interestAmount` (double, optional)
- `fineAmount` (double, optional)
- `totalUpdated` (double, optional) — Amount to pay today (face + interest + fine − discount). Send this value in `POST /boleto/pay`. Recalculated daily on overdue slips.
- `barcode` (string, optional) — Barcode (44 digits) as returned by the settlement bank
- `digitableLine` (string, optional) — Linha digitável (47/48 digits)
- `status` (enum, optional)
  - Allowed values: `PAYABLE`, `PAID`, `EXPIRED`, `BLOCKED`

## Errors

### 400 Bad Request Error

Invalid request sent by client.

- `errorCode` (string, required) — Stable machine-readable code. See `ErrorCode` for the known values.
- `message` (string, required) — Human-readable explanation (pt-BR). Presentation only; may change.
- `docs` (string, optional) — Link to this code in the public error catalogue.
- `requestId` (string, optional) — Gateway request id. Quote it when contacting support.
- `details` (map from string to any, optional) — Optional machine-readable context for the specific `errorCode` (for example `kind` on `identity_verification_monthly_limit_exceeded`, `maxBytes` on `payload_too_large`, `attemptsRemaining` on `facetec_attempts_exhausted`). Keys are documented per operation; absent when the code carries no extra context.
- `partner` (ErrorResponsePartner, optional) — Raw error from the settlement bank, when the failure came from it. Diagnostic only.

### 403 Forbidden Error

Feature not enabled or insufficient permissions

- `any`

### 502 Bad Gateway Error

Failed to query boleto from payment provider

- `any`

## Types

### ErrorResponsePartner

Raw error from the settlement bank, when the failure came from it. Diagnostic only.

- `code` (string, optional)
- `message` (string, optional)
- `field` (string, optional) — Field the partner pointed at, when any.

## Examples

**Request**

```json
{
  "barcode": "23793.38128 60000.000003 00000.000408 1 84340000012345"
}
```

**Response**

```json
{
  "type": "boleto-payment",
  "bank": "Itaú Unibanco S.A.",
  "bankCode": "341",
  "receiverName": "MARIA DA SILVA",
  "receiverTaxId": "8c1f6a2e-4d3b-4b9a-9f0e-1a2b3c4d5e6f",
  "payerName": "MARIA DA SILVA",
  "payerTaxId": "8c1f6a2e-4d3b-4b9a-9f0e-1a2b3c4d5e6f",
  "dueDate": "2026-02-20",
  "amount": 1430.63,
  "discountAmount": 150.75,
  "interestAmount": 3.29,
  "fineAmount": 28.61,
  "totalUpdated": 1462.53,
  "barcode": "23793381286000782713695000063305975520000015075",
  "digitableLine": "23793381286000782713695000063305975520000015075",
  "status": "PAYABLE"
}
```

**SDK Code**

```python Boleto Pay_previewBoleto_example
import requests

url = "https://tenant.api.corpx.com/v1/accounts/accountId/boleto/preview"

payload = { "barcode": "23793.38128 60000.000003 00000.000408 1 84340000012345" }
headers = {
    "X-Tenant-Id": "X-Tenant-Id",
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Boleto Pay_previewBoleto_example
const url = 'https://tenant.api.corpx.com/v1/accounts/accountId/boleto/preview';
const options = {
  method: 'POST',
  headers: {
    'X-Tenant-Id': 'X-Tenant-Id',
    Authorization: 'Bearer <token>',
    'Content-Type': 'application/json'
  },
  body: '{"barcode":"23793.38128 60000.000003 00000.000408 1 84340000012345"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Boleto Pay_previewBoleto_example
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://tenant.api.corpx.com/v1/accounts/accountId/boleto/preview"

	payload := strings.NewReader("{\n  \"barcode\": \"23793.38128 60000.000003 00000.000408 1 84340000012345\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("X-Tenant-Id", "X-Tenant-Id")
	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Boleto Pay_previewBoleto_example
require 'uri'
require 'net/http'

url = URI("https://tenant.api.corpx.com/v1/accounts/accountId/boleto/preview")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["X-Tenant-Id"] = 'X-Tenant-Id'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"barcode\": \"23793.38128 60000.000003 00000.000408 1 84340000012345\"\n}"

response = http.request(request)
puts response.read_body
```

```java Boleto Pay_previewBoleto_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://tenant.api.corpx.com/v1/accounts/accountId/boleto/preview")
  .header("X-Tenant-Id", "X-Tenant-Id")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"barcode\": \"23793.38128 60000.000003 00000.000408 1 84340000012345\"\n}")
  .asString();
```

```php Boleto Pay_previewBoleto_example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://tenant.api.corpx.com/v1/accounts/accountId/boleto/preview', [
  'body' => '{
  "barcode": "23793.38128 60000.000003 00000.000408 1 84340000012345"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
    'X-Tenant-Id' => 'X-Tenant-Id',
  ],
]);

echo $response->getBody();
```

```csharp Boleto Pay_previewBoleto_example
using RestSharp;

var client = new RestClient("https://tenant.api.corpx.com/v1/accounts/accountId/boleto/preview");
var request = new RestRequest(Method.POST);
request.AddHeader("X-Tenant-Id", "X-Tenant-Id");
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"barcode\": \"23793.38128 60000.000003 00000.000408 1 84340000012345\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Boleto Pay_previewBoleto_example
import Foundation

let headers = [
  "X-Tenant-Id": "X-Tenant-Id",
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["barcode": "23793.38128 60000.000003 00000.000408 1 84340000012345"] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://tenant.api.corpx.com/v1/accounts/accountId/boleto/preview")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```