Skip to main content
POST
← Facilities API Create one or many facilities. Creating a facility calculates nothing, so the request is synchronous (see how bulk ingestion works): it answers 201 Created with every facility, in the order you sent them, ready to use as facility_id in your consumption data.
Beta. Part of the bulk ingest API, in beta. The contract may still change before general availability.

How it works

  1. Every record is checked. If any is invalid the whole request is rejected with 422 BULK_RECORDS_REJECTED and nothing is created: rejected is the number of invalid records and errors lists them (up to 100), so you can fix them at once.
  2. Every facility is created in one transaction and returned, in the order sent. source_row_index is the position of the record in records, and client_row_id echoes yours. The answer is the result: no ingest_job.finished webhook is sent. The request is recorded as an ingest job born completed, with 0 of 0 chunks (see synchronous and asynchronous routes).
  3. country decides where the facility is. It is required and stored uppercase. address is optional and only informative: it is not geocoded (unlike POST /v1/facilities, which replaced the country with the one Google found for the address).
  4. A record with waste_water is a waste water treatment plant (see below).

Waste water treatment plants

A waste water treatment plant (WWTP, EDAR) is a facility with three treatment lines, which decide the CH₄ and N₂O emission factors of its measurements. Create it with a waste_water block, then send its measurements to POST /v2/waste-water-treatments. This replaces POST /v1/facilities/waste_water, deprecated. The lines come from a catalog that is the same for every organization, GET /v1/waste-water-treatments/lines (x-api-key and x-organization-id are enough). Each line has an id, a line_type (the slot it fills), a water_type, a line_code and its IPCC name (line_original_name). A plant takes one line of each line_type, all three of the same water_type: The water_type decides what the plant’s measurements send as organic load: BOD for domestic_dbo lines (urban, domestic water), COD for dqo_industrial lines (industrial water), whose factors are per kg of COD. See Organic load: BOD or COD.
A record that creates a plant with those lines:
The answer’s facility carries the same waste_water block; it is null for any other facility.

Request

Headers

string
required
Your API key (see Authentication).Example: ${DCYCLE_API_KEY}
string
required
Your organization UUIDExample: a8315ef3-dd50-43f8-b7ce-d839e68d51fa
string
required
1 to 255 characters, one per batch. It is looked up per organization across every v2 bulk route. Within 24 hours, the same key with the same route and body answers the same facilities (with Idempotent-Replayed: true) instead of creating them again; the same key with another body or on another route is 422 IDEMPOTENCY_KEY_REUSED, and while the first request is still being processed 409 IDEMPOTENCY_KEY_IN_PROGRESS. After 24 hours the key is free and a request with it is a new one. See The Idempotency-Key.

Query Parameters

boolean
default:"false"
Check only: the same 422 for invalid records, nothing created; 200 with {"dry_run": true, "submitted": n, "valid": n} when every record is valid. The Idempotency-Key header is still required, but a dry run does not check or store it.

Body Parameters

array[object]
required
The facilities to create, 1 to 1,000. A field a record does not declare (a typo, or v1’s type, logistic_factor, cups_list or surface_area_unit) rejects the record with SCHEMA_INVALID.

Response

201 Created with items: one per record, in the order sent, each with source_row_index, client_row_id and the created facility: id, organization_id, name, country, address, categories, cups_list, surface_area, surface_area_unit_id, status, UTC timestamps ending in Z and waste_water (the treatment lines of a waste water treatment plant, null for any other facility). Every facility is created as owned, with a logistic factor of 0.8; neither is part of this contract. Its CUPS codes (cups_list) are filled from its electricity invoices.

Errors

Problem details. Per-record codes in errors[].error_code: 401 for a missing or invalid API key, 403 LOGGED_USER_NOT_MEMBER when the key’s user is not a member of the organization, 422 REQUEST_VALIDATION_FAILED for a malformed body (no records, more than 1,000, no Idempotency-Key), 422 IDEMPOTENCY_KEY_REUSED for a key already used with another body or on another route, 409 IDEMPOTENCY_KEY_IN_PROGRESS while a request with the same key is still being processed, and 429 beyond the rate limits.

Retries and idempotency

  • Network error or timeout: retry within 24 hours with the same Idempotency-Key and body. If the first request was accepted you get the same facilities back, with Idempotent-Replayed: true, and nothing is duplicated.
  • 422 BULK_RECORDS_REJECTED: nothing was created. Fix the records and send the batch again.
  • 409 IDEMPOTENCY_KEY_IN_PROGRESS: the first request with that key is still being processed. Wait Retry-After seconds and retry with the same key and body.

Limits

Delete Facilities (v2)

Delete up to 1,000 facilities with their data

Create Wastes (v2)

Load wastes into the new facilities

Create Waste Water Treatments (v2)

Load the measurements of a new plant