Send a CNAB 240 Lerian remittance file
Receives one whole CNAB 240 Lerian remittance file as the raw body and answers with a receipt. The title lines run afterwards, in the background.
How it works
- Send the file as
text/plainorapplication/octet-stream, up to 4 MiB. - No
Idempotency-Keyis read. The file is the key: the agreement (G007) and NSA (G018) of the file header, and the SHA-256 of the normalized content. - Checks run in this order: authentication, permission, headers,
Content-Type, the resend check, then the acceptance checks. - The resend check comes first. The same file sent again returns
200with the first receipt, as it stands now, and does nothing. This holds even if CNAB 240 was turned off or the agreement deactivated since. A resend after a timeout is safe. - The same NSA with other content is refused with
PBP-0907. - Only a new remittance goes through the acceptance checks: CNAB 240 enabled, file structure, agreement in the header, agreement
ACTIVE, PCR connection, then the NSA. A refusal stores nothing and does not consume the NSA. - A new NSA returns
202with a new receipt. - An NSA that skips numbers, or is below the last accepted one, is accepted with an alert in the receipt (
NSA_GAP,NSA_OUT_OF_ORDER) andexpectedNsa. - Each title (segment P and the Q, R, S and Y-53 that follow it) is validated whole. A rejected title does not stop the others. It is listed with up to 5 C047 reason codes.
- Follow the remittance with
GET /v1/cnab/remittances/{remittance_id}and its lines. The outcome of each title at the base comes in the return file. - The receipt and the lines never carry a payerβs name, tax id or address.
Dry run
- With
dryRun=true, the same checks run, except the resend check and the NSA checks. There is no409and no NSA alert. - Then every title line is validated. The answer is
200with statusDRY_RUNand the outcome of each line inlines. - Nothing is stored and no NSA is consumed. The receipt has no id and cannot be read back.
Headers
Query Parameters
Body
Content-Type text/plain (any charset parameter, e.g. text/plain; charset=iso-8859-1) or application/octet-stream; anything else is refused with 415 PBP-0908. The whole remittance file, at most 4 MiB (4,194,304 bytes): records of 240 positions, ending in CRLF or LF, in ASCII, Latin-1 or UTF-8. File header, one or more collection batches (batch header, P/Q[/R][/S][/Y-53] segments per title, batch trailer), file trailer. The body is read raw, with a limit, and is not handed to the schema validator.
The body is of type file.
Response
OK. Two cases, told apart by status. DRY_RUN: the validation result, with lines. Nothing was stored. Any other status: the same file (same agreement, NSA and content) was received before. This is the first receipt as it stands now, and nothing new was done.
Fields taken as information only. MESSAGES_NOT_SENT: messages of the batch header, R and S are not sent to the boleto. ACCEPT_FLAG_INFORMATIONAL: the accept flag (25.3P) is kept but not sent. PROTEST_DAYS_IGNORED: protest days (37.3P) ignored with protest code 3 or 7.
MESSAGES_NOT_SENT, ACCEPT_FLAG_INFORMATIONAL, PROTEST_DAYS_IGNORED VALIDATED: stored, no line started yet. PROCESSING: lines being executed. COMPLETED: every line EXECUTED or REJECTED (also at once, when every line was rejected at validation). DRY_RUN: the answer of a dry run, never stored. Treat the list as open.
VALIDATED, PROCESSING, COMPLETED, DRY_RUN The NSA expected (last accepted + 1) when this one differs from it; null otherwise and on a DRY_RUN. 1000000 means the 6-digit range of G018 is exhausted: no NSA above the last one is accepted, and a lower NSA still free is accepted with NSA_OUT_OF_ORDER.
1 <= x <= 1000000
