---
title: "Groups with several legal entities"
description: "E-invoicing for a group with several legal entities: one company per entity, bulk creation, Peppol registration, keys per entity or one machine client, sending as an entity, routing received invoices, France SIREN/SIRET."
canonical: "https://docs.get-flowie.com/guides/multi-entity"
source: "https://docs.get-flowie.com/guides/multi-entity.html"
---

# Groups with several legal entities

Guides

# Groups with several legal entities

One customer, many legal entities — subsidiaries, establishments, countries: model each entity once, register it, then send and receive as the right entity from one integration.

For
    Large group · Mid-market with several entities — Sellers, Buyers or both

Time
    ≈ 1 h in sandbox

You need
    A sandbox key ([get one](<../sandbox/keys.html>)) and the list of your entities with their VAT numbers (SIREN in France)

Updated
    30 Nov 2026

Which part is for you

**Mid-market, a few entities, one ERP:** one company per entity (step 1), one key per entity (step 4) is often the simplest. **Large group, shared-service centre, many entities or countries:** bulk creation (step 2), one machine client for all entities (step 4) and webhook routing by receiver (step 6). **You invoice for companies outside your group** (accounting firm, software vendor): read [Partners](<partners.html>) instead. 

## 1 · Model one company per legal entity

A company in the API is a legal entity: it has one VAT number, one Peppol participant id and its own documents, webhooks and lifecycle. Map your group onto companies like this:

