Skip to main content
POST
← Facilities API Delete facilities by id, with everything they hold: invoices, wastes, waste water treatments and their emissions. The request checks every id, takes the facilities out of every list at once and answers 202 Accepted with a job (see how bulk ingestion works); the data is deleted in the background, one facility at a time. Follow it with GET /v2/ingest-jobs/{id} or, for a job submitted with an API key, the ingest_job.finished webhook.
Permanent. Deleted facilities and all their data cannot be recovered. Use dry_run=true first if you are not sure.
Beta. Part of the bulk ingest API, in beta. The contract may still change before general availability.

How it works

  1. The request checks every id. One that does not exist, is already deleted, is outside your perimeter or is repeated rejects the whole request with 422 and nothing is deleted.
  2. The facilities disappear at once. They are disabled in the request, so they no longer appear in List Facilities and nothing new can be attached to them.
  3. The job deletes their data in the background: invoices, wastes, waste water treatments, their emissions and calculation data, and the facility itself. Their supply contracts become inactive. Facilities with little data share a chunk (up to 50); one with a lot of data gets a chunk of its own. A facility that cannot be deleted fails alone, as DELETE_FAILED.
  4. When every chunk is done the job is completed (or completed_with_errors), and, for a job submitted with an API key, ingest_job.finished is sent to your webhook endpoints with "entity_type": "facilities" and "operation": "delete".

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, creates included: do not reuse the key of the batch that created the facilities. Within 24 hours, the same key with the same route and body returns the original job (with Idempotent-Replayed: true) instead of deleting 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 bad ids, nothing deleted or disabled, no job; 200 with {"dry_run": true, "submitted": n, "valid": n} when every id would be deleted. The Idempotency-Key header is still required, but a dry run does not check or store it.

Body Parameters

array[uuid]
required
Facility ids to delete, 1 to 1,000, each once.

Response

202 Accepted, the job (operation: delete) and a Location header to it. Per-id outcomes are in GET /v2/ingest-jobs/{id}/items: one item per id, in the order sent, with stage: delete and entity_id = the facility id. An item is failed with DELETE_FAILED when its facility was already gone by the time the job reached it. It also ends DELETE_FAILED when it could not be deleted: List Ingest Job Items says what to do.

Errors

Problem details. Per-id 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 (empty ids, more than 1,000, not UUIDs), 422 IDEMPOTENCY_KEY_REUSED, 409 IDEMPOTENCY_KEY_IN_PROGRESS, and 429 beyond the rate limits.

Create Facilities (v2)

Create up to 1,000 facilities in one request

Get Ingest Job

Follow the deletion