---
name: wisnots-netz-v2
description: Integrate the Wisnots Netz API v2 (netz-api.wisnots.com/v2), which registers PV, storage, heat pumps, wallboxes and air conditioning with the responsible grid operator, for one firm or for the installer firms a platform serves, and follows each case through commissioning and the Marktstammdatenregister. Use whenever code, configuration or documentation in this project talks to that API's /v2 routes.
---

# Wisnots Netz API v2

Registering an installation with the responsible grid operator through one API, and following it after the operator's yes. This skill is the workflow and the rules. The index is https://www.wisnots.com/netz-api/v2/llms.txt and the whole contract is https://www.wisnots.com/netz-api/v2/openapi.json, rendered at https://www.wisnots.com/en/netzanmeldung/api: read the index before the first call, and the operation's schema and examples before writing a body.

## Workflow

1. **Key.** Read it from the `NETZ_API_KEY` environment variable. `wnz_test_` is the sandbox, `wnz_live_` is live, same host (https://netz-api.wisnots.com) and same calls; build and test on the sandbox and switch the key to go live. Never write a key into a file, a log, a test fixture or a commit. If there is no key, ask for one: the console at https://www.wisnots.com/netzanmeldung/portal mints them under Developers.
2. **Businesses, if you file for installer firms.** `POST /v2/businesses` once per firm with your own id as `external_ref`, its name, address, contact, electrician and its registrations with grid operators. A case names it in `business_id` and takes its installer details from it. The firm hands in its grid operator logins itself, through the page `POST /v2/businesses/{id}/access-links` gives you; never ask for or carry a login.
3. **Open the case.** `POST /v2/cases` with `type` (`pv`, `storage`, `heat_pump`, `charge_point`, `air_conditioning`), `external_ref`, and what the system already holds in `declared`, at the paths `GET /v2/requirements` lists. Always a draft: it reads `needs_input` or `ready` until you submit it. Send an `Idempotency-Key`. Each document goes to `POST /v2/cases/{id}/documents`: a file as `multipart/form-data`, a text as JSON. The first call in a new integration is the fixture: `POST /v2/cases` with `{"type":"charge_point"}`, then `{"fixture":"wallbox-invoice-de"}` to its documents, which the sandbox reads without a model call.
4. **Wait for the reading.** Act on `case.documents_read` from a webhook (`POST /v2/webhooks`), or poll `GET /v2/cases/{id}` until `status` leaves `extracting`. Verify `Wisnots-Signature` (HMAC-SHA256 over `t.rawBody` with the endpoint secret, reject `t` older than five minutes) before trusting a delivery, and key on `Wisnots-Event-Id` because delivery is at least once. `GET /v2/events` is the same events to poll.
5. **Close the open items.** `open[]` is everything the case still needs. Each item says who is expected to know it (`owner`), whether it stops the case (`blocking`) and how it is answered (`resolve`): `field` is a path to PATCH under `declared` (`PATCH /v2/cases/{id}`), `document` means a document with `resolves` set to the item's `code`, `url` is a page to send a person to, and an empty `resolve` is ours to settle. Ask the customer or the installer for the rest, in the words of `text` and `help`.
6. **Submit.** `POST /v2/cases/{id}/submit` hands the case over and takes its credit. A draft that reads `needs_input` with nothing blocking in `open[]` and `requirements.operator_outstanding` above zero waits on Wisnots under a universal key: its grid operator's own questions are ours, we are told and answer them, and `case.updated` brings it to `ready`; submit then (a 409 `case_incomplete` before). On the sandbox `POST /v2/test_helpers/cases/{id}/advance` answers them at once. On the sandbox choose `sandbox_outcome` and `sandbox_pace`: at the default `instant` the answer comes inside the submit, and `staged` lets a test helper answer while the case waits. What the grid operator asks later comes back into `open[]` with `source: grid_operator` and is answered the same way, with no second submit.
7. **After the yes.** While `case.commissioning` is due, send the report with `POST /v2/cases/{id}/commissioning` (evidence as documents with `resolves` `commissioning.meter_photo`, `.e8` or `.protocol`). Then answer the items of `phase: mastr` that are `blocking` (yours to answer; what is `owner: wisnots` holds nothing) and release the registration with `POST /v2/cases/{id}/mastr/submit`; `case.mastr_registered` brings the register's numbers.
8. **Billing.** `GET /v2/usage` says what a month's cases took, per business and type; `GET /v2/invoices` lists one invoice per purchase of credits.
9. **Embedded components, if the product shows our forms in its own pages.** Each page (an origin) is listed in the console under Developers, Connect, Embed. On the server, `POST /v2/cases/{id}/embed-sessions` or `POST /v2/businesses/{id}/embed-sessions` with `origin`, `components` and `platform_name`; answer `client_secret` from the endpoint the page's `fetchClientSecret` calls, minting a fresh session on every call, only for a case or business the signed-in user may act on, resolved from the product's own records (never from an id the browser sends), and load `/netz-embed/v2/embed.js` on that page. Choose `components` by the case's `status` on every mint: a draft takes `["case", "upload"]` (created as `netz.create('upload')`, it follows the case after the hand-over), a handed-over case `["case"]`, never a draft's form (422). Style the frame only through `appearance.variables` and `appearance.fonts` (the names and forms are in llms-full.txt, Embedded components, Appearance); a wrong value is dropped without an error, so check the frame. The frame writes through v2's own rules, logins are typed in the frame and reach only our server, and what it does arrives as v2's webhooks.

## Rules

- Never invent a field or a value. `GET /v2/requirements` is the dictionary: path, number (`nr`), label, help text, type, options. A path not in it, a value that does not read as its field's type and one its schema does not allow are listed in the case's `rejected` with the reason and not kept; an unknown body field or query parameter is a 422 `unknown_field`.
- Declared values are authoritative and what is read from a document never overwrites them. A disagreement is an entry in `conflicts`, settled with a `PATCH`, never guessed.
- After hand-over a `PATCH` carries only what an open item asks for: while something is asked, any other path is a 422 naming it; with nothing asked, and while an answer is on its way, it is a 409 `case_already_filed`.
- A refusal is a problem document with `code` (closed enum), `detail` and `errors[]` (`path`, `code`, `message`). Show `errors[]` to the person; do not retry a 4xx unchanged. A 429 carries `Retry-After`.
- One case per installation. Cases of one connection (the same `external_ref`, site, end customer and business, on one plane) handed over before the first has reached the grid operator are filed and billed as one (`group`); one handed over later is a registration and a credit of its own. On the sandbox the first reaches the operator inside an `instant` submit: rehearse a pair at `sandbox_pace: staged`, the second within about four seconds.
- Ids carry the plane: `anm_`/`anm_test_` cases, `biz_`/`biz_test_` businesses, `doc_`/`doc_test_` documents. An event's id is an opaque string: key deliveries on it, never parse it. A key of one plane never sees the other's. Do not build a plane switch of your own: the key is the switch.
- Fixtures on the sandbox are free and identical every time; use them in automated tests. Real documents on the sandbox are read for real, 25 a day per account.
- Do not send a live key from a browser, and do not put the API behind a proxy that logs bodies: documents carry customer data.
- A `client_secret` is a bearer credential for its session: minted with the key on the server, handed only to our loader, never written into a log or a URL.
- v1 (`/v1/anmeldungen`) is the older contract over the same cases and is being retired: build on v2. Do not mix the two in one integration.

## Routes

- `POST /v2/cases`: Open a case
- `GET /v2/cases`: List cases
- `GET /v2/cases/{id}`: Read a case
- `PATCH /v2/cases/{id}`: Change a case
- `DELETE /v2/cases/{id}`: Delete a draft
- `POST /v2/cases/{id}/documents`: Send a document
- `POST /v2/cases/{id}/submit`: Submit a case
- `POST /v2/cases/{id}/withdraw`: Withdraw a handed-over case
- `GET /v2/requirements`: What a case asks
- `POST /v2/cases/{id}/commissioning`: Report the commissioning
- `POST /v2/cases/{id}/mastr/submit`: Release the MaStR registration
- `POST /v2/businesses`: Add a business
- `GET /v2/businesses`: List businesses
- `GET /v2/businesses/{id}`: Read a business
- `PATCH /v2/businesses/{id}`: Change a business
- `POST /v2/businesses/{id}/deactivate`: Deactivate a business
- `GET /v2/businesses/{id}/logins`: A business's logins
- `POST /v2/businesses/{id}/access-links`: The business's login page
- `POST /v2/cases/{id}/embed-sessions`: A session for a case's frame
- `POST /v2/businesses/{id}/embed-sessions`: A session for a business's frame
- `GET /v2/events`: Every event
- `GET /v2/cases/{id}/events`: A case's events
- `POST /v2/webhooks`: Register an endpoint
- `GET /v2/webhooks`: Your endpoints
- `DELETE /v2/webhooks/{id}`: Remove an endpoint
- `GET /v2/usage`: Credits used in a month
- `GET /v2/invoices`: Your invoices
- `GET /v2/invoices/{id}/pdf`: An invoice's PDF
- `POST /v2/test_helpers/cases/{id}/advance`: Play a test case's next step
- `POST /v2/test_helpers/cases/{id}/grid_operator_reply`: Reply as the grid operator
- `POST /v2/test_helpers/cases/{id}/requirements/{code}/resolve`: Answer an item as its owner would
- `POST /v2/test_helpers/webhooks/{event}`: Send an event again

## TypeScript

A dependency-free client is served at https://www.wisnots.com/netz-api/sdk/: `v2.ts`, `client.v2.ts`, `http.ts`, `types.v2.gen.ts`, `webhooks.ts`, `README.md`. Vendor the `.ts` files into the project and import from `v2.ts` (`@wisnots/netz/v2`); `README.md` is the guide. `createNetzClient({ apiKey })` gives `cases.create`, `cases.addDocument`, `cases.waitForDocuments`, `cases.patch`, `cases.submit`, `cases.reportCommissioning`, `cases.releaseMastr`, `cases.withdraw`, `cases.createEmbedSession`, `businesses.create`, `businesses.createEmbedSession`, `requirements.get`, `webhooks.create`, `events.list`, `usage.get` and `invoices.pdf`, with `iterate` on every list, and on a test key `testHelpers.advance`, `testHelpers.gridOperatorReply`, `testHelpers.resolveRequirement` and `testHelpers.sendWebhook`; `verifyWebhookEvent` checks and parses a delivery; every refusal is a `NetzApiError` with the problem's `code` and `errors`. In any other language, plain HTTP against the OpenAPI document is the whole integration.