In your group| In the API  
---|---  
A subsidiary with its own VAT number| One company.  
The same group in several countries (a GmbH, a SARL, a BV)| One company per country entity, each with its own VAT number; country rules follow that VAT number.  
A French legal unit (SIREN) with several establishments (SIRET)| One company per SIREN. Establishments are not separate companies — see [step 7](<#france>).  
A department, cost centre or business line with no legal personality| No company: carry it in your own data (references, custom fields), not as a sender.  
  
Creating a company is find-or-create: a VAT number already known returns the existing company instead of a duplicate, so the step is safe to re-run.

## 2 · Create the entities

One call per entity, with its VAT number. The sandbox accepts the documented [test VAT numbers](<../sandbox/index.html#test-vats>); this rehearses a group with a French, a Belgian and a German entity.
[code] 
    curl -X POST https://back.flowie.ink/exchange/v1/companies \
      -H "Authorization: Bearer $FLOWIE_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{"vatNumber": "DE000000001", "name": "Sandbox Deutschland GmbH"}'
[/code]

Expected response (`201`, one per entity, trimmed):
[code] 
    {
      "id": "comp_sbx_…",
      "name": "Sandbox Deutschland GmbH",
      "country": "DE",
      "vatNumber": "DE000000001",
      "peppolId": "9930:000000001",
      "status": "active",
      "smpRegistered": true
    }
[/code]

Store each `id` in your entity master data next to your ERP's company code: it is the value you send in `X-Flowie-Organization-Id` to act as that entity. Below, the ids are written `{franceEntityId}`, `{belgiumEntityId}`, `{germanyEntityId}`.

### Many French entities at once

[`POST /v1/companies/import/batch`](<../reference/index.html#import-companies-batch>) takes up to 500 items, each a `siren` or a `siret`. The SIREN, the Peppol id (`0009:<SIREN>`) and the legal name are derived for you. Items run independently: one failure is reported in its own row and never fails the whole call, and re-running a batch is safe.
[code] 
    curl -X POST https://back.flowie.ink/exchange/v1/companies/import/batch \
      -H "Authorization: Bearer $FLOWIE_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "items": [
          {"siren": "921376265"},
          {"siret": "92137626500018"}
        ]
      }'
[/code]

Expected response (`200`, trimmed):
[code] 
    {
      "results": [
        {"index": 0, "status": "imported", "companyId": "comp_sbx_…", "peppolId": "0009:921376265"},
        {"index": 1, "status": "imported", "companyId": "comp_sbx_…", "peppolId": "0009:921376265"}
      ],
      "imported": 2,
      "failed": 0
    }
[/code]

Both items above name the same legal unit — a SIRET is a SIREN plus an establishment number — so both rows carry the same Peppol id. For entities that are leaving another platform, add `effectiveDate` (`YYYY-MM-DD`) to an item so routing starts on the agreed date; the full migration is described in [Portability](<portability.html>). Outside France, loop over `POST /v1/companies` as above.

## 3 · Register each entity on Peppol

An entity can send once its Peppol registration is active, and its partners can only reach it once it is published. Register each entity:
[code] 
    curl -X POST https://back.flowie.ink/exchange/v1/companies/{companyId}/register \
      -H "Authorization: Bearer $FLOWIE_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{}'
[/code]

Expected response (`200`):
[code] 
    {
      "id": "comp_sbx_…",
      "peppolId": "9930:000000001",
      "status": "active",
      "smpRegistered": true,
      "smpRegisteredAt": "2026-11-30T…"
    }
[/code]

The call is idempotent: on an entity that is already provisioned it re-syncs and activates the registration. Subscribe to `company.smp_registered` to know when each entity's directory entry is live. An entity never provisioned before answers `400 invalid_request` asking for a `sovosOrganizationId`: the Flowie onboarding team provides it for your production entities. A document sent before an entity's registration is active is kept, not lost: it is reported with `deliveryStatus: "awaiting_registration"` and routed once the registration is active.

## 4 · Choose how you authenticate

A credential acts for one entity per call. There are three ways to reach several entities:

Option| How it works| Fits  
---|---|---  
**One API key per entity**|  Create it on the [API Keys](<../sandbox/keys.html>) page with that entity picked, or with [`POST /v1/api-keys`](<../reference/index.html#create-api-key>) and `X-Flowie-Organization-Id`. The key is bound to that entity and **ignores** the header.| A few entities; one ERP instance or one integrator per entity or country. A leaked key exposes one entity.  
**One machine client for all entities**|  An admin of every entity creates an OAuth client with [`POST /v1/oauth/clients`](<../reference/index.html#oauth-clients>) and `organizationIds` (up to 100). You get a token with the client-credentials grant and send `X-Flowie-Organization-Id` on **every** call.| A shared-service centre or one ERP that invoices for many entities.  
**A signed-in user**|  A user token reaches the entities the user is a member of, and the organizations below them in your group's hierarchy. Pick one per call with the header.| Back-office tools, agents, people.  
  
The machine client, created once by an admin of all three entities with their own user token:
[code] 
    curl -X POST https://back.flowie.ink/exchange/v1/oauth/clients \
      -H "Authorization: Bearer $FLOWIE_USER_TOKEN" \
      -H "Content-Type: application/json" \
      -d '{
        "name": "Group ERP connector",
        "organizationIds": ["{franceEntityId}", "{belgiumEntityId}", "{germanyEntityId}"],
        "role": "predefined.roles.admin"
      }'
[/code]

Expected response (`201`, trimmed):
[code] 
    {
      "clientId": "…",
      "clientSecret": "…",
      "tokenUrl": "https://login.flowieapp.io/oauth/token",
      "audience": "…",
      "organizationIds": ["…", "…", "…"],
      "role": "predefined.roles.admin",
      "technicalUserEmail": "m2m-group-erp-connector-…@flowie.fr"
    }
[/code]

`clientSecret` is shown once. The default role is read-only (`predefined.roles.viewer`); a client that sends invoices needs a role that can write, such as `predefined.roles.admin`, in every listed entity. Token request, renewal and the two different `403`s are covered in [Machine-to-machine](<../reference/index.html#m2m>). Before go-live, call `GET /v1/me` with each entity in `X-Flowie-Organization-Id`: every answer's `organizationId` must be the entity you named.

## 5 · Send as a given entity

`X-Flowie-Organization-Id` decides which entity the document is filed under and sent as; `from` names the same entity as the sender (its VAT number here; its Peppol id or `org:{germanyEntityId}` work too). With a per-entity key, drop the header: the key already is the entity. In the sandbox, `$FLOWIE_API_KEY` holds your sandbox key; in production it holds the entity's key or the machine token.
[code] 
    curl -X POST https://back.flowie.ink/exchange/v1/documents/send \
      -H "Authorization: Bearer $FLOWIE_API_KEY" \
      -H "X-Flowie-Organization-Id: {germanyEntityId}" \
      -H "Content-Type: application/json" \
      -d '{
        "type": "invoice",
        "from": "vat:DE000000001",
        "to": "0208:TEST_OK",
        "document": {
          "number": "DE-2026-0001",
          "issueDate": "2026-11-30",
          "currency": "EUR",
          "lines": [
            {"description": "Spare parts", "quantity": 4, "unitPrice": 125.00, "vatRate": 19}
          ]
        }
      }'
[/code]

Expected response (`201`, trimmed):
[code] 
    {
      "id": "doc_…",
      "status": "sent",
      "type": "INVOICE",
      "number": "DE-2026-0001",
      "from": {"peppolId": "9930:000000001", "name": "Sandbox Deutschland GmbH", "companyId": "…"},
      "to": {"peppolId": "0208:TEST_OK", "name": "…"},
      "totals": {"net": 500.0, "vat": 95.0, "gross": 595.0, "currency": "EUR"},
      "deliveryStatus": "delivered",
      "sentAt": "2026-11-30T…"
    }
[/code]

`status: "sent"` means Flowie accepted the document. `deliveryStatus` is the network state: `pending` on live Peppol until the recipient's access point confirms, then `delivered` or `failed`; the sandbox answers synchronously with `delivered`. Check that `from.peppolId` is the entity you meant.

The credential decides the entity, not the payload

A key bound to one entity files every document under that entity, whatever `from` says. A multi-entity credential sent with the header files it under the header's entity. A user token that reaches several entities, sent without the header, uses `from` to pick one of them and answers `403` when `from` matches none; a machine token without the header is refused. Always send the header with a multi-entity credential. 

## 6 · Receive per entity

A webhook belongs to the entity it was registered for, and fires only for that entity's events. Register one per entity — the same URL for all of them is fine:
[code] 
    curl -X POST https://back.flowie.ink/exchange/v1/webhooks \
      -H "Authorization: Bearer $FLOWIE_API_KEY" \
      -H "X-Flowie-Organization-Id: {germanyEntityId}" \
      -H "Content-Type: application/json" \
      -d '{
        "url": "https://erp.your-group.example/hooks/einvoicing",
        "events": ["document.received", "document.delivered", "document.failed", "lifecycle.updated"]
      }'
[/code]

Each delivery names the entity in `data.receiver` for an incoming document (`data.sender` for one you sent). Route on `data.receiver.organizationId` — the entity id you stored in step 2 — or on its `peppolId`:
[code] 
    {
      "id": "evt_…",
      "type": "document.received",
      "data": {
        "documentId": "doc_…",
        "direction": "incoming",
        "number": "SUP-88812",
        "sender":   {"organizationId": "…", "name": "…", "peppolId": "0208:…"},
        "receiver": {"organizationId": "{germanyEntityId}", "name": "Sandbox Deutschland GmbH",
                     "vatNumber": "DE000000001", "peppolId": "9930:000000001"},
        "…": "…"
      }
    }
[/code]

Verify `X-Flowie-Signature` before trusting the body; the payload, the signature scheme and the retry schedule are in [Webhooks](<../reference/webhooks.html>). Polling works per entity too, with the same header:
[code] 
    curl "https://back.flowie.ink/exchange/v1/documents?direction=incoming&limit=50" \
      -H "Authorization: Bearer $FLOWIE_API_KEY" \
      -H "X-Flowie-Organization-Id: {germanyEntityId}"
[/code]

When a supplier invoice lands at the wrong entity (the supplier used the wrong VAT number), the buyer entity can refuse it with [`POST /v1/documents/{documentId}/lifecycle`](<../reference/index.html#update-lifecycle>) and status `rejected`, so the supplier reissues it to the right entity. In France this is the 210 _Refusée_ status, reported to the tax administration automatically.

## 7 · France: SIREN, SIRET and one platform for the group

  * **One company per SIREN.** The French Peppol id is `0009:<SIREN>` (9 digits), so every establishment of a legal unit shares it. Creating or importing with a SIRET lands on the company of its SIREN.
  * **Establishments are reception points.** In the national directory a recipient is a reception point (_ligne annuaire_) inside a SIREN. Suppliers can address one with `{siren}_{siret}[_{suffix}]`, and you can do the same when your entities invoice French buyers — see [Reception-point addressing](<../reference/index.html#reception-point-addressing>).
  * **One accredited platform for the whole group.** Each SIREN declares its platform in the national directory. Register every entity of the group with Flowie and the directory lists Flowie SAS (SIREN 921 376 265, matricule 0064) for each of them, so all your French entities send, receive and report through one integration. An entity still on another platform moves with [Portability](<portability.html>).
  * **Lifecycle and reporting per entity.** Status changes (`rejected` = 210 _Refusée_ , `failed` = 213 _Rejetée_ , `paid`) are reported to the tax administration automatically for the entity that holds the document; each report fires `compliance.reported` to that entity's webhooks.



Country-by-country details: [France](<../compliance/fr/index.html>) and the [compliance overview](<../compliance/index.html>).

## Errors you may hit

Status · message| What it means| Fix  
---|---|---  
`403` · `Token does not grant access to organization '…'`| The header names an entity your user or machine client is not a member of.| Have an admin of that entity add it (for a machine client, recreate it with the entity in `organizationIds`).  
`403` · `No organization found in token`| A machine token sent without `X-Flowie-Organization-Id`.| Send the header on every call.  
`403` · `'from' (…) does not match any organization you have access to`| A user token reaching several entities, no header, and a `from` that is none of them.| Send the header; check the entity's VAT number or Peppol id.  
`403` · `PERMISSION_DENIED` (`companyId … is not accessible`)| A `companyId` filter names an entity the credential cannot reach.| Use the header for that entity, with a credential that reaches it.  
`400` · `invalid_request` on `/register`| The entity was never provisioned and no `sovosOrganizationId` was given.| Ask the Flowie onboarding team to provision it.  
`422` · `validation_error`| Malformed body, for instance a VAT number without its country prefix, or more than 500 items in a batch.| Fix the field named in `details`.  
`failed` row in a batch import| That item could not be imported; the others were.| Read the row's `error`, fix the item, re-run only that item.  
  
A per-entity key sent with a header for another entity does not fail: it ignores the header and acts as its own entity. Check with `GET /v1/me` when documents land under an unexpected entity. Every error code: [Errors](<../reference/errors.html>).

## Go-live checklist for groups

✓| Item  
---|---  
☐| Entity list agreed: one company per legal entity (per SIREN in France), with VAT numbers checked.  
☐| Every entity created and its `id` stored against your ERP company code.  
☐| Every entity registered; `company.smp_registered` received for each.  
☐| Credential model chosen; `GET /v1/me` answers the right entity for each one.  
☐| Every send names its entity (header or per-entity key) and `from` matches it.  
☐| One webhook per entity, signature verified, routing on `data.receiver.organizationId`.  
☐| France: every SIREN lists Flowie in the national directory; entities still on another platform scheduled for portability.  
☐| A test invoice sent and received for each entity in the sandbox.  
☐| The general [go-live checklist](<index.html#go-live>) is done too.  
  
## Next steps

  * [Send an invoice](<send-invoice.html>) — the full send path, for one entity.
  * [Receive invoices](<receive-invoices.html>) — webhooks or polling.
  * [Portability](<portability.html>) — bring French entities over from another platform.
  * [Companies endpoints](<../reference/index.html#companies>) — create, import, register.
  * [Partners](<partners.html>) — when you also serve companies outside your group.
