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

# Verträge und Fassungen

> What the contracts say, version by version - the basis for what the bridge and its workflows may do

n:lead is BKV, and supplies Cloover through its Bilanzkreise. What the
bridge may do - which Bilanzkreise, how much power, which Zeitreihentypen
a Netzbetreiber may activate, until when the trader takes orders - comes
from contracts. The bridge keeps them: the contract itself (type, partner,
status, term - see [the console](/setup/console#verträge)) and what it
says, in **Fassungen**.

## Fassungen

A Fassung is a contract's content from a day on.

* **A change is a new Fassung** from the day it applies. The Fassung
  before it ends the day before, by itself. A new Fassung starts after
  every Fassung there is.
* **A Fassung in force is never edited.** One not yet in force can be
  withdrawn; the one before it gets its end back.
* **What applies on a day** is the Fassung covering it - of a contract
  that is `aktiv` and whose term covers the day. Content of a contract not
  in force counts for nothing.
* A Fassung can start in the past - entering a contract that has run
  since August, say. The event says it was recorded retroactively.

## The contracts and what they say

| Contract | Between | Content |
| - | - | - |
| **Bilanzkreisvertrag** | BKV - ÜNB, per Regelzone | `bilanzkreis_eic`; `max_leistung_mw` - the maximum power per quarter-hour; `unterbilanzkreise` |
| **Bilanzkreisnutzungsvertrag** | Lieferant - BKV | `lieferant_mp_id`; `bilanzkreise` it may supply through; `regelzonen` |
| **Lieferantenrahmenvertrag** | Lieferant - Netzbetreiber | `zeitreihentypen` the Netzbetreiber may activate for us (UTILMD) |
| **Händlervertrag** | BKV - trader | `haendler_name`, `handels_bk_eic`, `heimat_regelzone`, `bestellfrist` (HH:MM the day before), `horizont_tage`, `richtung` (`kauf`, `verkauf`, `beides`), `format`, `transport`, `einheit` |

Each Unterbilanzkreis in a Bilanzkreisvertrag:

| Field | |
| - | - |
| `eic`, `name` | the Unterbilanzkreis |
| `typ` | e.g. `gruen`, `eeg_marktpraemie`, `standard` |
| `ausgleichsenergie` | `ueber_hauptbilanzkreis` (settled through the main Bilanzkreis) or `eigene` |
| `eigene_fahrplaene` | whether it runs schedules of its own |
| `zeitreihentypen` | what is activated for it |

The Zuordnungsvereinbarung and the Messstellenbetreiberrahmenvertrag carry
no content.

A new contract's first Fassung starts from what the bridge is configured
with: the Bilanzkreis and the Unterbilanzkreise of the Regelzone, the
trader's deadline and horizon. Entering the contract is then confirming the
configuration - or saying where it differs.

## What applies, and what differs

`GET /v1/process/vertragslage?tag=` gives, per contract type and partner,
whether the contract is in force on the day and the content of the Fassung
covering it - one answer for the bridge, the routines and the console.

`GET /v1/process/vertragspruefung?tag=` holds the contracts against what
is:

| Finding | When |
| - | - |
| `fehlt` | a contract expected is not in force, or has no Fassung for the day. Nothing is restricted while the data is being entered |
| `abweichung` | the configuration differs: the Bilanzkreis, an Unterbilanzkreis and its Zeitreihentypen, the trader's home Regelzone, deadline or horizon; a Lieferant supplies through a Bilanzkreis its contract does not name |
| `verletzung` | a schedule sent beyond the maximum power per quarter-hour; a Zeitreihentyp needed by customers or granted in a ZOE that the Lieferantenrahmenvertrag does not allow |

Every hour the bridge checks today and tomorrow. A new difference or
breach is reported once, as the event `vertragsbefund` (a breach alerts
High, a difference Normal); a finding that is gone is forgotten, so it
can come back. A missing contract is the console's business, not an
alarm.

## Next

The contracts are the basis for what the bridge may do. Next, the
workflows take their values from the Fassung in force - the trader's
deadline and horizon, the home Regelzone, the Unterbilanzkreise - instead
of the configuration, and gates come on as each contract's content is
entered: a schedule beyond the maximum power, a ZOE for a Zeitreihentyp the
Netzbetreiber's contract does not allow.

## Endpoints

| Call | Purpose |
| - | - |
| `GET /v1/process/vertraege/{art}/{partner}/fassungen` | the Fassungen, oldest first, and `vorlage`: content to start the next one from |
| `POST /v1/process/vertraege/{art}/{partner}/fassungen` | a new Fassung: `{"gueltig_ab", "gueltig_bis", "inhalt", "notiz"}`; `422` for content that does not fit the type, or a start not after the last Fassung's |
| `DELETE /v1/process/vertraege/{art}/{partner}/fassungen/{nr}` | withdraw the last Fassung while it is not in force (`409` once it is) |
| `GET /v1/process/vertragslage?tag=` | what applies on a day |
| `GET /v1/process/vertragspruefung?tag=` | the contracts against what is |

`partner` is the Regelzone for a Bilanzkreisvertrag, the trader's
Bilanzkreis (EIC) for a Händlervertrag, else the MP-ID. Recording a
Fassung sends nothing to anyone.


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