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

# Send correction mails for mixed acknowledgments

> A partner can accept one of our messages and reject the other:
the PARTIN datasheet accepted but the Zuordnungsermächtigung refused,
or the reverse. That split verdict is a partner-side processing issue
no resend fixes — someone at the partner has to correct it.

This endpoint finds every partner currently in such a state and writes
each one a mail naming what stands accepted, what was rejected when,
and the partner's own rejection reason, asking for correction.

**Addressing**: the mail goes to the contact address from the
partner's **own PARTIN** (`COM+…:EM`), deliberately not to the BDEW
list address — the PARTIN names the working Marktkommunikation desk.
Partners who never sent a PARTIN are listed under `skipped`, never
silently dropped.

**Idempotence**: one mail per standing rejection, tracked in a ledger.
Calling again mails nothing until a *newer* rejection appears. A
failed send is reported (`skip: "Versand: …"`) and retried on the
next call. CONTRL error 26 (duplicate transmission file) is excluded:
that one is fixed by our own fresh-reference resend, not by the
partner.

Start with `dry_run: true` — it returns the full target list with
addresses and reasons without sending anything.



## OpenAPI

````yaml /setup/internal-openapi.json post /v1/process/market-partners/korrektur-mails
openapi: 3.1.0
info:
  title: n:lead Scheduling Bridge — Internal API
  version: 0.4.0
  description: >-
    Internal API of the n:lead scheduling bridge: the process endpoints that
    drive the day-ahead pipeline (aggregate, publish the open position, submit
    schedules, generate forecasts, orchestrate) and the operator console
    endpoints. Requires the process API key; not for customer use.
servers:
  - url: >-
      https://nleadbridge-app.lemonisland-7d6503d3.germanywestcentral.azurecontainerapps.io
    description: Deployed service
  - url: http://localhost:8000
    description: Local development
security: []
paths:
  /v1/process/market-partners/korrektur-mails:
    post:
      summary: Send correction mails for mixed acknowledgments
      description: |-
        A partner can accept one of our messages and reject the other:
        the PARTIN datasheet accepted but the Zuordnungsermächtigung refused,
        or the reverse. That split verdict is a partner-side processing issue
        no resend fixes — someone at the partner has to correct it.

        This endpoint finds every partner currently in such a state and writes
        each one a mail naming what stands accepted, what was rejected when,
        and the partner's own rejection reason, asking for correction.

        **Addressing**: the mail goes to the contact address from the
        partner's **own PARTIN** (`COM+…:EM`), deliberately not to the BDEW
        list address — the PARTIN names the working Marktkommunikation desk.
        Partners who never sent a PARTIN are listed under `skipped`, never
        silently dropped.

        **Idempotence**: one mail per standing rejection, tracked in a ledger.
        Calling again mails nothing until a *newer* rejection appears. A
        failed send is reported (`skip: "Versand: …"`) and retried on the
        next call. CONTRL error 26 (duplicate transmission file) is excluded:
        that one is fixed by our own fresh-reference resend, not by the
        partner.

        Start with `dry_run: true` — it returns the full target list with
        addresses and reasons without sending anything.
      operationId: post_korrektur_mails_v1_process_market_partners_korrektur_mails_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/KorrekturMailRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/KorrekturMailResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
        '502':
          description: >-
            MakoFlow (the market-communication gateway) did not answer; retry
            once it recovers.
      security:
        - APIKeyHeader: []
        - HTTPBearer: []
components:
  schemas:
    KorrekturMailRequest:
      properties:
        dry_run:
          type: boolean
          title: Dry Run
          default: false
        lookback_days:
          type: integer
          maximum: 730
          minimum: 1
          title: Lookback Days
          default: 90
      type: object
      title: KorrekturMailRequest
      description: |-
        Mail partners whose acknowledgments split - one stream accepted,
        the other rejected - and ask them to correct the rejection.

        ``dry_run`` lists the targets and the addresses without sending.
    KorrekturMailResponse:
      properties:
        dry_run:
          type: boolean
          title: Dry Run
        lookback_days:
          type: integer
          title: Lookback Days
        targets:
          items:
            $ref: '#/components/schemas/KorrekturZiel'
          type: array
          title: Targets
          description: Every partner currently in a mixed-verdict state
        sent:
          items:
            $ref: '#/components/schemas/KorrekturZiel'
          type: array
          title: Sent
          description: Mails that went out now
        skipped:
          items:
            $ref: '#/components/schemas/KorrekturSkip'
          type: array
          title: Skipped
          description: Targets without a mail, each with the reason
      type: object
      required:
        - dry_run
        - lookback_days
        - targets
        - sent
        - skipped
      title: KorrekturMailResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    KorrekturZiel:
      properties:
        mp_id:
          type: string
          title: Mp Id
          description: The partner's MP-ID
        name:
          type: string
          title: Name
          description: The partner's name
        case:
          type: string
          enum:
            - zuordnung_abgelehnt
            - partin_abgelehnt
          title: Case
          description: >-
            `zuordnung_abgelehnt`: PARTIN stands accepted, the
            Zuordnungsermächtigung rejected. `partin_abgelehnt`: the reverse
        rejected_at:
          type: string
          title: Rejected At
          description: Date of the standing rejection
        reason:
          type: string
          title: Reason
          description: The partner's own rejection reason
        email:
          type: string
          title: Email
          description: >-
            Contact address from the partner's own PARTIN; empty when they never
            sent one
      type: object
      required:
        - mp_id
        - name
        - case
        - rejected_at
        - reason
        - email
      title: KorrekturZiel
    KorrekturSkip:
      properties:
        mp_id:
          type: string
          title: Mp Id
          description: The partner's MP-ID
        name:
          type: string
          title: Name
          description: The partner's name
        case:
          type: string
          enum:
            - zuordnung_abgelehnt
            - partin_abgelehnt
          title: Case
          description: >-
            `zuordnung_abgelehnt`: PARTIN stands accepted, the
            Zuordnungsermächtigung rejected. `partin_abgelehnt`: the reverse
        rejected_at:
          type: string
          title: Rejected At
          description: Date of the standing rejection
        reason:
          type: string
          title: Reason
          description: The partner's own rejection reason
        email:
          type: string
          title: Email
          description: >-
            Contact address from the partner's own PARTIN; empty when they never
            sent one
        skip:
          type: string
          title: Skip
          description: >-
            Why no mail went out: `bereits angeschrieben` (this rejection was
            already mailed), `keine Kontaktadresse in deren PARTIN`, `Fehler 26
            (Doppeluebertragung) - ...` (our side resends instead), or `Versand:
            <error>` (send failed, retried next call)
      type: object
      required:
        - mp_id
        - name
        - case
        - rejected_at
        - reason
        - email
        - skip
      title: KorrekturSkip
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    APIKeyHeader:
      type: apiKey
      in: header
      name: X-API-Key
    HTTPBearer:
      type: http
      description: OIDC access token (Auth0 M2M)
      scheme: bearer

````