> ## 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.

# Lender events

> Use Lender's v3 application streams, source-qualified CloudEvents types, outbox delivery, manifest, and runtime consumer contract.

Lender publishes business facts and commands as CloudEvents 1.0 over Kafka. Publication is optional, tenant-scoped, and backed by a transactional outbox.

## Turn publication on

***

| Setting                        | Value                                       |
| ------------------------------ | ------------------------------------------- |
| `STREAMING_ENABLED`            | `true`                                      |
| `STREAMING_BROKERS`            | Your Kafka or RedPanda brokers.             |
| `STREAMING_CLOUDEVENTS_SOURCE` | `lender`. Startup rejects any other source. |

Origination still works when publication is disabled. When publication is enabled, Lender fails startup if the broker or source configuration is invalid.

## Wire contract

***

Lender uses the v3 application-stream contract. A topic identifies the producing application and message class, not one event.

| Wire element  | Value                                                          |
| ------------- | -------------------------------------------------------------- |
| Fact topic    | `lerian.streaming.lender`                                      |
| Command topic | `lerian.streaming.lender.commands`                             |
| `ce-source`   | `lender`                                                       |
| `ce-type`     | `studio.lerian.lender.<resource>.<event>`                      |
| Dispatch key  | `<resource>.<event>` from `ce-resourcetype` and `ce-eventtype` |
| Partition key | Tenant identifier                                              |

For example, a disbursement fact travels on `lerian.streaming.lender` with `ce-type: studio.lerian.lender.loan_application.disbursed`.

`ce-schemaversion` carries the payload version. Schema v2 does not add a topic suffix under the v3 contract. Route on the CloudEvents headers, not on a per-event topic name.

## Published contract

***

The manifest declares **35 definitions**: 33 facts and two commands. Feature gates control individual integration paths, so consume only the contracts exposed by the deployed manifest.

The two catalog commands are:

* `consignado.exclusao.requested`: requests a consignado exclusion from the payroll rail.
* `consignado.redirecionamento.requested`: requests a consignado redirection from the payroll rail.

See [Lender event reference](/en/reference/events/lender) for every catalog definition and its source-qualified `ce-type`.

## Events Lender consumes

***

Lender wires 15 gateway-facing fact keys from `lerian.streaming.consignado-gw`. The keys include contract registration, disbursement confirmation, averbação rejection, employment status, redirection outcomes, reconciliation, exclusion outcomes, correction availability, portability outcomes, and refinance outcomes. The corresponding consumers are configuration-gated. Portability and refinance each use one opt-in flag for their pair of outcomes.

The gateway has emission paths for the first 13 keys. The portability pair reaches Lender only when its outcome consumer is enabled and the deployed gateway manifest declares the event. The manifest does not declare the two refinance outcomes, so those two listeners receive no live traffic from the current gateway runtime.

A Lender handler consumes `match_run.completed` from `lerian.streaming.matcher`. For the default handoff, Matcher must use `STREAMING_CLOUDEVENTS_SOURCE=matcher`. Lender routes `ce-source: matcher`, `ce-type: studio.lerian.matcher.match_run.completed`, `ce-resourcetype: match_run`, and `ce-eventtype: completed`. If Matcher uses another source, inspect its streaming manifest and align both sides before enabling the runtimes.

See [Consignado privado](/en/products/lender/consignado-privado) for the payroll journey.

## Durability and delivery

***

Lender writes each outbound business event to the PostgreSQL outbox in the same database transaction as the state change. A relay publishes it after commit. Broker delivery is at least once: deduplicate on `(ce-source, ce-id)` and make handlers idempotent.

The relay retries each row up to `OUTBOX_MAX_DISPATCH_ATTEMPTS` times. The `OUTBOX_RETRY_WINDOW_SEC` value sets the minimum wait between attempts for a row. It is a per-attempt delay, not a total retry window. The defaults are `10` attempts and `300` seconds.

## Payload conventions

***

Payloads are JSON facts, not diffs. Money and rate values use decimal strings rather than JSON numbers. Timestamps use RFC 3339 UTC. Read `ce-schemaversion` before decoding a versioned payload.

## Check the deployed contract

***

`GET /api/v1/streaming/manifest` returns the deployed catalog, application topics, schema versions, and delivery policies. It requires a bearer token with `streaming_manifest` `read`.

Read the manifest when your consumer starts and reject an unexpected source, event key, or schema version before processing traffic.

## Next steps

***

<CardGroup cols={2}>
  <Card title="Lender event reference" icon="list" href="/en/reference/events/lender">
    Inspect emitted, catalog-only, and consumed contracts.
  </Card>

  <Card title="Consignado privado" icon="brazilian-real-sign" href="/en/products/lender/consignado-privado">
    Follow the payroll command and fact flow.
  </Card>
</CardGroup>
