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

# Upsert market-location master data

> Mirror of the market locations' master data (GPKE/UTILMD content) -
the basis for the generated consumption forecast when you deliver no
portfolio forecast yourself.

Master data is stored as **time slices** (`valid_from` inclusive,
`valid_to` exclusive): send one slice per change, never the whole
history. A slice wins for its own window and leaves the surrounding
periods intact; re-sending identical slices changes nothing. For one
uninterrupted supply period the flat form (`delivery_start`,
attributes on the location) is shorthand for a single slice.



## OpenAPI

````yaml /api-reference/openapi.json put /v1/master-data
openapi: 3.1.0
info:
  title: n:lead Scheduling Bridge — Data Delivery API
  version: 0.4.0
  description: >-
    API for delivering portfolio data to the n:lead scheduling bridge. Send a
    portfolio forecast per delivery day, or — if no forecast is available — the
    market-location master data, metered data and rolled-out profiles the bridge
    needs to build the consumption forecast for you. Everything downstream
    (positions, trader handoff, schedule submission to the TSOs) is operated by
    n:lead. A read-only status endpoint reports the BRP activation state per
    DSO/MGA.
servers:
  - url: >-
      https://nleadbridge-app.lemonisland-7d6503d3.germanywestcentral.azurecontainerapps.io
    description: Deployed service
  - url: http://localhost:8000
    description: Local development
security: []
paths:
  /v1/master-data:
    put:
      summary: Upsert market-location master data
      description: |-
        Mirror of the market locations' master data (GPKE/UTILMD content) -
        the basis for the generated consumption forecast when you deliver no
        portfolio forecast yourself.

        Master data is stored as **time slices** (`valid_from` inclusive,
        `valid_to` exclusive): send one slice per change, never the whole
        history. A slice wins for its own window and leaves the surrounding
        periods intact; re-sending identical slices changes nothing. For one
        uninterrupted supply period the flat form (`delivery_start`,
        attributes on the location) is shorthand for a single slice.
      operationId: put_master_data_v1_master_data_put
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MasterDataUpsertRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MasterDataUpsertResponse'
        '401':
          description: Missing, wrong or expired credential.
        '413':
          description: Body larger than the request-size limit.
        '422':
          description: >-
            Validation failure. `detail` names the offending series/entry and
            the rule it broke - see the troubleshooting page for every message
            and its fix.
        '429':
          description: >-
            Rate limit exceeded - retry after the number of seconds in the
            `Retry-After` header.
      security:
        - APIKeyHeader: []
        - HTTPBearer: []
components:
  schemas:
    MasterDataUpsertRequest:
      properties:
        locations:
          items:
            $ref: '#/components/schemas/MarketLocationIn'
          type: array
          minItems: 1
          title: Locations
      type: object
      required:
        - locations
      title: MasterDataUpsertRequest
      example:
        locations:
          - malo: '51238696781'
            slices:
              - annual_consumption_kwh: 4200
                control_area: Amprion
                metering_type: profiled
                mga: 11YR00000002092Q
                profile_code: H0
                valid_from: '2026-09-01'
          - control_area: TenneT
            delivery_start: '2026-09-01'
            malo: '51238696782'
            metering_type: quarter_hourly
            mga: 11YN-E000-0001-K
    MasterDataUpsertResponse:
      properties:
        upserted:
          type: integer
          title: Upserted
        status:
          type: string
          enum:
            - stored
            - validated
          title: Status
          description: >-
            "validated" when the call ran under a sandbox key - everything
            checked, nothing stored
          default: stored
      type: object
      required:
        - upserted
      title: MasterDataUpsertResponse
    MarketLocationIn:
      properties:
        malo:
          type: string
          pattern: ^\d{11}$
          title: Malo
          description: Market location ID (MaLo) — 11 digits
        slices:
          anyOf:
            - items:
                $ref: '#/components/schemas/MasterDataSliceIn'
              type: array
            - type: 'null'
          title: Slices
        control_area:
          anyOf:
            - $ref: '#/components/schemas/ControlArea'
            - type: 'null'
        mga:
          anyOf:
            - type: string
            - type: 'null'
          title: Mga
        metering_type:
          anyOf:
            - type: string
              enum:
                - profiled
                - quarter_hourly
            - type: 'null'
          title: Metering Type
        delivery_start:
          anyOf:
            - type: string
              format: date
            - type: 'null'
          title: Delivery Start
        delivery_end:
          anyOf:
            - type: string
              format: date
            - type: 'null'
          title: Delivery End
          description: Exclusive; null = open-ended
        profile_code:
          anyOf:
            - type: string
            - type: 'null'
          title: Profile Code
        annual_consumption_kwh:
          anyOf:
            - type: number
              minimum: 0
            - type: 'null'
          title: Annual Consumption Kwh
      type: object
      required:
        - malo
      title: MarketLocationIn
      description: >-
        Master data of one market location (UTILMD mirror), as time slices.


        Either send ``slices`` (the full form, supporting changes over time and

        supply gaps), or the flat fields for the simple case of one
        uninterrupted

        period — the flat form is shorthand for a single slice.
    MasterDataSliceIn:
      properties:
        valid_from:
          type: string
          format: date
          title: Valid From
          description: First day this data applies (inclusive)
        valid_to:
          anyOf:
            - type: string
              format: date
            - type: 'null'
          title: Valid To
          description: First day it no longer applies (exclusive); null = open-ended
        active:
          type: boolean
          title: Active
          description: >-
            False marks a period without supply (de-registration); supply may
            resume with a later active slice
          default: true
        control_area:
          anyOf:
            - $ref: '#/components/schemas/ControlArea'
            - type: 'null'
        mga:
          anyOf:
            - type: string
            - type: 'null'
          title: Mga
          description: Metering grid area / Bilanzierungsgebiet
        metering_type:
          anyOf:
            - type: string
              enum:
                - profiled
                - quarter_hourly
            - type: 'null'
          title: Metering Type
        profile_code:
          anyOf:
            - type: string
            - type: 'null'
          title: Profile Code
          description: Load profile code (H0, G0, TLP code, ...)
        annual_consumption_kwh:
          anyOf:
            - type: number
              minimum: 0
            - type: 'null'
          title: Annual Consumption Kwh
          description: Jahresverbrauchsprognose in kWh
      type: object
      required:
        - valid_from
      title: MasterDataSliceIn
      description: |-
        Master data of a market location, valid for one period in time.

        Send one slice per change: supply start, a profile or balancing-regime
        change, a revised annual consumption forecast, a move to another
        metering grid area, or the end of supply (``active: false``). Slices
        that overlap stored ones win for their own window; the rest of the
        history is preserved.
    ControlArea:
      type: string
      enum:
        - 50Hertz
        - Amprion
        - TenneT
        - TransnetBW
      title: ControlArea
      description: The four German TSO control areas (Regelzonen).
  securitySchemes:
    APIKeyHeader:
      type: apiKey
      in: header
      name: X-API-Key
    HTTPBearer:
      type: http
      description: OIDC access token (Auth0 M2M)
      scheme: bearer

````