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

# Issue the CCB

> Have Lender emit the CCB or issue it yourself, then record the signed CCB on the loan application.

The CCB (*Cédula de Crédito Bancário*) evidences the credit contract of a direct loan. The loan product's version says who issues it: Lender renders the PDF, or your institution does.

## Choose who issues the CCB

***

A product version declares `terms.creditInstrumentMode` when you [create it](https://docs.lerian.studio/en/products/lender/define-a-loan-product.md). The value is `lender_emitted` (the default) or `client_issued`. A version never changes, so a different issuer means a new version.

| Topic | `lender_emitted` | `client_issued` |
| - | - | - |
| Who renders the PDF | Lender, from the product's published document template | Your institution |
| What you record afterwards | The signed CCB, naming the CCB Lender emitted | The signed CCB, with the digest of the document your institution issued |
| What Lender refuses | Emission on an application that is not approved | Any emission: `LENDER-0601` |

## Lender emits the CCB

***

**1. Publish a document template**

The product needs a published template before Lender can emit. [Create a draft](https://docs.lerian.studio/en/reference/products/lender/create-document-template-draft.md) with `POST /api/v1/loan-products/{productId}/document-templates`, then [publish it](https://docs.lerian.studio/en/reference/products/lender/publish-document-template.md). Publishing a new version replaces the active one. Without an active template, emission answers `LENDER-0616`.

**2. Approve the application, then emit before the release**

Lender emits only for an `approved` application. An application that is already disbursed answers `LENDER-0602`, so emit between the approval and the [release](https://docs.lerian.studio/en/products/lender/originate-a-loan.md#record-a-release-your-institution-made).

**3. Emit the CCB**

[`POST /api/v1/loan-applications/{applicationId}/credit-instruments`](https://docs.lerian.studio/en/reference/products/lender/issue-credit-instrument) takes `idempotencyKey` in the body, not in a header, and a `parties` block with the issuer and creditor names and documents, the places of issuance and payment, and any other field the template declares. The same key returns the same CCB, with `X-Idempotency-Replayed: true`. The same key with a different `parties` block is refused.

**4. List and download**

[`GET .../credit-instruments`](https://docs.lerian.studio/en/reference/products/lender/list-credit-instruments) lists the emissions, newest first. An older emission carries `supersededByInstrumentId`. The `issuance` block tells you whether the application can have a CCB emitted now (`canEmit`) and, when it cannot, the code the emission would answer (`refusalCode`). [`GET .../credit-instruments/{instrumentId}/download`](https://docs.lerian.studio/en/reference/products/lender/download-credit-instrument) returns the PDF Lender stores.

## Your institution issues the CCB

***

On a `client_issued` version, Lender emits no CCB. `POST .../credit-instruments` answers `LENDER-0601`, and the list shows `canEmit: false` with the same `refusalCode`. Render and collect the signature in your own document, then [record the signed CCB](#record-the-signed-ccb). Keep the digest of the document as it was before signing: the record is refused with `LENDER-0608` when `originalDocumentDigest` is missing or when `creditInstrumentId`, which names a CCB Lender emitted, is sent.

## Record the signed CCB

***

Record the signed CCB once the parties have signed, on an application that is `approved` or `disbursed`, in both modes. [`POST /api/v1/loan-applications/{applicationId}/signed-credit-instrument`](https://docs.lerian.studio/en/reference/products/lender/record-signed-credit-instrument) takes:

| Field | What to send |
| - | - |
| `document` | The signed PDF, base64-encoded with the standard alphabet, at most 20 MiB decoded. |
| `signedDocumentDigest` | The sha-256, in hex, of the decoded document. Lender computes its own and refuses a mismatch with `LENDER-0605`. |
| `creditInstrumentId` | `lender_emitted` only: the `id` of the CCB Lender emitted for this application. Required there, and refused on `client_issued`. Without it, or with the id of another application's CCB, Lender answers `LENDER-0607`. |
| `originalDocumentDigest` | The sha-256, in hex, of the document that was signed. Required on `client_issued`. On `lender_emitted` it is optional, and Lender checks it against its CCB. |
| `signedAt` | When the signature completed. At most 5 minutes after Lender's clock, to absorb a signature provider whose clock runs ahead. |
| `evidenceRef` | Your reference to the signature evidence, up to 1,024 bytes. |
| `signatories` | Every party that signed, from 1 to 20. Each has `role` (up to 64), `name` (up to 256), `taxId` (up to 32) and `signedAt`, which cannot be after the instrument's `signedAt`. Lender stores name and tax ID and never returns them. |

This route takes no `X-Idempotency` header. Sending the same document again returns the newest record, with `X-Idempotency-Replayed: true`, and ignores any metadata that differs in the resend: it does not update the record.

## Replace the signed CCB

***

A different document is refused with `LENDER-0604` unless it is a replacement. To replace, read the newest record, then send the new document with `supersedes` set to that record's `id` and a `replacementReason` of one line, up to 500 characters. Both go together. The replaced record stays in the history, and the newest one counts.

A document that already belongs to an earlier record cannot return as a replacement: Lender answers `LENDER-0613`. To return to that content, send a new file, such as a new export, whose bytes differ.

## Read and download

***

[`GET /api/v1/loan-applications/{applicationId}/signed-credit-instrument`](https://docs.lerian.studio/en/reference/products/lender/get-signed-credit-instrument) returns the newest record. `custodian` says who holds the PDF: `lender`, or `integrator`. [`GET .../signed-credit-instrument/download`](https://docs.lerian.studio/en/reference/products/lender/download-signed-credit-instrument) streams the PDF Lender stores. For a record whose custodian is `integrator`, it answers `LENDER-0614`: the PDF stays with the integrator, and the `signedDocumentDigest` from the read checks its bytes.

## Refusals

***

| Code | Status | What it means | What to do |
| - | - | - | - |
| `LENDER-0601` | `422` | The product version leaves the CCB to the institution, so Lender does not emit one. | Issue it yourself and record the signed CCB. To have Lender emit, book the application on a `lender_emitted` version. |
| `LENDER-0602` | `409` | The application is not approved, so Lender cannot emit its CCB. | Approve the application and emit again. |
| `LENDER-0604` | `409` | The application already has a signed CCB, and the request sent a different document without naming the record it replaces. | Replace with `supersedes` and `replacementReason`, or resend the same bytes. |
| `LENDER-0605` | `422` | `signedDocumentDigest` is not the sha-256 Lender computed over the document. | Hash the exact bytes you encode in `document`. |
| `LENDER-0607` | `422` | Lender emitted this application's CCB, and the request does not name it. | Send the `id` of the CCB that was signed, from the list. |
| `LENDER-0608` | `422` | The institution issues the CCB: `creditInstrumentId` was sent, or `originalDocumentDigest` is missing. | Drop `creditInstrumentId` and send `originalDocumentDigest`. |
| `LENDER-0613` | `409` | The document already belongs to an earlier record. | Send a new file whose bytes differ. |
| `LENDER-0614` | `409` | The newest signed CCB is held by the integrator. | Fetch the PDF from the integrator. |
| `LENDER-0616` | `422` | The product has no active document template. | Publish a template and emit again. |

Each operation's reference page lists its other refusals: the [issue](https://docs.lerian.studio/en/reference/products/lender/issue-credit-instrument.md), [record](https://docs.lerian.studio/en/reference/products/lender/record-signed-credit-instrument.md), [get](https://docs.lerian.studio/en/reference/products/lender/get-signed-credit-instrument.md) and [download](https://docs.lerian.studio/en/reference/products/lender/download-signed-credit-instrument.md) pages, and the template [create](https://docs.lerian.studio/en/reference/products/lender/create-document-template-draft.md) and [publish](https://docs.lerian.studio/en/reference/products/lender/publish-document-template.md) pages.

## In the console

***

The console shows the CCB of each application under **Credit instruments**: see [Credit instruments](https://docs.lerian.studio/en/products/lender/console/credit.md#credit-instruments).

## Next steps

***

> [card] [Originate a loan](https://docs.lerian.studio/en/products/lender/originate-a-loan.md)
>
> Walk an application from submission to the release.


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